/* ===== 基础 ===== */
:root {
  --bili: #00aeec;
  --bili-dark: #0091c8;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --border: #e5e8ee;
  --danger: #e5484d;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 40, 80, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -12%, #dff3fd 0%, rgba(223, 243, 253, 0) 62%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ===== 页面骨架 ===== */
.page {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 56px 20px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.hero {
  text-align: center;
}

.logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #00c3ff, var(--bili));
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  line-height: 60px;
  box-shadow: 0 8px 20px rgba(0, 174, 236, 0.35);
}

.title {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ===== 搜索区 ===== */
.search {
  width: 100%;
  max-width: 640px;
}

.search-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 52px;
  padding: 0 18px;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
  color: #9aa3b2;
}

.search-input:focus {
  border-color: var(--bili);
  box-shadow: 0 0 0 3px rgba(0, 174, 236, 0.18);
}

.search-btn {
  flex: 0 0 auto;
  height: 52px;
  padding: 0 30px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--bili);
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0, 174, 236, 0.3);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.search-btn:hover:not(:disabled) {
  background: var(--bili-dark);
}

.search-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.search-btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

.input-error {
  margin: 10px 2px 0;
  color: var(--danger);
  font-size: 13px;
}

/* ===== 解析中 ===== */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.loading[hidden] {
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 174, 236, 0.25);
  border-top-color: var(--bili);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 结果区 ===== */
.result {
  width: 100%;
}

.result-card {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fade-in 0.25s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.thumb-wrap {
  flex: 0 0 320px;
  max-width: 320px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 12px;
}

.thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge--type {
  color: #fff;
  background: var(--bili);
}

.badge--input {
  color: var(--bili-dark);
  background: rgba(0, 174, 236, 0.12);
  border: 1px solid rgba(0, 174, 236, 0.3);
}

.video-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
  word-break: break-word;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-row {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.6;
}

.meta-label {
  flex: 0 0 auto;
  color: var(--muted);
  min-width: 62px;
}

.meta-value {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.actions {
  margin-top: auto;
  padding-top: 6px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--bili);
  border-radius: 10px;
  transition: background 0.15s ease;
}

.download-btn:hover {
  background: var(--bili-dark);
}

/* ===== 错误面板 ===== */
.error-panel {
  width: 100%;
  padding: 20px;
  background: #fff5f5;
  border: 1px solid #ffd7d7;
  border-radius: var(--radius);
  animation: fade-in 0.25s ease both;
}

.error-title {
  margin: 0;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  word-break: break-word;
}

.error-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ===== 页脚 ===== */
.footer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.footer p {
  margin: 0;
}

/* ===== 平板 / 手机：结果卡改为上图下文 ===== */
@media (max-width: 640px) {
  .result-card {
    flex-direction: column;
    gap: 16px;
    padding: 14px;
  }

  .thumb-wrap {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }

  .actions {
    margin-top: 0;
  }
}

/* ===== 手机竖屏：输入框与按钮纵向堆叠 ===== */
@media (max-width: 480px) {
  .page {
    padding: 36px 14px 48px;
  }

  .title {
    font-size: 26px;
  }

  .search-row {
    flex-direction: column;
  }

  .search-input,
  .search-btn {
    width: 100%;
  }

  .video-title {
    font-size: 18px;
  }

  .download-btn {
    width: 100%;
  }
}
