:root {
    --ink: #17141f;
    --muted: #625d69;
    --paper: #f8f5f0;
    --card: #fffdf9;
    --ruby: #dc2b3a;
    --ruby-dark: #9e1625;
    --rust: #c8582c;
    --line: #ddd4c9;
    --code: #211d29;
    --code-bar: #302a39;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 92% 5%, rgba(220, 43, 58, 0.13), transparent 27rem),
        radial-gradient(circle at 5% 34%, rgba(200, 88, 44, 0.1), transparent 25rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: inherit;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--rust);
    outline-offset: 4px;
}

button,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.shell {
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
}

.skip-link {
    position: absolute;
    top: -5rem;
    left: 1rem;
    z-index: 1200;
    padding: 0.65rem 1rem;
    color: white;
    background: var(--ink);
    border-radius: 0.35rem;
}

.skip-link:focus {
    top: 1rem;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    min-height: 5rem;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none;
}

.mark {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    color: white;
    background: var(--ruby);
    border-radius: 0.55rem 0.55rem 0.55rem 0.15rem;
    box-shadow: 0.22rem 0.22rem 0 var(--ink);
}

.mark svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
    font-weight: 700;
}

.nav-links a {
    text-decoration: none;
}

.nav-links a:hover {
    color: var(--ruby-dark);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(20rem, 0.8fr);
    gap: clamp(2rem, 7vw, 6rem);
    align-items: center;
    min-height: 31rem;
    padding-block: 3.5rem 6rem;
}

.eyebrow {
    margin: 0 0 1rem;
    color: var(--ruby-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

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

h1 {
    max-width: 10ch;
    margin-bottom: 1.5rem;
    color: var(--ink);
    font-size: clamp(3.5rem, 9vw, 7rem);
    font-weight: 800;
    line-height: 0.91;
    letter-spacing: -0.075em;
}

h1 span {
    color: var(--ruby);
}

.lede {
    max-width: 41rem;
    margin-bottom: 2rem;
    color: #4d4854;
    font-size: clamp(1.08rem, 2vw, 1.3rem);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.button,
.header-buttons button,
.button-group button,
#clearButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: 0.7rem 1.1rem;
    border: 2px solid var(--ink);
    border-radius: 0.55rem;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover,
.header-buttons button:hover,
.button-group button:hover,
#clearButton:hover {
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--ink);
}

.button-primary,
#runButton {
    color: white;
    background: var(--ink);
}

.button-secondary,
.info-btn,
#resetButton,
#clearButton {
    color: var(--ink);
    background: rgba(255, 253, 249, 0.78);
}

.release-notes-btn,
#saveButton {
    color: white;
    background: var(--ruby);
}

#saveButton:disabled {
    color: #ddd7e3;
    background: #746e7c;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

.terminal {
    overflow: hidden;
    color: #f8f3ed;
    background: var(--code);
    border: 2px solid var(--ink);
    border-radius: 0.8rem;
    box-shadow: 0.7rem 0.7rem 0 var(--ruby);
    transform: rotate(1.5deg);
}

.terminal-bar {
    display: flex;
    gap: 0.4rem;
    padding: 0.8rem 1rem;
    background: var(--code-bar);
}

.terminal-bar span {
    width: 0.7rem;
    height: 0.7rem;
    background: #8f879a;
    border-radius: 50%;
}

.terminal-bar span:first-child {
    background: var(--ruby);
}

.terminal pre {
    margin: 0;
    padding: 1.5rem;
    overflow-x: auto;
    font: 0.88rem/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.terminal .prompt {
    color: #ff7f68;
}

.terminal .output {
    color: #c9c1d4;
}

.playground-section {
    padding-block: 5.5rem 7rem;
}

.section-heading {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(18rem, 1.2fr);
    gap: 2rem;
    align-items: end;
    margin-bottom: 3rem;
}

h2 {
    margin-bottom: 0;
    color: var(--ink);
    font-size: clamp(2.2rem, 5vw, 4.25rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.055em;
}

.section-heading > p {
    max-width: 42rem;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.container {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(21rem, 0.88fr);
    max-width: none;
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--ink);
    border-radius: 0.85rem;
    box-shadow: 0.8rem 0.8rem 0 var(--ruby);
}

.header {
    grid-column: 1 / -1;
    padding: 1.35rem 1.5rem;
    background: var(--card);
    border-bottom: 2px solid var(--ink);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-left h3 {
    margin: 0 0 0.2rem;
    color: var(--ink);
    font-size: 1.6rem;
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.workbench-label {
    margin: 0 0 0.2rem;
    color: var(--ruby-dark);
    font: 800 0.68rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.subtitle {
    margin-top: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.header-buttons {
    display: flex;
    flex: 0 0 auto;
    gap: 0.65rem;
}

.header-buttons button {
    min-height: 2.65rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
}

.editor-panel {
    display: flex;
    min-width: 0;
    padding: 1.5rem;
    background: var(--card);
    flex-direction: column;
}

.editor-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

label,
.console-title {
    display: block;
    margin: 0;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

#presetSelect {
    min-width: 13.5rem;
    padding: 0.55rem 2rem 0.55rem 0.75rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    cursor: pointer;
    font-size: 0.78rem;
    outline: none;
}

#presetSelect:hover {
    border-color: var(--ruby);
}

#codeInput {
    width: 100%;
    height: 25rem;
    min-height: 18rem;
    padding: 1.25rem;
    resize: vertical;
    color: #f8f3ed;
    background: var(--code);
    border: 0;
    border-radius: 0.65rem;
    outline: 2px solid var(--ink);
    outline-offset: -2px;
    font: 0.86rem/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 2;
}

#codeInput:focus {
    border: 0;
    outline-color: var(--ruby);
}

#codeInput::placeholder {
    color: #938b9e;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1rem;
}

.button-group button {
    min-height: 2.8rem;
    padding: 0.6rem 1rem;
    font-size: 0.84rem;
}

.console-panel {
    min-width: 0;
    padding: 1.5rem;
    background: var(--code);
    border-top: 0;
    border-left: 2px solid var(--ink);
}

.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
    color: #f8f3ed;
}

.console-title {
    color: #f8f3ed;
}

#clearButton {
    min-height: 2.15rem;
    padding: 0.35rem 0.65rem;
    color: #f8f3ed;
    background: #3b3545;
    border-color: #5c5468;
    font-size: 0.72rem;
}

#clearButton:hover {
    background: #4b4456;
    box-shadow: 3px 3px 0 #09070c;
}

#console {
    min-height: 25rem;
    max-height: 31rem;
    padding: 1.1rem;
    overflow: auto;
    color: #f8f3ed;
    background: #151219;
    border: 1px solid #4a4452;
    border-radius: 0.6rem;
    font: 0.78rem/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    scrollbar-color: #51495d #151219;
}

.console-system,
.console-output,
.console-error,
.console-prompt {
    margin: 0.2rem 0;
    white-space: pre;
    overflow-wrap: normal;
}

.console-system {
    color: #ffac9d;
    font-weight: 600;
}

.console-output {
    color: #d8d0e2;
}

.console-error {
    color: #ff8c78;
    font-weight: 600;
}

.console-prompt {
    color: #938b9e;
    opacity: 1;
}

#console::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#console::-webkit-scrollbar-track {
    background: #151219;
}

#console::-webkit-scrollbar-thumb {
    background: #51495d;
    border-radius: 4px;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    max-width: none;
    margin: 0 auto;
    padding: 2rem 0 3rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.85rem;
    text-align: left;
}

.footer p {
    margin: 0;
}

.footer a {
    color: var(--ink);
    font-weight: 800;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22rem;
}

.footer a:hover {
    color: var(--ruby-dark);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    width: 100%;
    height: 100%;
    padding: 2rem 1rem;
    overflow-y: auto;
    background: rgba(23, 20, 31, 0.76);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: min(800px, 100%);
    max-width: 800px;
    max-height: none;
    margin: 2rem auto;
    padding: clamp(1.4rem, 4vw, 2.2rem);
    overflow: visible;
    color: var(--ink);
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0.85rem;
    box-shadow: 0.8rem 0.8rem 0 var(--ruby);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
}

.modal-header .eyebrow {
    margin-bottom: 0.4rem;
}

.modal-header h2 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.close-btn {
    display: grid;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    place-items: center;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--ink);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.close-btn:hover {
    color: white;
    background: var(--ruby);
}

.release-item {
    margin-bottom: 1rem;
    padding: 1.25rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 0.35rem solid var(--ruby);
    border-radius: 0.55rem;
}

.release-item:last-child {
    margin-bottom: 0;
}

.release-title,
.release-title a {
    color: var(--ink);
}

.release-title {
    margin: 0 0 0.45rem;
    font-size: 1.15rem;
    font-weight: 800;
}

.release-title a {
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2rem;
}

.release-title a:hover,
.release-link:hover {
    color: var(--ruby-dark);
}

.release-tag {
    margin-bottom: 0.25rem;
    color: var(--ruby-dark);
    font: 700 0.76rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.release-date {
    margin-bottom: 0.8rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.release-body {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.release-link {
    display: inline-block;
    margin-top: 0.8rem;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 800;
    text-underline-offset: 0.2rem;
}

.loading,
.error {
    padding: 2rem;
    color: var(--muted);
    text-align: center;
}

.error {
    color: var(--ruby-dark);
}

@media (max-width: 820px) {
    .nav-links li:not(:last-child) {
        display: none;
    }

    .hero,
    .section-heading,
    .container {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
        padding-block: 3rem 5rem;
    }

    .terminal {
        transform: none;
    }

    .header {
        grid-column: 1;
    }

    .console-panel {
        border-top: 2px solid var(--ink);
        border-left: 0;
    }
}

@media (max-width: 620px) {
    .header-content {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .header-buttons {
        width: 100%;
    }

    .header-buttons button {
        flex: 1 1 0;
        width: auto;
    }

    .editor-panel,
    .console-panel {
        padding: 1rem;
    }

    .editor-controls {
        align-items: stretch;
        flex-direction: column;
    }

    #presetSelect {
        width: 100%;
    }

    #codeInput {
        width: 100%;
        height: 22rem;
        margin: 0;
    }

    .button-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 0;
    }

    #runButton {
        grid-column: 1 / -1;
    }

    #runButton,
    #saveButton,
    #resetButton {
        width: 100%;
    }

    #console {
        min-height: 18rem;
        margin: 0;
        border: 1px solid #4a4452;
        border-radius: 0.6rem;
    }

    .footer {
        align-items: flex-start;
        flex-direction: column;
        padding-inline: 0;
    }

    .modal {
        padding: 0.5rem;
    }

    .modal-content {
        width: calc(100% - 0.75rem);
        margin: 1rem auto;
        padding: 1.25rem;
    }
}

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

    .button,
    .header-buttons button,
    .button-group button,
    #clearButton {
        transition: none;
    }
}
