/* Subtitle Edit Guide — shared stylesheet
   Unofficial guide. Colors are defined as tokens and re-defined for dark mode. */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #efede6;
  --ink: #16181d;
  --ink-2: #444a55;
  --ink-3: #6b7280;
  --line: #dedbd2;
  --accent: #f2c230;          /* subtitle yellow */
  --accent-ink: #1a1400;      /* text on accent */
  --link: #0b6e75;
  --link-hover: #06474c;
  --tip-bg: #e6f4f1;  --tip-line: #2a9d8f;
  --warn-bg: #fdf3dc; --warn-line: #c98a00;
  --err-bg: #fbe9e7;  --err-line: #c0392b;
  --screen: #101318;
  --screen-ink: #f5f5f5;
  --wave: #2a9d8f;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px rgba(20, 20, 30, .06);
  --radius: 12px;
  --maxw: 1160px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #181b21;
    --surface-2: #20242c;
    --ink: #eceef2;
    --ink-2: #b9bfca;
    --ink-3: #8b93a1;
    --line: #2c313b;
    --accent: #f2c230;
    --accent-ink: #1a1400;
    --link: #5cc8cf;
    --link-hover: #93e0e4;
    --tip-bg: #13302c;  --tip-line: #3cb8a8;
    --warn-bg: #33290f; --warn-line: #e0a82e;
    --err-bg: #3a1c19;  --err-line: #e0675a;
    --screen: #07090c;
    --wave: #3cb8a8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #181b21;
  --surface-2: #20242c;
  --ink: #eceef2;
  --ink-2: #b9bfca;
  --ink-3: #8b93a1;
  --line: #2c313b;
  --accent: #f2c230;
  --accent-ink: #1a1400;
  --link: #5cc8cf;
  --link-hover: #93e0e4;
  --tip-bg: #13302c;  --tip-line: #3cb8a8;
  --warn-bg: #33290f; --warn-line: #e0a82e;
  --err-bg: #3a1c19;  --err-line: #e0675a;
  --screen: #07090c;
  --wave: #3cb8a8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); letter-spacing: -.025em; }
h2 { font-size: clamp(1.45rem, 2.8vw, 1.9rem); margin-top: 2.2em; }
h3 { font-size: 1.2rem; margin-top: 1.6em; }
p, ul, ol { margin: 0 0 1em; }
li + li { margin-top: .3em; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: .08em .38em;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
kbd {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: .02em .45em;
  font-size: .82em;
  white-space: nowrap;
}
.menu-path {
  font-weight: 600;
  background: var(--surface-2);
  border-radius: 6px;
  padding: .05em .4em;
  white-space: normal;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .6em 1em; border-radius: 8px; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 28px; } }
.muted { color: var(--ink-3); }
.lead { font-size: 1.18rem; color: var(--ink-2); max-width: 62ch; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.01em;
  margin-right: auto; white-space: nowrap;
}
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: #16181d; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
}
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--ink-3); letter-spacing: .02em; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.nav-list li + li { margin: 0; }
.nav-list a {
  display: block; padding: .45em .75em; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.nav-list a:hover { background: var(--surface-2); color: var(--ink); }
.nav-list a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.nav-toggle { display: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

@media (max-width: 960px) {
  .nav-toggle { display: inline-grid; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--bg); border-bottom: 1px solid var(--line);
    display: none; padding: 8px 16px 16px;
  }
  .site-nav.open { display: block; }
  .nav-list { flex-direction: column; }
  .nav-list a { padding: .7em .8em; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .78em 1.25em; border-radius: 10px;
  font-weight: 700; font-size: 1rem; line-height: 1.2; text-decoration: none;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.05); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 1.4em 0; }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; gap: 40px; align-items: center; }
@media (min-width: 960px) { .hero-grid { grid-template-columns: 1.05fr 1fr; } }
.eyebrow {
  display: inline-flex; align-items: center; gap: .5em;
  font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  padding: .35em .8em; border-radius: 999px; margin-bottom: 1.2em;
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hero h1 .hl { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 70%, transparent) 62%); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--ink-3); font-size: .92rem; }
.hero-meta span::before { content: "✓ "; color: var(--wave); font-weight: 700; }

.page-hero { padding: 44px 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.breadcrumb { font-size: .9rem; color: var(--ink-3); margin-bottom: .8em; }
.breadcrumb a { color: var(--ink-3); }

/* ---------- Editor mockup (pure CSS) ---------- */
.mock {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; font-size: .8rem;
}
.mock-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mock-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; }
.mock-bar b { margin-left: 8px; font-weight: 600; color: var(--ink-3); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock-body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 520px) { .mock-body { grid-template-columns: 1.1fr 1fr; } }
.mock-grid { border-right: 1px solid var(--line); min-width: 0; }
.mock-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.mock-row .n { color: var(--ink-3); font-family: var(--mono); }
.mock-row .t { font-family: var(--mono); color: var(--ink-3); font-size: .72rem; display: block; }
.mock-row .x { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock-row.sel { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.mock-video {
  background: var(--screen); min-height: 160px; position: relative;
  display: flex; align-items: flex-end; justify-content: center; padding: 14px;
  background-image: radial-gradient(ellipse at 30% 30%, #2b3440 0, transparent 60%), radial-gradient(ellipse at 75% 60%, #20303a 0, transparent 55%);
}
.mock-sub { color: #fff; text-align: center; font-weight: 600; font-size: .9rem; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.mock-wave {
  grid-column: 1 / -1; height: 62px; border-top: 1px solid var(--line); position: relative;
  background:
    repeating-linear-gradient(90deg, transparent 0 3px, var(--surface) 3px 5px),
    linear-gradient(var(--surface), var(--surface));
  overflow: hidden;
}
.mock-wave .bars { position: absolute; inset: 8px 0; display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.mock-wave .bars span { flex: 1; background: var(--wave); border-radius: 2px; opacity: .8; }
.mock-wave .cue { position: absolute; top: 4px; bottom: 4px; background: color-mix(in srgb, var(--accent) 30%, transparent); border: 1px solid var(--accent); border-radius: 4px; }
.mock-wave .head { position: absolute; top: 0; bottom: 0; width: 2px; background: #e5484d; }

/* ---------- Sections & cards ---------- */
.section { padding: 48px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 680px; margin-bottom: 28px; }
.section-head h2 { margin-top: 0; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.section-alt .card { background: var(--bg); }
.card h3 { margin-top: 0; font-size: 1.1rem; }
.card p { color: var(--ink-2); font-size: .98rem; }
.card .more { margin-top: auto; font-weight: 700; text-decoration: none; }
.card .more::after { content: " →"; }
.card-icon {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--ink); margin-bottom: 14px;
}
.card-icon svg { width: 22px; height: 22px; }

/* ---------- Guide layout with TOC ---------- */
.guide { display: grid; gap: 40px; padding-top: 36px; padding-bottom: 64px; }
@media (min-width: 1000px) { .guide { grid-template-columns: 230px minmax(0, 1fr); } }
.toc { font-size: .92rem; }
@media (min-width: 1000px) { .toc { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; } }
.toc-title { font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .6em; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li + li { margin-top: 0; }
.toc a { display: block; padding: .35em .9em; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); }
.toc a.active { border-left-color: var(--accent); color: var(--ink); font-weight: 700; }
@media (max-width: 999px) {
  .toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
}
.prose { max-width: 78ch; min-width: 0; }
.prose > section:first-child h2 { margin-top: 0; }
.prose section { scroll-margin-top: 84px; }

/* ---------- Steps ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 1.2em 0 1.6em; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 1.3em 3.2em; margin: 0; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -.1em;
  width: 2.1em; height: 2.1em; border-radius: 50%;
  display: grid; place-items: center;
  background: #16181d; color: var(--accent); font-weight: 800; box-shadow: inset 0 0 0 1px var(--line); font-size: .95rem;
}
.steps > li:not(:last-child)::after {
  content: ""; position: absolute; left: 1.02em; top: 2.2em; bottom: .2em; width: 2px; background: var(--line);
}
.steps > li strong:first-child { display: block; }

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--tip-line);
  background: var(--tip-bg); border-radius: 10px; padding: 14px 16px; margin: 1.2em 0;
}
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout-title { font-weight: 800; display: block; margin-bottom: .25em; }
.callout.warn { border-left-color: var(--warn-line); background: var(--warn-bg); }
.callout.err { border-left-color: var(--err-line); background: var(--err-bg); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 1.2em 0 1.6em; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-size: .82rem; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); white-space: nowrap; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15em .55em; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--tip-line) 22%, transparent); color: var(--ink); }
.badge.no { background: color-mix(in srgb, var(--err-line) 22%, transparent); color: var(--ink); }
.badge.mid { background: color-mix(in srgb, var(--warn-line) 25%, transparent); color: var(--ink); }

/* ---------- Download cards ---------- */
.dl-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin: 1.4em 0; }
.dl-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.dl-card.featured { border: 2px solid var(--accent); }
.dl-card h3 { margin: 0; font-size: 1.1rem; }
.dl-card .file { font-family: var(--mono); font-size: .8rem; color: var(--ink-3); overflow-wrap: anywhere; }
.dl-card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.dl-card .btn { margin-top: auto; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 1.2em 0; }
.facts div { background: var(--surface); padding: 14px 16px; }
.facts dt { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.facts dd { margin: .2em 0 0; font-weight: 600; }

/* ---------- Code block + copy ---------- */
.codeblock { position: relative; margin: 1em 0 1.4em; }
.codeblock pre {
  margin: 0; background: var(--screen); color: #e8eaed; border-radius: 10px;
  padding: 14px 16px; padding-right: 76px; overflow-x: auto; font-family: var(--mono); font-size: .88rem; line-height: 1.55;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  font: 600 .75rem var(--font); padding: .4em .7em; border-radius: 6px;
  border: 1px solid #3a404b; background: #20252d; color: #e8eaed; cursor: pointer;
}
.copy-btn:hover { background: #2b313b; }

/* ---------- Timing diagram ---------- */
.timing { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; margin: 1.2em 0 1.6em; }
.timing-row { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 10px; margin: 8px 0; }
.timing-row .lbl { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.track { position: relative; height: 28px; background: var(--surface-2); border-radius: 6px; }
.track span { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; }
.track.speech span { background: color-mix(in srgb, var(--wave) 55%, transparent); }
.track.cues span { background: color-mix(in srgb, var(--accent) 70%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 90%, #000); }
.timing figcaption { font-size: .85rem; color: var(--ink-3); margin-top: 8px; }

/* ---------- Srt sample ---------- */
.srt { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin: 1em 0 1.4em; }
.srt figure { margin: 0; }
.srt figcaption { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.srt pre { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: .85rem; overflow-x: auto; }
.srt .chg { background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 3px; }

/* ---------- Notice + footer ---------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: .9rem; color: var(--ink-2);
}
.notice strong { color: var(--ink); }
.cta-band { background: var(--ink); color: var(--bg); border-radius: 16px; padding: 32px; display: grid; gap: 16px; align-items: center; }
@media (min-width: 800px) { .cta-band { grid-template-columns: 1fr auto; } }
.cta-band h2 { margin: 0 0 .3em; color: var(--bg); }
.cta-band p { margin: 0; color: color-mix(in srgb, var(--bg) 75%, var(--ink)); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 40px 0 28px; font-size: .92rem; color: var(--ink-2); }
.footer-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.footer-grid h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .8em; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li + li { margin-top: .4em; }
.footer-grid a { color: var(--ink-2); text-decoration: none; }
.footer-grid a:hover { color: var(--ink); text-decoration: underline; }
.footer-legal { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px; font-size: .84rem; color: var(--ink-3); }
.ext::after { content: " ↗"; font-size: .85em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
