:root {
  /* Monochrome: every surface is pure black; structure comes from faint-white
     hairlines, not gray fills. Active/armed states invert to white-on-black. */
  --bg: #000000;      /* terminal + every panel/chrome surface */
  --panel: #000000;   /* window body / cards */
  --chrome: #000000;  /* window title bar */
  --tabbg: #000000;   /* inactive tab */
  --keycap: #000000;  /* key bar cap */
  --border: rgba(255,255,255,0.22);  /* faint white hairline */
  --border-strong: rgba(255,255,255,0.55);
  --text: #ffffff;
  --muted: rgba(255,255,255,0.5);
  --accent: #31e722; /* bright terminal green — focus, active tab, armed ctrl, digits */
  --link: #14f0f0;   /* bright terminal cyan — tappable links */
  --mono: Menlo, Monaco, "SF Mono", "Courier New", monospace; /* matches the xterm console */
}

* { box-sizing: border-box; }

:root { color-scheme: dark; } /* dark soft keyboard + form controls */

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

/* --app-height tracks the *visible* viewport (shrinks when the keyboard opens). */
.view { height: var(--app-height, 100dvh); width: 100vw; }
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; padding: 24px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;  /* a macOS window corner; the controls inside stay sharp */
  padding: 22px;
  width: 100%;
  max-width: 420px;
}

h1, h2 { margin: 0 0 8px; font-weight: 600; letter-spacing: 0.5px; }
.muted { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.error { color: #c23621; font-size: 13px; min-height: 18px; margin: 8px 0 0; }

input, button { font-size: 16px; font-family: var(--mono); } /* 16px avoids iOS zoom-on-focus */

input {
  width: 100%;
  padding: 11px 12px;
  margin: 6px 0;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
}
input:focus { outline: none; border-color: var(--accent); }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 11px 16px;
  background: #000;
  color: var(--text);
  font-weight: 500;
}
button:active { background: rgba(255,255,255,0.16); }
button.link { background: none; border: none; color: var(--muted); padding: 8px 0; font-weight: 400; text-decoration: underline; }
/* primary actions: bright-green glyph + border so they read as primary */
#loginForm button[type="submit"], #emptyAdd, #copyAll, #newProjectForm button {
  color: var(--accent);
  border-color: var(--accent);
}

.list { list-style: none; padding: 0; margin: 0 0 12px; max-height: 45vh; overflow-y: auto; }
.list li { padding: 12px; border: 1px solid var(--border); border-radius: 0; margin-bottom: 6px; cursor: pointer; display: flex; align-items: center; }
.list li:active { background: rgba(255,255,255,0.1); }
.list li::before { content: "›"; color: var(--accent); margin-right: 10px; font-weight: 700; }

.row { display: flex; gap: 8px; }
.row input { margin: 0; }
.row button { padding: 11px 16px; }

/* Workspace layout */
#workspace { display: flex; flex-direction: column; }

/* Title bar (window chrome; also holds the action buttons) */
#tabbar {
  display: flex;
  align-items: stretch;
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top); /* clear the notch/status bar */
}
#tabs { display: flex; flex: 1 1 auto; overflow-x: auto; min-width: 0; }
#tabbar .actions { display: flex; flex: 0 0 auto; align-items: center; }
#tabbar .actions button, #tabbar .actions label {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 9px;
  line-height: 1;
  border-radius: 0;
}
/* A−/A+ are text, not glyphs — keep them from dwarfing the icon buttons. */
#fontDec, #fontInc { font-size: 13px; font-weight: 600; padding: 4px 6px; }
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--tabbg);
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  max-width: 160px;
}
.tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab.attn { color: var(--text); }
/* Attention dot: hidden until a terminal bell flags the tab (Claude wants you). */
.tab .dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.tab.attn .dot { display: inline-block; }
.tab .label { overflow: hidden; text-overflow: ellipsis; }
.tab .close { color: var(--muted); font-size: 15px; padding: 0 2px; }
.tab .close:active { color: #fff; }
#addTab { background: none; border: none; color: var(--muted); font-size: 20px; padding: 8px 16px; flex: 0 0 auto; }

/* Terminals */
#terminals { flex: 1; min-height: 0; position: relative; }
.termpane { position: absolute; inset: 0; padding: 6px 8px; overflow: hidden; }
.termpane.hidden { display: none; }
#emptyState { position: absolute; inset: 0; }

/* Mobile key bar — two fixed rows, no sideways scrolling */
#keybar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--bg);  /* continuous with the terminal */
  border-top: 1px solid var(--border);
}
.keyrow { display: flex; gap: 5px; }
#keybar button {
  flex: 1 1 0;       /* each button fills an equal slice of the row */
  min-width: 0;
  background: var(--keycap);
  color: rgba(255,255,255,0.78);
  border: 1px solid var(--border);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: -0.3px;  /* keep wider labels (⇧Tab, Ctrl) inside their slice */
  padding: 11px 1px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;        /* clip rather than spill past the button edge */
}
#keybar button:active { background: rgba(255,255,255,0.16); border-color: var(--border-strong); }
#keybar button.active { background: var(--accent); border-color: var(--accent); color: #000; } /* ctrl armed -> inverted */
/* digit keys: the 1..0 menu keys read as plain bright-white (just a touch bolder
   than the other keys) — no per-key color, that was too much. */
#keybar button[data-key^="d"] { color: var(--text); font-weight: 700; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20; }

/* Copy/select panel */
.copycard { max-width: 560px; display: flex; flex-direction: column; }
#copyText {
  width: 100%;
  height: 50vh;
  margin: 0 0 12px;
  resize: none;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre;
  overflow: auto;
  -webkit-user-select: text;
  user-select: text;
}
/* Make links inside the terminal obviously tappable */
.xterm a { color: var(--link); text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 0;
  font-size: 13px;
  font-family: var(--mono);
  z-index: 30;
}
