:root {
  --bg: #262624;
  --side: #1f1e1d;
  --raise: #30302e;
  --line: #3a3935;
  --text: #faf9f5;
  --muted: #a3a097;
  --accent: #d97757;
  --ok: #7fae6e;
  --mono: ui-monospace, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); }
[hidden] { display: none !important; }
button { font: inherit; color: var(--text); background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #1f1e1d; font-weight: 600; }
button.link { background: none; border: 0; color: var(--muted); padding: 4px 0; }
button.icon { background: none; border: 0; font-size: 18px; padding: 4px 8px; }
input, select { font: inherit; color: var(--text); background: var(--side); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.error { color: #e5876b; min-height: 1.2em; margin: 0; font-size: 13px; }

.login { max-width: 320px; margin: 18vh auto 0; padding: 0 16px; display: grid; gap: 14px; }
.login h1 { font: 600 20px var(--mono); margin: 0 0 8px; }

.app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.brand { font: 600 15px var(--mono); }
.machines { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.side-foot { border-top: 1px solid var(--line); padding: 8px 14px; }

.group-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.group-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head button { text-transform: none; letter-spacing: 0; font-size: 12px; padding: 2px 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--muted); flex: none; }
.dot.on { background: var(--ok); border-color: var(--ok); }
.group-note { padding: 2px 14px 8px; color: var(--muted); font-size: 12px; }

.row { display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 2px solid transparent; border-radius: 0; padding: 7px 14px 7px 12px; }
.row:hover { background: var(--raise); border-color: transparent; }
.row.active { background: var(--raise); border-left-color: var(--accent); }
.row .l1 { display: flex; gap: 8px; align-items: baseline; }
.row .sname { font: 13px var(--mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { color: var(--muted); font-size: 11px; }
.row .l2 { display: flex; gap: 6px; color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; }
.row .state.working { color: var(--text); }
.row .state.waiting { color: var(--accent); }
.row .sep { opacity: .5; }

.scrim { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.bar { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.bar .title { font: 13px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .subtitle { color: var(--muted); font-size: 12px; white-space: nowrap; }
#menu, #bar-new { display: none; }
#bar-new { flex: none; }
.attach-status { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.attach-status.error { color: #e5876b; }
.attach { flex: none; font-size: 12px; padding: 4px 10px; }
.banner { padding: 6px 12px; border-bottom: 1px solid var(--line); color: var(--accent); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term.dropping { outline: 1px dashed var(--accent); outline-offset: -4px; }
.empty { margin: auto; color: var(--muted); padding: 16px; text-align: center; }
.term { flex: 1; min-height: 0; overflow: hidden; }
.term .xterm { height: 100%; padding: 6px 0 0 8px; }
.detached { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--side); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; color: var(--muted); }

dialog.new { background: var(--side); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 18px; width: min(420px, calc(100vw - 32px)); }
dialog.new::backdrop { background: rgba(0, 0, 0, .55); }
dialog.new form { display: grid; gap: 14px; }
dialog.new h2 { margin: 0; font: 600 15px var(--sans); }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.choices button { text-align: left; }
.choices button small { display: block; color: var(--muted); font-size: 11px; }
.choices button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; justify-content: flex-end; }

@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 10; transform: translateX(-100%); transition: transform .15s ease-out; }
  .app.drawer .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 9; }
  .app.drawer .scrim { display: block; }
  #menu, #bar-new { display: inline-block; }
  .bar .subtitle { display: none; }
  .term .xterm { padding-left: 2px; }
}
