.download {
  min-height: 40px;
  display: grid;
  place-items: center;
  white-space: nowrap;
}

.mobile-save-tip {
  max-width: 800px;
  margin: 14px auto 0;
  padding: 11px 14px;
  border-radius: 10px;
  background: #fff5f6;
  color: #8d4d57;
  font-size: 12px;
  line-height: 1.6;
}

.media-warning {
  display: block;
  margin-top: 5px;
  color: #c66b18;
  font-size: 11px;
  line-height: 1.35;
}

.media-warning.compatible { color: #218653; }

/* ---------- 移动端操作区 ---------- */

.media-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.copy-link {
  border: 1px solid #e8e8eb;
  background: #fff;
  color: #5f6269;
  font-size: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}

/* Keep the input width stable while the paste/clear action swaps. The
   wrapper remains in the flex row even when one button is display:none. */
.input-action-slot {
  flex: 0 0 76px;
  width: 76px;
  display: grid;
  place-items: center;
}

.input-action-slot > button { grid-area: 1 / 1; }
.input-action-slot > .paste { width: 70px; }
.input-action-slot > .clear { width: 44px; }

/* The clear control is shown only after text is present. Keep it a real
   button-sized target so the input never shifts when its state changes. */
.clear {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f2f2f4;
  color: #777b84;
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.clear:hover { background: #e8e8eb; color: #3d4047; }
.clear:focus-visible,
.paste:focus-visible,
.parse-btn:focus-visible { outline: 3px solid #ffb8c2; outline-offset: 2px; }

body.locked { overflow: hidden; }

/* ---------- 遮罩层通用 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 12, 14, .82);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* ---------- 内置浏览器引导 ---------- */

.guide-overlay {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: calc(12px + env(safe-area-inset-top)) 18px 0;
}

.guide-arrow {
  color: #fff;
  font-size: 40px;
  line-height: 1;
  margin-right: 8px;
  animation: guide-bounce 1.1s ease-in-out infinite;
}

@keyframes guide-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@media (prefers-reduced-motion: reduce) {
  .guide-arrow { animation: none; }
}

.guide-card {
  width: 100%;
  max-width: 340px;
  margin-top: 10px;
  background: #fff;
  border-radius: 16px;
  padding: 20px 18px 16px;
  text-align: left;
}

.guide-card h3 { margin: 0 0 10px; font-size: 17px; }

.guide-card p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.75;
  color: #55585f;
}

.guide-card b { color: var(--red); }

.guide-note {
  background: #fff5f6;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px !important;
}

.guide-copy {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

.guide-close {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: #9a9da4;
}

/* ---------- 全屏预览 ---------- */

.viewer {
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 10, .95);
}

.viewer-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 14px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.viewer-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: calc(60px + env(safe-area-inset-top)) 14px 10px;
}

.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.viewer-actions {
  padding: 0 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}

.viewer-actions p {
  color: #d8d9dd;
  font-size: 13px;
  line-height: 1.7;
  margin: 0 0 14px;
}

.viewer-download {
  display: inline-grid;
  place-items: center;
  min-height: 46px;
  padding: 0 30px;
  border-radius: 11px;
  background: var(--red);
  color: #fff;
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
}

/* ---------- 轻提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(340px, calc(100vw - 40px));
  padding: 11px 17px;
  border-radius: 11px;
  background: rgba(20, 20, 23, .93);
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 760px) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .nav {
    height: calc(62px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
  }

  .hero-content { padding-top: 40px; }
  .parser {
    margin-top: 22px;
    padding: 8px;
    border-color: #ffd5dc;
    box-shadow: 0 12px 32px #a73a4d18, 0 2px 8px #3030300b;
  }
  .input-wrap {
    height: 56px;
    border: 1px solid #ececef;
    border-radius: 11px;
    background: #fff;
  }
  .input-wrap:focus-within { border-color: #ff9eac; box-shadow: 0 0 0 3px #ff244214; }
  .input-wrap input { font-size: 16px; }
  .paste {
    min-width: 70px;
    min-height: 46px;
    padding: 5px 12px;
    border-left: 0;
    border-radius: 9px;
    background: #fff0f2;
    color: var(--red);
    font-weight: 650;
  }
  .clear { flex-basis: 44px; width: 44px; height: 44px; }
  .parse-btn { height: 52px; margin-top: 8px; }
  .media-item { padding: 12px; gap: 10px; }
  .media-thumb { width: 62px; cursor: pointer; }
  .download { min-width: 84px; min-height: 44px; }
  .copy-link { min-width: 84px; min-height: 44px; }
  footer { padding-bottom: calc(25px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .media-meta small { font-size: 11px; }
  .media-item { gap: 8px; }
  .media-thumb { width: 54px; height: 52px; }
  .download, .copy-link { min-width: 76px; padding-left: 8px; padding-right: 8px; }
  .parser { margin-top: 18px; }
  .paste { min-width: 70px; }
}
