@layer tokens, base, components, page, theme-overrides, utilities;

@layer tokens {
  :root {
    color-scheme: light;
    --ui-bg: #f5f5f7;
    --ui-surface: #ffffff;
    --ui-surface-muted: #f0f2f5;
    --ui-glass: rgba(255, 255, 255, 0.74);
    --ui-text: #1d1d1f;
    --ui-muted: #6e6e73;
    --ui-faint: #8e8e93;
    --ui-line: rgba(29, 29, 31, 0.12);
    --ui-line-strong: rgba(29, 29, 31, 0.2);
    --ui-accent: #007aff;
    --ui-accent-hover: #0068d9;
    --ui-accent-soft: rgba(0, 122, 255, 0.1);
    --ui-success: #248a3d;
    --ui-radius-sm: 8px;
    --ui-radius: 12px;
    --ui-radius-lg: 18px;
    --ui-blur: blur(22px) saturate(155%);
  }

  html[data-theme="dark"] {
    color-scheme: dark;
    --ui-bg: #000000;
    --ui-surface: #1c1c1e;
    --ui-surface-muted: #2c2c2e;
    --ui-glass: rgba(28, 28, 30, 0.76);
    --ui-text: #f5f5f7;
    --ui-muted: #a1a1a6;
    --ui-faint: #8e8e93;
    --ui-line: rgba(255, 255, 255, 0.12);
    --ui-line-strong: rgba(255, 255, 255, 0.2);
    --ui-accent: #0a84ff;
    --ui-accent-hover: #409cff;
    --ui-accent-soft: rgba(10, 132, 255, 0.15);
  }
}

@layer base {
  :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--ui-accent) 48%, transparent);
    outline-offset: 2px;
  }

  ::selection {
    color: #fff;
    background: var(--ui-accent);
  }
}

@layer components {
  .header-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  .select-shell,
  .icon-button,
  .info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    color: var(--ui-text);
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
  }

  .select-shell {
    gap: 4px;
    padding-left: 9px;
  }

  .select-shell select {
    min-height: 32px;
    padding: 0 24px 0 3px;
    color: inherit;
    background: transparent;
    border: 0;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }

  .icon-button,
  .info-button {
    width: 34px;
    padding: 0;
    cursor: pointer;
  }

  .header-tools svg,
  .button svg,
  .text-link svg,
  .tts-controls svg {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
  }

  .preset-demo {
    display: grid;
    gap: 18px;
    padding: 24px;
    color: var(--ui-text);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-lg);
  }

  .setup-heading {
    display: grid;
    grid-template-columns: 1fr minmax(180px, .7fr);
    gap: 18px;
    align-items: end;
    padding: 2px 2px 4px;
  }

  .setup-heading span {
    color: var(--ui-faint);
    font: 750 9px/1 ui-monospace, monospace;
    letter-spacing: 0.12em;
  }

  .setup-heading h3 {
    margin: 7px 0 0;
    color: var(--ui-text);
    font-size: 22px;
    letter-spacing: -0.035em;
  }

  .setup-heading p {
    margin: 0;
    color: var(--ui-muted);
    font-size: 11px;
    line-height: 1.55;
  }

  .preset-switcher {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: 10px;
  }

  .preset-switcher button {
    min-height: 32px;
    color: var(--ui-muted);
    background: transparent;
    border: 0;
    border-radius: 7px;
    font: 650 12px/1 system-ui, sans-serif;
    cursor: pointer;
    transition: color 180ms ease, background 180ms ease;
  }

  .preset-switcher button.is-active {
    color: #fff;
    background: var(--ui-accent);
  }

  .module-chain {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .module-block {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
    min-height: 122px;
    padding: 13px 11px;
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    transition: border-color 180ms ease, transform 180ms ease;
  }

  .module-block:not(:last-child)::after {
    position: absolute;
    z-index: 2;
    top: 48px;
    right: -10px;
    width: 11px;
    height: 20px;
    content: "";
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-right: 0;
    border-radius: 7px 0 0 7px;
  }

  .module-block > small {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: var(--ui-accent);
    background: var(--ui-surface);
    border: 1px solid color-mix(in srgb, var(--ui-accent) 30%, var(--ui-line));
    border-radius: 50%;
    font: 750 9px/1 ui-monospace, monospace;
  }

  .module-block > span { color: var(--ui-faint); font-size: 9px; font-weight: 720; letter-spacing: .06em; text-transform: uppercase; }
  .module-block > b { font-size: 10px; line-height: 1.35; letter-spacing: -.015em; }

  .preset-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 42px;
    padding: 0 13px;
    color: var(--ui-text);
    background: var(--ui-accent-soft);
    border: 1px solid color-mix(in srgb, var(--ui-accent) 18%, transparent);
    border-radius: var(--ui-radius-sm);
    font-size: 10px;
  }
  .preset-summary span { display: flex; align-items: center; gap: 7px; }
  .preset-summary i { width: 7px; height: 7px; background: var(--ui-accent); border-radius: 50%; }
  .preset-summary strong { color: var(--ui-muted); font-weight: 620; }

  .still-demo { position: relative; isolation: isolate; }
  .still-demo img { width: 100%; height: auto; }

  .source-image {
    display: grid;
    gap: 0;
    margin: 0;
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
  }

  .source-image-stage { overflow: hidden; background: #0d1210; }
  .source-image-stage img { display: block; filter: none; }
  .source-image figcaption {
    padding: 9px 11px;
    color: var(--ui-muted);
    background: var(--ui-surface);
    border-top: 1px solid var(--ui-line);
    font-size: 10px;
  }

  .scan-line {
    position: absolute;
    z-index: 2;
    top: -16%;
    left: 0;
    right: 0;
    height: 16%;
    background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--ui-accent) 12%, transparent) 72%, var(--ui-accent));
    box-shadow: none;
    opacity: 0.78;
    animation: image-scan 5.2s cubic-bezier(.4, 0, .2, 1) infinite;
    pointer-events: none;
  }

  .still-status {
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    backdrop-filter: blur(14px);
    font-size: 10px;
  }

  .still-status > i { width: 6px; height: 6px; background: #30d158; border-radius: 50%; }

  .tts-panel.is-playing .tts-wave i { animation: tts-wave 1.1s ease-in-out infinite alternate; }
  .tts-panel.is-playing .tts-wave i:nth-child(3n) { animation-delay: -0.3s; }
  .tts-panel.is-playing .tts-wave i:nth-child(4n) { animation-delay: -0.6s; }
}

@layer theme-overrides {
  body {
    color: var(--ui-text);
    background: var(--ui-bg);
    transition: color .25s ease, background-color .25s ease;
  }

  body::before { display: none; }

  .site-header {
    grid-template-columns: auto 1fr auto;
    top: 10px;
    margin-top: 10px;
    padding: 7px 8px 7px 10px;
    background: var(--ui-glass);
    border-color: var(--ui-line);
    border-radius: var(--ui-radius);
    backdrop-filter: var(--ui-blur);
  }

  .nav-links { justify-self: center; color: var(--ui-muted); }
  .nav-links a:hover, .site-footer a:hover { color: var(--ui-accent); }
  .app-icon { border-radius: 10px; box-shadow: none; }

  .header-download,
  .button.primary {
    color: #fff;
    background: var(--ui-accent);
    border-color: var(--ui-accent);
  }

  .header-download {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border-radius: var(--ui-radius-sm);
  }

  .header-download svg { width: 13px; height: 13px; }
  .header-download:hover, .button.primary:hover { background: var(--ui-accent-hover); }

  .hero { min-height: 720px; }
  .eyebrow, .kicker, .hero h1 > span:last-child { color: var(--ui-accent); }
  .hero h1 .hero-line { color: var(--ui-text); }
  .hero-copy, .section-heading > p:last-child, .control-section > div:first-child > p:not(.kicker) { color: var(--ui-muted); }
  .eyebrow i { background: var(--ui-accent); box-shadow: 0 0 0 5px var(--ui-accent-soft); }

  .button {
    min-height: 44px;
    gap: 9px;
    padding-inline: 15px;
    border-radius: var(--ui-radius-sm);
    box-shadow: none;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease;
  }

  .button.secondary {
    color: var(--ui-text);
    background: var(--ui-surface);
    border-color: var(--ui-line-strong);
  }

  .button.secondary:hover { color: var(--ui-accent); background: var(--ui-accent-soft); border-color: var(--ui-accent); }
  .hero-facts { border-color: var(--ui-line); }
  .hero-facts dt { color: var(--ui-faint); }
  .hero-facts dd { color: var(--ui-text); }

  .demo-window {
    background: var(--ui-surface);
    border-color: var(--ui-line);
    border-radius: var(--ui-radius-lg);
    box-shadow: none;
    transform: none;
  }

  .translation-line { box-shadow: none; }

  .window-bar { color: var(--ui-muted); background: var(--ui-surface-muted); border-color: var(--ui-line); font-family: system-ui, sans-serif; font-weight: 680; letter-spacing: .08em; }
  .float-note { color: var(--ui-text); background: var(--ui-surface); border-color: var(--ui-line-strong); border-radius: var(--ui-radius); box-shadow: none; transform: none; backdrop-filter: none; }
  .float-note strong { font-size: 15px; font-weight: 720; }
  .float-note span { font-size: 11px; font-weight: 560; }
  .note-bottom { color: #fff; background: var(--ui-accent); border-color: var(--ui-accent); }

  .hero-demo { padding: 10px; background: var(--ui-surface); }

  .hero-demo-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 10px;
  }

  .hero-stage-switcher { display: flex; align-items: center; gap: 4px; }

  .hero-stage-switcher button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px;
    color: var(--ui-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font: 650 11px/1 system-ui, sans-serif;
    cursor: pointer;
    transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
  }

  .hero-stage-switcher button b { color: var(--ui-faint); font: 760 9px/1 ui-monospace, monospace; }
  .hero-stage-switcher button:hover { color: var(--ui-text); background: var(--ui-surface-muted); }
  .hero-stage-switcher button.is-active { color: #fff; background: var(--ui-accent); border-color: var(--ui-accent); }
  .hero-stage-switcher button.is-active b { color: #fff; opacity: .72; }

  .hero-shot-source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ui-muted);
    font: 620 10px/1 system-ui, sans-serif;
    white-space: nowrap;
  }

  .hero-shot-source > i { width: 6px; height: 6px; background: var(--ui-success); border-radius: 50%; }

  .hero-shot {
    position: relative;
    aspect-ratio: 20 / 9;
    overflow: hidden;
    background: #111;
    border: 1px solid var(--ui-line);
    border-radius: 10px;
    isolation: isolate;
  }

  .hero-shot-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    filter: none;
    transform: scale(1.008);
    transition: opacity 320ms ease, transform 520ms ease;
  }

  .hero-shot-layer.is-active { z-index: 1; opacity: 1; transform: scale(1); }

  .hero-shot-manga {
    aspect-ratio: 4 / 3;
    background:
      radial-gradient(circle at 50% 46%, rgba(255,255,255,.92), rgba(222,232,241,.82) 44%, rgba(198,214,228,.62)),
      var(--ui-surface-muted);
  }

  .hero-shot-manga .hero-shot-layer {
    object-fit: contain;
    object-position: center top;
  }

  .hero-shot-original {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
  }

  .manga-stage-demo { min-width: 0; }

  .manga-stage-viewport {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background:
      radial-gradient(circle at 50% 46%, rgba(255,255,255,.92), rgba(222,232,241,.82) 44%, rgba(198,214,228,.62)),
      var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: 10px;
    isolation: isolate;
  }

  .manga-stage-demo-showcase { width: 100%; padding: 10px; }
  .manga-stage-demo-showcase .manga-stage-viewport { aspect-ratio: 1432 / 2357; background: #fff; }

  .manga-stage-panel {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    visibility: hidden;
    transform: scale(1.006);
    transition: opacity 320ms ease, transform 520ms ease, visibility 0s linear 520ms;
  }

  .manga-stage-panel.is-active {
    z-index: 1;
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    transition-delay: 0s;
  }

  .manga-stage-canvas {
    position: relative;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1432 / 2357;
    overflow: hidden;
    background: #fff;
    container-type: inline-size;
  }

  .manga-stage-canvas > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center top;
    filter: none;
  }

  .manga-html-overlay { position: absolute; inset: 0; pointer-events: none; }

  .manga-stage-label {
    position: absolute;
    z-index: 2;
    top: 1.7%;
    left: 2.6%;
    display: inline-flex;
    align-items: center;
    gap: .55em;
    padding: .45em .7em;
    color: #18212b;
    background: rgba(225, 239, 251, .94);
    border: 1px solid rgba(20, 34, 48, .32);
    border-radius: .45em;
    font: 760 clamp(7px, 3cqw, 15px)/1 system-ui, sans-serif;
    backdrop-filter: blur(6px);
  }

  .manga-stage-label b { font: 800 .85em/1 ui-monospace, monospace; }

  .manga-translation {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    padding: .45em .55em;
    color: #111;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(17,17,17,.72);
    font: 760 clamp(7px, 4cqw, 18px)/1.2 system-ui, sans-serif;
    text-align: center;
    opacity: 0;
    transform: translateY(6px) scale(.97);
  }

  .manga-html-overlay-adaptive .manga-translation { border-radius: 48% 52% 45% 55% / 54% 48% 52% 46%; }
  .manga-html-overlay-layout .manga-translation { color: #fff; background: rgba(17, 24, 32, .92); border-color: rgba(255,255,255,.9); border-radius: .35em; }
  .manga-html-overlay-layout .manga-stage-label { color: #fff; background: rgba(17, 24, 32, .92); border-color: rgba(255,255,255,.64); }

  .manga-translation-one { top: 9%; left: 48%; width: 20%; min-height: 7%; }
  .manga-translation-two { top: 8%; right: 6%; width: 22%; min-height: 10%; }
  .manga-translation-three { top: 49%; right: 7%; width: 27%; min-height: 9%; }
  .manga-translation-four { top: 78%; left: 7%; width: 18%; min-height: 8%; }

  .manga-stage-panel.is-active .manga-translation { animation: manga-translation-in 420ms ease forwards; }
  .manga-stage-panel.is-active .manga-translation-two { animation-delay: 80ms; }
  .manga-stage-panel.is-active .manga-translation-three { animation-delay: 160ms; }
  .manga-stage-panel.is-active .manga-translation-four { animation-delay: 240ms; }

  @keyframes manga-translation-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  .hero-scan-line {
    position: absolute;
    z-index: 2;
    top: 0;
    bottom: 0;
    left: -24%;
    width: 18%;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(0, 122, 255, .24), transparent);
    animation: hero-scan 4.2s ease-in-out 1 both;
    mix-blend-mode: screen;
  }

  .hero-tts-bar {
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    left: 12px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 7px 12px 7px 8px;
    color: #1d1d1f;
    background: rgba(255, 255, 255, .91);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 10px;
    opacity: 0;
    transform: translateY(7px);
    backdrop-filter: blur(14px) saturate(140%);
    transition: opacity 220ms ease, transform 220ms ease;
  }

  .hero-demo[data-stage="translate"] .hero-tts-bar { opacity: 1; transform: translateY(0); }

  .hero-tts-bar button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    color: #1d1d1f;
    background: transparent;
    border: 0;
    cursor: pointer;
  }

  .hero-tts-bar button > svg,
  .hero-tts-bar button > i {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 8px;
    color: #fff;
    background: var(--ui-accent);
    border-radius: 8px;
  }

  .hero-tts-bar button span { display: grid; gap: 3px; text-align: left; }
  .hero-tts-bar button small { color: #6e6e73; font-size: 9px; }
  .hero-tts-bar button b { font-size: 11px; }
  .hero-tts-bar time { color: #6e6e73; font: 650 10px/1 ui-monospace, monospace; }

  .hero-wave { display: flex; align-items: center; gap: 3px; height: 22px; opacity: .36; }
  .hero-wave i { width: 2px; height: 7px; background: var(--ui-accent); border-radius: 99px; }
  .hero-wave i:nth-child(3n + 1) { height: 13px; }
  .hero-wave i:nth-child(4n + 2) { height: 19px; }
  .hero-demo.is-speaking .hero-wave { opacity: 1; }
  .hero-demo.is-speaking .hero-wave i { animation: hero-wave 900ms ease-in-out infinite alternate; }
  .hero-demo.is-speaking .hero-wave i:nth-child(2n) { animation-delay: -300ms; }
  .hero-demo.is-speaking .hero-wave i:nth-child(3n) { animation-delay: -600ms; }

  .signal-strip { color: var(--ui-text); background: var(--ui-surface); border-color: var(--ui-line); }
  .signal-strip b { color: var(--ui-accent); background: var(--ui-accent-soft); }
  .signal-strip i { color: var(--ui-accent); }

  .showcase,
  .showcase-manga,
  .showcase-tts {
    color: var(--ui-text);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-lg);
  }

  .showcase-copy .kicker { color: var(--ui-faint); }
  .showcase-copy > p:not(.kicker):not(.feature-note), .feature-note { color: var(--ui-muted); }
  .feature-number, .feature-note { border-color: var(--ui-line); }
  .layout-pills span { background: var(--ui-surface-muted); border-color: var(--ui-line); }
  .showcase-media { border-radius: var(--ui-radius); }
  .media-tag { color: #fff; background: rgba(0, 0, 0, .58); border-color: rgba(255,255,255,.16); }
  .showcase-copy li::before { color: var(--ui-accent); }

  .tts-panel {
    min-height: 500px;
    padding: 24px;
    color: var(--ui-text);
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    box-shadow: none;
  }

  .tts-header {
    align-items: center;
    color: var(--ui-text);
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 680;
    letter-spacing: 0;
  }

  .tts-header span { gap: 9px; }

  .tts-header span svg {
    width: 30px;
    height: 30px;
    padding: 7px;
    color: #fff;
    background: var(--ui-accent);
    border-radius: 8px;
    stroke-width: 1.9;
  }

  .tts-header b {
    padding: 8px 10px;
    color: var(--ui-muted);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 620;
  }

  .tts-copy {
    max-width: none;
    margin: 50px 0 0;
    padding: 25px 26px;
    text-align: left;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
  }

  .tts-copy small {
    color: var(--ui-accent);
    font: 700 10px/1 system-ui, sans-serif;
    letter-spacing: .08em;
  }

  .tts-copy p {
    max-width: 520px;
    margin: 12px 0 0;
    color: var(--ui-text);
    font-size: clamp(23px, 2.7vw, 34px);
    font-weight: 680;
    letter-spacing: -.035em;
    line-height: 1.35;
  }

  .tts-wave {
    justify-content: flex-start;
    height: 52px;
    margin: 12px 0 0;
    padding: 0 20px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
  }

  .tts-wave i { width: 2px; background: var(--ui-accent); opacity: .42; }

  .tts-controls { gap: 14px; margin-top: 18px; }

  .tts-controls button {
    width: 38px;
    height: 38px;
    color: var(--ui-muted);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
  }

  .tts-controls .tts-play {
    width: 54px;
    height: 54px;
    color: #fff;
    background: var(--ui-accent);
    border-color: var(--ui-accent);
  }

  .tts-progress {
    margin-top: 22px;
    color: var(--ui-muted);
    font-family: system-ui, sans-serif;
  }

  .tts-progress::before { background: linear-gradient(90deg, var(--ui-accent) 43%, var(--ui-line) 43%); }
  .tts-progress i { background: var(--ui-surface); border: 2px solid var(--ui-accent); box-shadow: none; }

  .tts-options { margin-top: 18px; }

  .tts-options span {
    padding: 8px 10px;
    color: var(--ui-muted);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    font-size: 10px;
  }

  .workflow-section { border-color: var(--ui-line); }
  .workflow-grid { border-color: var(--ui-line); border-radius: var(--ui-radius-lg); }
  .workflow-grid li { border-color: var(--ui-line); }
  .workflow-grid li::after { color: #fff; background: var(--ui-accent); }
  .workflow-grid span { color: var(--ui-accent); }
  .workflow-grid p { color: var(--ui-muted); }

  .feature-section { color: var(--ui-text); background: var(--ui-surface-muted); }
  .feature-section .kicker { color: var(--ui-accent); }
  .bento-card, .bento-card.accent, .bento-card.dark {
    color: var(--ui-text);
    background: var(--ui-surface);
    border-color: var(--ui-line);
    border-radius: var(--ui-radius-lg);
    box-shadow: none;
  }
  .bento-card.dark p, .bento-card p { color: var(--ui-muted); }
  .bento-card.dark > span { border-color: var(--ui-line-strong); }
  .big-word { color: var(--ui-surface-muted); }
  .manga-card { grid-template-columns: minmax(220px, .78fr) minmax(360px, 1.22fr); gap: clamp(28px, 5vw, 72px); align-items: center; }
  .manga-copy { align-self: center; }
  .manga-copy > span { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-bottom: 28px; border: 1px solid var(--ui-line); border-radius: 50%; font: 700 10px/1 ui-monospace, monospace; }
  .manga-copy h3 { max-width: 9em; margin: 0 0 16px; }
  .manga-tech { display: flex; flex-wrap: wrap; gap: 7px; margin: 24px 0 0; padding: 0; list-style: none; }
  .manga-tech li { padding: 7px 9px; color: var(--ui-muted); background: var(--ui-surface-muted); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-sm); font-size: 10px; font-weight: 680; }
  .manga-proof { min-width: 0; margin: 0; overflow: hidden; background: var(--ui-surface-muted); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
  .manga-proof-image { position: relative; height: 300px; overflow: hidden; background: #fff; }
  .manga-proof-image::after { position: absolute; inset: 0; content: ""; pointer-events: none; background: linear-gradient(90deg, transparent 0 48%, color-mix(in srgb, var(--ui-accent) 5%, transparent) 48% 100%); }
  .manga-proof-image img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; filter: none; }
  .manga-route { position: absolute; z-index: 2; inset: 0; margin: 0; padding: 0; list-style: none; }
  .manga-route li { position: absolute; display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--ui-accent); border: 3px solid rgba(255,255,255,.94); border-radius: 50%; font: 760 9px/1 ui-monospace, monospace; animation: route-pulse 3.2s ease-in-out infinite; }
  .manga-route .route-one { top: 18%; right: 13%; animation-delay: 0s; }
  .manga-route .route-two { top: 23%; right: 41%; animation-delay: .35s; }
  .manga-route .route-three { top: 24%; right: 53%; animation-delay: .7s; }
  .manga-route .route-four { top: 67%; right: 75%; animation-delay: 1.05s; }
  .route-arrow { position: absolute; z-index: 2; color: var(--ui-accent); font: 800 22px/1 system-ui, sans-serif; animation: route-arrow 3.2s ease-in-out infinite; }
  .arrow-one { top: 20%; right: 27%; }
  .arrow-two { top: 23%; right: 47%; animation-delay: .45s; }
  .arrow-three { top: 45%; right: 64%; animation-delay: .9s; }
  .manga-proof figcaption { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 11px 13px; color: var(--ui-muted); font-size: 10px; }
  .manga-proof figcaption span { display: flex; gap: 6px; align-items: center; }
  .manga-proof figcaption i { width: 7px; height: 7px; background: #34c759; border-radius: 50%; }
  .manga-proof figcaption strong { color: var(--ui-text); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .04em; }
  @keyframes route-pulse { 0%, 12%, 100% { transform: scale(.88); opacity: .72; } 22%, 64% { transform: scale(1); opacity: 1; } }
  @keyframes route-arrow { 0%, 18%, 100% { opacity: .25; transform: translateX(4px); } 34%, 65% { opacity: 1; transform: translateX(0); } }
  .select-demo { color: var(--ui-muted); background: var(--ui-surface-muted); }
  .select-demo mark { color: #fff; background: var(--ui-accent); }

  .control-section h2 { font-size: clamp(42px, 5vw, 66px); }
  .stack-board { background: var(--ui-surface-muted); border-color: var(--ui-line); border-radius: var(--ui-radius-lg); }
  .text-link { align-items: center; color: var(--ui-accent); }

  .manga-media.source-image { max-height: none; }
  .manga-media.source-image .source-image-stage { background: #fff; }
  .manga-media.source-image .source-image-stage img { height: auto; max-height: none; object-fit: contain; object-position: top; }

  .download-section {
    color: #fff;
    background: #315f88;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: var(--ui-radius-lg);
    box-shadow: none;
  }
  html[data-theme="dark"] .download-section { background: #1f3b55; }
  .download-section .kicker, .download-section p:not(.kicker) { color: rgba(255,255,255,.78); }
  .button.download-primary { color: #315f88; background: #fff; border-color: #fff; filter: none; }
  .button.download-primary:hover { color: #244967; background: #fff; border-color: #fff; filter: none; }
  .button.dark-outline { color: #fff; background: transparent; border-color: rgba(255,255,255,.5); }
  .button.dark-outline:hover { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.72); }
  .icon-orbit { background: transparent; }
  .icon-orbit, .icon-orbit::before, .icon-orbit::after { border-color: rgba(255,255,255,.35); }
  .icon-orbit img { box-shadow: none; }

  .site-footer { color: var(--ui-muted); }
  .guide-hero, .guide-block { border-color: var(--ui-line); }
  .guide-hero > p:last-child, .guide-block > p { color: var(--ui-muted); }
  .guide-card { color: var(--ui-text); background: var(--ui-surface); border: 1px solid var(--ui-line); }
  .guide-card p { color: var(--ui-muted); }
  .guide-note { color: var(--ui-text); background: var(--ui-accent-soft); border-color: color-mix(in srgb, var(--ui-accent) 28%, transparent); }
}

@layer utilities {
  [hidden] { display: none !important; }
}

@keyframes image-scan {
  0%, 14% { transform: translateY(0); opacity: 0; }
  22% { opacity: .78; }
  72% { transform: translateY(725%); opacity: .78; }
  86%, 100% { transform: translateY(725%); opacity: 0; }
}

@keyframes tts-wave {
  from { transform: scaleY(.45); opacity: .42; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes hero-scan {
  0%, 18% { transform: translateX(0); opacity: 0; }
  30% { opacity: 1; }
  72% { opacity: 1; }
  88%, 100% { transform: translateX(760%); opacity: 0; }
}

@keyframes hero-wave {
  from { transform: scaleY(.45); }
  to { transform: scaleY(1.15); }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: ease-out;
}

@media (max-width: 980px) {
  .header-tools { justify-self: end; }
  .showcase-game .showcase-media { order: 2; }
  .manga-card { grid-template-columns: 1fr; }
  .manga-copy h3 { max-width: none; }
}

@media (max-width: 640px) {
  .site-header { grid-template-columns: 1fr auto; }
  .select-shell i { display: none; }
  .header-download span { display: none; }
  .header-download { width: 34px; padding: 0; justify-content: center; }
  .hero { padding-top: 64px; }
  .setup-heading { grid-template-columns: 1fr; gap: 8px; }
  .module-chain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-block { min-height: 104px; }
  .module-block:not(:last-child)::after { display: none; }
  .module-block:last-child { grid-column: span 2; min-height: 88px; }
  .preset-summary { align-items: flex-start; flex-direction: column; gap: 5px; padding-block: 10px; }
  .still-status { left: 10px; right: auto; }
  .hero-demo-toolbar { align-items: stretch; flex-direction: column; }
  .hero-stage-switcher { display: grid; grid-template-columns: repeat(3, 1fr); }
  .hero-stage-switcher button { justify-content: center; padding-inline: 5px; }
  .hero-shot-source { padding-left: 4px; }
  .hero-shot { aspect-ratio: 16 / 10; }
  .hero-shot-manga { aspect-ratio: 1 / 1; }
  .manga-stage-demo-hero .manga-stage-viewport { aspect-ratio: 1 / 1; }
  .hero-shot-layer { object-position: center; }
  .hero-tts-bar { right: 8px; bottom: 8px; left: 8px; }
  .hero-wave { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scan-line, .hero-scan-line { animation: none; opacity: 0; }
  .hero-wave i { animation: none !important; }
  .manga-route li, .route-arrow { animation: none; }
  .manga-stage-panel, .manga-translation { transition: none; animation: none !important; }
  .manga-stage-panel.is-active .manga-translation { opacity: 1; transform: none; }
}

@layer theme-overrides {
  .header-github { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 12px; color: var(--ui-text); background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
  .header-github:hover { color: var(--ui-accent); border-color: var(--ui-accent); }
  .header-github svg { width: 16px; height: 16px; }
  .hero-github { order: 2; }
  .capability-section { padding-block: 44px 72px; }
  .capability-heading { max-width: 700px; margin-bottom: 28px; }
  .capability-heading h2 { margin: 12px 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.04em; line-height: 1.15; }
  .capability-heading > p:last-child { color: var(--ui-muted); font-size: 15px; line-height: 1.6; }
  .capability-card { color: var(--ui-text); background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 16px; }
  .capability-card > svg { width: 38px; height: 38px; padding: 9px; color: var(--ui-accent); background: var(--ui-accent-soft); border-radius: 10px; }
  .capability-card h3 { margin: 22px 0 10px; font-size: 17px; line-height: 1.3; letter-spacing: -.025em; }
  .capability-card p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--ui-muted); }
  .pipeline { display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px; align-items: center; margin-top: 32px; padding: 28px 0; border-block: 1px solid var(--ui-line); }
  .pipeline h3 { margin: 0 0 10px; font-size: 18px; }
  .pipeline p { max-width: 480px; margin: 0; font-size: 13px; line-height: 1.7; color: var(--ui-muted); }
  .pipeline ol { list-style: none; margin: 0; padding: 0; }
  .pipeline li { display: grid; gap: 12px; padding: 16px; background: var(--ui-surface); border-radius: 10px; }
  .pipeline li span { color: var(--ui-accent); font: 700 11px ui-monospace, monospace; }
  .pipeline li b { font-size: 13px; }
  .workflow-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .workflow-grid li { min-height: 230px; }
  .workflow-grid b { margin-top: 52px; }
  .workflow-grid li:nth-child(-n+4) { border-bottom: 0; }
  .workflow-grid li:last-child { grid-column: auto; }
  @media (min-width: 981px) and (max-width: 1200px) { .nav-links { gap: 12px; font-size: 11px; } .brand { font-size: 14px; } }
  @media (max-width: 760px) { .pipeline { grid-template-columns: 1fr; gap: 24px; } }
  @media (max-width: 640px) {
    .site-header .brand > span { display: none; }
    .header-tools { gap: 5px; } .header-github { padding: 8px; gap: 5px; } .header-github > svg:last-child { display: none; }
    .workflow-grid { grid-template-columns: 1fr; } .workflow-grid li:nth-child(-n+4) { border-bottom: 1px solid var(--ui-line); } .workflow-grid li:last-child { border-bottom: 0; }
    .capability-section { padding-top: 16px; padding-bottom: 40px; }
  }
}
