:root {
  color-scheme: dark;
  --bg: #0e0c0d;
  --bg-soft: #181516;
  --surface: rgba(26, 22, 24, 0.92);
  --surface-solid: #201c1e;
  --text: #f0ecee;
  --muted: #958b90;
  --line: rgba(255,255,255,0.08);
  --accent: #f0576b;
  --accent-dark: #d94356;
  --accent-soft: rgba(240,87,107,0.12);
  --gold: #d4a84b;
  --gold-soft: rgba(212,168,75,0.1);
  --success: #3ab882;
  --shadow: 0 24px 80px rgba(0,0,0,0.45);
  --shadow-small: 0 12px 36px rgba(0,0,0,0.28);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max: 960px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #faf7f5;
  --bg-soft: #f3efec;
  --surface: rgba(255,255,255,0.88);
  --surface-solid: #fff;
  --text: #1f1a1c;
  --muted: #8a7e84;
  --line: rgba(60,45,50,0.1);
  --accent-soft: rgba(240,87,107,0.08);
  --gold-soft: rgba(212,168,75,0.07);
  --shadow: 0 24px 80px rgba(60,40,45,0.1);
  --shadow-small: 0 12px 36px rgba(60,40,45,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; overflow-x: hidden;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
button, textarea, input { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

/* ---- Ambient ---- */
.ambient {
  position: fixed; z-index: -1; border-radius: 50%;
  pointer-events: none; filter: blur(90px);
}
.ambient-one {
  width: 500px; height: 500px; top: -200px; right: -150px;
  background: radial-gradient(circle, rgba(240,87,107,0.12), transparent 70%);
}
.ambient-two {
  width: 400px; height: 400px; left: -180px; top: 350px;
  background: radial-gradient(circle, rgba(212,168,75,0.08), transparent 70%);
}
.ambient-three {
  width: 350px; height: 350px; right: -100px; bottom: 100px;
  background: radial-gradient(circle, rgba(240,87,107,0.06), transparent 70%);
}

/* ---- Topbar ---- */
.topbar {
  width: min(calc(100% - 32px), 1100px);
  margin: 0 auto; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0576b, #d94356);
  color: #fff; box-shadow: 0 6px 20px rgba(240,87,107,0.3);
}
.brand-mark svg { width: 19px; stroke: none; fill: currentColor; }
.brand strong { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; display: block; }
.brand small { font-size: 10px; color: var(--muted); display: block; margin-top: 1px; }
.icon-button {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  cursor: pointer; backdrop-filter: blur(16px);
  transition: background 0.2s;
}
.icon-button:hover { background: var(--bg-soft); }
.icon-button svg { width: 18px; }

/* ---- Page Shell ---- */
.page-shell {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto; padding: 32px 0 56px;
}

/* ---- Hero ---- */
.hero { max-width: 680px; margin: 0 auto 24px; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: 11px; font-weight: 800;
  letter-spacing: 0.12em;
}
.eyebrow span { width: 16px; height: 2px; border-radius: 2px; background: currentColor; }
.hero h1 {
  margin: 10px 0 10px;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.08; letter-spacing: -0.04em;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p {
  max-width: 600px; margin: 0 auto;
  color: var(--muted); font-size: 14px; line-height: 1.7;
}

/* ---- Parse Card ---- */
.parse-card {
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow);
  backdrop-filter: blur(22px); padding: clamp(20px, 3.5vw, 32px);
}
.card-heading {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px;
}
.step-label {
  color: var(--accent); font-size: 10px; font-weight: 900;
  letter-spacing: 0.15em; margin-bottom: 3px;
}
.card-heading h2 { font-size: 20px; font-weight: 800; }
.secure-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  color: var(--muted); background: var(--bg-soft);
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.secure-badge svg { width: 14px; stroke-width: 1.6; }

/* ---- Input ---- */
.input-wrap {
  overflow: hidden; border: 1.5px solid var(--line);
  border-radius: var(--radius-lg); background: var(--bg-soft);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  display: block; width: 100%; min-height: 100px; resize: vertical;
  border: 0; outline: 0; padding: 16px 18px 6px;
  background: transparent; color: var(--text);
  font-size: 14px; line-height: 1.65;
}
textarea::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
.input-tools {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 14px 10px 18px; color: var(--muted); font-size: 11px;
}
.text-button {
  padding: 5px 8px; border: 0; background: transparent;
  color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer;
}
.text-button:hover { opacity: 0.8; }

/* ---- Buttons ---- */
.primary-actions { display: grid; grid-template-columns: 1.2fr 1fr; gap: 10px; margin-top: 14px; }
.button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 0 18px; text-decoration: none; font-weight: 700;
  cursor: pointer; font-size: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button svg { width: 18px; }
.button-primary {
  background: linear-gradient(135deg, #f0576b, #d94356);
  color: #fff; box-shadow: 0 8px 24px rgba(240,87,107,0.25);
}
.button-primary:hover { box-shadow: 0 10px 30px rgba(240,87,107,0.3); }
.button-secondary {
  border-color: var(--line); background: var(--surface-solid);
  color: var(--text);
}
.button-secondary:hover { border-color: var(--muted); }
.button-ghost {
  color: var(--accent); background: var(--accent-soft);
  border-color: transparent;
}
.button-loading { display: none; align-items: center; gap: 8px; }
.button.is-loading .button-label { display: none; }
.button.is-loading .button-loading { display: inline-flex; }
.button:disabled { opacity: 0.65; cursor: wait; transform: none !important; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Error ---- */
.error-box {
  display: flex; gap: 12px; margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(240,87,107,0.2);
  border-radius: var(--radius-md);
  background: rgba(240,87,107,0.08);
  color: #f0576b;
}
.error-box svg { flex: 0 0 auto; width: 20px; }
.error-box strong { font-size: 13px; display: block; }
.error-box p { margin: 4px 0 0; font-size: 12px; line-height: 1.5; }

/* ---- Result ---- */
.result-section { margin-top: 36px; }
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 2px 14px; gap: 14px;
}
.section-title-row h2 { font-size: 20px; font-weight: 800; }
.result-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  color: var(--success); background: rgba(58,184,130,0.08);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.result-status span {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(58,184,130,0.12);
}
.result-card {
  display: grid; grid-template-columns: 1fr 1fr;
  overflow: hidden; border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
}

/* ---- Media Panel ---- */
.media-panel {
  position: relative; display: grid; place-items: center;
  min-height: 380px; overflow: hidden;
  background: #0c0a0b;
}
.media-placeholder { color: rgba(255,255,255,0.15); }
.media-placeholder svg { width: 56px; }
.media-video {
  width: 100%; max-height: 600px; min-height: 380px;
  object-fit: contain; background: #0c0a0b;
}
.media-embed {
  width: 100%; height: 100%; min-height: 380px;
  border: 0; display: block; background: #0c0a0b;
}
@media (max-width: 700px) {
  .media-panel, .media-video, .media-embed { min-height: 280px; }
}
.image-grid {
  width: 100%; height: 100%; max-height: 600px;
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 2px; overflow: auto; background: var(--line);
}
.image-item {
  position: relative; min-height: 180px;
  overflow: hidden; background: var(--bg);
}
.image-item img {
  width: 100%; height: 100%; min-height: 180px;
  display: block; object-fit: cover;
}
.image-download {
  position: absolute; right: 8px; bottom: 8px;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm);
  color: #fff; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); cursor: pointer;
}
.image-download svg { width: 16px; }

/* ---- Result Content ---- */
.result-content {
  padding: clamp(24px, 3.5vw, 36px);
  display: flex; flex-direction: column; justify-content: center;
}
.result-meta-top {
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
  flex-wrap: wrap;
}
.media-type, .parser-label, .platform-badge {
  display: inline-flex; align-items: center; min-height: 26px;
  padding: 0 10px; border-radius: 999px;
  font-size: 10px; font-weight: 800;
}
.media-type {
  color: #fff; background: linear-gradient(135deg, #f0576b, #d94356);
}
.platform-badge {
  color: #fff; background: linear-gradient(135deg, #667eea, #764ba2);
}
.parser-label {
  color: var(--muted); background: var(--bg-soft);
}
.result-content h3 {
  font-size: clamp(22px, 3.5vw, 30px);
  line-height: 1.25; letter-spacing: -0.03em;
}
.author-line {
  margin-top: 8px; color: var(--accent);
  font-size: 13px; font-weight: 700;
}
.description {
  margin-top: 14px; color: var(--muted);
  font-size: 13px; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 4;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- Facts ---- */
.facts {
  display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap;
}
.facts div {
  padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--bg-soft);
  flex: 1 1 auto;
}
.facts dt { color: var(--muted); font-size: 10px; font-weight: 600; }
.facts dd { margin-top: 3px; font-size: 13px; font-weight: 800; }

/* ---- Format Picker ---- */
.format-picker {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line);
}
.format-section { margin-bottom: 14px; }
.format-label {
  margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--muted);
}
.format-list { display: grid; gap: 6px; }
.format-button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--text);
  text-decoration: none; font-size: 13px;
  transition: background 0.15s, transform 0.12s;
}
.format-button:hover { background: var(--surface-solid); transform: translateY(-1px); }
.format-badge {
  display: inline-flex; align-items: center; min-height: 26px;
  padding: 0 10px; border-radius: 7px;
  background: linear-gradient(135deg, #f0576b, #d94356);
  color: #fff; font-weight: 800; font-size: 11px;
}
.format-button.audio .format-badge {
  background: linear-gradient(135deg, #d4a84b, #b89138);
}
.format-meta { flex: 1; color: var(--muted); font-size: 11px; }
.format-dl { color: var(--accent); font-weight: 700; font-size: 12px; }
.format-notice {
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--accent-soft); color: var(--muted);
  font-size: 12px; line-height: 1.6;
}
.format-notice code {
  background: var(--surface-solid); padding: 2px 6px;
  border-radius: 4px; font-size: 11px;
}

/* ---- Actions ---- */
.result-actions {
  display: grid; grid-template-columns: 1.4fr 1fr;
  gap: 8px; margin-top: 20px;
}

/* ---- How Section ---- */
.how-section { margin-top: 36px; }
.how-card {
  display: flex; gap: 16px;
  padding: 22px; border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-small);
  backdrop-filter: blur(16px);
}
.how-icon {
  flex: 0 0 auto; width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent-soft); color: var(--accent);
}
.how-icon svg { width: 22px; }
.how-card h2 { font-size: 16px; font-weight: 800; }
.how-card p { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---- History ---- */
.history-section { margin-top: 36px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); backdrop-filter: blur(16px); }
.section-title-row.compact { margin-bottom: 14px; }
.history-list { display: grid; gap: 8px; }
.history-item {
  display: grid; grid-template-columns: 44px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--bg-soft);
  color: var(--text); text-align: left; cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: var(--surface-solid); }
.history-thumb {
  width: 44px; height: 44px; display: grid; place-items: center;
  overflow: hidden; border-radius: var(--radius-sm);
  background: var(--surface-solid); color: var(--accent);
}
.history-thumb img, .history-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.history-thumb svg { width: 18px; }
.history-info { min-width: 0; }
.history-info strong, .history-info span {
  display: block; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis;
}
.history-info strong { font-size: 13px; }
.history-info span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.history-arrow { width: 16px; color: var(--muted); }

/* ---- Footer ---- */
footer {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto; padding: 0 0 28px;
  color: var(--muted); text-align: center; font-size: 11px; line-height: 1.6;
}

/* ---- Toast ---- */
.toast {
  position: fixed; z-index: 50;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 16px);
  padding: 11px 16px; border-radius: var(--radius-sm);
  background: rgba(24,20,22,0.92); color: #fff;
  box-shadow: 0 12px 36px rgba(0,0,0,0.2);
  font-size: 13px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(12px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Utility ---- */
.is-hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .page-shell { padding-top: 20px; }
  .hero { margin-bottom: 18px; }
  .primary-actions { grid-template-columns: 1fr; }
  .result-card { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr; }
  .format-button { padding: 12px 14px; }
}
@media (max-width: 480px) {
  .topbar { width: min(calc(100% - 20px), var(--max)); min-height: 56px; }
  .page-shell { width: min(calc(100% - 20px), var(--max)); padding-top: 14px; }
  .brand small { display: none; }
  .hero h1 { font-size: 30px; }
  .hero p { font-size: 12px; }
  .parse-card { padding: 16px; border-radius: 20px; }
  .media-panel, .media-video, .media-embed { min-height: 240px; }
  .image-grid { grid-template-columns: 1fr; }
  .image-item { min-height: 220px; }
  .how-card { flex-direction: column; align-items: flex-start; }
}
