/* =====================================================================
   Brain in a Jar — "Institutional ward" visual system
   Hospital-mint walls, carbon-copy blue ink, brain pink, warning-tape yellow.
   The jar is the one loud element; everything else is quiet paperwork.
   ===================================================================== */

:root {
    --wall: #D6E8E1;        /* hospital tile mint */
    --wall-deep: #B7D3C8;
    --paper: #F6FAF7;       /* cool form paper */
    --paper-line: #C9DCD4;
    --ink: #1F2D5C;         /* carbon-copy blue */
    --ink-soft: #4A5A8A;
    --ink-faint: #8794B8;
    --brain: #EE9AA6;
    --brain-deep: #C9667A;
    --brain-edge: #9E4A5C;
    --tape: #F2C230;        /* warning tape */
    --fluid: #E3EFAE;       /* formalin */
    --danger: #B8364A;
    --ok: #2F7D5B;

    --f-ui: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
    --f-form: "Courier Prime", "Courier New", monospace;

    --step--1: clamp(.82rem, .8rem + .1vw, .9rem);
    --step-0: clamp(1rem, .96rem + .2vw, 1.08rem);
    --step-1: clamp(1.2rem, 1.1rem + .5vw, 1.4rem);
    --step-2: clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --step-3: clamp(2rem, 1.6rem + 2vw, 3rem);

    --r-paper: 3px;
    --r-btn: 999px;
    --shadow-paper: 0 1px 0 var(--paper-line), 0 14px 30px -18px rgba(31, 45, 92, .45);
    --gutter: clamp(16px, 4vw, 40px);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--f-ui);
    font-size: var(--step-0);
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--wall);
    /* tiled wall: 48px tiles with grout lines */
    background-image:
        linear-gradient(var(--wall-deep) 1px, transparent 1px),
        linear-gradient(90deg, var(--wall-deep) 1px, transparent 1px);
    background-size: 48px 48px;
    background-position: -1px -1px;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--brain-edge); }
:focus-visible { outline: 3px solid var(--tape); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-weight: 800; line-height: 1.1; margin: 0 0 .5em; font-variation-settings: "wdth" 85; letter-spacing: -.01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-1); }
p { margin: 0 0 1em; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 99; background: var(--tape); padding: 8px 12px; }

/* ------------------------------------------------------------- header */
.top {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px var(--gutter);
    background: var(--ink); color: var(--paper);
    position: sticky; top: 0; z-index: 20;
}
.wordmark { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: var(--step-1); font-variation-settings: "wdth" 78; letter-spacing: -.02em; }
.wordmark:hover { color: var(--brain); }
.wordmark-jar { width: 28px; height: 34px; }
.wm-lid { fill: var(--paper); }
.wm-glass { fill: var(--fluid); stroke: var(--paper); stroke-width: 2.5; }
.wm-brain { fill: var(--brain); }
.menu { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.menu a, .menu button { color: var(--paper); text-decoration: none; font: inherit; font-weight: 600; background: none; border: 0; padding: 6px 0; cursor: pointer; }
.menu a[aria-current] { box-shadow: inset 0 -3px var(--tape); }
.menu a:hover, .menu button:hover { color: var(--brain); }
.menu .who { opacity: .6; font-weight: 400; }
.menu-logout { margin: 0; }
.menu-btn { display: none; }

@media (max-width: 860px) {
    .menu-btn {
        display: inline-flex; font: inherit; font-weight: 700; color: var(--ink); background: var(--tape);
        border: 0; border-radius: var(--r-btn); padding: 6px 14px; cursor: pointer;
    }
    .menu:not(.menu-guest) {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--ink); padding: 8px var(--gutter) 16px; border-top: 1px solid var(--ink-soft);
    }
    .menu.is-open { display: flex; }
    .menu a, .menu button { padding: 12px 0; border-bottom: 1px solid rgba(246, 250, 247, .12); text-align: left; width: 100%; }
}

/* ------------------------------------------------------------- layout */
.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) var(--gutter); }
.foot { padding: 24px var(--gutter) 32px; text-align: center; font-size: var(--step--1); color: var(--ink-soft); }
.foot p { max-width: 60ch; margin: 0 auto 10px; }
.langs { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.langs a { color: var(--ink-soft); }
.langs a[aria-current] { color: var(--ink); font-weight: 700; text-decoration: none; }

/* ------------------------------------------------------------- paper */
.paper {
    background: var(--paper);
    border-radius: var(--r-paper);
    box-shadow: var(--shadow-paper);
    padding: clamp(22px, 4vw, 44px);
    max-width: 880px; margin: 0 auto;
    /* ruled form lines */
    background-image: repeating-linear-gradient(transparent 0 31px, rgba(201, 220, 212, .55) 31px 32px);
    background-position: 0 14px;
}
.paper-narrow { max-width: 520px; }
.lede { font-size: var(--step-1); line-height: 1.35; color: var(--ink-soft); max-width: 46ch; }
.aside { margin-top: 1.2em; }
.empty { font-family: var(--f-form); color: var(--ink-soft); padding: 24px 0; }
.alert { background: #FBE3E6; border-left: 5px solid var(--danger); padding: 10px 14px; color: var(--danger); font-weight: 600; }
.notice { background: #E2F2EA; border-left: 5px solid var(--ok); padding: 10px 14px; color: var(--ok); font-weight: 600; }

/* ------------------------------------------------------------- forms */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field > label, .field legend { font-weight: 700; }
.field small { color: var(--ink-soft); font-size: var(--step--1); }
input, select {
    font: inherit; font-family: var(--f-form); font-size: var(--step-1); color: var(--ink);
    background: transparent; border: 0; border-bottom: 2px solid var(--ink);
    padding: 6px 2px; border-radius: 0; width: 100%; min-width: 0;
}
input::placeholder { color: var(--ink-faint); }
input:focus { outline: none; border-bottom-color: var(--brain-edge); background: rgba(238, 154, 166, .08); }
select { background: var(--paper); }
.input-with-btn { display: flex; gap: 10px; align-items: end; }
.choices { gap: 8px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--paper-line); border-radius: 10px; cursor: pointer; background: var(--paper); }
.choice:has(input:checked) { border-color: var(--ink); background: #EEF3FB; }
.choice input, .check input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.tz { font-family: var(--f-form); font-size: var(--step-1); }

.btn, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
    border-radius: var(--r-btn); padding: 10px 20px; border: 2px solid var(--ink);
    transition: transform .08s ease, background-color .15s ease;
}
.btn { background: var(--ink); color: var(--paper); }
.btn:hover { background: var(--brain-edge); border-color: var(--brain-edge); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink); white-space: nowrap; }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn:active, .btn-ghost:active, .act:active { transform: translateY(1px); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn-wide { width: 100%; padding: 14px 20px; font-size: var(--step-1); }
.btn-seal { background: var(--brain-edge); border-color: var(--brain-edge); }

/* =================================================================
   THE JAR — the loud element
   ================================================================= */
.jar-stage { position: relative; --fluid-now: var(--fluid); }
.jar-stage[data-mood="stable"] { --fluid-now: #DCE8A2; }
.jar-stage[data-mood="troubled"] { --fluid-now: #CBD47E; }
.jar-stage[data-mood="awakened"] { --fluid-now: #C3CCC2; }
.jar-stage[data-mood="dead"] { --fluid-now: #B4BAB2; }

.jar { width: 100%; height: auto; overflow: visible; }
.jar-shadow { fill: rgba(31, 45, 92, .18); }
.jar-fluid { fill: var(--fluid-now); transition: fill 1.2s ease; }
.jar-surface { fill: #fff; opacity: .35; }
.jar-glass { fill: rgba(255, 255, 255, .12); stroke: var(--ink); stroke-width: 5; }
.jar-shine { opacity: .9; }
.jar-neck { fill: var(--ink-soft); }
.jar-lid { fill: var(--ink); }
.jar-lid-lines { stroke: var(--ink-soft); stroke-width: 2; }
.jar-wire { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.bubbles circle { fill: #fff; opacity: .7; animation: rise 7s linear infinite; }
.bubbles circle:nth-child(2) { animation-duration: 9s; animation-delay: -3s; }
.bubbles circle:nth-child(3) { animation-duration: 6s; animation-delay: -1s; }
.bubbles circle:nth-child(4) { animation-duration: 10s; animation-delay: -5s; }
.bubbles circle:nth-child(5) { animation-duration: 8s; animation-delay: -6s; }
.bubbles circle:nth-child(6) { animation-duration: 7.5s; animation-delay: -2s; }
@keyframes rise { from { transform: translateY(0); opacity: .75; } 90% { opacity: .6; } to { transform: translateY(-270px); opacity: 0; } }

.brain { animation: bob 5s ease-in-out infinite; transform-origin: 150px 210px; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1.5deg); } }
.brain-body { fill: var(--brain); stroke: var(--brain-edge); stroke-width: 4; transition: fill 1s ease; }
.brain-stem { fill: none; stroke: var(--brain-deep); stroke-width: 16; stroke-linecap: round; }
.brain-folds path { fill: none; stroke: var(--brain-deep); stroke-width: 4; stroke-linecap: round; }
.face { display: none; }
.face circle, .face path { fill: var(--ink); stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.face path { fill: none; }
.face .blush { fill: var(--brain-deep); stroke: none; opacity: .35; }
.face .sweat { fill: #9DD3E8; stroke: var(--ink); stroke-width: 1.5; }
.eye-white { fill: #FFF8EA !important; stroke: var(--ink) !important; stroke-width: 3 !important; }
.eye-iris { fill: #6B2A3A !important; stroke: none !important; }
.eye-pupil { fill: #111 !important; stroke: none !important; }
.vein { stroke: var(--danger) !important; stroke-width: 2 !important; }
.jar-stage[data-mood="content"] .face-content,
.jar-stage[data-mood="stable"] .face-stable,
.jar-stage[data-mood="troubled"] .face-troubled,
.jar-stage[data-mood="awakened"] .face-awakened,
.jar-stage[data-mood="dead"] .face-dead { display: inline; }
.jar-stage[data-mood="troubled"] .brain { animation-duration: 2.6s; }
.jar-stage[data-mood="awakened"] .brain { animation: none; }
.jar-stage[data-mood="awakened"] .brain-body { fill: #D9A3AC; }
.jar-stage[data-mood="awakened"] .eye-iris { animation: watch 6s ease-in-out infinite; }
@keyframes watch { 0%, 40% { transform: translateX(0); } 50%, 70% { transform: translateX(-7px); } 80%, 100% { transform: translateX(5px); } }
.jar-stage[data-mood="dead"] .brain { animation: none; transform: translateY(70px) rotate(14deg); }
.jar-stage[data-mood="dead"] .brain-body { fill: #CDB2B6; }
.jar-stage[data-mood="dead"] .bubbles { display: none; }

/* reactions triggered by JS */
.jar-stage.is-shake .jar { animation: shake .45s ease; }
@keyframes shake { 20% { transform: rotate(-2deg); } 40% { transform: rotate(2deg); } 60% { transform: rotate(-1.5deg); } 80% { transform: rotate(1deg); } }
.jar-stage.is-happy .brain-body { animation: glow .9s ease; }
@keyframes glow { 50% { fill: #FFB8C2; } }
.jar-stage.is-sad .brain { animation: droop 1.2s ease; }
@keyframes droop { 50% { transform: translateY(14px) rotate(-3deg); } }

.jar-label {
    position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%) rotate(-2deg);
    background: var(--paper); border: 2px solid var(--ink); padding: 6px 14px 4px;
    text-align: center; min-width: 42%; max-width: 64%; box-shadow: 2px 3px 0 rgba(31, 45, 92, .25);
}
.jar-label-name { display: block; font-weight: 800; font-size: var(--step-1); line-height: 1.05; font-variation-settings: "wdth" 80; overflow-wrap: anywhere; }
.jar-label-day { display: block; font-family: var(--f-form); font-size: var(--step--1); color: var(--ink-soft); }

/* speech bubble */
.speech {
    position: relative; z-index: 2;
    margin: 0 auto 10px; max-width: 30ch; min-height: 3.2em;
    background: var(--paper); border: 2.5px solid var(--ink); border-radius: 22px;
    padding: 12px 16px; font-size: var(--step-1); line-height: 1.25; font-weight: 600; font-style: italic;
    font-variation-settings: "wdth" 92;
    box-shadow: 3px 4px 0 var(--ink);
}
.speech::after {
    content: ""; position: absolute; left: 54%; bottom: -14px; width: 22px; height: 22px;
    background: var(--paper); border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink);
    transform: rotate(45deg) skew(10deg, 10deg);
}
.speech.is-new { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lab[data-mood="awakened"] .speech { background: var(--ink); color: var(--paper); font-style: normal; letter-spacing: .02em; }
.lab[data-mood="awakened"] .speech::after { background: var(--ink); }

/* mood gauge */
.gauge { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gauge li {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: var(--step--1); font-weight: 600; color: var(--ink-faint); text-align: center;
}
.gauge-dot { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid currentColor; background: var(--paper); transition: all .4s ease; }
.gauge li.is-on { color: var(--ink); }
.gauge li.is-on .gauge-dot { background: var(--brain); border-color: var(--ink); box-shadow: 0 0 0 5px rgba(238, 154, 166, .35); }
.gauge li[data-mood="awakened"].is-on .gauge-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(184, 54, 74, .25); }

/* ------------------------------------------------------------- lab layout */
.lab { display: grid; gap: clamp(24px, 4vw, 48px); grid-template-columns: 1fr; align-items: start; }
.stage { max-width: 420px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) {
    .lab { grid-template-columns: minmax(340px, 440px) 1fr; }
    .stage { position: sticky; top: 90px; }
}

/* the clipboard chart */
.chart {
    position: relative; background: var(--paper); border-radius: var(--r-paper);
    box-shadow: var(--shadow-paper); padding: 40px clamp(18px, 3vw, 32px) 28px;
    border-top: 14px solid #8B6B4E; /* clipboard board edge */
}
.clip {
    position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 30px; border-radius: 8px 8px 4px 4px;
    background: linear-gradient(#B9C1CF, #8D97AA); border: 2px solid var(--ink);
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--ink); margin-bottom: 14px; }
.chart-head h1 { font-size: var(--step-2); margin-bottom: 6px; }
.clock { font-family: var(--f-form); font-size: var(--step-1); font-weight: 700; }

.needs { margin: 0 0 18px; display: grid; gap: 0; }
.need { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--paper-line); }
.need dt { font-weight: 700; }
.need dd { margin: 0; font-family: var(--f-form); }
.slots { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.slot { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); }
.slot-box { width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 3px; position: relative; background: var(--paper); flex: none; }
.slot.is-done { color: var(--ink); font-weight: 700; }
.slot.is-done .slot-box::after {
    content: ""; position: absolute; left: 5px; top: -2px; width: 8px; height: 15px;
    border: solid var(--brain-edge); border-width: 0 4px 4px 0; transform: rotate(40deg);
}
.slot.is-now .slot-box { box-shadow: 0 0 0 4px rgba(242, 194, 48, .55); }
.slot.is-locked { opacity: .45; text-decoration: line-through; }
.fog-dots { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-right: 10px; vertical-align: middle; max-width: 100%; }
.fog-dot { width: 14px; height: 14px; border-radius: 50%; background: #9AA3B5; }
.fog-dot.is-clear { background: transparent; border: 2px dashed var(--ink-faint); }
.fog-text { color: var(--ink-soft); }
.love { font-weight: 700; }
.love.is-got { color: var(--brain-edge); }
.love.is-locked { color: var(--ink-faint); font-weight: 400; }

.controls { display: grid; gap: 14px; }
.mode { display: flex; flex-wrap: wrap; background: #E6EEF0; border-radius: var(--r-btn); padding: 4px; gap: 4px; width: fit-content; max-width: 100%; }
.mode label { position: relative; padding: 6px 14px; border-radius: var(--r-btn); font-weight: 600; font-size: var(--step--1); cursor: pointer; }
.mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.mode label:has(input:checked) { background: var(--ink); color: var(--paper); }
.mode label:has(input:focus-visible) { outline: 3px solid var(--tape); }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 340px) { .actions { grid-template-columns: 1fr; } }
.act {
    display: grid; justify-items: center; align-content: start; gap: 4px; text-align: center;
    font: inherit; font-weight: 800; font-size: var(--step-0); line-height: 1.15; color: var(--ink);
    background: var(--paper); border: 2.5px solid var(--ink); border-radius: 16px;
    padding: 14px 10px 12px; cursor: pointer; box-shadow: 0 4px 0 var(--ink);
    transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
}
@media (max-width: 340px) { .act { grid-template-columns: auto 1fr; justify-items: start; text-align: left; align-items: center; column-gap: 12px; } .act .act-why { grid-column: 2; } }
.act:hover:not([disabled]) { background: #FFF1F3; }
.act:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.act[disabled] { cursor: not-allowed; color: var(--ink-faint); border-color: var(--ink-faint); box-shadow: 0 4px 0 var(--ink-faint); background: transparent; }
.act-ico { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.act-ico circle { fill: currentColor; stroke: none; }
.act-why { font-weight: 500; font-size: var(--step--1); color: var(--ink-soft); min-height: 1.2em; }
.act.is-streak { background: var(--tape); animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-3px); } }
.status { min-height: 1.5em; margin: 0; font-family: var(--f-form); font-weight: 700; }

/* dice tray */
.tray { margin-top: 18px; padding: 18px; background: #23335F; border-radius: 14px; color: var(--paper); box-shadow: inset 0 3px 12px rgba(0, 0, 0, .35); }
.tray-goal { margin: 0 0 12px; font-size: var(--step--1); opacity: .8; }
.dice { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 64px; }
.die {
    --size: 58px; width: var(--size); height: var(--size); border-radius: 13px;
    background: var(--paper); box-shadow: inset 0 -5px 0 #CBD6E2, 0 4px 0 rgba(0, 0, 0, .35);
    display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 8px; gap: 2px;
    transition: box-shadow .2s ease, transform .2s ease;
}
.die .pip { width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--ink); align-self: center; justify-self: center; max-width: 11px; }
.die.is-rolling { animation: tumble .55s cubic-bezier(.3, .7, .4, 1) both; }
@keyframes tumble {
    0% { transform: translate(-60px, -30px) rotate(-200deg) scale(.6); opacity: 0; }
    60% { transform: translate(6px, 4px) rotate(18deg) scale(1.05); opacity: 1; }
    100% { transform: none; }
}
.die.pair-a { box-shadow: inset 0 -5px 0 #CBD6E2, 0 0 0 4px var(--brain); transform: translateY(-4px); }
.die.pair-b { box-shadow: inset 0 -5px 0 #CBD6E2, 0 0 0 4px var(--tape); transform: translateY(-4px); }
.die.is-dim { opacity: .45; }
.tray-result { margin: 14px 0 0; text-align: center; font-family: var(--f-form); font-size: var(--step-1); font-weight: 700; }
.tray-result.is-ok { color: #A6F0C8; }
.tray-result.is-fail { color: #FFB3BE; }

/* manual keypad */
.keypad { margin-top: 18px; padding: 16px; border: 2.5px dashed var(--ink); border-radius: 14px; }
.keypad-hint { margin: 0 0 10px; font-weight: 600; }
.keypad-slots { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.keypad-slot { width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--ink-faint); display: grid; place-items: center; font-family: var(--f-form); font-weight: 700; font-size: 1.3rem; }
.keypad-slot.is-filled { border-color: var(--ink); background: var(--paper); }
.keypad-keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.keypad-keys button { aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; }
.keypad-keys .die { --size: 100%; width: 100%; height: auto; aspect-ratio: 1; padding: 18%; }
.keypad-bar { display: flex; justify-content: space-between; gap: 10px; }

/* log */
.log { margin-top: 26px; }
.log h2 { font-size: var(--step-0); border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.log ol { list-style: none; margin: 0; padding: 0; font-family: var(--f-form); font-size: var(--step--1); }
.log li { display: grid; grid-template-columns: 3.4em 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px dotted var(--paper-line); }
.log .t { color: var(--ink-soft); }
.log .ok { color: var(--ok); font-weight: 700; }
.log .no { color: var(--danger); font-weight: 700; }
.sound-toggle { position: absolute; top: 12px; right: 14px; font: inherit; font-size: var(--step--1); background: none; border: 1.5px solid var(--ink-faint); color: var(--ink-soft); border-radius: var(--r-btn); padding: 2px 10px; cursor: pointer; }

/* ------------------------------------------------------------- sheet (dialog) */
.sheet { border: 0; padding: 0; background: transparent; max-width: min(560px, calc(100vw - 32px)); width: 100%; }
.sheet::backdrop { background: rgba(31, 45, 92, .55); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-in .3s ease; }
@keyframes sheet-in { from { transform: translateY(20px) rotate(-1deg); opacity: 0; } }
.sheet-paper { background: var(--paper); border-radius: var(--r-paper); padding: clamp(20px, 4vw, 34px); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); border-top: 10px solid var(--tape); }
.sheet h2 { font-size: var(--step-2); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.sheet .dice { margin: 12px 0; }
.sheet .tray { margin: 12px 0; }
.sheet-form { font-family: var(--f-form); display: grid; gap: 4px; margin: 10px 0 14px; }
.sheet-form div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--paper-line); padding: 4px 0; }
.sheet-big { font-family: var(--f-form); font-size: var(--step-2); font-weight: 700; text-align: center; margin: 8px 0; }
.sheet-verdict { text-align: center; font-weight: 800; font-size: var(--step-1); }
.sheet.is-dead .sheet-paper { border-top-color: var(--danger); }
.sheet.is-awake .sheet-paper { background: var(--ink); color: var(--paper); border-top-color: var(--danger); }
.sheet.is-awake .btn { background: var(--danger); border-color: var(--danger); }
.lede-inherit { color: inherit; }
.sheet-epitaph { font-style: italic; font-weight: 600; }
.auto-list { font-family: var(--f-form); padding-left: 1.2em; }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 18px; transform: translateX(-50%); display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); border-radius: 14px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); border-left: 6px solid var(--tape); animation: toast-in .35s ease; }
.toast strong { display: block; color: var(--tape); }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }

/* ------------------------------------------------------------- intake (create) */
.intake { display: grid; gap: 24px; align-items: center; max-width: 980px; margin: 0 auto; }
.intake-jar { max-width: 260px; margin: 0 auto; width: 100%; }
@media (min-width: 860px) { .intake { grid-template-columns: 320px 1fr; } .intake-jar { max-width: none; } }

/* ------------------------------------------------------------- archive shelf */
.shelf { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
.specimen { display: grid; justify-items: center; text-align: center; gap: 4px; text-decoration: none; padding: 8px; border-radius: 10px; }
.specimen:hover { background: rgba(238, 154, 166, .12); color: var(--ink); }
.specimen-jar { width: 76px; height: 92px; border: 3.5px solid var(--ink); border-radius: 18px 18px 20px 20px; background: var(--fluid); position: relative; border-top-width: 12px; }
.specimen[data-mood="dead"] .specimen-jar { background: #C6CCC4; }
.specimen[data-mood="awakened"] .specimen-jar { background: #C3CCC2; }
.specimen-brain { position: absolute; left: 50%; top: 52%; width: 46px; height: 32px; transform: translate(-50%, -50%); background: var(--brain); border-radius: 50% 50% 44% 44%; border: 2.5px solid var(--brain-edge); }
.specimen[data-mood="dead"] .specimen-brain { background: #CDB2B6; top: 72%; transform: translate(-50%, -50%) rotate(16deg); }
.specimen-name { font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.specimen-meta { font-family: var(--f-form); font-size: var(--step--1); color: var(--ink-soft); }
.badge { font-style: normal; }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px 20px; }
table { width: 100%; border-collapse: collapse; font-family: var(--f-form); font-size: var(--step--1); }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--paper-line); vertical-align: top; }
thead th { border-bottom: 2px solid var(--ink); font-family: var(--f-ui); font-weight: 800; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hall .rank { font-weight: 700; width: 2.5em; }
.hall .is-podium td { font-weight: 700; }
.hall .is-podium .rank { color: var(--brain-edge); }
.hall .is-me { background: rgba(242, 194, 48, .2); }
.living { list-style: none; padding: 0; display: grid; gap: 8px; }
.living li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--paper-line); }
.living li a { font-weight: 800; }
.living span { font-family: var(--f-form); font-size: var(--step--1); color: var(--ink-soft); }
tr.is-auto { color: var(--ink-faint); }
.mini { max-width: 280px; margin-top: 16px; }

/* ------------------------------------------------------------- records */
.ledger { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 24px; margin: 0 0 28px; }
.ledger div { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-bottom: 1px dashed var(--paper-line); padding: 10px 0; }
.ledger dt { color: var(--ink-soft); }
.ledger dd { margin: 0; font-family: var(--f-form); font-weight: 700; font-size: var(--step-1); }
.ledger small { font-size: var(--step--1); font-weight: 400; }
.count { font-family: var(--f-form); font-weight: 400; color: var(--ink-soft); font-size: var(--step-0); }
.badges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.badges li { display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; align-items: center; padding: 10px; border-radius: 12px; border: 2px solid var(--paper-line); }
.badges strong { grid-column: 2; line-height: 1.2; }
.badges span:not(.medal) { grid-column: 2; font-size: var(--step--1); color: var(--ink-soft); }
.medal { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; background: var(--tape); border: 3px solid var(--ink); position: relative; }
.medal::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--brain); border: 2px solid var(--ink); }
.badges .is-locked { opacity: .5; border-style: dashed; }
.badges .is-locked .medal { background: #DDE3E8; border-color: var(--ink-faint); }
.badges .is-locked .medal::after { background: #EEF1F4; border-color: var(--ink-faint); }

/* ------------------------------------------------------------- settings */
.settings-block { margin-top: 30px; padding-top: 18px; border-top: 2px solid var(--ink); }
.push-status { font-family: var(--f-form); }

/* ------------------------------------------------------------- rules */
.rules section { margin-bottom: 20px; }
.rules section p { max-width: 68ch; }

/* =================================================================
   SPECIMEN REPORT — a filled-in carbon form
   ================================================================= */
.report {
    background: var(--paper); max-width: 860px; margin: 0 auto; padding: clamp(22px, 4vw, 48px);
    box-shadow: var(--shadow-paper); border-radius: var(--r-paper); position: relative;
    border: 2px solid var(--ink); outline: 6px solid var(--paper); outline-offset: -12px;
}
.report-head { border-bottom: 3px double var(--ink); margin-bottom: 20px; }
.report-inst { font-family: var(--f-form); color: var(--ink-soft); margin: 0 0 4px; }
.report-head h1 { font-size: var(--step-2); }
.report-note { font-family: var(--f-form); font-size: var(--step--1); color: var(--ink-soft); }
.report-grid { display: grid; gap: 24px; }
@media (min-width: 720px) { .report-grid { grid-template-columns: 1fr 240px; } }
.report-fields { margin: 0; display: grid; gap: 4px; }
.report-fields div { display: grid; grid-template-columns: 10em 1fr; gap: 12px; align-items: end; border-bottom: 1.5px solid var(--ink); padding: 6px 0 2px; }
.report-fields dt { font-size: var(--step--1); font-weight: 700; text-transform: none; color: var(--ink-soft); }
.report-fields dd { margin: 0; }
.hand { font-family: var(--f-form); font-size: var(--step-1); font-weight: 700; color: #2A3F8F; }
.hand.big { font-size: var(--step-3); line-height: 1; }
.polaroid { margin: 0; background: #fff; padding: 12px 12px 8px; box-shadow: 0 6px 18px rgba(31, 45, 92, .25); transform: rotate(2.5deg); align-self: start; }
.polaroid .jar-stage { background: var(--wall); padding: 8px; }
.polaroid figcaption { text-align: center; font-size: var(--step-0); padding-top: 8px; }
.report-perf { margin: 26px 0 18px; }
.tiers { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.tiers li { padding: 6px 12px; position: relative; font-size: var(--step--1); }
.tiers li span { color: var(--ink-soft); font-family: var(--f-form); }
.tiers li.is-circled::before {
    content: ""; position: absolute; inset: -4px -6px; border: 3px solid var(--brain-edge);
    border-radius: 50% 45% 52% 48%; transform: rotate(-3deg);
}
.report-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 20px; margin: 0 0 22px; }
.report-stats div { border-bottom: 1px dashed var(--paper-line); padding: 8px 0; display: flex; justify-content: space-between; gap: 8px; }
.report-stats dt { font-size: var(--step--1); color: var(--ink-soft); }
.report-stats dd { margin: 0; font-family: var(--f-form); font-weight: 700; text-align: right; }
.epitaph { margin: 0 0 22px; padding: 14px 18px; background: #EEF3FB; border-left: 5px solid var(--ink); }
.epitaph .hand { margin: 0; font-style: italic; }
.report-label { margin: 0 0 4px; font-size: var(--step--1); font-weight: 700; color: var(--ink-soft); }
.report-foot { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; margin-top: 18px; }
.signature { font-size: var(--step--1); color: var(--ink-soft); display: grid; gap: 4px; min-width: 200px; }
.sig-line { display: block; border-bottom: 1.5px solid var(--ink); height: 34px; }
.stamp {
    display: inline-block; padding: 6px 14px; font-weight: 800; font-size: var(--step-1);
    border: 4px solid currentColor; border-radius: 8px; transform: rotate(-8deg);
    font-variation-settings: "wdth" 75; letter-spacing: .04em; opacity: .85; mix-blend-mode: multiply;
}
.stamp-red { color: var(--danger); font-size: var(--step-2); }
.stamp-blue { color: #2A3F8F; font-size: var(--step--1); max-width: 18ch; text-align: center; transform: rotate(5deg); }
.report-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 24px auto 0; }

/* ------------------------------------------------------------- print */
@media print {
    body { background: #fff; }
    .top, .foot, .report-actions, .toasts { display: none !important; }
    .main { padding: 0; max-width: none; }
    .report { box-shadow: none; max-width: none; }
    .polaroid { box-shadow: none; border: 1px solid #999; }
    .bubbles, .brain { animation: none !important; }
}

/* ------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .bubbles { display: none; }
}
@media (max-width: 480px) {
    .act { padding: 12px 6px 10px; font-size: var(--step--1); border-radius: 12px; }
    .act-ico { width: 24px; height: 24px; }
    .need { grid-template-columns: 6em 1fr; }
}

/* last brain notice on the intake form */
.obituary { border: 2px solid var(--ink); border-left: 8px solid var(--danger); padding: 12px 16px; margin-bottom: 22px; background: #FBF1F2; }
.obituary p { margin: 0 0 6px; }
.obituary .hand { font-size: var(--step-0); }
