:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1c1b19;
  --muted: #6f6c66;
  --border: #e4e2dc;
  --accent: #e5484d;
  --accent-hover: #d43c41;
  --accent-soft: rgba(229, 72, 77, 0.1);
  --on-accent: #ffffff;
  --error: #c92a2f;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 8px 24px rgba(28, 27, 25, 0.06);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1e;
    --surface-2: #242428;
    --text: #ededee;
    --muted: #9b9ba1;
    --border: #2e2e33;
    --accent: #f2555a;
    --accent-hover: #ff6a6f;
    --accent-soft: rgba(242, 85, 90, 0.14);
    --error: #ff7b7f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }

svg { width: 100%; height: 100%; display: block; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.error-text {
  color: var(--error);
  font-size: 14px;
  min-height: 22px;
  margin: 10px 0 0;
}

.boot { min-height: 100vh; }

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 12px;
  display: inline-flex;
  box-shadow: 0 6px 18px var(--accent-soft);
}

.brand-mark.small {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  padding: 5px;
  box-shadow: none;
}

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 11px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.icon-btn.primary { background: var(--accent); color: var(--on-accent); }
.icon-btn.primary:hover { background: var(--accent-hover); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn:disabled { opacity: 0.5; cursor: default; }

.text-btn {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.text-btn:hover { color: var(--text); background: var(--surface-2); }

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 26px;
  margin: 18px 0 4px;
  letter-spacing: 0.02em;
}

.login-card .muted { margin: 0 0 24px; }

.pin-field {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pin-field:focus-within, .url-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.pin-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  padding: 0 12px;
  font-size: 18px;
  letter-spacing: 0.3em;
}

.pin-field input::placeholder { letter-spacing: normal; font-size: 16px; }

.shake { animation: shake 0.35s; }

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.hero {
  text-align: center;
  padding: 40px 0 8px;
}

.hero h2 {
  font-size: clamp(24px, 5vw, 34px);
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}

.hero > .muted { margin: 0 0 28px; }

.url-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.url-icon { width: 20px; height: 20px; flex: none; color: var(--muted); }

.url-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  height: 44px;
  font-size: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 16px;
  animation: rise 0.3s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.loading { display: grid; grid-template-columns: 220px 1fr; }

.loading-media { aspect-ratio: 16 / 9; }

.loading-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
}

.loading-title { margin: 0; font-weight: 600; }
.loading-body p { margin: 0; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.result-head {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}

.thumb:hover img { transform: scale(1.04); }

.thumb .play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 13px 11px 13px 15px;
}

.result-meta {
  padding: 18px 20px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-meta h3 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.4;
}

.result-meta .original {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.chip.accent { background: var(--accent-soft); color: var(--accent); }

.result-body { padding: 20px; }

.theme {
  margin: 0 0 4px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 4px 12px 12px 4px;
  line-height: 1.7;
}

.theme strong { color: var(--accent); }

.topic { padding-top: 18px; }

.topic + .topic { border-top: 1px dashed var(--border); margin-top: 18px; }

.topic h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.4;
}

.topic .num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  display: grid;
  place-items: center;
}

.takeaway .num { background: var(--accent-soft); }

.points {
  margin: 0;
  padding: 0 0 0 20px;
}

.points li {
  padding: 5px 0;
  line-height: 1.75;
  text-align: justify;
}

.points li::marker { color: var(--accent); }

.points strong { font-weight: 600; }

.ts {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
  text-decoration: none;
  vertical-align: 1px;
}

.ts:hover { background: var(--accent-soft); }

.result.error-card .result-body { display: flex; gap: 12px; align-items: flex-start; }

.error-icon {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--error);
  margin-top: 2px;
}

.error-card h3 { margin: 0 0 4px; font-size: 16px; }
.error-card p { margin: 0; }

@media (max-width: 640px) {
  .hero { padding-top: 20px; }
  .hero > .muted { font-size: 14px; margin-bottom: 20px; }
  .loading, .result-head { grid-template-columns: 1fr; }
  .result-meta { padding: 16px; }
  .result-body { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
