:root {
  --bg: #15161a;
  --panel: #1e2026;
  --line: #2c2f38;
  --text: #d8dae0;
  --dim: #8a8f9c;
  --accent: #d97757;
  --ok: #4fb477;
  --bad: #d65c5c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI", "Malgun Gothic", system-ui, sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; height: 100dvh; }

#bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none; }
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tab { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; border-radius: 6px;
  background: transparent; color: var(--dim); cursor: pointer; white-space: nowrap; user-select: none; }
.tab:hover { background: #262932; }
.tab.active { background: var(--bg); color: var(--text); }
.tab .st { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.tab.dead .st { background: var(--dim); }
.tab.unread:not(.active) .st { box-shadow: 0 0 0 3px #4fb47744; }
.tab .x { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 0 2px; font-size: 14px; }
.tab .x:hover { color: var(--bad); }

.act { border: 0; border-radius: 6px; padding: 5px 10px; background: var(--accent); color: #fff;
  cursor: pointer; font: inherit; white-space: nowrap; }
.act.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.act.ghost:hover, .act.ghost.on { color: var(--text); border-color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }

#workspace { flex: 1; display: flex; min-height: 0; position: relative; }
#terms { flex: 1; position: relative; min-height: 0; min-width: 0; }
.icon { border: 0; background: none; color: var(--dim); cursor: pointer; font: inherit; font-size: 15px;
  padding: 4px 6px; border-radius: 6px; flex: none; }
.icon:hover { color: var(--text); background: #262932; }

#side { width: 260px; flex: none; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); min-height: 0; }
body.side-hidden #side { display: none; }
.side-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 6px 12px; color: var(--dim);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.side-head span { flex: 1; }
#projects { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.side-empty { color: var(--dim); padding: 10px 8px; font-size: 12px; }
.proj { margin-bottom: 2px; }
.proj-head { display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 6px; cursor: pointer;
  user-select: none; }
.proj-head:hover { background: #262932; }
.proj-head .caret { width: 12px; color: var(--dim); font-size: 10px; flex: none; }
.proj-head .pname { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-head .icon { padding: 1px 6px; font-size: 13px; visibility: hidden; }
.proj-head:hover .icon, .proj.open .proj-head .new { visibility: visible; }
.proj-list { display: none; padding-left: 14px; }
.proj.open .proj-list { display: block; }
.sess { display: flex; gap: 6px; align-items: baseline; padding: 4px 8px; border-radius: 6px; cursor: pointer;
  color: var(--dim); }
.sess:hover { background: #262932; color: var(--text); }
.sess.running { color: var(--text); }
.sess.running::before { content: '●'; color: var(--ok); font-size: 8px; }
.sess .stitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .when { font-size: 11px; color: #6b7080; flex: none; }
.sess-more { padding: 4px 8px; color: var(--accent); cursor: pointer; font-size: 12px; }

@media (max-width: 800px) {
  #side { position: absolute; inset: 0 auto 0 0; z-index: 5; width: min(300px, 85vw); box-shadow: 8px 0 24px #0008; }
}
.term { position: absolute; inset: 0; padding: 6px 0 0 8px; display: none; }
.term.active { display: block; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim);
  white-space: pre-line; text-align: center; padding: 16px; }

#keys { display: none; gap: 4px; padding: 6px; background: var(--panel); border-top: 1px solid var(--line);
  overflow-x: auto; flex: none; }
#keys button { flex: 1 0 auto; min-width: 44px; padding: 9px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
@media (pointer: coarse) { #keys { display: flex; } }

#remote { position: fixed; top: 48px; right: 8px; width: min(420px, calc(100vw - 16px)); padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; z-index: 10;
  box-shadow: 0 10px 30px #0008; }
#remote h2 { margin: 0 0 10px; font-size: 15px; }
#remote .hint { color: var(--dim); font-size: 12px; margin: 8px 0; }
#remote-urls a { display: block; margin: 8px 0; padding: 8px; background: var(--bg); border-radius: 6px;
  color: var(--accent); word-break: break-all; font-family: Consolas, monospace; font-size: 12px; }
.switch { display: flex; gap: 8px; align-items: center; cursor: pointer; }
#remote h2.sub { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
#remote { max-height: calc(100dvh - 60px); overflow-y: auto; }
#pair-qr { margin: 10px 0 4px; }
#pair-qr svg { display: block; width: 220px; height: 220px; border-radius: 8px; }
.device { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0;
  padding: 6px 8px; background: var(--bg); border-radius: 6px; }
.device button { border: 0; background: none; color: var(--dim); cursor: pointer; font: inherit; }
.device button:hover { color: var(--bad); }
#toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 14px; background: #2c2f38; color: var(--text); border-radius: 8px; z-index: 20;
  box-shadow: 0 6px 20px #0008; }

@media (max-width: 600px) {
  #new-shell { display: none; }
  .term { padding: 4px 0 0 4px; }
}
