:root {
    color-scheme: dark;
    --bg: #070b0e;
    --surface: #0b1014;
    --surface-raised: #10171c;
    --line: #29353d;
    --line-bright: #3f525d;
    --text: #c9d2d7;
    --muted: #73838d;
    --cyan: #56d4dd;
    --cyan-dim: #17383d;
    --green: #9dde6f;
    --yellow: #e5c76b;
    --magenta: #d783d7;
    --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
    --shadow: 0 20px 70px rgb(0 0 0 / 38%);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding: clamp(0px, 2vw, 28px);
    background:
        linear-gradient(rgb(86 212 221 / 2%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(86 212 221 / 2%) 1px, transparent 1px),
        var(--bg);
    background-size: 32px 32px;
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1.65;
}

::selection { background: var(--cyan); color: var(--bg); }

a {
    color: var(--cyan);
    text-decoration-color: rgb(86 212 221 / 45%);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
}

a:hover { color: #a4f8ff; text-decoration-color: currentColor; }

:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 3px;
}

.terminal-shell {
    display: flex;
    flex-direction: column;
    width: min(1180px, 100%);
    min-height: calc(100vh - clamp(0px, 4vw, 56px));
    margin: 0 auto;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line-bright);
    box-shadow: var(--shadow);
}

.app-header { border-bottom: 1px solid var(--line); }

.title-bar,
.command-bar,
.status-bar,
.panel-heading {
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.title-bar {
    min-height: 48px;
    justify-content: space-between;
    gap: 20px;
    padding: 0 18px;
    background: var(--surface-raised);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    background: var(--cyan);
    color: var(--bg);
    font-weight: 900;
}

.title-meta {
    display: flex;
    gap: 22px;
    color: var(--muted);
    font-size: 0.68rem;
}

.status-online { color: var(--green) !important; }
.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 7px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.command-bar {
    min-height: 42px;
    gap: 9px;
    padding: 7px 18px;
    overflow-x: auto;
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.prompt { color: var(--green); font-weight: 800; }
.command { color: var(--magenta); }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li { color: var(--text); }
.breadcrumbs li + li::before { content: "/"; margin-right: 7px; color: var(--line-bright); }
.breadcrumbs a { color: var(--cyan); text-decoration: none; }

.cursor {
    display: inline-block;
    width: 0.58em;
    height: 1.05em;
    background: var(--cyan);
    vertical-align: -0.18em;
    animation: blink 1.1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.screen {
    flex: 1;
    padding: clamp(14px, 3vw, 34px);
}

.panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line-bright);
}

.panel-heading {
    justify-content: space-between;
    gap: 20px;
    min-height: 34px;
    padding: 6px 11px;
    background: var(--cyan-dim);
    color: var(--cyan);
    border-bottom: 1px solid var(--line-bright);
    font-size: 0.66rem;
    font-weight: 700;
}

.panel-heading span:last-child { color: #8ca2ab; font-weight: 400; }

.document,
.hero-content,
.tool-header { padding: clamp(24px, 5vw, 64px); }

.document { max-width: 860px; }

.document-header {
    margin-bottom: clamp(28px, 5vw, 52px);
    padding-bottom: 24px;
    border-bottom: 1px dashed var(--line-bright);
}

.eyebrow {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.eyebrow span { color: var(--green); }

h1, h2, h3, h4 {
    color: #edf5f7;
    font-weight: 650;
    line-height: 1.18;
    text-wrap: balance;
}

h1 {
    max-width: 19ch;
    margin: 0;
    font-size: clamp(2rem, 7vw, 4.7rem);
    letter-spacing: -0.055em;
}

h2 {
    margin: 2.8em 0 0.8em;
    color: var(--yellow);
    font-size: clamp(1.15rem, 3vw, 1.45rem);
}

h2::before { content: "## "; color: var(--muted); }
h3 { margin-top: 2em; font-size: 1.05rem; }
h3::before { content: "> "; color: var(--magenta); }

.prose { max-width: 78ch; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1.35em; }
.prose strong { color: #eef7f8; }
.prose hr { margin: 2.5em 0; border: 0; border-top: 1px dashed var(--line-bright); }

.prose ul,
.prose ol { padding-left: 1.55rem; }
.prose li { margin: 0.45em 0; padding-left: 0.35em; }
.prose li::marker { color: var(--cyan); }

code,
kbd {
    padding: 0.15em 0.4em;
    background: var(--surface-raised);
    color: var(--yellow);
    border: 1px solid var(--line);
    font: inherit;
    font-size: 0.88em;
}

pre {
    max-width: 100%;
    margin: 1.8em 0;
    padding: 20px;
    overflow: auto;
    background: #06090b;
    color: #d9e4e7;
    border: 1px solid var(--line);
    border-left: 3px solid var(--magenta);
    line-height: 1.55;
}

pre code { padding: 0; background: none; border: 0; color: inherit; }
blockquote { margin: 1.8em 0; padding: 2px 0 2px 20px; color: #aebbc0; border-left: 3px solid var(--yellow); }
img { max-width: 100%; height: auto; border: 1px solid var(--line-bright); }
audio { width: min(100%, 560px); }

.child-panel { margin-top: 18px; }
.directory-list,
.module-list { margin: 0; padding: 0; list-style: none; }
.directory-list li + li,
.module-list li + li { border-top: 1px solid var(--line); }

.directory-list a {
    display: grid;
    grid-template-columns: 2.6rem 1.2rem 1fr auto;
    gap: 10px;
    align-items: center;
    min-height: 50px;
    padding: 7px 14px;
    color: var(--text);
    text-decoration: none;
}

.directory-list a:hover,
.module-list a:hover { background: rgb(86 212 221 / 8%); color: #fff; }
.directory-index,
.module-number { color: var(--muted); font-size: 0.72rem; }
.directory-icon { color: var(--cyan); }
.directory-arrow { color: var(--line-bright); }

.status-bar {
    min-height: 30px;
    gap: 12px;
    padding-right: 12px;
    background: #121a1f;
    color: var(--muted);
    border-top: 1px solid var(--line-bright);
    font-size: 0.65rem;
}

.status-bar .mode {
    align-self: stretch;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--cyan);
    color: var(--bg);
    font-weight: 800;
}
.status-spacer { flex: 1; }

/* Homepage */
.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
    gap: 18px;
}

.hero-panel { min-height: 500px; }
.hero-content { display: flex; min-height: 450px; flex-direction: column; justify-content: center; }
.hero-content h1 { max-width: none; color: #fff; text-transform: uppercase; }
.title-bracket { color: var(--cyan); font-weight: 300; }
.hero-copy { margin-top: 30px; color: #a7b5bb; font-size: clamp(0.95rem, 2vw, 1.1rem); }
.hero-hint { margin: auto 0 0; padding-top: 50px; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; }

.module-list a {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-height: 82px;
    padding: 14px 16px;
    color: var(--text);
    text-decoration: none;
}

.module-copy { min-width: 0; }
.module-copy strong { display: block; overflow: hidden; color: #e8f0f2; font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.module-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 0.64rem; text-overflow: ellipsis; white-space: nowrap; }
.module-state { color: var(--green); font-size: 0.58rem; }

.activity-panel { grid-column: 1 / -1; }
.log-lines { padding: 12px 16px; font-size: 0.7rem; }
.log-lines p { display: grid; grid-template-columns: 5.5rem 1.8rem 1fr auto; gap: 10px; margin: 4px 0; }
.log-lines time { color: var(--muted); }
.log-ok { color: var(--green); }
.log-wait { color: var(--yellow); }

/* Calculator */
.calculator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
}

.tool-header { padding-bottom: 36px; }
.tool-header h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.tool-header > p:last-child { max-width: 66ch; margin: 20px 0 0; color: var(--muted); }
.calculator-form { padding: 0 clamp(18px, 5vw, 64px) clamp(28px, 5vw, 58px); }

.calculator-form fieldset { margin: 0; padding: 0; border: 0; border-top: 1px solid var(--line-bright); }
.calculator-form legend { padding: 0 12px 0 0; color: var(--cyan); font-size: 0.67rem; letter-spacing: 0.08em; }

.field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 0.55fr);
    gap: 24px;
    align-items: center;
    padding: 25px 0;
    border-bottom: 1px dashed var(--line);
}

.field-copy label { color: #eaf2f4; font-size: 0.83rem; font-weight: 700; text-transform: uppercase; }
.field-index { margin-right: 9px; color: var(--cyan); }
.field-copy p { margin: 5px 0 0 31px; color: var(--muted); font-size: 0.7rem; }
.presets { display: flex; gap: 7px; margin: 10px 0 0 31px; }

button,
input { font: inherit; }

.presets button {
    padding: 3px 8px;
    background: transparent;
    color: var(--cyan);
    border: 1px solid var(--line-bright);
    cursor: pointer;
    font-size: 0.62rem;
}
.presets button:hover { background: var(--cyan); color: var(--bg); }

.input-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    background: #070b0e;
    border: 1px solid var(--line-bright);
}

.input-shell:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.input-shell input {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    color: #fff;
    border: 0;
    outline: 0;
    font-size: 1rem;
    font-weight: 700;
}
.input-shell > span { display: flex; align-items: center; padding: 0 10px; background: var(--surface-raised); color: var(--muted); border-left: 1px solid var(--line); font-size: 0.63rem; }

.result-block {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: center;
    margin-top: 30px;
    padding: 20px;
    background: var(--cyan-dim);
    border: 1px solid var(--cyan);
}

.result-label { color: var(--muted); font-size: 0.67rem; }
.result-label > span:first-child { display: block; margin-bottom: 7px; color: var(--cyan); }
.result-value { display: flex; align-items: baseline; gap: 10px; }
.result-value output { color: #fff; font-size: clamp(2.4rem, 7vw, 4.3rem); font-weight: 800; line-height: 1; letter-spacing: -0.06em; }
.result-value span { color: var(--cyan); font-size: 0.75rem; }

.telemetry-panel { align-self: start; }
.reticle {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 42px auto;
    background:
        linear-gradient(transparent calc(50% - .5px), var(--line-bright) 50%, transparent calc(50% + .5px)),
        linear-gradient(90deg, transparent calc(50% - .5px), var(--line-bright) 50%, transparent calc(50% + .5px));
    border: 1px solid var(--line-bright);
    border-radius: 50%;
}
.reticle::before,
.reticle::after,
.reticle span { content: ""; position: absolute; inset: 50%; border: 1px solid var(--cyan); border-radius: 50%; transform: translate(-50%, -50%); }
.reticle::before { width: 74px; height: 74px; opacity: 0.55; }
.reticle::after { width: 8px; height: 8px; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.reticle span { width: 120px; height: 120px; border-color: var(--line); }

.telemetry-list { margin: 0; border-top: 1px solid var(--line); }
.telemetry-list div { display: flex; justify-content: space-between; gap: 15px; padding: 12px; border-bottom: 1px solid var(--line); font-size: 0.61rem; }
.telemetry-list dt { color: var(--muted); }
.telemetry-list dd { margin: 0; color: var(--text); }

@media (max-width: 800px) {
    .home-grid,
    .calculator-layout { grid-template-columns: 1fr; }
    .hero-panel { min-height: 420px; }
    .hero-content { min-height: 370px; }
    .telemetry-panel { display: none; }
}

@media (max-width: 560px) {
    body { padding: 0; }
    .terminal-shell { min-height: 100vh; border-width: 0; }
    .title-meta > span:first-child,
    .status-wide { display: none; }
    .screen { padding: 10px; }
    .panel-heading { font-size: 0.58rem; }
    .document,
    .hero-content,
    .tool-header { padding: 26px 20px; }
    .field-row { grid-template-columns: 1fr; gap: 14px; }
    .calculator-form { padding-right: 20px; padding-left: 20px; }
    .result-block { grid-template-columns: 1fr; }
    .result-value { justify-content: space-between; }
    .module-list a { grid-template-columns: 1.5rem minmax(0, 1fr); }
    .module-state { display: none; }
    .log-lines p { grid-template-columns: 4.7rem 1.4rem 1fr; }
    .log-lines .cursor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .cursor { animation: none; }
}
