/* ccweb — phone first. Everything here assumes a thumb, not a mouse:
   44px minimum targets, no hover-only affordances, and a terminal that gets
   the whole viewport once you are in it. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-hi: #1e222b;
  --line: #272c37;
  --text: #e6e9ef;
  --dim: #8b93a7;
  --accent: #6ee7a8;
  --accent-dim: #2f6b4f;
  --danger: #ff6b6b;
  --danger-dim: #5a2626;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
body { display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------------------------------------------------------------- chrome */
header {
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
header h1 { margin: 0; font: 600 16px/1 var(--mono); letter-spacing: .5px; }
header .count { color: var(--dim); font-size: 13px; margin-left: auto; }
header button.icon {
  width: 40px; height: 40px; margin: -8px -6px -8px 0;
  border-radius: 10px; color: var(--dim); font-size: 18px;
}
header button.icon:active { background: var(--panel-hi); }
.back { font-size: 22px; line-height: 1; width: 36px; height: 36px; margin-left: -8px; border-radius: 10px; color: var(--dim); }
.back:active { background: var(--panel-hi); }
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------- login/offline */
#login, #offline { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; height: 100%; padding: 24px; }
#login .mark, #offline .mark { font: 600 34px/1 var(--mono); letter-spacing: 3px; color: var(--accent); }
#login .sub, #offline .sub { color: var(--dim); font-size: 14px; margin-top: -10px; }
#offline .btn { max-width: 320px; width: 100%; }
#login form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
input {
  width: 100%; padding: 14px; font: 16px/1 var(--mono);
  color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); outline: none;
}
input:focus { border-color: var(--accent-dim); }
.btn {
  padding: 14px; border-radius: var(--radius); font-weight: 600;
  background: var(--accent); color: #07130d; text-align: center;
}
.btn:active { filter: brightness(.9); }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; text-align: center; }

/* --------------------------------------------------------------- session */
ul#list { list-style: none; margin: 0; padding: 8px 10px 96px; display: flex; flex-direction: column; gap: 8px; }
li.row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 12px 12px 14px; position: relative; overflow: hidden;
}
li.row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .85; }
li.row.detached::before { background: var(--dim); opacity: .45; }
.open { grid-column: 1; text-align: left; padding: 0; min-height: 44px; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.open:active { opacity: .6; }
.name { font: 600 16px/1.2 var(--mono); display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.detached .dot { background: var(--dim); opacity: .5; }
.meta { color: var(--dim); font-size: 12.5px; }
.dir { color: var(--dim); font: 12px/1.3 var(--mono); word-break: break-all; opacity: .75; }
.tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--dim); }
.kill { grid-column: 2; grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: 10px; color: var(--dim); font-size: 17px; border: 1px solid transparent; }
.kill:active { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.empty { text-align: center; color: var(--dim); padding: 56px 24px; font-size: 14px; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 14px 22px; border-radius: 999px; font-weight: 600;
  background: var(--accent); color: #07130d;
  box-shadow: 0 6px 22px rgba(0,0,0,.45); z-index: 4;
}
.fab:active { filter: brightness(.9); }

/* ----------------------------------------------------------------- modal */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 10; }
.sheet form {
  width: 100%; background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  border-top: 1px solid var(--line);
}
.sheet h2 { margin: 0 0 2px; font-size: 17px; }
.sheet label { font-size: 12.5px; color: var(--dim); margin-bottom: -6px; }
.sheet .hint { font-size: 12px; color: var(--dim); margin-top: -6px; }
.sheet .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

/* -------------------------------------------------------------- terminal */
#term-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#term { flex: 1; min-height: 0; padding: 4px 0 0 6px; overflow: hidden; }
.keys {
  display: flex; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.keys::-webkit-scrollbar { display: none; }
.keys button {
  flex: none; min-width: 46px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel-hi);
  font: 13px/1 var(--mono); color: var(--text);
}
.keys button:active, .keys button.on { background: var(--accent); color: #07130d; border-color: var(--accent); }
.keys button.wide { font-size: 12px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom));
  background: var(--panel-hi); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; z-index: 20;
  max-width: 90vw; text-align: center;
}
.toast.bad { border-color: var(--danger); color: var(--danger); }
