/* ============================================================
   Frontlog pilot: quiet, fast, typographic operator tool.
   Dark-first ink theme, one signature copper accent.
   Type scale: 12 / 14 / 16 / 20 / 24 / 32. Spacing: 4/8/12/16/24/32.
   Radius: 6px everywhere. Flat surfaces, except the signature copper,
   which is a diagonal rose-gold metal gradient. No blur.
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #131110;
  --surface: #1d1a17;
  --surface-shift: #25211c;
  --ink: #f4f1ea;
  --muted: #a39d92;
  --line: #2e2a24;
  --accent: #b87333;
  --accent-hover: #cd8142;
  --accent-ink: #131110;
  --copper-hi: #d99a55;
  --copper-lo: #96602a;
  --copper-edge: #5f3c1c;
  --copper-3d: linear-gradient(135deg,
    #7c4f22 0%,
    #b87333 28%,
    #eec084 46%,
    #f7d9ae 52%,
    #e5ae76 58%,
    #a5652f 78%,
    #6e4520 100%);
  --danger: #d9705f;
  --danger-hover: #e58270;
  --radius: 6px;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --p0-bg: rgba(217,112,95,.14); --p0-fg: #e08d7f;
  --p1-bg: rgba(244,241,234,.16); --p1-fg: #ece7dc;
  --p2-bg: rgba(244,241,234,.08); --p2-fg: #b3aca0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

h1, h2, h3, .brand, label, .tab, .btn, button, .badge, .seg button {
  font-family: var(--font-display);
}

/* ---------- focus: visible ring on everything interactive ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.app-header {
  padding: 16px 0 4px;
}
.app-header .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-header .tabs-row { margin-top: 12px; }
.brand { font-weight: 700; font-size: 20px; margin-right: auto; letter-spacing: -0.01em; }
.brand::before {
  content: ""; display: inline-block; width: 9px; height: 9px;
  border: 2px solid var(--accent); border-radius: 50%; margin-right: 10px;
  transform: translateY(1px);
  box-shadow: 0 0 8px rgba(184,115,51,.5);
}
.tabs { display: flex; gap: 4px; }
.tab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px; font-weight: 600;
  min-height: 44px; transition: background-color 120ms ease, color 120ms ease;
}
.tab:hover { background: var(--surface-shift); color: var(--ink); }
.tab:active { background: var(--line); }
.tab.active {
  background: var(--copper-3d); border-color: var(--copper-edge); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255,240,214,.45), inset 0 -2px 3px rgba(50,25,5,.35);
}
.user-chip {
  font-size: 12px; color: var(--muted); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- buttons: primary / secondary / danger ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600; border-radius: var(--radius);
  padding: 12px 16px; min-height: 44px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease;
  font-family: var(--font-display);
}
.btn svg, button svg { width: 16px; height: 16px; flex: none; }

.btn-primary, button.primary {
  background: var(--copper-3d); border-color: var(--copper-edge); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255,240,214,.55), inset 0 -2px 3px rgba(50,25,5,.45);
  transition: filter 120ms ease, border-color 120ms ease;
}
.btn-primary:hover, button.primary:hover { filter: brightness(1.07); border-color: var(--copper-edge); }
.btn-primary:active, button.primary:active { filter: brightness(.92); }

/* Sheen sweep: light passes across the metal on hover. */
.btn-primary, button.primary { position: relative; overflow: hidden; }
.btn-primary::after, button.primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255,244,220,.55) 50%, transparent 58%);
  transform: translateX(-130%);
}
.btn-primary:hover::after, button.primary:hover::after {
  transform: translateX(130%);
  transition: transform 650ms ease;
}

.btn-secondary:hover, button.ghost:hover { background: var(--surface-shift); border-color: #4a453c; }
.btn-secondary:active, button.ghost:active { background: var(--line); }

.btn-danger, button.danger { color: var(--danger); border-color: rgba(217,112,95,.45); background: var(--surface); }
.btn-danger:hover, button.danger:hover { background: rgba(217,112,95,.12); border-color: var(--danger); }
.btn-danger:active, button.danger:active { background: rgba(217,112,95,.22); }

.btn-sm { font-size: 14px; padding: 8px 12px; min-height: 44px; }

.btn:disabled, button:disabled {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}
.btn.is-loading, button.is-loading { opacity: 0.7; pointer-events: none; }
.btn.is-loading::after, button.is-loading::after {
  content: ""; animation: loading-dots 1.2s steps(1) infinite;
}
@keyframes loading-dots {
  0% { content: ""; } 25% { content: "."; }
  50% { content: ".."; } 75% { content: "..."; }
}

/* Quiet text button, for progressive disclosure toggles. */
.link-btn { display: inline; padding: 0; min-height: 0; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; margin-top: 12px; font-family: var(--font-display); }
.link-btn:hover { color: var(--ink); }

/* Confirmation strip after a capture, with the next step. */
.capture-done { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.capture-done p { margin: 0; font-size: 14px; }
.capture-done .btn-row { margin-top: 10px; }

/* Live status line shown under a button while a slow call runs. */
.wait-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; min-height: 20px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- cards, forms ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 16px 0;
}
.card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.01em; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; line-height: 1.5; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }

input[type="text"], input[type="email"], input[type="password"],
textarea, select {
  width: 100%; font-size: 16px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-family: var(--font-body);
  transition: border-color 120ms ease;
}
input:hover, textarea:hover, select:hover { border-color: #4a453c; }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

.error { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 20px; }

/* ---------- login ---------- */
.login-wrap { max-width: 420px; margin: 12vh auto 0; padding: 0 16px 32px; }
.login-wrap h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -0.02em; }
.login-wrap p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* ---------- filters ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.filters .full { grid-column: 1 / -1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button {
  flex: 1; border: 0; border-radius: 0; background: transparent;
  font-size: 14px; min-height: 44px; padding: 8px 12px; color: var(--muted);
}
.seg button:hover { background: var(--surface-shift); color: var(--ink); }
.seg button.active { background: var(--ink); color: var(--bg); }

/* ---------- idea list ---------- */
.idea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin: 8px 0; cursor: pointer; text-align: left; width: 100%;
  display: block; transition: background-color 120ms ease, border-color 120ms ease;
}
.idea:hover { background: var(--surface-shift); border-color: #4a453c; }
.idea:active { background: #2a251f; }
.idea.selected { border-color: var(--accent); background: var(--surface-shift); }
.idea-title { font-weight: 600; font-size: 16px; margin: 0 0 4px; font-family: var(--font-display); letter-spacing: -0.005em; }
.idea-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700; border-radius: var(--radius);
  padding: 2px 8px; line-height: 1.5; border: 1px solid transparent;
}
.badge.p0 { background: var(--p0-bg); color: var(--p0-fg); }
.badge.p1 { background: var(--p1-bg); color: var(--p1-fg); }
.badge.p2 { background: var(--p2-bg); color: var(--p2-fg); }
.badge.p3 { background: transparent; color: var(--muted); border-color: var(--line); }
.badge.status { background: transparent; color: var(--muted); border-color: var(--line); font-weight: 600; }
.badge.status.validated { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge.status.killed { background: transparent; color: var(--muted); border-color: var(--line); }
.badge.backlog { background: var(--ink); color: var(--bg); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; max-width: 65ch; margin: 0 auto; }
.empty::before {
  content: ""; display: block; width: 46px; height: 46px; margin: 0 auto 20px;
  border: 3px solid var(--accent); border-radius: 50%;
  box-shadow: 0 0 20px rgba(184,115,51,.35), inset 0 0 10px rgba(238,192,132,.22);
}
.empty p { margin: 0 0 16px; }

/* ---------- detail overlay ---------- */
.detail-overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.detail-head {
  position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 8px 0; z-index: 2;
}
.results-doc {
  background: var(--surface-shift); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-top: 8px; white-space: pre-wrap; word-wrap: break-word;
  max-width: 65ch; font-size: 14px; line-height: 1.5;
}
.results-doc h3 { margin: 0 0 4px; font-size: 16px; }
.results-doc .doc-meta { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* ---------- decide queue / decision record ---------- */
.decide-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin: 8px 0;
}
.decide-row .idea-title { margin-bottom: 4px; }
.decide-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.decide-confirm { margin-top: 12px; }
.decide-confirm .btn-row { margin-top: 8px; }
.idea-prove { font-size: 14px; color: var(--muted); margin-top: 8px; }
.idea-outcome {
  font-size: 14px; color: var(--ink); margin-top: 8px;
  border-left: 2px solid var(--ink); padding-left: 8px;
}
.idea-verdict { font-size: 14px; color: var(--ink); margin-top: 8px; }
.verdict-line { font-size: 14px; margin: 0 0 8px; }
.outcome-doc {
  background: var(--surface-shift); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-top: 8px; max-width: 65ch; font-size: 14px; line-height: 1.5;
}
.outcome-doc h3 { margin: 0 0 4px; font-size: 16px; }
.outcome-doc p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }
.tagline { font-size: 14px; color: var(--muted); margin: 0 0 8px; line-height: 1.5; }

/* ---------- AI research brief ---------- */
.ai-brief-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.ai-brief-bar .hint { margin: 0; }
.ai-brief {
  background: var(--surface-shift); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; font-size: 14px; line-height: 1.5; max-width: 65ch;
}
.ai-section { margin: 0 0 12px; }
.ai-section:last-child { margin-bottom: 0; }
.ai-section h4 {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  margin: 0 0 4px;
}
.ai-section p { margin: 0 0 8px; }
.ai-section ul { margin: 0 0 8px; padding-left: 20px; }
.ai-section li { margin-bottom: 4px; }

/* ---------- shortcuts footer ---------- */
.shortcuts {
  margin: 32px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); text-align: center;
}
kbd {
  font-family: var(--font-body); font-size: 12px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius);
  padding: 0 6px; background: var(--surface); color: var(--ink);
}

/* ---------- setup notice ---------- */
.setup-notice {
  max-width: 640px; margin: 12vh auto 0; padding: 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.setup-notice code { background: var(--p2-bg); padding: 2px 6px; border-radius: var(--radius); font-size: 14px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.toolbar .spacer { flex: 1; }

@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .toolbar .btn-sm { flex: 1; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; }
}

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

/* ---------- workspaces ---------- */
.ws-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0 0; }
.ws-bar[hidden] { display: none; }
#workspace-switch {
  flex: 1; min-width: 160px; font-size: 16px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius); padding: 8px 12px; min-height: 44px;
}
.notice {
  margin: 8px 0 0; padding: 10px 12px; font-size: 14px;
  background: var(--surface-shift); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink);
}
.notice[hidden] { display: none; }
.onboard {
  margin: 20px 0 0; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.onboard[hidden] { display: none; }
.onboard h2 { margin: 0 0 10px; font-size: 17px; }
.onboard ol { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
.onboard li { margin: 0 0 8px; }
.onboard .hint { margin: 0; }
.onboard-banner .btn-row { margin-top: 10px; }
.modal {
  position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 9, 8, 0.7);
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.modal-card .tagline { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.modal-card input[type="text"] { width: 100%; }
#invite-link { font-size: 13px; }
