/* ==========================================================================
   Logbook — a project tracker you can stand up and present from.
   Three type roles carry the whole idea: mono for machine facts (dates, ids,
   counts), sans for interface, serif for the human words you read aloud.
   Amber appears in exactly one situation: "now", and the line where the last
   standup ended.
   ========================================================================== */

:root {
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: "Avenir Next", Avenir, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  --ink-900: #0f1420;
  --ink-850: #121927;
  --ink-800: #151d2b;
  --ink-700: #1b2434;
  --ink-600: #222d40;
  --ink-500: #2b3850;
  --rule: #263149;
  --rule-soft: #1e2739;
  --rule-strong: #3a4761;

  --text: #e7eaf1;
  --text-dim: #94a1b9;
  --text-faint: #64728d;

  --signal: #ffb020;
  --signal-dim: #7a5510;

  --t-update: #6aa9ff;
  --t-client: #ff8f6b;
  --t-decision: #b79bff;
  --t-blocker: #ff6b6b;
  --t-risk: #ffc861;
  --t-demo: #4fd1c5;
  --t-note: #94a3b8;
  --t-activity: #5d6b85;

  --ok: #4ade80;
  --warn: #ffc861;
  --danger: #ff6b6b;

  --r1: 3px;
  --r2: 6px;
  --r3: 10px;
  --r4: 16px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 6px 20px rgba(0,0,0,.45);
  --shadow-3: 0 18px 50px rgba(0,0,0,.55);

  --topbar-h: 52px;
  --tabs-h: 42px;

  /* Stacking order, low to high: menus sit over content, the deck and the
     walkthrough cover the app, a dialog covers those, toasts cover everything. */
  --z-menu: 60;
  --z-deck: 150;
  --z-tour: 180;
  --z-dialog: 300;
  --z-picker: 320;
  --z-toast: 400;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--t-update); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--r1);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26314a; border-radius: 6px; border: 2px solid var(--ink-900); }
::-webkit-scrollbar-thumb:hover { background: #33415f; }

/* --- typographic roles ---------------------------------------------------- */

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.prose {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: #d6dbe6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- shell ---------------------------------------------------------------- */

#app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: 0 var(--s4);
  background: var(--ink-850);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(255,176,32,.15);
}

.topbar .spacer { flex: 1; }

.today {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .06em;
  white-space: nowrap;
}

/* project switcher */
.switcher { position: relative; }
.switcher > button {
  display: flex; align-items: center; gap: 8px;
  max-width: 300px;
  padding: 6px 10px;
  background: var(--ink-700);
  border: 1px solid var(--rule);
  border-radius: var(--r2);
  cursor: pointer;
}
.switcher > button:hover { background: var(--ink-600); }
.switcher .swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.switcher .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.switcher .caret { color: var(--text-faint); }

.menu {
  position: absolute; z-index: var(--z-menu); top: calc(100% + 6px); left: 0;
  min-width: 280px; max-height: 60vh; overflow: auto;
  background: var(--ink-800);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r3);
  box-shadow: var(--shadow-3);
  padding: var(--s1);
}
.menu[hidden] { display: none; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; background: none; border: 0; border-radius: var(--r2);
  text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--ink-600); }
.menu .sep { height: 1px; background: var(--rule); margin: var(--s1) 0; }
.menu .meta { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }

/* search */
.search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 260px;
  padding: 6px 10px;
  background: var(--ink-800);
  border: 1px solid var(--rule);
  border-radius: var(--r2);
  color: var(--text-faint);
}
.search:focus-within { border-color: var(--rule-strong); background: var(--ink-700); }
.search input {
  flex: 1; background: none; border: 0; outline: none; color: var(--text); min-width: 0;
}
.search kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-faint);
  border: 1px solid var(--rule); border-radius: var(--r1); padding: 1px 4px;
}

/* --- tabs ----------------------------------------------------------------- */

.tabs {
  height: var(--tabs-h);
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 var(--s4);
  background: var(--ink-850);
  border-bottom: 1px solid var(--rule);
}

.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 0 12px;
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,.03); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--signal); }
.tab .count {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-faint);
  background: var(--ink-700); border-radius: 20px; padding: 1px 6px;
}

/* --- view container ------------------------------------------------------- */

#view { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.scroll { height: 100%; overflow: auto; }
.pad { padding: var(--s5) var(--s6) var(--s7); }
.narrow { max-width: 960px; margin: 0 auto; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  background: var(--ink-700);
  border: 1px solid var(--rule);
  border-radius: var(--r2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--ink-600); border-color: var(--rule-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--signal); border-color: var(--signal); color: #241701; font-weight: 600; }
.btn-primary:hover { background: #ffc247; border-color: #ffc247; }
.btn-ghost { background: none; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--ink-700); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger:hover { background: #3a1c22; border-color: var(--danger); color: #ffb4b4; }

/* --- forms ---------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  background: var(--ink-800);
  border: 1px solid var(--rule);
  border-radius: var(--r2);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--rule-strong); background: var(--ink-700); }
.textarea { resize: vertical; min-height: 90px; font-family: var(--font-serif); font-size: 15px; line-height: 1.55; }
.select { appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 16px, calc(100% - 9px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.row { display: flex; gap: var(--s3); flex-wrap: wrap; }
.row > * { min-width: 0; }
.grow { flex: 1; }

/* --- type chips ----------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.update { color: var(--t-update); }
.chip.client { color: var(--t-client); }
.chip.decision { color: var(--t-decision); }
.chip.blocker { color: var(--t-blocker); }
.chip.risk { color: var(--t-risk); }
.chip.demo { color: var(--t-demo); }
.chip.note { color: var(--t-note); }
.chip.activity { color: var(--t-activity); }

/* --- misc ----------------------------------------------------------------- */

.empty {
  border: 1px dashed var(--rule);
  border-radius: var(--r3);
  padding: var(--s6);
  text-align: center;
  color: var(--text-dim);
}
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); font-weight: 600; }
.empty p { margin: 0 0 var(--s4); font-size: 13px; }

.section-head {
  display: flex; align-items: baseline; gap: var(--s3);
  margin: 0 0 var(--s4);
}
.section-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }

.toast-stack {
  position: fixed; z-index: var(--z-toast); right: var(--s5); bottom: var(--s5);
  display: flex; flex-direction: column; gap: var(--s2);
}
.toast {
  background: var(--ink-700);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--signal);
  border-radius: var(--r2);
  padding: 10px 14px;
  box-shadow: var(--shadow-2);
  max-width: 380px;
  animation: rise .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* --- dialog --------------------------------------------------------------- */

.backdrop {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  background: rgba(6,9,15,.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh var(--s4) var(--s4);
  overflow: auto;
}
.dialog {
  width: 100%; max-width: 620px;
  background: var(--ink-800);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r4);
  box-shadow: var(--shadow-3);
  animation: rise .16s ease-out;
}
.dialog.wide { max-width: 860px; }
.dialog header {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--rule);
}
.dialog header h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.dialog .body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.dialog footer {
  display: flex; justify-content: flex-end; gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--rule);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* --- command palette ------------------------------------------------------- */

.palette-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 16px; background: none; border: 0; text-align: left; cursor: pointer;
}
.palette-row:hover, .palette-row:focus-visible { background: var(--ink-700); }

/* --- projects home --------------------------------------------------------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s4);
}

.project-card {
  position: relative;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
  background: var(--ink-800);
  border: 1px solid var(--rule);
  border-radius: var(--r3);
  overflow: hidden;
  transition: border-color .12s, transform .12s;
}
.project-card:hover { border-color: var(--rule-strong); transform: translateY(-1px); }
.project-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--spine, var(--rule-strong));
}
.project-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.project-card h3 a { color: var(--text); }
.project-card .client { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.project-card .stats { display: flex; gap: var(--s4); font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.project-card .stats b { color: var(--text); font-weight: 600; }
.project-card .actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: var(--s2); border-top: 1px solid var(--rule-soft); }

.swatch-btn {
  width: 22px; height: 22px; border-radius: var(--r2);
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.swatch-btn.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--ink-800); }
