:root {
  --bg: #0b0c0d;
  --panel: #101315;
  --raised: #15191b;
  --line: #1e2427;
  --line-soft: #191e21;
  --ink: #dfe4e6;
  --muted: #8b949a;
  --dim: #79838a;
  --accent: #d8a05a;
  --ok: #82b98f;
  --bad: #cf6f66;
  --ui: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #2a3236;
  border-radius: 2px;
  background: #1a1f22;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: #3a454a; background: #1f2529; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.ghost:hover { color: var(--ink); border-color: #3a454a; }
button.danger-btn { border-color: #5a2c29; background: #2a1514; color: #e7a09a; }
button.danger-btn:hover { background: #351a18; }

input, select, textarea {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0d1012;
  color: var(--ink);
  outline: none;
}
textarea { height: auto; padding: 9px; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 0;
}
::placeholder { color: var(--dim); }

.muted { color: var(--muted); }
.hint { color: var(--dim); font-size: 11px; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  align-items: stretch;
}

.login-mark {
  padding: clamp(32px, 7vw, 96px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.wordmark {
  font-family: var(--ui);
  font-size: clamp(56px, 9vw, 120px);
  font-weight: 600;
  line-height: .86;
  letter-spacing: .04em;
  color: var(--ink);
}
.wordmark::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin-top: 22px;
  background: var(--accent);
}

.login-line { margin: 0; color: var(--muted); font-size: 15px; max-width: 34ch; }

.login-facts { margin: 18px 0 0; display: grid; gap: 0; max-width: 420px; }
.login-facts > div { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.login-facts dt { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.login-facts dd { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.login-form {
  padding: clamp(32px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  max-width: 420px;
  width: 100%;
}
.login-form h1 { margin: 0 0 8px; font-size: 22px; font-weight: 500; letter-spacing: .01em; }
.login-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.login-form input { height: 34px; text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 13px; }
.login-form button { height: 34px; margin-top: 6px; border-color: #6b4a24; background: #2a1f12; color: #f0c489; }
.login-form button:hover { background: #332516; }
.login-err { min-height: 18px; margin: 2px 0 0; color: var(--bad); font-size: 12px; }

/* ---------------------------------------------------------------- chrome */

#app {
  height: 100%;
  display: grid;
  grid-template-rows: 46px 1fr 28px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-size: 15px; font-weight: 600; letter-spacing: .14em; }
.brand span { color: var(--accent); font-size: 10px; letter-spacing: .18em; margin-left: 7px; vertical-align: 2px; }
.bar-meta { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.bar-gap { flex: 1; }
.bar button { height: 24px; font-size: 11px; }

.shell { display: grid; grid-template-columns: 292px 1fr; min-height: 0; }

/* ---------------------------------------------------------------- rail */

.rail {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail-head {
  display: flex;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.rail-count { font-family: var(--mono); color: var(--accent); }
.session-list { overflow: auto; flex: 1; }
.rail-foot { padding: 11px 14px; border-top: 1px solid var(--line); color: var(--dim); font-family: var(--mono); font-size: 11px; }

.session {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.session:hover { background: #131719; }
.session.on { background: var(--raised); }
.session.on::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}
.session .num { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.session .who { min-width: 0; }
.session .host { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .sub { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.session .contact {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  width: var(--w, 100%);
  background: var(--accent);
  opacity: .75;
  transition: width 1s linear;
}

.tag {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  vertical-align: 2px;
}
.tag.admin { color: var(--accent); border-color: #4a3820; }
.tag.svc { color: #c9b06e; border-color: #443a20; }
.tag.usr { color: #8fb6c9; border-color: #223840; }

/* ---------------------------------------------------------------- work */

.work { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.empty { margin: auto; max-width: 380px; text-align: center; }
.empty-title { margin: 0 0 6px; font-size: 15px; }
.empty p { margin: 0; }

.sess-head { padding: 14px 18px 12px; border-bottom: 1px solid var(--line); }
.sess-id { display: flex; align-items: center; gap: 10px; }
.sess-host { font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.sess-sub { margin-top: 3px; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.tabs {
  display: flex;
  gap: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.tabs button:hover { background: transparent; color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.panes { flex: 1; min-height: 0; overflow: auto; }
.pane { display: none; padding: 16px 18px 24px; }
.pane.on { display: block; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar input:not([type="number"]) { flex: 1; min-width: 160px; }
.toolbar input[type="number"] { width: 74px; }
.inline { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.inline input { height: 26px; text-transform: none; letter-spacing: 0; font-family: var(--mono); }
.upload { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); cursor: pointer; }
.upload:hover { color: var(--ink); border-color: #3a454a; }

.out {
  margin: 0 0 12px;
  padding: 12px;
  min-height: 240px;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: #0d1012;
  color: #cfd6d9;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.out.preview { min-height: 120px; max-height: 32vh; }
.out .ok { color: var(--ok); }
.out .bad { color: var(--bad); }

.cmdline {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #0d1012;
}
.cmdline:focus-within { border-color: var(--accent); }
.cmdline .prompt { color: var(--accent); font-family: var(--mono); }
.cmdline input { flex: 1; height: 34px; padding: 0; border: 0; background: transparent; font-family: var(--mono); font-size: 12.5px; }
.cmdline input:focus { outline: none; }
.cmdline button { height: 26px; }

/* facts */

.facts { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.facts dt, .facts dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.facts dt { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.facts dd { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* files */

.listing { border: 1px solid var(--line); background: var(--panel); }
.lrow {
  display: grid;
  grid-template-columns: 1fr 92px 150px 150px;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
}
.lrow:last-child { border-bottom: 0; }
.lrow.head { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; font-family: var(--ui); }
.lrow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.lrow .name:hover { color: var(--accent); }
.lrow .name.dir { color: #a8c4d2; }
.lrow .size, .lrow .mod { color: var(--muted); font-size: 11px; }
.lrow .acts { display: flex; gap: 6px; justify-content: flex-end; }
.lrow .acts button { height: 22px; padding: 0 7px; font-size: 10.5px; }

/* tables */

.table-wrap { border: 1px solid var(--line); background: var(--panel); max-height: 58vh; overflow: auto; }
.grid { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.grid th {
  position: sticky; top: 0;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .09em;
  text-align: left;
}
.grid td { padding: 5px 10px; border-bottom: 1px solid var(--line-soft); }
.grid tr:hover td { background: #131719; }
.grid td.num { color: var(--muted); }
.grid button { height: 21px; padding: 0 7px; font-size: 10.5px; }

/* desktop */

.live-controls { gap: 18px; margin-top: -4px; }
.live-controls input[type="range"] { flex: 0 0 128px; width: 128px; height: 18px; padding: 0; background: transparent; border: 0; accent-color: var(--accent); }
.live-controls output { min-width: 34px; font-family: var(--mono); font-size: 11px; color: var(--ink); text-transform: none; letter-spacing: 0; }

.live {
  position: relative;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #080a0b;
  overflow: hidden;
}
.live img { display: block; max-width: 100%; max-height: 68vh; image-rendering: auto; }
.live img[hidden] { display: none; }
.live-empty { margin: 0; max-width: 46ch; padding: 0 20px; text-align: center; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.live:fullscreen { min-height: 100vh; border: 0; background: #000; }
.live:fullscreen img { max-height: 100vh; max-width: 100vw; }
#liveFoot { margin: 8px 0 0; }
#liveWrap + #liveFoot { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chips button { height: 22px; padding: 0 8px; font-size: 10.5px; font-family: var(--mono); color: var(--muted); background: transparent; border-color: var(--line-soft); }
.chips button:hover { color: var(--ink); border-color: #3a454a; }

.rail-filter { margin: 9px 12px 0; width: calc(100% - 24px); height: 26px; font-family: var(--mono); font-size: 11px; }

.shot { border: 1px solid var(--line); background: #0d1012; min-height: 120px; display: flex; align-items: center; justify-content: center; margin-top: 12px; }
.shot img { max-width: 100%; display: block; }
.shot img:not([src]) { display: none; }

/* input */

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.split h2 { margin: 0 0 10px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.split textarea { width: 100%; margin-bottom: 8px; }

/* persistence */

.danger { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); max-width: 560px; }
.danger p { margin: 0 0 10px; color: var(--muted); }

/* status */

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}
#transcript { overflow: hidden; text-overflow: ellipsis; }
#transcript::before { content: "» "; color: var(--accent); }
#clock { color: var(--dim); }

/* toast */

.toast {
  position: fixed;
  right: 16px;
  bottom: 42px;
  max-width: 380px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: #14181a;
  color: var(--ink);
  font-size: 12px;
  z-index: 20;
}
.toast.bad { border-left-color: var(--bad); }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-mark { border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 28px; }
  .login-form { padding-top: 28px; max-width: none; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .session-list { display: flex; overflow-x: auto; }
  .session { min-width: 230px; border-right: 1px solid var(--line-soft); border-bottom: 0; }
  .rail-foot { display: none; }
  .split { grid-template-columns: 1fr; }
  .lrow { grid-template-columns: 1fr 80px 120px; }
  .lrow .mod { display: none; }
  .facts { grid-template-columns: 110px 1fr; }
  .bar-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  button:active { transform: none; }
}
