:root {
    color-scheme: dark;
    --bg: #05070a;
    --panel: rgba(9, 13, 18, 0.88);
    --panel-solid: #0b1016;
    --panel-soft: rgba(18, 25, 34, 0.72);
    --border: rgba(112, 128, 144, 0.28);
    --border-strong: rgba(137, 162, 181, 0.42);
    --text: #e9eef4;
    --muted: #8f9ba8;
    --dim: #5d6976;
    --green: #5ef38c;
    --cyan: #69d7ff;
    --amber: #ffc66d;
    --red: #ff6b6b;
    --shadow: rgba(0, 0, 0, 0.48);
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 22% 18%, rgba(105, 215, 255, 0.12), transparent 28%),
        radial-gradient(circle at 82% 78%, rgba(94, 243, 140, 0.08), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.55;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 78%);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.025),
        rgba(255, 255, 255, 0.025) 1px,
        transparent 1px,
        transparent 8px
    );
    mix-blend-mode: screen;
    opacity: 0.18;
}

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

a:hover {
    text-decoration: underline;
}

button,
input {
    font: inherit;
}

#fx {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

.shell {
    width: min(100% - 32px, 1180px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 0 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.identity {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.identity:hover {
    text-decoration: none;
}

.identity strong,
.identity small {
    display: block;
}

.identity strong {
    font-size: 1rem;
    line-height: 1.1;
}

.identity small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.82rem;
}

.avatar {
    width: 46px;
    height: 46px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--panel-solid);
}

.top-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.top-links a,
.icon-button,
.command-pills button {
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(13, 19, 26, 0.72);
    color: var(--text);
    cursor: pointer;
}

.top-links a {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.86rem;
}

.top-links a:hover,
.icon-button:hover,
.command-pills button:hover {
    border-color: var(--border-strong);
    background: rgba(26, 37, 49, 0.78);
    text-decoration: none;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 16px;
    align-items: stretch;
}

.terminal,
.side-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 24px 80px var(--shadow);
    backdrop-filter: blur(18px);
}

.terminal {
    min-height: calc(100vh - 126px);
    overflow: hidden;
}

.terminal-bar {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(24, 32, 42, 0.94), rgba(12, 17, 24, 0.94));
}

.window-buttons {
    display: flex;
    gap: 7px;
}

.window-buttons span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.window-buttons span:nth-child(1) { background: var(--red); }
.window-buttons span:nth-child(2) { background: var(--amber); }
.window-buttons span:nth-child(3) { background: var(--green); }

.terminal-title {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.78rem;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 16px rgba(94, 243, 140, 0.9);
    animation: pulse 1.8s ease-in-out infinite;
}

.icon-button {
    padding: 5px 9px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
}

.terminal-screen {
    height: calc(100vh - 172px);
    min-height: 560px;
    padding: 20px;
    overflow: auto;
    font-family: var(--mono);
    font-size: 0.92rem;
    line-height: 1.58;
    scrollbar-color: rgba(105, 215, 255, 0.35) transparent;
}

.terminal-screen:focus-within {
    box-shadow: inset 0 0 0 1px rgba(105, 215, 255, 0.14);
}

.line {
    min-height: 1.4em;
    margin: 2px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.command-line {
    color: var(--text);
}

.prompt {
    color: var(--green);
    white-space: nowrap;
}

.dim {
    color: var(--dim);
}

.muted {
    color: var(--muted);
}

.token {
    color: var(--amber);
}

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

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

.red {
    color: var(--red);
}

.input-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

#terminal-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    caret-color: var(--green);
    font-family: var(--mono);
    font-size: inherit;
}

.side-panel {
    padding: 14px;
}

.panel-block {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.panel-block:first-child {
    padding-top: 0;
}

.panel-block:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

h2 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.status-list {
    display: grid;
    gap: 8px;
    margin: 0;
    font-family: var(--mono);
    font-size: 0.82rem;
}

.status-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.status-list dt,
.mini-repos li {
    color: var(--muted);
}

.status-list dd {
    margin: 0;
    color: var(--text);
}

.command-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.command-pills button {
    padding: 5px 9px;
    color: var(--cyan);
    font-family: var(--mono);
    font-size: 0.78rem;
}

.mini-repos {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.86rem;
}

.mini-repos a {
    color: var(--text);
}

.mini-repos span {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
}

.terminal-table {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 2px 14px;
}

.terminal-table span:nth-child(odd) {
    color: var(--amber);
}

.repo-output {
    display: grid;
    gap: 6px;
}

.repo-output a {
    color: var(--cyan);
}

.lights-board {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(2, 6, 10, 0.42);
    color: var(--muted);
}

.lights-cell {
    width: 1.7em;
    height: 1.7em;
    min-height: 0;
    padding: 0;
    border: 1px solid rgba(112, 128, 144, 0.22);
    border-radius: 4px;
    background: rgba(12, 18, 24, 0.92);
    color: var(--dim);
    font-family: var(--mono);
    line-height: 1;
    vertical-align: middle;
}

.lights-cell:hover {
    border-color: var(--cyan);
    color: var(--text);
}

.lights-cell.on {
    border-color: rgba(94, 243, 140, 0.58);
    background: rgba(94, 243, 140, 0.12);
    color: var(--green);
    box-shadow: 0 0 16px rgba(94, 243, 140, 0.22);
}

.copy-flash {
    color: var(--green);
}

.not-found-shell {
    display: grid;
    place-items: center;
}

.not-found-terminal {
    width: min(100%, 720px);
    min-height: 0;
}

.not-found-screen {
    height: auto;
    min-height: 300px;
}

.home-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.42;
        transform: scale(0.76);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    #fx {
        display: none;
    }
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .terminal {
        min-height: 650px;
    }

    .terminal-screen {
        height: 600px;
        min-height: 0;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 14px;
    }

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

    .top-links {
        width: 100%;
    }

    .top-links a {
        flex: 1 1 auto;
        justify-content: center;
    }

    .terminal-bar {
        grid-template-columns: 58px 1fr auto;
        gap: 8px;
    }

    .terminal-title {
        justify-content: flex-start;
    }

    .terminal-screen {
        height: 64vh;
        padding: 14px;
        font-size: 0.84rem;
    }

    .terminal-table {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .input-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}
