/* Slowframe: световой стол.
   Layout: content sits on a cool lit surface, 12-column grid up to 1240px; every section is one frame.
   Radius rule: panels 18px, tiles inside panels 12px, buttons and chips are pills. */
:root {
  --bg: #ECEEF1;
  --surface: #F8F9FB;
  --surface-2: #E1E5EA;
  --ink: #14161B;
  --muted: #555E6E;
  --line: #D2D7DE;
  --accent: #FFC21A;
  --on-accent: #14161B;
  --accent-text: #7A5300;
  --danger: #D93B3F;
  --on-danger: #FFFFFF;
  --knob: #FFFFFF;
  --trail-1: rgba(20, 22, 27, .34);
  --trail-2: rgba(20, 22, 27, .14);
  --shadow: 0 1px 0 rgba(26, 34, 52, .04), 0 18px 40px -24px rgba(26, 34, 52, .32);
  --shadow-pop: 0 2px 6px rgba(26, 34, 52, .08), 0 22px 48px -18px rgba(26, 34, 52, .38);

  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);

  --r-panel: 18px;
  --r-tile: 12px;
  --wrap: 1240px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #171A20;
    --surface-2: #222630;
    --ink: #E9ECF1;
    --muted: #9BA3B2;
    --line: #2B303A;
    --accent: #FFC93D;
    --on-accent: #14161B;
    --accent-text: #FFC93D;
    --danger: #F2555A;
    --on-danger: #14161B;
    --knob: #B4BBC7;
    --trail-1: rgba(233, 236, 241, .34);
    --trail-2: rgba(233, 236, 241, .14);
    --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 18px 40px -24px rgba(0, 0, 0, .7);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, .3), 0 22px 48px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #171A20;
  --surface-2: #222630;
  --ink: #E9ECF1;
  --muted: #9BA3B2;
  --line: #2B303A;
  --accent: #FFC93D;
  --on-accent: #14161B;
  --accent-text: #FFC93D;
  --danger: #F2555A;
  --on-danger: #14161B;
  --knob: #B4BBC7;
  --trail-1: rgba(233, 236, 241, .34);
  --trail-2: rgba(233, 236, 241, .14);
  --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 18px 40px -24px rgba(0, 0, 0, .7);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, .3), 0 22px 48px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
@media (min-width: 768px) { :root { --gutter: 32px; } }

.skip {
  position: fixed; left: 16px; top: 12px; z-index: 100;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 999px;
  transform: translateY(-160%); transition: transform 200ms var(--ease-out);
}
.skip:focus { transform: none; }
.anchor-top { position: absolute; top: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 999px;
  font: 500 15px/1 var(--font-body); white-space: nowrap; text-decoration: none;
  border: 1px solid transparent;
  transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}
.btn:active { transform: scale(.97); }
.btn i { font-size: 18px; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-small { height: 38px; padding: 0 16px; font-size: 14px; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
  .btn-ghost:hover { border-color: var(--ink); }
  .btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease;
}
.icon-btn i { font-size: 18px; }
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--surface-2); } }

/* Segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  height: 30px; padding: 0 12px; border-radius: 999px;
  font: 500 12.5px/1 var(--font-mono);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 180ms ease, color 180ms ease, transform 160ms var(--ease-out);
}
.seg-btn i { font-size: 16px; }
.seg-btn:active { transform: scale(.95); }
.seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg-small .seg-btn { padding: 0 9px; }

/* Nav */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.nav-in { height: 64px; display: flex; align-items: center; gap: 24px; }
.logo {
  display: inline-flex; align-items: center; gap: 14px;
  font: 600 17px/1 var(--font-display); letter-spacing: -.01em; text-decoration: none;
}
.logo-mark {
  width: 13px; height: 13px; border-radius: 3px; margin-left: 12px;
  background: var(--accent); border: 2px solid var(--ink);
  box-shadow: -6px 0 0 -2px var(--trail-1), -11px 0 0 -4px var(--trail-2);
}
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  text-decoration: none; font-size: 14.5px; font-weight: 500; color: var(--muted);
  padding: 8px 12px; border-radius: 999px; transition: color 160ms ease, background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) { .nav-links a:hover { color: var(--ink); background: var(--surface-2); } }
.nav-actions { display: flex; gap: 8px; }
.menu-btn { display: none; }
.mobile-menu { display: grid; gap: 2px; padding-block: 8px 16px; }
.mobile-menu a { text-decoration: none; padding: 12px 4px; font-weight: 500; font-size: 17px; border-bottom: 1px solid var(--line); }
.mobile-menu a:last-child { border-bottom: 0; }
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-actions { margin-left: auto; }
  .menu-btn { display: inline-grid; }
}
@media (min-width: 901px) { .mobile-menu { display: none !important; } }

/* Hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px;
  padding-block: 48px 72px;
}
@media (min-width: 1000px) {
  .hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center; padding-block: 72px 96px; }
}
.hero-copy { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.hero h1 {
  font: 600 clamp(2.15rem, 1.1rem + 3.6vw, 3.7rem)/1.06 var(--font-display);
  letter-spacing: -.035em;
  max-width: 12ch;
}
.lead { font-size: clamp(1.05rem, .98rem + .3vw, 1.2rem); color: var(--muted); max-width: 46ch; line-height: 1.55; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* Scrubber */
.scrub {
  margin: 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px;
}
.scrub-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tc {
  font-size: 13px; letter-spacing: .04em; color: var(--ink);
  background: var(--surface-2); padding: 6px 10px; border-radius: 999px;
}
.stage {
  position: relative; height: 170px; border-radius: var(--r-tile);
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box;
  display: grid; place-items: center; overflow: hidden;
}
.actor-slot {
  position: absolute; width: 268px; height: 64px; border-radius: 14px;
  border: 1.5px dashed var(--line);
}
.actor {
  position: relative;
  width: 268px; height: 64px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  will-change: transform, opacity;
}
.actor-ico {
  width: 32px; height: 32px; border-radius: 999px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: 17px;
}
.actor-txt { display: grid; line-height: 1.25; min-width: 0; }
.actor-txt b { font-weight: 600; font-size: 14.5px; }
.actor-txt small { color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); }

.strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.strip li { display: grid; gap: 4px; justify-items: center; }
.frame {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; position: relative; overflow: hidden;
  background: var(--surface-2); border: 1.5px solid transparent;
  transition: border-color 120ms ease;
}
.frame .mini {
  position: absolute; left: 50%; top: 50%;
  width: 268px; height: 64px; margin: -32px 0 0 -134px;
  transform: scale(var(--fs, .2));
}
.frame .actor { box-shadow: none; }
.strip li.is-now .frame { border-color: var(--ink); }
.strip li span { font: 500 10.5px/1 var(--font-mono); color: var(--muted); }
.strip li.is-now span { color: var(--ink); }

.transport { display: flex; align-items: center; gap: 12px; }
.play {
  width: 40px; height: 40px; border-radius: 999px; border: 0; flex: none;
  background: var(--ink); color: var(--surface); display: grid; place-items: center; font-size: 18px;
  transition: transform 160ms var(--ease-out);
}
.play:active { transform: scale(.94); }
.transport input[type="range"] { flex: 1; min-width: 0; }
.scrub-cap { display: grid; gap: 8px; }
.scrub-cap p { font-size: 14px; color: var(--muted); min-height: 3em; }
.scrub-read { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Range input */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 28px; background: transparent; cursor: pointer;
  --p: 100%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--ink) var(--p), var(--line) var(--p));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--ink);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--ink); }

/* Sections */
.section { padding-block: 72px; }
@media (min-width: 900px) { .section { padding-block: 104px; } }
.sec-head { display: grid; gap: 14px; margin-bottom: 36px; max-width: 760px; }
.sec-head h2 { font: 600 clamp(1.8rem, 1.2rem + 2vw, 2.7rem)/1.1 var(--font-display); letter-spacing: -.03em; }
.sec-head p { color: var(--muted); font-size: 1.06rem; max-width: 62ch; }

/* Template gallery */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip-btn {
  height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  font: 500 14px/1 var(--font-body); display: inline-flex; align-items: center; gap: 8px;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 160ms var(--ease-out);
}
.chip-btn span { font: 500 12px/1 var(--font-mono); color: var(--muted); }
.chip-btn:active { transform: scale(.97); }
.chip-btn.is-on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip-btn.is-on span { color: color-mix(in srgb, var(--surface) 70%, transparent); }

.tgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 760px) { .tgrid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; } }
.tcard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.tcard[data-span="7"] { grid-column: span 7; }
.tcard[data-span="5"] { grid-column: span 5; }
.tcard[data-span="6"] { grid-column: span 6; }
.tcard[data-span="12"] { grid-column: span 12; }
@media (max-width: 759px) { .tcard[data-span] { grid-column: auto; } }
.tcard.is-hiding { display: none; }
.tcard-preview {
  position: relative; aspect-ratio: 16 / 10; max-width: 100%;
  border-radius: var(--r-panel); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  --s: .4;
}
.tcard[data-span="5"] .tcard-preview { aspect-ratio: 9 / 8; }
.tcard[data-span="6"] .tcard-preview { aspect-ratio: 4 / 3; }
@media (max-width: 759px) { .tcard[data-span] .tcard-preview { aspect-ratio: 16 / 10; } }
.tcard-preview iframe {
  position: absolute; left: 0; top: 0;
  width: 1280px; height: 1140px; border: 0;
  transform: scale(var(--s)); transform-origin: 0 0;
  pointer-events: none; background: #fff;
}
.tcard-open {
  position: absolute; inset: 0; border: 0; background: transparent; border-radius: inherit;
  transition: background-color 200ms ease;
}
.tcard-open::after {
  content: "Открыть"; position: absolute; right: 14px; bottom: 14px;
  background: var(--ink); color: var(--surface); font: 500 13px/1 var(--font-body);
  padding: 10px 14px; border-radius: 999px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.tcard-open:focus-visible::after { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .tcard-open:hover::after { opacity: 1; transform: none; }
  .tcard-open:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
}
@media (hover: none) { .tcard-open::after { opacity: 1; transform: none; } }
.tcard-body { display: grid; gap: 8px; padding-inline: 4px; }
.tcard-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tcard-title h3 { font: 600 1.2rem/1.2 var(--font-display); letter-spacing: -.02em; }
.tag { font-size: 13px; color: var(--muted); }
.tcard-body p { color: var(--muted); max-width: 56ch; }
.tcard-body .tcard-meta { font-size: 12.5px; color: var(--ink); }

/* Viewer dialog */
html:has(dialog[open]) { overflow: hidden; }
.viewer {
  width: min(1320px, calc(100vw - 24px)); height: min(900px, calc(100dvh - 24px));
  max-width: none; max-height: none; padding: 0; border: 1px solid var(--line);
  border-radius: var(--r-panel); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: scale(.97);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out), overlay 220ms allow-discrete, display 220ms allow-discrete;
}
.viewer[open] { opacity: 1; transform: none; display: flex; flex-direction: column; }
@starting-style { .viewer[open] { opacity: 0; transform: scale(.97); } }
.viewer::backdrop { background: rgba(10, 12, 16, .55); backdrop-filter: blur(4px); opacity: 0; transition: opacity 220ms ease, overlay 220ms allow-discrete, display 220ms allow-discrete; }
.viewer[open]::backdrop { opacity: 1; }
@starting-style { .viewer[open]::backdrop { opacity: 0; } }
.viewer-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line);
}
.viewer-name { display: grid; gap: 2px; margin-right: auto; min-width: 0; }
.viewer-name h3 { font: 600 1.05rem/1.2 var(--font-display); letter-spacing: -.02em; }
.viewer-name span { font-size: 12px; color: var(--muted); }
.viewer-actions { display: flex; gap: 8px; align-items: center; }
.viewer-stage { flex: 1; min-height: 0; background: var(--surface-2); display: flex; justify-content: center; overflow: auto; padding: 16px; }
.viewer-frame {
  width: 100%; height: 100%; max-width: 100%;
  border-radius: var(--r-tile); overflow: hidden; background: #fff;
  box-shadow: var(--shadow);
  transition: width 320ms var(--ease-in-out);
}
.viewer-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 640px) {
  .viewer-bar .seg { display: none; }
  .viewer-actions .btn-ghost { display: none; }
  .viewer-stage { padding: 8px; }
}

/* Components bento */
.bento { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 700px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) {
  .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
  .span-3 { grid-column: span 3; }
  .span-5 { grid-column: span 5; }
  .span-7 { grid-column: span 7; }
}
@media (min-width: 700px) and (max-width: 1099px) {
  .span-7, .span-5 { grid-column: span 2; }
}
.tile {
  min-width: 0; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 20px;
}
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tile-head h3 { font: 600 1rem/1.25 var(--font-display); letter-spacing: -.015em; }
.chip { font-size: 11.5px; padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tile-desc { color: var(--muted); font-size: 14px; }
.tile-demo { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: center; padding-block: 18px; min-height: 150px; }
.demo-center { place-items: center; }

.tile-ink { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tile-ink .tile-desc { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.tile-ink .chip { background: color-mix(in srgb, var(--surface) 14%, transparent); color: color-mix(in srgb, var(--surface) 80%, transparent); }
.tile-ink .code summary { color: color-mix(in srgb, var(--surface) 75%, transparent); border-color: color-mix(in srgb, var(--surface) 20%, transparent); }
.tile-ink .code pre { background: color-mix(in srgb, var(--surface) 8%, transparent); color: var(--surface); }
.tile-ink .code-copy { color: var(--surface); border-color: color-mix(in srgb, var(--surface) 25%, transparent); }

.tile-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tile-accent .tile-desc { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.tile-accent .chip { background: rgba(20, 22, 27, .1); color: var(--on-accent); }
.tile-accent .code summary { color: var(--on-accent); border-color: rgba(20, 22, 27, .2); }
.tile-accent .code pre { background: rgba(20, 22, 27, .08); color: var(--on-accent); }
.tile-accent .code-copy { color: var(--on-accent); border-color: rgba(20, 22, 27, .25); }
.tile-accent :focus-visible { outline-color: var(--on-accent); }

.tile-grid {
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}
.tile-grid .tile-head, .tile-grid .tile-desc { position: relative; }

/* Code drawer */
.code { border-top: 1px solid var(--line); padding-top: 10px; }
.code summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font: 500 13px/1 var(--font-mono); color: var(--muted); padding: 6px 0;
}
.code summary::-webkit-details-marker { display: none; }
.code summary::before { content: "+"; display: inline-block; width: 12px; transition: transform 200ms var(--ease-out); }
.code[open] summary::before { transform: rotate(45deg); }
.code-body { position: relative; margin-top: 8px; }
.code pre {
  margin: 0; max-height: 280px; overflow: auto;
  background: var(--surface-2); border-radius: var(--r-tile); padding: 14px 16px; padding-right: 48px;
  font: 400 12.5px/1.6 var(--font-mono); white-space: pre; tab-size: 2;
}
.code-copy {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; display: grid; place-items: center;
  transition: transform 160ms var(--ease-out);
}
.code-copy:active { transform: scale(.92); }

/* Demo: tabs */
.ctabs { position: relative; justify-self: start; max-width: 100%; overflow-x: auto; }
.ctabs-list { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface-2); width: max-content; }
.ctabs-list > * {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px 16px; border-radius: 999px; font: 500 14px/1 var(--font-body);
}
.ctabs-active {
  position: absolute; inset: 0; background: transparent; pointer-events: none;
  clip-path: inset(4px 100% 4px 4px round 999px);
  transition: clip-path 250ms var(--ease-out);
}
.ctabs-active > * { background: var(--ink); color: var(--surface); }
.ctabs-panel { color: var(--muted); font-size: 14.5px; min-height: 2.6em; }

/* Demo: toasts */
.demo-toasts { align-content: end; justify-items: start; }
.tstack { position: relative; width: 100%; height: 132px; }
.mtoast {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); color: var(--ink); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5);
  font-size: 14px;
  transition: transform 400ms var(--ease-out), opacity 400ms var(--ease-out);
  will-change: transform;
}
.mtoast i { color: var(--accent-text); font-size: 18px; }
.mtoast small { margin-left: auto; color: var(--muted); font: 400 12px/1 var(--font-mono); }

/* Demo: press */
.press-pair { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.nopress:active { transform: none; }

/* Demo: switch */
.switches { display: grid; gap: 12px; width: 100%; max-width: 230px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14.5px; cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 44px; height: 26px; border-radius: 999px; position: relative; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background-color 200ms ease, border-color 200ms ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--knob); box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform 260ms cubic-bezier(.34, 1.36, .64, 1), background-color 200ms ease;
}
.switch:checked { background: var(--ink); border-color: var(--ink); }
.switch:checked::after { transform: translateX(18px); background: var(--surface); }

/* Demo: hold to delete */
.hold {
  position: relative; overflow: hidden; border: 0; border-radius: 999px;
  height: 48px; padding: 0 24px; background: var(--ink); color: var(--surface);
  font: 500 15px/1 var(--font-body);
  transition: transform 160ms var(--ease-out);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.hold:active, .hold.is-holding { transform: scale(.97); }
.hold-base, .hold-fill { display: inline-flex; align-items: center; gap: 8px; }
.hold-fill {
  position: absolute; inset: 0; justify-content: center;
  background: var(--danger); color: var(--on-danger);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 200ms var(--ease-out);
}
.hold.is-holding .hold-fill { clip-path: inset(0 0 0 0); transition: clip-path 1.6s linear; }
.hold.is-done .hold-fill { clip-path: inset(0 0 0 0); transition: none; }

/* Demo: tooltips */
.tips { display: flex; gap: 8px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.tips .icon-btn { border-color: transparent; }
.tip-wrap { position: relative; }
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  translate: -50% 0;
  transform: scale(.97); transform-origin: 50% 100%;
  background: var(--ink); color: var(--surface); font-size: 12.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 125ms var(--ease-out), transform 125ms var(--ease-out);
}
.tip-wrap.is-open .tip { opacity: 1; transform: none; }
.tips.is-instant .tip { transition-duration: 0ms; }

/* Demo: field */
.field { display: grid; gap: 8px; justify-items: start; }
.field label { font-weight: 500; font-size: 14px; }
.field input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px;
  transition: border-color 160ms ease, box-shadow 200ms var(--ease-out);
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 25%, transparent); }
.help { color: var(--muted); font-size: 13px; }
.msg { font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.msg.is-error { color: var(--danger); }
.msg.is-ok { color: var(--ink); }
.msg i { font-size: 16px; }

/* Demo: spotlight */
.spots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .spots { grid-template-columns: minmax(0, 1fr); } }
.spot {
  position: relative; display: grid; gap: 4px; align-content: start;
  padding: 16px; border-radius: var(--r-tile); background: var(--surface);
  border: 1px solid var(--line); font-size: 13px; color: var(--muted);
  isolation: isolate;
}
.spot i { font-size: 22px; color: var(--ink); margin-bottom: 6px; }
.spot b { color: var(--ink); font-size: 14.5px; font-weight: 600; }
.spot::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px;
  background: radial-gradient(180px circle at var(--x, 50%) var(--y, -40%), var(--accent), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 200ms ease; pointer-events: none;
}
.spot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  background: radial-gradient(220px circle at var(--x, 50%) var(--y, -40%), color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
  opacity: 0; transition: opacity 200ms ease; pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .spots:hover .spot::before, .spots:hover .spot::after { opacity: 1; }
}

/* Motion lab */
.motion { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 1000px) { .motion { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; } }
.curve-list { display: grid; gap: 6px; }
.curve {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  text-align: left; padding: 12px 14px; border-radius: var(--r-tile);
  background: transparent; border: 1px solid transparent; color: var(--ink);
  transition: background-color 180ms ease, border-color 180ms ease;
}
.curve svg { width: 44px; height: 44px; }
.curve-name { display: grid; gap: 2px; min-width: 0; }
.curve-name b { font-weight: 600; font-size: 15px; }
.curve-name span { color: var(--muted); font-size: 13.5px; }
.curve-val { font: 400 11.5px/1.3 var(--font-mono); color: var(--muted); text-align: right; }
.curve.is-on { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.curve.is-bad .curve-name b::after { content: "не для UI"; margin-left: 8px; font: 500 10.5px/1 var(--font-mono); color: var(--danger); vertical-align: 2px; }
@media (hover: hover) and (pointer: fine) { .curve:not(.is-on):hover { background: color-mix(in srgb, var(--surface) 55%, transparent); } }
@media (max-width: 520px) { .curve-val { display: none; } .curve { grid-template-columns: 40px minmax(0, 1fr); } }

.lab {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; box-shadow: var(--shadow);
  position: sticky; top: 88px;
}
@media (min-width: 640px) { .lab { grid-template-columns: minmax(0, 280px) minmax(0, 1fr); } }
@media (max-width: 999px) { .lab { position: static; } }
.graph { width: 100%; max-width: 300px; aspect-ratio: 1; justify-self: center; }
.graph .g-box { fill: var(--surface-2); }
.graph .g-grid { stroke: var(--line); stroke-width: 1; }
.graph .g-handle { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 3; }
.graph .g-curve { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.graph .g-pt { fill: var(--accent); stroke: var(--ink); stroke-width: 2; }
.graph .g-end { fill: var(--ink); }
.graph .g-dot { fill: var(--accent); stroke: var(--ink); stroke-width: 2; }
.graph text { fill: var(--muted); font: 500 10px var(--font-mono); }
.lab-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; min-width: 0; }
.tracks { display: grid; gap: 12px; }
.track-row { display: grid; gap: 6px; }
.track { position: relative; height: 44px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.track-label { font-size: 11.5px; color: var(--muted); }
.dot {
  position: absolute; left: 6px; top: 6px; width: 32px; height: 32px; border-radius: 999px;
  background: var(--accent); border: 2px solid var(--ink);
}
.dot-ghost { background: var(--surface); border-color: var(--muted); }
.lab-controls { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; }
.range-field { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 4px 12px; flex: 1 1 220px; }
.range-field label { font-size: 14px; font-weight: 500; }
.range-field output { font-size: 13px; color: var(--muted); }
.range-field input { grid-column: 1 / -1; width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.codeline {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: var(--r-tile); padding: 8px 8px 8px 14px;
}
.codeline code { font-size: 12.5px; line-height: 1.55; flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; }

/* Timing ruler */
.ruler { margin-top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.ruler h3 { font: 600 1.1rem/1.25 var(--font-display); letter-spacing: -.02em; }
.ruler-note { color: var(--muted); font-size: 14.5px; max-width: 62ch; }
.ruler-chart { margin-top: 16px; display: grid; gap: 10px; overflow-x: auto; }
.r-row { display: grid; grid-template-columns: 180px minmax(260px, 1fr); gap: 16px; align-items: center; }
.r-label { font-size: 14px; }
.r-label small { display: block; color: var(--muted); font: 400 12px/1.4 var(--font-mono); }
.r-track { position: relative; height: 28px; }
.r-bar {
  position: absolute; top: 6px; height: 16px; border-radius: 999px;
  background: var(--accent); border: 1.5px solid var(--ink);
}
.r-limit { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 1.5px dashed var(--danger); }
.r-axis .r-track { height: 22px; }
.r-tick { position: absolute; top: 0; translate: -50% 0; font: 400 11px/1 var(--font-mono); color: var(--muted); }
.r-tick::before { content: ""; position: absolute; left: 50%; top: 14px; height: 6px; border-left: 1px solid var(--line); }
.r-tick.is-limit { color: var(--danger); }
.r-tick:first-child { translate: 0 0; }
.r-tick:first-child::before { left: 0; }
.r-tick:last-child { translate: -100% 0; }
.r-tick:last-child::before { left: 100%; }
@media (max-width: 600px) { .r-row { grid-template-columns: 120px minmax(220px, 1fr); gap: 10px; } }

/* Palettes */
.palettes { display: grid; gap: 14px; }
.pal {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px;
}
@media (min-width: 980px) { .pal { grid-template-columns: minmax(0, 3fr) minmax(0, 6fr) minmax(0, 3fr); gap: 20px; padding: 16px 16px 16px 22px; } }
.pal-info { display: grid; gap: 6px; min-width: 0; }
.pal-info h3 { font: 600 1.05rem/1.25 var(--font-display); letter-spacing: -.015em; }
.pal-info p { color: var(--muted); font-size: 14px; }
.pal-copy { justify-self: start; margin-top: 6px; }
.swatches { display: flex; gap: 6px; min-width: 0; height: 112px; }
.sw {
  flex: 1 1 0; min-width: 0; border-radius: var(--r-tile); border: 1px solid rgba(0, 0, 0, .08);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 2px;
  padding: 10px; text-align: left; font: 500 11.5px/1.2 var(--font-mono);
  transition: flex-grow 320ms var(--ease-in-out), transform 160ms var(--ease-out);
}
.sw:active { transform: scale(.97); }
.sw span { opacity: .75; font-size: 10.5px; font-family: var(--font-body); }
@media (hover: hover) and (pointer: fine) { .sw:hover { flex-grow: 1.6; } }
@media (max-width: 560px) { .swatches { height: 92px; } .sw { padding: 8px 6px; font-size: 10px; } .sw span { display: none; } }
.pal-demo {
  border-radius: var(--r-tile); padding: 14px; display: grid; gap: 10px; min-height: 112px;
  border: 1px solid rgba(0, 0, 0, .08);
}
.pal-demo-card { border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.pal-demo-card b { font-size: 14px; }
.pal-demo-card span { font-size: 12px; opacity: .78; }
.pal-demo-row { display: flex; gap: 6px; align-items: center; }
.pal-demo-btn { font: 600 12px/1 var(--font-body); padding: 8px 12px; border-radius: 999px; }
.pal-demo-pop { width: 10px; height: 10px; border-radius: 999px; margin-left: auto; }

/* Fonts rail */
.font-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.font-input { display: grid; gap: 8px; flex: 1 1 320px; max-width: 520px; }
.rail-nav { display: flex; gap: 8px; }
.rail-nav .icon-btn { width: 48px; height: 48px; }
@media (hover: none) { .rail-nav { display: none; } }
.font-input label { font-weight: 500; font-size: 14px; }
.font-input input {
  height: 48px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 16px;
  transition: border-color 160ms ease, box-shadow 200ms var(--ease-out);
}
.font-input input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
.font-rail-wrap { position: relative; }
.font-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(340px, 82vw); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  padding-block: 4px 20px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px), calc((100vw - var(--wrap)) / 2));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  scroll-padding-left: max(var(--gutter), calc((100vw - var(--wrap)) / 2));
  scrollbar-width: thin;
}
.font-rail:focus-visible { outline-offset: -2px; }
.spec {
  scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; min-height: 420px;
}
.spec-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.spec-glyph { font-size: 64px; line-height: 1; letter-spacing: -.02em; }
.spec-mood { font-size: 12.5px; color: var(--muted); text-align: right; max-width: 14ch; }
.spec-head { font-size: 1.55rem; line-height: 1.15; overflow-wrap: anywhere; min-height: 3.45em; }
.spec-body { font-size: 15px; line-height: 1.6; color: var(--muted); flex: 1; }
.spec-names { font: 400 12px/1.5 var(--font-mono); color: var(--ink); border-top: 1px solid var(--line); padding-top: 12px; }
.spec-actions { display: flex; gap: 8px; }

/* Skills */
.repos { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.repo {
  display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 6px 24px; align-items: start;
  padding: 28px 4px; text-decoration: none; border-bottom: 1px solid var(--line);
  transition: background-color 200ms ease;
}
@media (min-width: 900px) {
  .repo { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr) 40px; align-items: center; padding: 32px 8px; }
  .repo > .repo-path { grid-column: 1; grid-row: 1; }
  .repo > .repo-title { grid-column: 1; grid-row: 2; }
  .repo > .repo-desc { grid-column: 2; grid-row: 1 / span 2; }
  .repo > .repo-arrow { grid-column: 3; grid-row: 1 / span 2; }
}
.repo-path { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.repo-path i { font-size: 15px; }
.repo-title { font: 600 clamp(1.25rem, 1rem + 1vw, 1.7rem)/1.15 var(--font-display); letter-spacing: -.025em; }
.repo-desc { color: var(--muted); max-width: 60ch; }
.repo-arrow {
  grid-column: 2; grid-row: 1 / span 3; align-self: center;
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center;
  border: 1px solid var(--line); font-size: 18px;
  transition: background-color 200ms ease, color 200ms ease, transform 200ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .repo:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
  .repo:hover .repo-arrow { background: var(--accent); color: var(--on-accent); border-color: var(--accent); transform: rotate(45deg); }
}
.tools { margin-top: 56px; display: grid; gap: 32px 24px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tool-group h3 { font: 600 .95rem/1.3 var(--font-display); letter-spacing: -.01em; margin-bottom: 12px; }
.tool-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tool-group li { display: grid; gap: 1px; }
.tool-group a { font-weight: 500; text-decoration: none; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0% 2px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size 250ms var(--ease-out); justify-self: start; }
.tool-group a:hover, .tool-group a:focus-visible { background-size: 100% 2px; }
.tool-group span { font-size: 13px; color: var(--muted); }

/* Footer */
.foot { border-top: 1px solid var(--line); padding-block: 40px calc(40px + env(safe-area-inset-bottom, 0px)); }
.foot-in { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .foot-in { grid-template-columns: minmax(0, 4fr) minmax(0, 6fr) auto; } }
.foot-brand { display: grid; gap: 10px; }
.foot-brand p { color: var(--muted); font-size: 14px; max-width: 36ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-links a { text-decoration: none; color: var(--muted); font-size: 14.5px; }
.foot-links a:hover { color: var(--ink); }
.foot-copy { font-size: 12.5px; color: var(--muted); }

/* Global toast */
.toast-region {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 80;
  translate: -50% 0; display: grid; gap: 8px; justify-items: center; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.gtoast {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-pop);
  transition: transform 300ms var(--ease-out), opacity 300ms var(--ease-out);
}
.gtoast i { color: var(--accent); font-size: 18px; }
.gtoast[data-state="enter"] { transform: translateY(16px) scale(.96); opacity: 0; }
.gtoast[data-state="exit"] { transform: translateY(6px) scale(.98); opacity: 0; transition-duration: 180ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .gtoast, .mtoast, .viewer, .tip { transition-property: opacity !important; transition-duration: 150ms !important; }
}
