:root {
  --bg: #111316;
  --panel: #181b1f;
  --panel-2: #1f2328;
  --line: #2b3036;
  --text: #e6e8eb;
  --muted: #8b939c;
  --accent: #f2a93b;
  --accent-ink: #1a1203;
  --good: #46a758;
  --bad: #e5484d;
  --warn: #ffc53d;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
kbd { font: 12px var(--mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); }

/* ---------- controls ---------- */
button, .btn, select, input {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
}
button, .btn { cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { border-color: #3d444c; text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.ghost, a.ghost { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 5px 9px; border-radius: 6px; font-size: 13px; }
button.ghost:hover, a.ghost:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
button.danger:hover { color: var(--bad); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input::placeholder { color: #5f6770; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; letter-spacing: .02em; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.good { color: var(--good); border-color: #2b4a31; background: #15241a; }
.pill.bad { color: var(--bad); border-color: #4d2426; background: #261416; }
.pill.busy { color: var(--accent); border-color: #4a3818; background: #241c0e; }
.pill.dim { color: var(--muted); }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 12px var(--mono); }

/* ---------- centered card pages (join, login) ---------- */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.card h1 { font-size: 20px; margin: 18px 0 4px; letter-spacing: -.01em; }
.card p.sub { margin: 0 0 22px; color: var(--muted); }
.card .field { margin-bottom: 16px; }
.card input { width: 100%; padding: 10px 12px; }
.card button.primary { width: 100%; padding: 10px; margin-top: 4px; }
.code-input { font: 600 26px var(--mono) !important; letter-spacing: .4em; text-align: center; padding: 10px 0 10px .4em !important; }
.alert { border-radius: 8px; padding: 9px 12px; margin-bottom: 16px; font-size: 13px; background: #261416; border: 1px solid #4d2426; color: #ffb4b0; }
.alert.info { background: #1b2027; border-color: var(--line); color: var(--text); }

/* ---------- editor page ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; flex-wrap: wrap; }
.topbar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .spacer { flex: 1; }
#conn { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
#conn[data-state="connected"] { background: var(--good); }
#timer { font: 13px var(--mono); color: var(--muted); }
#timer[data-warn="1"] { color: var(--warn); }
.people { display: flex; }
.person { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #111; background: var(--c); border: 2px solid var(--panel); margin-left: -6px; }
.staffbar { display: none; align-items: center; gap: 4px; }
body.staff .staffbar { display: flex; }
.staffbar .code { font: 600 14px var(--mono); letter-spacing: .12em; margin-right: 6px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 34%); min-height: 0; }
#editor { min-height: 0; overflow: hidden; border-right: 1px solid var(--line); }
.side { display: grid; grid-template-rows: auto 140px auto 1fr; min-height: 0; background: var(--panel); }
.side .head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.side .head + * { border-bottom: 1px solid var(--line); }
#stdin { min-height: 0; overflow: hidden; }
#output { overflow: auto; padding: 10px 12px; min-height: 0; }
#output pre { margin: 0 0 12px; font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
#output pre.err { color: #ff9c97; }
#output pre.warn { color: #ffd88a; }
#output .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
#output .empty { color: var(--muted); }
#run-status { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 12px; }
.runbar { display: flex; gap: 8px; align-items: center; }
.runbar select { padding: 6px 8px; }

.overlay { position: fixed; inset: 0; background: rgba(8, 9, 11, .82); display: grid; place-items: center; z-index: 10; padding: 16px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; z-index: 20; }

@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  #editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .side { grid-template-rows: auto 100px auto 260px; }
}

/* ---------- dashboard ---------- */
.dash { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }
.dash header { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.dash header .spacer { flex: 1; }
.newpad { display: grid; grid-template-columns: 1fr 180px 150px auto; gap: 10px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.newpad input, .newpad select { width: 100%; }
.created { background: #241c0e; border: 1px solid #4a3818; border-radius: 12px; padding: 14px 16px; margin: -8px 0 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.created .bigcode { font: 700 26px var(--mono); letter-spacing: .18em; color: var(--accent); }
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input { width: 100%; padding: 11px 14px; font-size: 15px; }
table.pads { width: 100%; border-collapse: collapse; }
table.pads th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.pads td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.pads tr:hover td { background: #15181b; }
table.pads .name a { color: var(--text); font-weight: 600; }
table.pads .code { font: 600 14px var(--mono); letter-spacing: .1em; }
table.pads .snippet { font: 12px/1.45 var(--mono); color: var(--muted); margin-top: 4px; white-space: pre-wrap; word-break: break-word; max-height: 3em; overflow: hidden; }
table.pads mark { background: #4a3818; color: var(--accent); border-radius: 2px; }
table.pads .actions { white-space: nowrap; text-align: right; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }
@media (max-width: 760px) {
  .newpad { grid-template-columns: 1fr 1fr; }
  .newpad .grow { grid-column: 1 / -1; }
  table.pads th:nth-child(4), table.pads td:nth-child(4), table.pads th:nth-child(5), table.pads td:nth-child(5) { display: none; }
}
