* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --ink: #000000;
    --ink-soft: #4a4a4a;
    --paper: #F3F3EF;
    --blue: #0000FF;
    --blue-soft: rgba(0, 0, 255, 0.55);
    --red: #E01B24;
    --red-soft: rgba(224, 27, 36, 0.18);
    --blue-strong: #1300F3;

    --say-dim: 0.4;

    --ink-faint: rgba(0, 0, 0, 0.45);
    --line: rgba(0, 0, 0, 0.16);
    --blue-hair: rgba(0, 0, 255, 0.32);

    --diag-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='21.213' height='21.213'><path d='M0 21.213L21.213 0' stroke='rgba(0,0,255,0.22)' stroke-width='1' stroke-dasharray='3 2'/></svg>");
    --grid-step: 15px;
    --frame-offset: 15px;

    --frame-gap: var(--frame-offset);
    --frame-border: 5px;

    --safe-top: env(safe-area-inset-top);
    --safe-right: env(safe-area-inset-right);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);

    --content-w: 1100px;
    --radius: 14px;
}

body {
    font-family: 'Inter', 'Space Grotesk', sans-serif;
    background-color: var(--paper);
    background-image: var(--diag-image);
    background-repeat: repeat;
    background-size: 21.213px 21.213px;
    background-position: var(--frame-offset) var(--frame-offset);
    color: var(--ink);
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
}

body.sheet-locked { overflow: hidden; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.blue-frame {
    position: relative;
    margin: calc(var(--frame-offset) + var(--safe-top)) calc(var(--frame-offset) + var(--safe-right)) calc(var(--frame-offset) + var(--safe-bottom)) calc(var(--frame-offset) + var(--safe-left));
    min-height: calc(100dvh - (var(--frame-offset) * 2));
    border: 5px solid var(--blue-pure);
    padding: 30px;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: calc(var(--grid-step) * 3);
    width: 100%;
    max-width: var(--content-w);
    margin: 0 auto;
    padding-top: calc(var(--grid-step) * 5);
    padding-bottom: calc(var(--grid-step) * 3);
    flex: 1 1 auto;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-title {
    font-family: var(--brand);
    font-weight: 500;
    font-size: clamp(34px, 6.4vw, 68px);
    line-height: 0.98;
    letter-spacing: 0;
    color: var(--ink);
}

.page-subtitle {
    font-family: var(--hand);
    font-synthesis-weight: none;
    font-size: clamp(21px, 3.2vw, 30px);
    font-weight: 600;
    line-height: 1;
    color: var(--blue);
    align-self: flex-start;
    transform: rotate(-4.5deg);
    transform-origin: left center;
    margin: 4px 0 calc(var(--grid-step) * 0.8) 4px;
}

.section-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: var(--grid-step);
}

:root { --machine-bg: rgb(var(--surface-rgb) / 0.62); }
:root[data-theme="dark"] { --machine-bg: var(--paper); }

.machine {
    border: 1.5px solid var(--ink);
    background: var(--machine-bg);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.machine-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px var(--grid-step);
    border-bottom: 1.5px solid var(--ink);
}

.machine-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.machine-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--red);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.machine.is-heard .machine-count { color: var(--ink-soft); }

.led {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
    animation: led-blink 1.6s steps(1, end) infinite;
    flex: 0 0 auto;
}

.led-sm { width: 7px; height: 7px; box-shadow: 0 0 0 2px var(--red-soft); }

.machine.is-heard .led,
.machine.is-playing .led { animation: none; opacity: 0.35; }

@keyframes led-blink {
    0%, 55% { opacity: 1; }
    56%, 100% { opacity: 0.15; }
}

.sound-toggle {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgb(var(--ink-rgb) / 0.2);
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.sound-toggle:hover { color: var(--blue); border-color: var(--blue); }
.sound-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.sound-toggle svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.sound-toggle .ico-sound-off { display: none; }
.sound-toggle[aria-pressed="false"] .ico-sound-on { display: none; }
.sound-toggle[aria-pressed="false"] .ico-sound-off { display: block; }

.machine-deck {
    display: flex;
    align-items: center;
    gap: var(--grid-step);
    padding: var(--grid-step);
    border-bottom: 1.5px dashed rgb(var(--ink-rgb) / 0.2);
}

.play-btn {
    width: 62px;
    height: 62px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--ink);
    background: var(--blue);
    color: var(--on-accent);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, background 0.2s ease;
}

.play-btn:hover { background: var(--blue-strong); transform: translateY(-1px); }
.play-btn:active { transform: translateY(0); }
.play-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.play-btn svg { width: 26px; height: 26px; }
.play-btn .ico-stop { display: none; }
.machine.is-playing .play-btn .ico-play { display: none; }
.machine.is-playing .play-btn .ico-stop { display: block; }

.deck-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wave {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 34px;
}

.wave-bar {
    flex: 1 1 0;
    min-width: 2px;
    background: rgb(var(--ink-rgb) / 0.22);
    height: 22%;
    transform-origin: bottom;
    transition: height 0.18s ease, background 0.18s ease;
}

.machine.is-playing .wave-bar { background: var(--blue); }
.wave-bar.is-past { background: var(--blue-soft); }

.deck-meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.deck-time {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.deck-hint {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--ink-soft);
}

.transcript {
    position: relative;
    padding: calc(var(--grid-step) * 1.4) var(--grid-step);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border-bottom: 1.5px solid var(--ink);
}

.transcript .line {
    font-family: 'Inter', sans-serif;
    font-size: clamp(16px, 2.1vw, 21px);
    line-height: 1.8;
    max-width: 52ch;
    text-align: center;
    color: var(--ink);
    opacity: 0.6;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.transcript .line.is-lit {
    opacity: 1;
    transform: none;
}

.say-dim {
    position: absolute;
    z-index: 1;
    background: var(--paper);
    opacity: var(--say-dim);
    pointer-events: none;
}

.transcript.is-fill .line { opacity: 1; }

.transcript.is-forming .say-dim { opacity: 0; }

.transcript.is-fill .say-mute {
    opacity: calc(1 - var(--say-dim));
    transition: opacity 0.3s ease;
}

.transcript.is-fill .line.is-lit .say-mute { opacity: 1; }

.transcript .line:first-child {
    font-weight: 600;
}

.say-mute { display: inline-block; }

.beep {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--red);
    border: 1px solid currentColor;
    padding: 1px 7px;
    white-space: nowrap;
}

.machine.is-beeping .beep { background: var(--red); color: var(--on-accent); }

.say-all,
.say-tape { transition: opacity 0.18s linear; }

.transcript.is-forming .say-all,
.transcript.is-forming .say-tape { opacity: 0; }

.force-air {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 4;
    opacity: calc(1 - var(--say-dim));
    transition: opacity 0.18s linear;
}

.force-glyph {
    position: absolute;
    white-space: pre;
    will-change: transform, opacity;
}

.burn-air {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.say-was {
    transition: opacity 0.5s ease;
}

.say-was.is-struck { opacity: 0.42; }

.say-now {
    position: absolute;
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
    font-family: var(--hand);
    font-synthesis-weight: none;
    font-weight: 600;
    font-size: 1.06em;
    line-height: 1;
    color: var(--blue);
}

.cast-ink {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 2;
}

.cast-mark {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cast-strike { stroke: var(--red); }

.cast-prop {
    position: absolute;
    color: var(--red);
    overflow: visible;
    pointer-events: none;
    z-index: 2;
}

.cast-prop .pen {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: cast-draw 0.5s ease-out var(--d, 0s) forwards;
}

.cast-prop.is-drawn .pen { animation: none; stroke-dashoffset: 0; }

@keyframes cast-draw { to { stroke-dashoffset: 0; } }

.cast-prop[data-icon="helmet"] { width: 96px; height: 96px; }
.cast-prop[data-icon="droid"]  { width: 62px; height: 62px; }
.cast-prop[data-icon="sage"]   { width: 88px; height: 88px; }
.cast-prop[data-icon="sabers"] { width: 76px; height: 76px; }

.cast-prop.is-force { color: var(--blue); }

.cast-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--grid-step) * 0.9);
    margin-top: 4px;
}

.cast-row:empty { display: none; }

.cast-prop.is-row { position: static; }
.cast-row .cast-prop[data-icon="helmet"] { width: 68px; height: 68px; }
.cast-row .cast-prop[data-icon="droid"]  { width: 46px; height: 46px; }
.cast-row .cast-prop[data-icon="sage"]   { width: 62px; height: 62px; }
.cast-row .cast-prop[data-icon="sabers"] { width: 54px; height: 54px; }

.machine-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.act {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: calc(var(--grid-step) * 1.3) var(--grid-step);
    background: transparent;
    border: none;
    border-left: 1.5px solid var(--ink);
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.act:first-child { border-left: none; }
.act:hover { background: var(--blue); color: var(--on-accent); }
.act:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }

.act-num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--blue);
    flex: 0 0 auto;
}

.act:hover .act-num { color: rgb(var(--on-accent-rgb) / 0.75); }

.act-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.act-title {
    font-size: clamp(15px, 1.7vw, 18px);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.act-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink-soft);
}

.act:hover .act-sub { color: rgb(var(--on-accent-rgb) / 0.8); }

.act-arrow {
    width: 20px; height: 20px;
    flex: 0 0 auto;
    margin-left: auto;
    fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
    transition: transform 0.2s ease;
}

.act:hover .act-arrow { transform: translateX(4px); }

.brief-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1.5px solid var(--ink);
}

.brief-cell {
    padding: var(--grid-step);
    border-left: 1.5px solid var(--ink);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.brief-cell:first-child { border-left: none; }

.brief-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.brief-value {
    font-size: 13px;
    line-height: 1.45;
}

.brief-link {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid var(--blue-soft);
}

.brief-link:hover { opacity: 0.65; }

[hidden] { display: none !important; }

.sheet {
    --sheet-side: right;
    --sheet-pad: 44px;
    width: min(720px, 100%);
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 0 0 auto;
    padding: 0;
    border: none;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    overflow: hidden;
    box-shadow: -2px 0 8px rgb(var(--shadow-rgb) / 0.06),
                -14px 0 44px rgb(var(--shadow-rgb) / 0.10);
}

.sheet::backdrop { background: rgb(var(--scrim-rgb) / 0.42); }

.sheet[open] { animation: sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1); }
.sheet[open]::backdrop { animation: backdrop-in 0.32s ease; }

@keyframes sheet-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@keyframes backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sheet-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100dvh;
}

.sheet-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px 9px var(--sheet-pad);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.sheet-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.sheet-grip { display: none; }

.sheet-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.sheet-close:hover { background: rgb(var(--ink-rgb) / 0.07); color: var(--ink); }
.sheet-close:active { background: rgb(var(--ink-rgb) / 0.11); }
.sheet-close:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.sheet-close svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round;
}

.sheet-scroll {
    padding: 30px var(--sheet-pad) 36px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
}

.sheet-form .sheet-scroll > * { max-width: 560px; }

.sheet-title {
    font-family: 'Inter', sans-serif;
    font-size: clamp(24px, 3.2vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sheet-lead {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink-faint);
    margin-top: -6px;
}

.sheet-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 14px var(--sheet-pad);
    border-top: 1px solid var(--line);
    flex: 0 0 auto;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.field-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
}

.field-input {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-area {
    display: block;
    line-height: 1.5;
    min-height: calc(1.5em * 4 + 24px);
    resize: none;
    overflow-y: hidden;
}

.field-input::placeholder { color: rgb(var(--ink-rgb) / 0.3); }
.field-input:hover { border-color: rgb(var(--ink-rgb) / 0.24); }

.field-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.12);
}

.field.is-invalid .field-input { border-color: var(--red); }

.field-error {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--red);
    display: none;
}

.field.is-invalid .field-error { display: block; }

.field-counter {
    position: absolute;
    top: 1px; right: 0;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

.field-note {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-faint);
}

.field-agree {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    column-gap: 10px;
    row-gap: 4px;
    cursor: pointer;
    margin-top: 2px;
}

.field-box {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--blue);
    cursor: pointer;
}

.field-agree-text {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-soft);
}

.field-agree-text a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid rgb(var(--ink-rgb) / 0.28);
}

.field-agree-text a:hover { border-bottom-color: currentColor; }

.field-agree .field-error { grid-column: 2; }
.field-agree.is-invalid .field-box { outline: 2px solid var(--red); outline-offset: 2px; }

.field-trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.btn {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    padding: 9px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent); }
.btn-primary:hover { background: var(--blue-strong); border-color: var(--blue-strong); }
.btn-primary[disabled] { opacity: 0.55; cursor: progress; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: rgb(var(--ink-rgb) / 0.05); border-color: rgb(var(--ink-rgb) / 0.22); }

.sheet-done .sheet-scroll {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
}

.sheet-done .sheet-foot { justify-content: center; }

.done-mark {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgb(var(--blue-rgb) / 0.12);
    color: var(--blue);
}

.done-mark svg {
    width: 21px; height: 21px;
    fill: none; stroke: currentColor;
    stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}

.chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px var(--sheet-pad);
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.msg {
    max-width: 86%;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    padding: 10px 13px;
    border-radius: 8px;
    border: 1px solid transparent;
    animation: msg-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-bot {
    align-self: flex-start;
    background: rgb(var(--ink-rgb) / 0.05);
    border-bottom-left-radius: 3px;
}

.msg-user {
    align-self: flex-end;
    background: var(--blue);
    border-color: var(--blue);
    color: var(--on-accent);
    border-bottom-right-radius: 3px;
}

.msg p + p { margin-top: 8px; }
.msg strong { font-weight: 600; }

.msg-bot a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid var(--blue-hair);
}

.msg-bot a:hover { border-bottom-color: currentColor; }

.msg-list {
    list-style: none;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.msg-list li {
    position: relative;
    padding-left: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.msg-list li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--ink-faint);
}

.typing { display: inline-flex; gap: 4px; align-items: center; height: 10px; }

.typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ink-soft);
    animation: typing-bounce 1.1s ease-in-out infinite;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-chips {
    display: flex;
    gap: 6px;
    padding: 0 var(--sheet-pad) 12px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 0 0 auto;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 34px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 34px), transparent 100%);
}

.chat-chips::-webkit-scrollbar { display: none; }

.chip {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover { color: var(--ink); border-color: rgb(var(--ink-rgb) / 0.22); background: rgb(var(--ink-rgb) / 0.06); }
.chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px var(--sheet-pad);
    border-top: 1px solid var(--line);
    flex: 0 0 auto;
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input::placeholder { color: rgb(var(--ink-rgb) / 0.3); }

.chat-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.12);
}

.chat-send {
    width: 38px; height: 38px;
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 6px;
    color: var(--on-accent);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-send:hover { background: var(--blue-strong); border-color: var(--blue-strong); }
.chat-send:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.chat-send svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

@media (max-width: 900px) {
    .brief-grid { grid-template-columns: 1fr 1fr; }
    .brief-cell:nth-child(odd) { border-left: none; }
    .brief-cell:nth-child(n + 3) { border-top: 1.5px solid var(--ink); }
}

@media (max-width: 768px) {
    .blue-frame { padding: 20px; }
    .main-content { padding-top: calc(var(--grid-step) * 4.5); gap: calc(var(--grid-step) * 2.4); }

    .machine-actions { grid-template-columns: 1fr; }
    .act { border-left: none; border-top: 1.5px solid var(--ink); }
    .act:first-child { border-top: none; }

    .play-btn { width: 54px; height: 54px; }
    .play-btn svg { width: 22px; height: 22px; }
    .wave { height: 28px; }
    .deck-hint { display: none; }

    .sheet {
        --sheet-side: bottom;
        --sheet-pad: 20px;
        width: 100%;
        height: 92dvh;
        max-height: 92dvh;
        margin: auto 0 0 0;
        border-left: none;
        border-top: 1px solid var(--line);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -2px 8px rgb(var(--shadow-rgb) / 0.06),
                    0 -14px 44px rgb(var(--shadow-rgb) / 0.16);
    }

    .sheet[open] { animation: sheet-up 0.34s cubic-bezier(0.2, 0.8, 0.3, 1); }

    .sheet.is-going {
        transition: transform 0.24s ease-in;
        transform: translateY(100%);
    }

    .sheet-bar {
        position: relative;
        padding: 18px 10px 9px var(--sheet-pad);
        touch-action: none;
        cursor: grab;
    }

    .sheet-grip {
        display: block;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: rgb(var(--ink-rgb) / 0.22);
    }

    .sheet-scroll { padding: 24px var(--sheet-pad) 30px; }
    .sheet-form .sheet-scroll > * { max-width: none; }
    .sheet-title { font-size: 26px; }

    .sheet-foot { padding-bottom: calc(14px + var(--safe-bottom)); }
    .chat-form { padding-bottom: calc(12px + var(--safe-bottom)); }
}

@media (max-width: 560px) {
    :root { --frame-offset: 10px; }
    .blue-frame { border-width: 4px; padding: 16px; }
    .brief-grid { grid-template-columns: 1fr; }
    .brief-cell { border-left: none; border-top: 1.5px solid var(--ink); }
    .brief-cell:first-child { border-top: none; }

    .sheet-foot .btn { flex: 1 1 auto; text-align: center; }
    .msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
    .led { animation: none; }
    .sheet[open], .sheet[open]::backdrop, .msg { animation: none; }
    .sheet.is-going { transition: none; }
    .typing span { animation: none; }
    .transcript .line { transition: none; }
    .say-was, .say-now, .say-all { transition: none; }
    .transcript { transition: none !important; }
    .cast-prop .pen { animation: none; stroke-dashoffset: 0; }
    .wave-bar { transition: none; }
    .act-arrow { transition: none; }
}
