:root {
  --bg: #111317;
  --desk: #15181d;
  --win: #1b1f25;
  --title: #232831;
  --title-active: #2b313c;
  --tabbar: #1e2229;
  --line: #323946;
  --text: #c9d1d9;
  --dim: #8590a0;
  --accent: #79b8a8;
  --accent-ink: #0f1a17;
  --danger: #e0786b;
  --term-bg: #15181d;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Ubuntu, Cantarell, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { font: 12px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* ── sign-in / ended ─────────────────────────────── */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% 30%, #1a1e25, var(--bg)); }
.card { width: min(420px, 100%); text-align: center; }
.eyebrow { margin: 0 0 18px; color: var(--dim); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.code { font: 600 clamp(40px, 12vw, 64px)/1 var(--mono); letter-spacing: .06em; color: #e8eef4;
  padding: 22px 0; border: 1px solid var(--line); border-radius: 12px; background: #171a20; user-select: all; }
.msg { margin: 18px 0 10px; min-height: 2.8em; }
.login-row { display: flex; align-items: center; justify-content: center; gap: 28px; flex-wrap: wrap; }
.qr { width: 132px; height: 132px; border-radius: 8px; overflow: hidden; background: #fff; padding: 4px; box-sizing: border-box; }
.qr svg { width: 100%; height: 100%; display: block; }
.msg code { display: inline-block; margin-top: 6px; white-space: nowrap; font: 13px var(--mono); background: #1c2027; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.bar { height: 3px; background: #22272f; border-radius: 2px; overflow: hidden; }
.bar > div { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform 1s linear; }
.card button { margin-top: 18px; padding: 9px 18px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.hint { margin-top: 26px; color: var(--dim); font-size: 12.5px; }

/* ── desktop ─────────────────────────────────────── */
#desk { position: fixed; inset: 0; background: var(--desk);
  background-image: radial-gradient(#ffffff08 1px, transparent 1px); background-size: 22px 22px; }
#windows { position: absolute; inset: 0 0 42px 0; overflow: hidden; }

.win { position: absolute; display: flex; flex-direction: column; min-width: 320px; min-height: 180px;
  background: var(--win); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px #0008, 0 2px 6px #0006; overflow: hidden; }
.win.active { border-color: #44505f; box-shadow: 0 16px 44px #000a, 0 2px 8px #0008; }
.win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; border-width: 0; }
.win.dragging, .win.resizing { user-select: none; }
.win.dragging .xterm, .win.resizing .xterm { pointer-events: none; }

.titlebar, .tabbar, #taskbar, .menu, #veil { user-select: none; -webkit-user-select: none; }
.titlebar { display: flex; align-items: center; height: 32px; padding-left: 12px; background: var(--title);
  cursor: default; touch-action: none; flex: none; }
.win.active .titlebar { background: var(--title-active); }
.titlebar .title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; color: var(--dim); }
.win.active .titlebar .title { color: var(--text); }
.titlebar .host { font: 11px var(--mono); color: var(--accent); border: 1px solid #79b8a855; border-radius: 4px; padding: 0 5px; margin-right: 8px; }
.wbtn { width: 40px; height: 32px; display: grid; place-items: center; color: var(--dim); }
.wbtn:hover { background: #ffffff12; color: var(--text); }
.wbtn.close:hover { background: var(--danger); color: #1a0d0b; }
.wbtn svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 1.4; fill: none; }

.tabbar { display: flex; align-items: stretch; height: 30px; background: var(--tabbar); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; flex: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; max-width: 200px; padding: 0 6px 0 12px; font-size: 12.5px; color: var(--dim);
  border-right: 1px solid var(--line); white-space: nowrap; }
.tab .tl { overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--term-bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab.dead .tl { text-decoration: line-through; opacity: .7; }
.tab .tx { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; opacity: .55; }
.tab .tx:hover { background: #ffffff18; opacity: 1; }
.tab .tx svg { width: 9px; height: 9px; stroke: currentColor; stroke-width: 1.6; }
.tab input, .titlebar input { font: inherit; color: var(--text); background: #0d0f12; border: 1px solid var(--accent); border-radius: 3px; padding: 0 4px; width: 130px; }
.tabadd { width: 30px; color: var(--dim); font-size: 18px; line-height: 1; }
.tabadd:hover { color: var(--text); background: #ffffff10; }

.body { position: relative; flex: 1; min-height: 0; background: var(--term-bg); }
.pane { position: absolute; inset: 4px 2px 2px 8px; }
.pane .xterm { height: 100%; }
.pane .xterm-viewport { scrollbar-width: thin; scrollbar-color: #3a4250 transparent; }

.rz { position: absolute; z-index: 2; touch-action: none; }
.rz.n, .rz.s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rz.e, .rz.w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rz.n { top: 0; } .rz.s { bottom: 0; } .rz.e { right: 0; } .rz.w { left: 0; }
.rz.ne, .rz.nw, .rz.se, .rz.sw { width: 12px; height: 12px; }
.rz.ne { top: 0; right: 0; cursor: nesw-resize; } .rz.sw { bottom: 0; left: 0; cursor: nesw-resize; }
.rz.nw { top: 0; left: 0; cursor: nwse-resize; } .rz.se { bottom: 0; right: 0; cursor: nwse-resize; }
.win.max .rz { display: none; }

/* ── taskbar ─────────────────────────────────────── */
#taskbar { position: absolute; left: 0; right: 0; bottom: 0; height: 42px; display: flex; align-items: center; gap: 4px;
  padding: 0 6px; background: #0e1014ee; border-top: 1px solid #262c35; backdrop-filter: blur(8px); }
#start { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px; border-radius: 6px; font-weight: 600; }
#start:hover, #start.open { background: #ffffff10; }
.logo { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, var(--accent), #4f7f9e);
  box-shadow: inset 0 0 0 2px #0e1014, inset 0 0 0 3px #ffffff22; }
#spaces { display: flex; gap: 2px; padding: 0 6px; border-left: 1px solid #262c35; border-right: 1px solid #262c35; }
.space { height: 26px; padding: 0 9px; border-radius: 5px; font: 12px var(--mono); color: var(--dim); position: relative; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 2px solid hsl(var(--hue, 210) 70% 55% / .55); }
.space.gone { text-decoration: line-through; opacity: .6; }
.wsgroup { display: inline-flex; gap: 1px; margin-left: 6px; padding-left: 6px; border-left: 1px solid #262c35; }
.ws { width: 22px; height: 26px; border-radius: 5px; font: 11px var(--mono); color: var(--dim); position: relative; }
.ws:hover { background: #ffffff10; }
.ws.on { background: #ffffff14; color: var(--text); }
.ws.used::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
#desklabel { position: absolute; left: 18px; top: 12px; font: 600 28px/1 var(--mono); letter-spacing: .04em; color: hsl(var(--hue, 210) 70% 70% / .22); pointer-events: none; user-select: none; }
#desklabel.gone { text-decoration: line-through; }
.space:hover { background: #ffffff10; }
.space.on { background: #ffffff14; color: var(--text); }
.space.used::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
#pins, #tasks { display: flex; gap: 2px; min-width: 0; }
#pins:not(:empty) { padding-right: 6px; border-right: 1px solid #262c35; }
#tasks { flex: 1; overflow: hidden; }
.pin, .task { height: 32px; border-radius: 6px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--dim); white-space: nowrap; }
.pin:hover, .task:hover { background: #ffffff10; color: var(--text); }
.task { max-width: 200px; min-width: 0; font-size: 12.5px; position: relative; }
.task span { overflow: hidden; text-overflow: ellipsis; }
.task.on { background: #ffffff14; color: var(--text); }
.task.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 1px; height: 2px; border-radius: 1px; background: var(--accent); }
.task.min { opacity: .6; }
.ticon { width: 16px; height: 14px; flex: none; border: 1.4px solid currentColor; border-radius: 3px; position: relative; }
.ticon::before { content: ""; position: absolute; left: 2px; top: 3px; width: 4px; height: 4px; border-right: 1.4px solid currentColor; border-bottom: 1.4px solid currentColor; transform: rotate(-45deg); }
#hide { width: 34px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--dim); }
#hide:hover { background: #ffffff10; color: var(--text); }
.eye { width: 16px; height: 10px; border: 1.4px solid currentColor; border-radius: 50% / 60%; position: relative; }
.eye::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: currentColor; }
#clock { font: 12.5px var(--mono); color: var(--dim); padding: 0 8px; min-width: 64px; text-align: right; }
#clock.low { color: var(--danger); }

/* ── menus, toast, veil, dialog ──────────────────── */
.menu { position: fixed; z-index: 100000; min-width: 200px; padding: 5px; background: #20252d; border: 1px solid #3a4250;
  border-radius: 8px; box-shadow: 0 12px 32px #000a; font-size: 13px; }
.menu .mi { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; padding: 6px 10px; border-radius: 5px; text-align: left; }
.menu .mi:hover:not(:disabled), .menu .mi:focus-visible { background: #ffffff14; outline: none; }
.menu .mi:disabled { opacity: .4; cursor: default; }
.menu .mi.danger { color: var(--danger); }
.menu .k { color: var(--dim); font: 11px var(--mono); }
.menu .sep { height: 1px; margin: 5px 4px; background: #343b47; }
.menu .hd { padding: 6px 10px 2px; color: var(--dim); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.menu .mi.sub { padding-left: 20px; }
#startmenu { left: 6px; bottom: 48px; width: 260px; }

#toast { position: fixed; z-index: 100001; left: 50%; bottom: 58px; transform: translateX(-50%); padding: 9px 16px;
  background: #2a303a; border: 1px solid #3f4857; border-radius: 8px; box-shadow: 0 8px 24px #0009; font-size: 13px; }
#toast.warn { border-color: var(--danger); }

#veil { position: fixed; inset: 0; z-index: 200000; background: #000; display: grid; place-items: center; color: #444; font-size: 13px; cursor: pointer; }

#dialog { position: fixed; inset: 0; z-index: 150000; background: #0008; display: grid; place-items: center; padding: 16px; }
.dlg { width: min(560px, 100%); background: #20252d; border: 1px solid #3a4250; border-radius: 10px; padding: 20px; box-shadow: 0 20px 50px #000c; }
.dlg p { margin: 0 0 18px; white-space: pre-line; overflow-wrap: anywhere; max-height: 60vh; overflow-y: auto; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; }
.dlg button { padding: 7px 16px; border-radius: 6px; background: #2c333e; }
.dlg button:hover { background: #363e4b; }
.dlg button.danger { background: var(--danger); color: #1a0d0b; font-weight: 600; }

@media (max-width: 640px) {
  #spaces, #pins { display: none; }
  .win { min-width: 0; }
}

/* DeskDE app windows (docs/09): no tab bar, the app's root fills the body. */
.win.app .tabbar { display: none; }
.win.app .body { position: relative; }
.win.app .approot { position: absolute; inset: 0; overflow: auto; }
