:root {
    color-scheme: dark;
    --bg: #0e0b07;
    --panel: #15110c;
    --panel-soft: #1b160f;
    --panel-strong: #211a12;
    --line: #2e2519;
    --line-soft: #241d14;
    --text: #f7efe4;
    --muted: #9d8f7e;
    --faint: #6e6254;
    --accent: #ff9f2f;
    --accent-strong: #ffb65f;
    --green: #55d36f;
    --danger: #ff7c7c;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4eee5;
    --panel: #f8f1e8;
    --panel-soft: #f1e9de;
    --panel-strong: #ffb45b;
    --line: #e4d9c8;
    --line-soft: #e7dccd;
    --text: #12100d;
    --muted: #756d63;
    --faint: #8b8378;
    --accent: #ff9f2f;
    --accent-strong: #d77d17;
    --green: #1f9b43;
    --danger: #a53232;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0, rgba(255, 159, 47, 0.08), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: "Space Grotesk", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

.op-page {
    min-height: 100vh;
    padding: 30px 22px;
}

.op-landing {
    display: grid;
    place-items: center;
}

.op-window {
    width: min(1180px, 100%);
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(18, 14, 9, 0.92);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
    overflow: hidden;
}

.op-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 64px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line-soft);
}

.op-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 0;
    text-decoration: none;
}

.op-brand img {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex: 0 0 auto;
}

.op-landing .op-brand img {
    width: 46px;
    height: 46px;
    border-radius: 12px;
}

.mascot-icon {
    animation: mascot-icon-bob 4s ease-in-out infinite;
}

.op-brand span span {
    color: var(--accent);
}

.op-topnav {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 0.84rem;
}

.op-topnav a {
    text-decoration: none;
}

.op-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    white-space: nowrap;
}

.op-status span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 16px rgba(85, 211, 111, 0.8);
}

.op-theme-toggle {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #0d0a07;
    color: var(--muted);
    overflow: hidden;
    cursor: pointer;
}

.op-theme-toggle span {
    display: inline-grid;
    place-items: center;
    min-width: 78px;
    height: 42px;
    border-radius: 0;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
}

.op-theme-toggle span:first-child {
    border-radius: 999px 0 0 999px;
    background: var(--accent);
    color: #15100a;
}

:root[data-theme="light"] .op-theme-toggle {
    background: #f8f1e8;
    border-color: #e2d6c5;
}

:root[data-theme="light"] .op-theme-toggle span:first-child {
    background: transparent;
    color: #5f574f;
}

:root[data-theme="light"] .op-theme-toggle span:last-child {
    border-radius: 0 999px 999px 0;
    background: #ffb45b;
    color: #fff8ed;
}

:root[data-theme="light"] .op-window,
:root[data-theme="light"] .auth-form,
:root[data-theme="light"] .chat-shell,
:root[data-theme="light"] .installer {
    background: #f8f1e8;
    box-shadow: none;
}

:root[data-theme="light"] body {
    background: var(--bg);
}

:root[data-theme="light"] .auth-form input,
:root[data-theme="light"] .chat-compose,
:root[data-theme="light"] .installer input:not([type="checkbox"]),
:root[data-theme="light"] .installer pre,
:root[data-theme="light"] .installer textarea {
    background: #fffaf2;
}

:root[data-theme="light"] .op-topbar {
    background: #f8f1e8;
}

:root[data-theme="light"] .op-eyebrow {
    color: #ffc476;
}

:root[data-theme="light"] .op-button-primary {
    border-color: #18100a;
    background: #18100a;
    color: #d49a48;
}

:root[data-theme="light"] .op-launch {
    border-color: #ffbd72;
    background: transparent;
    color: #f0a24c;
}

:root[data-theme="light"] .op-button:not(.op-button-primary) {
    border-color: #ded3c2;
    background: transparent;
    color: #5f574f;
}

:root[data-theme="light"] .op-terminal {
    border-color: #17120c;
    background: #050402;
    box-shadow: 0 34px 64px rgba(40, 32, 22, 0.28);
}

:root[data-theme="light"] .op-terminal-bar {
    border-bottom-color: #17120c;
    color: #726a5f;
}

:root[data-theme="light"] .op-terminal pre {
    color: #c7b8a4;
}

:root[data-theme="light"] .op-terminal code span {
    color: #c78b2f;
}

.op-launch,
.op-button,
.chat-new,
.chat-logout,
.chat-compose button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 18px;
    background: #100d09;
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.op-launch,
.op-button-primary,
.chat-compose button {
    border-color: rgba(255, 159, 47, 0.45);
    background: var(--accent);
    color: #1b1005;
}

.op-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(350px, 0.92fr);
    gap: 52px;
    align-items: center;
    min-height: 0;
    padding: 42px 50px 48px;
}

.op-copy {
    max-width: 720px;
}

.op-eyebrow {
    margin: 0 0 14px;
    color: var(--accent);
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.op-copy h1 {
    margin: 0;
    max-width: 660px;
    font-size: clamp(2.45rem, 4.4vw, 4.05rem);
    line-height: 0.96;
    letter-spacing: 0;
    overflow-wrap: normal;
    word-break: normal;
}

.op-copy > p:not(.op-eyebrow) {
    max-width: 560px;
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.55;
}

.op-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.op-button {
    min-height: 42px;
    padding: 0 18px;
}

.op-terminal {
    align-self: stretch;
    min-height: 300px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #0b0906;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.op-terminal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--faint);
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.op-window-dots {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.op-window-dots span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
}

.op-window-dots span:nth-child(1) {
    background: #ff5f57;
}

.op-window-dots span:nth-child(2) {
    background: #ffbd2e;
}

.op-window-dots span:nth-child(3) {
    background: #28c840;
}

.op-terminal pre {
    margin: 0;
    padding: 20px;
    color: #d7c8b3;
    white-space: pre-wrap;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.58;
}

.op-terminal code span {
    color: var(--accent);
}

.op-auth-page {
    display: grid;
    place-items: center;
}

.auth-form {
    width: min(100%, 340px);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    background: rgba(18, 14, 9, 0.95);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.38);
}

.auth-brand {
    margin-bottom: 22px;
}

.auth-form h1 {
    margin: 0 0 16px;
    font-size: 2rem;
    line-height: 1;
}

.auth-form label {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    color: var(--muted);
    font-weight: 750;
    font-size: 0.9rem;
}

.auth-form input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 12px;
    background: #0c0a07;
    color: var(--text);
}

.auth-form .op-button {
    width: 100%;
    min-height: 38px;
    margin-top: 18px;
}

.form-error {
    margin: 0 0 16px;
    color: var(--danger);
}

.op-chat-page {
    min-height: 100vh;
    padding: 22px;
    background: var(--bg);
    font-size: 0.82rem;
}

.chat-shell {
    position: relative;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - 44px);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(18, 14, 9, 0.95);
    overflow: hidden;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-right: 1px solid var(--line-soft);
    background: #100d09;
}

.chat-new {
    width: 100%;
    min-height: 34px;
    border-radius: 13px;
    background: var(--panel-strong);
    font-size: 0.76rem;
}

.chat-list {
    display: grid;
    gap: 5px;
}

.chat-list a {
    min-height: 32px;
    border-radius: 11px;
    padding: 8px 10px;
    color: var(--muted);
    font-size: 0.76rem;
    text-decoration: none;
}

.chat-list a.active,
.chat-list a:hover {
    background: var(--panel-strong);
    color: var(--text);
}

.chat-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    padding: 22px 22px 14px;
}

.chat-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.chat-head h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2.4vw, 2.15rem);
    line-height: 1;
}

.chat-empty {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    min-height: 420px;
    text-align: center;
}

.chat-empty img {
    width: 112px;
    height: 112px;
}

.mascot-animated {
    animation: mascot-bob 3.2s ease-in-out infinite;
    transform-origin: 50% 82%;
}

@keyframes mascot-bob {
    0%,
    100% {
        transform: translateY(0) rotate(-1deg);
    }

    50% {
        transform: translateY(-8px) rotate(1deg);
    }
}

@keyframes mascot-icon-bob {
    0%,
    100% {
        transform: translateY(0) rotate(-1deg);
    }

    50% {
        transform: translateY(-3px) rotate(1deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mascot-icon,
    .mascot-animated {
        animation: none;
    }
}

.chat-empty p {
    max-width: 390px;
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.chat-empty code {
    color: var(--accent-strong);
}

.chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 17px;
    padding: 7px;
    background: #0c0a07;
}

.chat-compose input {
    min-width: 0;
    min-height: 36px;
    border: 0;
    padding: 0 8px;
    background: transparent;
    color: var(--text);
    font-size: 0.78rem;
}

.chat-compose input::placeholder {
    color: var(--faint);
}

.chat-compose button:disabled,
.chat-compose input:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

.chat-logout {
    position: absolute;
    left: 18px;
    bottom: 18px;
    min-height: 32px;
    background: transparent;
    color: var(--muted);
    font-size: 0.76rem;
}

.installer {
    width: min(100% - 28px, 780px);
    margin: 24px auto;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(18, 14, 9, 0.95);
    font-size: 0.86rem;
}

.installer h1 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.45rem;
    line-height: 1.08;
}

.installer h2 {
    margin: 18px 0 6px;
    font-size: 0.95rem;
}

.installer p {
    color: var(--muted);
    line-height: 1.45;
    margin: 8px 0;
}

.installer a {
    color: var(--accent-strong);
}

.installer form,
.installer label {
    display: grid;
    gap: 6px;
}

.installer form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
}

.installer form h2,
.installer .checkbox,
.installer button {
    grid-column: 1 / -1;
}

.installer label {
    margin-top: 9px;
    color: var(--muted);
    font-weight: 650;
    font-size: 0.82rem;
}

.installer input:not([type="checkbox"]) {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 10px;
    background: #0c0a07;
    color: var(--text);
}

.installer .checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.installer button {
    width: fit-content;
    min-height: 36px;
    margin-top: 14px;
    border: 0;
    border-radius: 999px;
    padding: 0 15px;
    background: var(--accent);
    color: #1b1005;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.installer pre,
.installer textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    overflow: auto;
    background: #0c0a07;
    color: var(--text);
    font-size: 0.78rem;
}

.installer textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.errors {
    border: 1px solid rgba(255, 124, 124, 0.55);
    border-radius: 10px;
    background: rgba(255, 124, 124, 0.08);
    color: var(--danger);
}

.errors ul {
    margin: 0;
    padding: 10px 14px 10px 28px;
}

@media (max-width: 900px) {
    .op-page {
        padding: 18px;
    }

    .op-window {
        min-height: auto;
        border-radius: 24px;
    }

    .op-topbar {
        align-items: flex-start;
    }

    .op-topnav {
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .op-status,
    .op-topnav > a:not(.op-launch),
    .op-theme-toggle {
        display: none;
    }

    .op-hero,
    .chat-shell {
        grid-template-columns: 1fr;
    }

    .op-hero {
        gap: 34px;
        min-height: auto;
        padding: 46px 24px 28px;
    }

    .op-copy h1 {
        font-size: clamp(2.9rem, 14vw, 3.7rem);
    }

    .op-terminal {
        min-height: 280px;
    }

    .chat-shell {
        min-height: calc(100vh - 36px);
    }

    .chat-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line-soft);
    }

    .chat-list {
        display: none;
    }

    .chat-main {
        padding: 24px 18px 78px;
    }

    .chat-head {
        align-items: flex-start;
    }

    .chat-compose {
        grid-template-columns: 1fr;
    }

    .chat-logout {
        left: 22px;
        bottom: 20px;
    }
}

@media (max-width: 760px) {
    .installer form {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 901px) {
    .op-landing {
        min-height: 100vh;
    }

    .op-landing .op-window {
        height: auto;
        min-height: 0;
    }

    .op-landing .op-hero {
        min-height: 0;
    }
}

@media (max-width: 520px) {
    .op-page,
    .op-chat-page {
        padding: 12px;
    }

    .op-topbar {
        min-height: 68px;
        padding: 14px;
    }

    .op-brand {
        font-size: 1rem;
    }

    .op-brand img {
        width: 36px;
        height: 36px;
    }

    .op-launch {
        min-height: 36px;
        padding: 0 13px;
    }

    .op-hero {
        padding: 34px 20px 22px;
    }

    .op-copy > p:not(.op-eyebrow) {
        font-size: 1rem;
    }

    .op-button {
        width: 100%;
    }

    .op-terminal pre {
        padding: 18px;
        font-size: 0.82rem;
    }

    .auth-form {
        padding: 22px;
        border-radius: 22px;
    }

    .installer {
        margin: 18px auto;
        padding: 20px;
    }
}
