:root {
  --bg: #f6f1e8; --ink: #1c1917; --muted: #78716c; --card: #fffcf7;
  --line: #e7e0d4; --accent: #0f766e; --accent-soft: #ccfbf1;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif; color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #fde68a55, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #99f6e455, transparent 55%),
    var(--bg);
  padding: 2rem 1.25rem 4rem;
}
main { width: min(820px, 100%); margin: 0 auto; }
a { color: var(--accent); }
.nav { font-size: 0.9rem; margin-bottom: 1.25rem; color: var(--muted); }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 1.5rem 1.35rem; margin-bottom: 1.1rem;
}
.hero h1 {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: clamp(2rem, 6vw, 2.6rem); line-height: 1.1; margin: 0 0 0.65rem;
}
h2 {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: 1.45rem; margin: 0 0 0.55rem;
}
.cat {
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 0.35rem;
}
.lede { color: #44403c; line-height: 1.55; margin: 0 0 0.85rem; }
.meta, .hint { font-size: 0.9rem; color: var(--muted); line-height: 1.5; margin: 0 0 0.75rem; }
.ep-link { font-size: 0.92rem; margin: 0; }
.soon { color: var(--muted); font-style: italic; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0 0 0.85rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; border-radius: 999px; padding: 0.7rem 1rem;
  font-weight: 600; font-size: 0.9rem; border: 1px solid transparent;
  cursor: pointer; font-family: inherit; background: var(--card); color: var(--ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-secondary { border-color: var(--line); }
.file-btn { cursor: pointer; }
.status {
  font-size: 0.88rem; color: #57534e; margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem; border-radius: 12px; background: #fafaf9; border: 1px solid var(--line);
}
.stage-wrap {
  position: relative; width: 100%; background: #1c1917; border-radius: 16px;
  overflow: hidden; border: 1px solid var(--line);
}
#canvas { display: block; width: 100%; height: auto; vertical-align: middle; }
.detections {
  list-style: none; padding: 0; margin: 0.85rem 0 0;
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.detections li {
  font-size: 0.8rem; padding: 0.3rem 0.65rem; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid #99f6e4; color: #0f766e;
}
.samples { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sample {
  display: flex; flex-direction: column; gap: 0.45rem; text-align: left;
  background: #fafaf9; border: 1px solid var(--line); border-radius: 14px;
  padding: 0.65rem; cursor: pointer; font-family: inherit; color: inherit;
}
.sample:hover { border-color: #99f6e4; }
.sample img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #e7e0d4;
}
.sample strong { font-size: 0.92rem; }
.sample span { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.privacy { background: var(--accent-soft); border-color: #99f6e4; }
.plain { margin: 0 0 0.75rem; padding-left: 1.1rem; color: #44403c; line-height: 1.55; }
.plain li { margin-bottom: 0.35rem; }
footer { margin-top: 1.5rem; text-align: center; color: var(--muted); font-size: 0.8rem; }
footer a { color: var(--muted); }
code { font-size: 0.85em; background: #f5f5f4; padding: 0.1em 0.35em; border-radius: 6px; }

.caption-box {
  margin-top: 0.85rem; padding: 0.9rem 1rem; border-radius: 14px;
  background: #fafaf9; border: 1px solid var(--line);
}
.caption-en {
  margin: 0 0 0.35rem; font-size: 1.02rem; line-height: 1.5; color: #44403c;
}
.caption-zh {
  margin: 0 0 0.55rem; font-size: 1.02rem; line-height: 1.55; color: #1c1917;
}
.caption-note {
  margin: 0; font-size: 0.78rem; color: var(--muted); line-height: 1.45;
}

.toolbar-note { margin: -0.35rem 0 0.85rem; min-height: 1.2rem; }
.save-link {
  font-size: 0.88rem; font-weight: 600; color: var(--accent); text-decoration: none;
}
.save-link:hover { text-decoration: underline; }
.save-link[hidden] { display: none !important; }

@media (max-width: 420px) {
  .toolbar { gap: 0.5rem; }
  .toolbar .btn,
  .toolbar .file-btn {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }
  .hero h1 { font-size: 1.85rem; }
  .caption-en, .caption-zh { font-size: 0.95rem; }
}
