/* Ultimate Motion Design docs. One accent: the red of a recording light. System fonts only (no network fonts). */
:root {
  --bg: #faf9f7; --surface: #ffffff; --ink: #17181b; --muted: #5b5f66; --line: #e4e1db; --code-bg: #f1efea;
  --rec: #e0452b; --link: #b0361d; --btn: #c13a20; --btn-ink: #ffffff; --mark: #fbe3dc;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px; --s12: 48px; --s16: 64px;
  --radius: 8px; --top: 56px; --content: 760px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --surface: #1a1b1e; --ink: #ecebe8; --muted: #a2a5ac; --line: #2c2e33; --code-bg: #1e2024;
    --rec: #ff5a3c; --link: #ff8f74; --btn: #ff6a4d; --btn-ink: #1a0e0b; --mark: #3a211b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121315; --surface: #1a1b1e; --ink: #ecebe8; --muted: #a2a5ac; --line: #2c2e33; --code-bg: #1e2024;
  --rec: #ff5a3c; --link: #ff8f74; --btn: #ff6a4d; --btn-ink: #1a0e0b; --mark: #3a211b; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + var(--s4)); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--font); }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--rec); outline-offset: 2px; border-radius: 4px; }
img, video { max-width: 100%; height: auto; display: block; }

.skip { position: absolute; left: var(--s4); top: -100px; background: var(--ink); color: var(--bg); padding: var(--s2) var(--s4); border-radius: var(--radius); z-index: 20; }
.skip:focus { top: var(--s2); }

/* ---- top bar */
.top { position: sticky; top: 0; z-index: 10; height: var(--top); display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s6); background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(8px); }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.version { font: 12px/1 var(--mono); color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.top-actions a, .top-actions button { display: inline-flex; align-items: center; justify-content: center; height: 36px; min-width: 36px; padding: 0 var(--s3);
  border-radius: var(--radius); color: var(--ink); background: none; border: 0; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.top-actions a:hover, .top-actions button:hover { background: var(--code-bg); }
.top-actions .theme, .top-actions .gh { padding: 0; width: 36px; }

/* ---- layout */
.layout { display: grid; grid-template-columns: 232px minmax(0, var(--content)) 200px; gap: var(--s12); max-width: 1320px; margin: 0 auto; padding: 0 var(--s6); }
.side { position: sticky; top: var(--top); align-self: start; max-height: calc(100vh - var(--top)); overflow-y: auto; padding: var(--s8) 0; }
.side summary { display: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: block; padding: 6px var(--s3); border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 15px; line-height: 1.4; }
.side nav a:hover { color: var(--ink); background: var(--code-bg); }
.side nav a[aria-current="page"] { color: var(--ink); background: var(--mark); font-weight: 600; }
main { min-width: 0; padding: var(--s8) 0 var(--s12); }
.toc { position: sticky; top: var(--top); align-self: start; padding: var(--s8) 0; display: flex; flex-direction: column; gap: var(--s1); font-size: 14px; }
.toc p { margin: 0 0 var(--s2); font-weight: 600; color: var(--ink); }
.toc a { color: var(--muted); text-decoration: none; line-height: 1.4; padding: 2px 0; }
.toc a:hover { color: var(--ink); }
body.home .layout { grid-template-columns: 232px minmax(0, 1fr); }
body.home main { max-width: 980px; }
body.home article > p, body.home article > ul, body.home article > ol { max-width: 72ch; }
.brand .short { display: none; }

/* ---- content */
article > :first-child { margin-top: 0; }
h1 { font-size: 2.25rem; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 var(--s6); }
h2 { font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.01em; margin: var(--s12) 0 var(--s4); padding-top: var(--s2); }
h3 { font-size: 1.125rem; line-height: 1.35; margin: var(--s8) 0 var(--s3); }
h4 { font-size: 1rem; margin: var(--s6) 0 var(--s2); }
h1 + h2 { margin-top: 0; }
article > p, article > ul > li, article > ol > li { max-width: 75ch; }
h2, h3, h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; width: 1em; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
p, ul, ol { margin: 0 0 var(--s4); }
ul, ol { padding-left: 1.4em; }
li { margin: var(--s1) 0; }
li > ul, li > ol { margin: var(--s1) 0 0; }
strong { font-weight: 650; }
code { font: 14px/1.5 var(--mono); background: var(--code-bg); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
blockquote { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-left: 3px solid var(--line); color: var(--muted); }

.code { position: relative; margin: 0 0 var(--s6); }
.code pre { margin: 0; padding: var(--s4) var(--s4); padding-right: 88px; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy { position: absolute; top: var(--s2); right: var(--s2); height: 32px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted); font: 14px var(--font); cursor: pointer; }
.copy:hover { color: var(--ink); }
.copy[data-done] { color: var(--ink); border-color: var(--rec); }

.table { overflow-x: auto; margin: 0 0 var(--s6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
th { font-weight: 600; font-size: 14px; color: var(--muted); background: var(--code-bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s4); margin-top: var(--s16); padding-top: var(--s6); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot a { color: var(--muted); }

/* ---- home */
.hero { display: flex; flex-direction: column; gap: var(--s8); margin-bottom: var(--s16); }
.hero h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); margin-bottom: var(--s4); }
.lead { font-size: 1.375rem; line-height: 1.4; margin: 0 0 var(--s4); max-width: 34em; }
.hero-sub { color: var(--muted); max-width: 40em; margin: 0 0 var(--s6); }
.install { max-width: 720px; }
.hero-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s6); margin: 0; }
.hero-links a { display: inline-flex; align-items: center; min-height: 44px; }
.hero-links .primary { display: inline-flex; align-items: center; height: 44px; padding: 0 var(--s6); border-radius: var(--radius); background: var(--btn); color: var(--btn-ink); font-weight: 600; text-decoration: none; }
.hero-links .primary:hover { filter: brightness(1.05); }
.hero-media { margin: 0; }
.hero-media video { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; border: 1px solid var(--line); background: #0d0e10; }
.hero-media figcaption { margin-top: var(--s3); color: var(--muted); font-size: 14px; }

/* ---- style library */
body.wide .layout { grid-template-columns: 232px minmax(0, 1fr); }
body.wide main { max-width: 1120px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lib { margin: var(--s8) 0 var(--s12); }
.lib-bar { position: sticky; top: var(--top); z-index: 4; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center;
  margin: 0 calc(var(--s2) * -1); padding: var(--s3) var(--s2); background: var(--bg); border-bottom: 1px solid var(--line); }
.lib-search { flex: 1 1 280px; }
.lib-bar input, .lib-bar select { width: 100%; height: 40px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: 15px var(--font); }
.lib-cat { flex: 0 1 240px; }
.lib-src { display: flex; flex-wrap: wrap; gap: var(--s1); }
.lib-src button { height: 40px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted);
  font: 14px var(--font); cursor: pointer; }
.lib-src button span { font: 12px var(--mono); margin-left: var(--s1); }
.lib-src button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.lib-count { margin: var(--s4) 0; color: var(--muted); font-size: 14px; }
.lib-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s6) var(--s4); }
.lib-grid .card { margin: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card-media { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: #0d0e10; cursor: pointer; overflow: hidden; }
.card-media img, .card-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-media video { z-index: 1; }
.card-media:hover img { filter: brightness(1.06); }
.card-ph { position: absolute; inset: 0; display: grid; place-items: center; color: #a2a5ac; font-size: 14px; }
.card-badge, .card-score { position: absolute; z-index: 2; top: var(--s2); padding: 2px var(--s2); border-radius: 4px; font: 12px/1.5 var(--font); color: #fff; background: rgb(0 0 0 / 0.62); }
.card-badge { left: var(--s2); }
.card-score { right: var(--s2); font-family: var(--mono); background: var(--rec); }
.card-body { padding: var(--s3) var(--s4) 0; flex: 1; }
.card-body h3 { margin: 0 0 var(--s1); font-size: 1rem; line-height: 1.35; }
.card-meta { margin: 0 0 var(--s2); color: var(--muted); font-size: 13px; }
.card-line { margin: 0; font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); font-size: 14px; }
.card-prompt { height: 36px; padding: 0 var(--s4); border: 0; border-radius: 6px; background: var(--btn); color: var(--btn-ink); font: 600 14px var(--font); cursor: pointer; }
.card-prompt:hover { filter: brightness(1.05); }
.card-actions a { display: inline-flex; align-items: center; min-height: 36px; }
.lib-more-wrap { text-align: center; margin: var(--s8) 0 0; }
.lib-more { height: 44px; padding: 0 var(--s6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: 15px var(--font); cursor: pointer; }
.lib-dlg { width: min(860px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); overflow: hidden; }
.lib-dlg[open] { display: flex; flex-direction: column; }
.lib-dlg::backdrop { background: rgb(0 0 0 / 0.6); }
.lib-dlg-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s6); border-bottom: 1px solid var(--line); }
.lib-dlg-head h2 { margin: 0; padding: 0; font-size: 1.25rem; flex: 1; min-width: 0; }
.lib-close { width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: none; color: var(--ink); font-size: 28px; line-height: 1; cursor: pointer; }
.lib-close:hover { background: var(--code-bg); }
.lib-dlg-body { padding: var(--s6); overflow-y: auto; }
.lib-dlg-body h3 { margin: var(--s6) 0 var(--s3); }
.lib-dlg-media { margin: 0 0 var(--s4); }
.lib-dlg-media img, .lib-dlg-media video { width: 100%; max-height: 52vh; object-fit: contain; border-radius: var(--radius); background: #0d0e10; }
.lib-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.lib-links a { display: inline-flex; align-items: center; min-height: 36px; }
.lib-film, .lib-hint { color: var(--muted); font-size: 14px; }
.lib-prompt pre { max-height: 46vh; }

/* ---- responsive */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); gap: var(--s8); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .top { padding: 0 var(--s4); gap: var(--s2); }
  .version { display: none; }
  .brand { height: 44px; }
  .foot a { display: inline-flex; align-items: center; min-height: 44px; }
  .brand .long { display: none; }
  .brand .short { display: inline; }
  .top-actions a, .top-actions button { height: 44px; min-width: 44px; }
  .top-actions .theme, .top-actions .gh { width: 44px; }
  .side nav a { padding: 10px var(--s3); }
  .code pre { padding-right: var(--s4); }
  .copy { position: static; display: block; height: 40px; margin: var(--s2) 0 0 auto; }
  .layout, body.home .layout, body.wide .layout { display: block; padding: 0 var(--s4); }
  .lib-bar { position: static; }
  .lib-cat { flex: 1 1 100%; }
  .lib-src button { height: 44px; }
  .lib-dlg { width: 100%; max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; border: 0; }
  .lib-dlg-body { padding: var(--s4); }
  .card-prompt, .card-actions a, .lib-links a { min-height: 44px; }
  .side { position: sticky; top: var(--top); z-index: 5; max-height: none; overflow: visible; padding: 0; margin: 0 calc(var(--s4) * -1); background: var(--bg); border-bottom: 1px solid var(--line); }
  .side summary { display: flex; align-items: center; height: 44px; padding: 0 var(--s4); cursor: pointer; font-weight: 600; list-style: none; }
  .side summary::-webkit-details-marker { display: none; }
  .side summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
  .side[open] summary::after { transform: rotate(-135deg); }
  .side nav { padding: 0 var(--s4) var(--s4); max-height: 70vh; overflow-y: auto; }
  main { padding-top: var(--s8); }
  h1 { margin-bottom: var(--s4); }
  h1 { font-size: 1.875rem; }
  .anchor { display: none; }
  .lead { font-size: 1.1875rem; }
  th, td { padding: var(--s2) var(--s3); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---- sound palette */
.sfx-grid { list-style: none; margin: var(--s6) 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s4); }
.sfx { padding: var(--s3) var(--s4) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: var(--s2); }
.sfx-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.sfx-head span { color: var(--muted); font: 12px var(--mono); }
.sfx p { margin: 0; font-size: 14px; color: var(--muted); flex: 1 1 auto; }
.sfx audio { width: 100%; height: 36px; }
