:root {
    color-scheme: dark;
    --bg: #0b1120;
    --panel: #111b2e;
    --panel-raised: #17243a;
    --border: #263650;
    --text: #e8edf5;
    --muted: #9aa9bd;
    --accent: #c9a96e;
    --success: #64d6a0;
    --danger: #ff8c8c;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(ellipse at 15% 0%, #14223a 0, transparent 38%), var(--bg);
    color: var(--text);
    font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.shell { max-width: 1440px; margin: 0 auto; padding: 2rem; }
.brand { color: var(--text); font-size: 1.35rem; font-weight: 750; letter-spacing: .02em; text-decoration: none; }
.brand span { color: var(--accent); }
.muted, .field-help { color: var(--muted); }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 700; letter-spacing: .16em; margin: 0 0 .35rem; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 2.7rem); line-height: 1.12; margin-bottom: .65rem; }
h2 { font-size: 1.15rem; margin-bottom: 0; }
.login-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; margin: 10vh auto; max-width: 420px; padding: 2.5rem; box-shadow: 0 24px 70px #0005; }
.login-panel h1 { margin-top: 2rem; font-size: 1.8rem; }
.login-panel form { display: grid; gap: .6rem; margin-top: 2rem; }
.topbar, .topbar-actions, .intro, .panel-heading, .form-actions { align-items: center; display: flex; justify-content: space-between; gap: 1rem; }
.topbar { border-bottom: 1px solid var(--border); padding-bottom: 1.25rem; }
.topbar-actions { justify-content: flex-end; }
.private-badge, .mode-badge, .count { border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .75rem; padding: .2rem .7rem; }
.intro { margin: 2.5rem 0 1.4rem; }
.intro p:last-child { margin-bottom: 0; }
.notice { background: #2a241b; border: 1px solid #6c5838; border-radius: 10px; color: #f0d7a8; margin-bottom: 1.5rem; padding: .9rem 1rem; }
.layout { display: grid; grid-template-columns: minmax(230px, .75fr) minmax(0, 2.25fr); gap: 1.25rem; align-items: start; }
.panel { background: color-mix(in srgb, var(--panel) 95%, transparent); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; }
.panel-heading { margin-bottom: 1.25rem; }
.scripts-list, .runs-list { display: grid; gap: .75rem; }
.script-item { border: 1px solid var(--border); border-radius: 10px; padding: .9rem; }
.script-item.active { border-color: var(--accent); }
.script-select { background: none; border: 0; color: var(--text); display: block; font-weight: 650; padding: 0; text-align: left; width: 100%; }
.script-meta { color: var(--muted); font-size: .8rem; margin-top: .35rem; }
.status { color: var(--muted); font-size: .78rem; margin-top: .45rem; }
.status.running { color: var(--success); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.field { display: grid; gap: .4rem; margin-bottom: 1rem; min-width: 0; }
.field.wide { grid-column: span 3; }
label { color: #cbd5e1; font-size: .88rem; font-weight: 600; }
input, select, textarea {
    background: #0b1424;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    min-height: 44px;
    padding: .65rem .75rem;
    width: 100%;
}
textarea { font: 13px/1.6 Consolas, "SFMono-Regular", monospace; min-height: 250px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid #c9a96e33; }
.field-help { font-size: .78rem; margin: -.15rem 0 .25rem; }
.form-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: .25rem; }
.button { border: 1px solid transparent; border-radius: 8px; font-weight: 650; min-height: 42px; padding: .55rem 1rem; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button.primary { background: var(--accent); color: #101725; }
.button.secondary { background: #20304a; border-color: #344967; color: var(--text); }
.button.quiet { background: transparent; border-color: var(--border); color: var(--muted); }
.button.danger { color: var(--danger); }
.button.full { margin-top: .8rem; width: 100%; }
.message { color: var(--muted); min-height: 1.5rem; margin: .4rem 0 0; }
.message.error { color: var(--danger); }
.message.success { color: var(--success); }
.runs-panel { margin-top: 1.25rem; }
.run-item { border-top: 1px solid var(--border); padding: .85rem 0; }
.run-topline { align-items: baseline; display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; }
.run-state.success { color: var(--success); }
.run-state.error { color: var(--danger); }
.run-detail { color: var(--muted); font-size: .84rem; margin: .4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.footer-note { color: var(--muted); font-size: .8rem; margin: 1.5rem 0; text-align: center; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .scripts-panel { order: 2; }
    .editor-panel { order: 1; }
}
@media (max-width: 600px) {
    .shell { padding: 1rem; }
    .login-panel { margin: 6vh auto; padding: 1.5rem; }
    .intro { align-items: flex-start; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .field.wide { grid-column: span 2; }
    .panel { padding: 1rem; }
    .form-actions .button { flex: 1 1 42%; }
}
