/* Tesla-first: dark, big type, fat targets. Tokens first. */
:root {
  --bg: #0b0f14; --surface: #151b23; --surface-2: #1d2530;
  --text: #e6edf3; --text-dim: #8b98a5; --accent: #d97706;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444; --info: #38bdf8;
  --radius: 14px; --tap: 64px;
  --font: -apple-system, "SF Pro", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 20px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--info); }
button {
  font: inherit; color: inherit; background: var(--surface-2);
  border: 1px solid #2c3947; border-radius: var(--radius);
  min-height: var(--tap); padding: 0 22px; cursor: pointer;
}
button:active { transform: scale(0.98); background: #26303d; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0b0f14; font-weight: 700; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button:disabled { opacity: 0.45; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid #2c3947; border-radius: var(--radius);
  min-height: var(--tap); padding: 12px 16px; width: 100%;
}
.center { display: grid; place-items: center; min-height: 100vh; color: var(--text-dim); }

/* header */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; position: sticky; top: 0; background: var(--bg); z-index: 5;
  border-bottom: 1px solid #1d2530;
}
.topbar h1 { font-size: 22px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--err); } .dot.warn { background: var(--warn); }
.conn { color: var(--text-dim); font-size: 16px; }

/* chips */
.chip {
  display: inline-block; padding: 4px 14px; border-radius: 999px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.chip.working { background: #14321d; color: var(--ok); }
.chip.needs-input { background: #3a2a08; color: var(--warn); }
.chip.done { background: #14232e; color: var(--info); }
.chip.error { background: #341418; color: var(--err); }
.chip.idle { background: #232b35; color: var(--text-dim); }

/* home */
.cards { display: grid; gap: 16px; padding: 20px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid #222c38; border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  min-height: 120px; text-align: left;
}
.card .row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.card .title { font-size: 24px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.card .sub { color: var(--text-dim); font-size: 17px; }
.banner { margin: 16px 20px 0; padding: 14px 18px; border-radius: var(--radius); background: #341418; color: var(--err); }
.banner button { margin-left: 12px; min-height: 48px; }
.fab {
  position: fixed; right: 24px; bottom: 24px; min-width: var(--tap);
  font-size: 22px; box-shadow: 0 6px 24px rgba(0,0,0,0.5); z-index: 6;
}

/* pin */
.pin-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 26px; }
.pin-dots { font-size: 34px; letter-spacing: 14px; color: var(--accent); }
.pin-err { color: var(--err); min-height: 28px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 110px); gap: 16px; }
.pin-key { font-size: 30px; min-height: 84px; }

/* detail */
.stream { padding: 20px; padding-bottom: 190px; max-width: 1100px; margin: 0 auto; }
.block-text { background: var(--surface); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; overflow-wrap: anywhere; }
.block-text pre { background: #0d1219; border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 16px; margin: 10px 0; }
.block-text code { background: #0d1219; padding: 2px 6px; border-radius: 6px; font-size: 17px; }
.block-text p { margin: 8px 0; }
.block-tool { color: var(--text-dim); font-size: 16px; padding: 2px 8px; }
.block-meta { color: var(--text-dim); text-align: center; font-size: 15px; margin: 10px 0; }
.block-streaming { border-left: 3px solid var(--accent); }
.block-error {
  background: #341418; color: var(--err); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 14px; overflow-wrap: anywhere; font-size: 17px;
}
.block-error pre { white-space: pre-wrap; font-size: 14px; margin: 0; }
.sendbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg);
  border-top: 1px solid #1d2530; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; z-index: 5;
}
.chips { display: flex; gap: 10px; overflow-x: auto; }
.chips button { flex: none; min-height: 52px; font-size: 17px; }
.sendrow { display: flex; gap: 10px; }
.sendrow input { flex: 1; }
.queue { font-size: 15px; color: var(--text-dim); padding: 4px 8px; }
.queue.failed { color: var(--err); }
.queue button { min-height: 44px; padding: 0 14px; }

/* forms */
.form { padding: 20px; display: flex; flex-direction: column; gap: 18px; max-width: 900px; margin: 0 auto; }
.dirgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.dirgrid button.sel { border-color: var(--accent); color: var(--accent); }

@media (max-width: 640px) {
  body { font-size: 17px; }
  .cards { grid-template-columns: 1fr; padding: 14px; }
  .pin-pad { grid-template-columns: repeat(3, 88px); }
  .pin-key { min-height: 72px; }
  .dirgrid { grid-template-columns: 1fr; }
}
