:root {
    color-scheme: dark;
    --bg: #070b0d;
    --panel: #0d1316;
    --panel-2: #111a1e;
    --line: #223039;
    --text: #d8e1e5;
    --muted: #7d929d;
    --green: #68f6a4;
    --cyan: #64d9ef;
    --amber: #ffc96b;
    --red: #ff6b78;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 0%, rgba(37, 115, 89, 0.12), transparent 34rem),
        radial-gradient(circle at 90% 20%, rgba(54, 132, 157, 0.1), transparent 30rem),
        var(--bg);
}

a {
    color: var(--cyan);
}

code,
pre,
input,
button {
    font: inherit;
}

.shell,
.help-shell {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
}

.shell {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    padding: 42px 0 24px;
}

.topbar,
.help-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 26px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 7px;
    font-size: clamp(2.4rem, 7vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: -0.075em;
}

.cursor-mark {
    color: var(--green);
    animation: blink 1.1s step-end infinite;
}

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

.tagline {
    margin-bottom: 0;
    color: var(--muted);
    font-size: clamp(0.8rem, 2vw, 1rem);
}

.actions {
    display: flex;
    gap: 10px;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-2);
    cursor: pointer;
    text-decoration: none;
}

.button:hover,
.button:focus-visible {
    border-color: var(--cyan);
    outline: none;
}

.button.danger {
    color: #ff98a2;
}

.language-button {
    min-width: 48px;
    color: var(--cyan);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.terminal {
    display: flex;
    min-height: 520px;
    flex: 1;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(13, 19, 22, 0.96);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.terminal-head {
    display: flex;
    height: 48px;
    flex: 0 0 48px;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    background: #11181c;
}

.dot {
    width: 11px;
    height: 11px;
    margin-right: 8px;
    border-radius: 50%;
}

.dot.red { background: #ff605c; }
.dot.amber { background: #ffbd44; }
.dot.green { background: #00ca4e; }

.terminal-title {
    margin: auto;
    transform: translateX(-27px);
    color: #60727b;
    font-size: 0.72rem;
}

.terminal-body {
    padding: clamp(18px, 4vw, 34px);
    overflow-wrap: anywhere;
}

.welcome {
    margin-bottom: 26px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

.welcome code { color: var(--green); }
.history-entry { margin-bottom: 19px; }

.history-line,
.prompt-row {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 13px;
    line-height: 1.6;
}

.history-line.output { color: var(--green); }
.history-line.error { color: var(--red); }

.history-value {
    margin: 0;
    white-space: pre-wrap;
}

.plot-panel {
    width: min(760px, calc(100% - 75px));
    margin: 9px 0 0 75px;
    overflow: hidden;
    border: 1px solid #1d3038;
    border-radius: 9px;
    background: #091013;
}

.plot-svg {
    display: block;
    width: 100%;
    height: auto;
    min-height: 190px;
}

.plot-grid {
    stroke: #1b2b32;
    stroke-width: 1;
}

.plot-axis {
    stroke: #53666f;
    stroke-width: 1.2;
}

.plot-curve {
    fill: none;
    stroke: var(--green);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.2;
    vector-effect: non-scaling-stroke;
}

.plot-label {
    fill: var(--muted);
    font-size: 11px;
}

.plot-error {
    display: block;
    padding: 16px;
    color: var(--red);
}

.prompt {
    color: var(--cyan);
    font-weight: 700;
    white-space: nowrap;
}

.output .prompt { color: var(--green); }
.error .prompt { color: var(--red); }

.input-stack {
    position: relative;
    min-width: 0;
}

#expression {
    width: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    caret-color: var(--green);
    line-height: 1.6;
}

#expression::placeholder { color: #3e5059; }

.signature-hint {
    display: block;
    min-height: 1.35rem;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.input-assist {
    display: flex;
    min-height: 1.25rem;
    align-items: center;
    gap: 10px;
    color: #53666f;
    font-size: 0.66rem;
}

.input-help-button {
    padding: 1px 6px;
    border: 1px solid #2a3b43;
    border-radius: 4px;
    color: var(--cyan);
    background: transparent;
    cursor: pointer;
}

.input-help-button:hover,
.input-help-button:focus-visible {
    border-color: var(--cyan);
    outline: none;
}

.autocomplete {
    position: absolute;
    z-index: 10;
    top: calc(100% + 6px);
    left: 0;
    width: min(560px, 100%);
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #2b414b;
    border-radius: 9px;
    background: #10191d;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.suggestion {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    padding: 9px 12px;
    border: 0;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.suggestion:hover,
.suggestion.selected { background: #18272d; }

.suggestion-name {
    overflow: hidden;
    color: var(--green);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-category {
    color: var(--muted);
    font-size: 0.68rem;
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-top: 16px;
    color: #52636b;
    font-size: 0.7rem;
}

.dev-info {
    position: relative;
}

.dev-badge {
    padding: 2px 5px;
    border: 1px solid #4a4127;
    border-radius: 4px;
    color: var(--amber);
    background: transparent;
    cursor: help;
    text-decoration: none;
}

.dev-tooltip {
    position: absolute;
    z-index: 20;
    right: 0;
    bottom: calc(100% + 9px);
    width: min(370px, calc(100vw - 32px));
    padding: 10px 12px;
    border: 1px solid #4a4127;
    border-radius: 7px;
    opacity: 0;
    color: var(--text);
    background: #141710;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    font-size: 0.72rem;
    line-height: 1.45;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.dev-info:hover .dev-tooltip,
.dev-info:focus-within .dev-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.help-shell { padding: 46px 0 80px; }

.help-header {
    align-items: center;
    margin-bottom: 36px;
}

.help-header h1 { font-size: clamp(2.2rem, 7vw, 4rem); }

.help-card {
    margin-bottom: 18px;
    padding: clamp(22px, 4vw, 34px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(13, 19, 22, 0.86);
}

.help-card h2 {
    margin-bottom: 22px;
    color: var(--green);
    font-size: 1rem;
    letter-spacing: 0.04em;
}

.anchored-card {
    scroll-margin-top: 18px;
}

.contents-table-wrap {
    overflow-x: auto;
    border: 1px solid #1d3038;
    border-radius: 8px;
}

.contents-table {
    width: 100%;
    border-collapse: collapse;
    background: #091013;
    text-align: left;
}

.contents-table th,
.contents-table td {
    padding: 11px 13px;
    border-bottom: 1px solid #1d3038;
    vertical-align: top;
    line-height: 1.45;
}

.contents-table th {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.contents-table tr:last-child td {
    border-bottom: 0;
}

.contents-table code {
    color: var(--green);
    white-space: nowrap;
}

.contents-table a {
    color: var(--cyan);
    text-decoration: none;
}

.contents-table a:hover,
.contents-table a:focus-visible {
    text-decoration: underline;
}

.category-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.category-heading h2 {
    margin-bottom: 7px;
}

.category-heading p {
    margin-bottom: 12px;
}

.prefix-badge {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 5px;
    color: var(--green);
    background: #102128;
}

.help-card p {
    color: #aab9bf;
    line-height: 1.7;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

pre {
    margin: 0;
    padding: 18px;
    overflow-x: auto;
    border: 1px solid #1d3038;
    border-radius: 8px;
    color: var(--cyan);
    background: #091013;
    line-height: 1.65;
}

.constant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.constant-list code,
.function-item > code {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 5px;
    color: var(--cyan);
    background: #102128;
}

.muted,
.function-item small { color: var(--muted) !important; }

.function-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 32px;
}

.function-item {
    padding: 18px 0;
    border-top: 1px solid #1c2930;
}

.function-item p {
    margin: 10px 0 5px;
    font-size: 0.87rem;
}

.function-item small {
    display: block;
    margin-top: 5px;
    font-size: 0.72rem;
}
.safety-card { border-color: #3a3423; }
.safety-card h2 { color: var(--amber); }

@media (max-width: 700px) {
    .shell,
    .help-shell { width: min(100% - 24px, 1120px); }
    .shell { padding-top: 24px; }

    .topbar,
    .help-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .actions,
    .actions .button {
        flex: 1;
        width: 100%;
    }

    .terminal { min-height: 65vh; }
    .terminal-body { padding: 18px 14px 28px; }

    .history-line,
    .prompt-row {
        grid-template-columns: 51px minmax(0, 1fr);
        gap: 7px;
        font-size: 0.83rem;
    }

    .plot-panel {
        width: calc(100% - 58px);
        margin-left: 58px;
    }

    .example-grid,
    .function-list { grid-template-columns: 1fr; }
    .input-assist { align-items: flex-start; flex-direction: column; gap: 4px; }
    footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .cursor-mark { animation: none; }
}
