/* FormFlow design system — minimalist, warm, editorial. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #55504a;
  --muted: #8a857c;
  --faint: #b9b4aa;
  --line: #e8e5de;
  --line-strong: #d6d2c8;
  --accent: #2f5aa8;
  --accent-soft: #eef2f9;
  --danger: #a83a2f;
  --danger-soft: #f9efee;
  --ok: #3c7a4e;
  --ok-soft: #eef5f0;
  --warn: #93690f;
  --warn-soft: #faf4e6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-pop: 0 12px 40px rgba(28, 26, 23, 0.14), 0 2px 8px rgba(28, 26, 23, 0.06);
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The UA rule for [hidden] is display:none at the lowest specificity, so any
   component that sets its own display (.seg, .card, flex rows) silently
   defeats it. Make the attribute authoritative. */
[hidden] { display: none !important; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

::selection { background: #dce6f6; }

h1, h2, h3 { font-weight: 560; letter-spacing: -0.015em; }

a { color: inherit; text-decoration: none; }
a.link { color: var(--accent); }
a.link:hover { text-decoration: underline; }

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, textarea, select { font: inherit; color: inherit; }

.eyebrow {
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 540;
  line-height: 1.3;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    opacity 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #33302b; }

.btn-quiet { border-color: var(--line-strong); background: var(--surface); }
.btn-quiet:hover { border-color: var(--faint); background: #fdfcfa; }

.btn-ghost { color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(28, 26, 23, 0.05); color: var(--ink); }

.btn-danger { color: var(--danger); border-color: #e5cbc8; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

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

.field { margin-bottom: 18px; }
.field label,
.field .lbl {
  display: block;
  font-size: 12px;
  font-weight: 570;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.input, textarea.input, select.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 90, 168, 0.12);
}
.input::placeholder { color: var(--faint); }
textarea.input { resize: vertical; min-height: 74px; }
.input-err { border-color: var(--danger) !important; }
.err-text { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }

.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; font-size: 13.5px; }
.check input { margin-top: 3px; accent-color: var(--ink); }

/* toggle switch */
.switch { position: relative; width: 34px; height: 20px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 20px; background: var(--line-strong);
  transition: background 0.15s ease;
}
.switch i::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(14px); }

/* ------------------------------------------------ layout chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  font-weight: 640;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.brand .mark svg { display: block; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--muted); }

.container { max-width: 1060px; margin: 0 auto; padding: 34px 26px 90px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 26px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-pad { padding: 22px; }

/* ------------------------------------------------ tables */

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 620; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:hover { background: #fcfbf8; }

/* ------------------------------------------------ badges, pills */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 590; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2.5px 9px; border-radius: 99px; border: 1px solid transparent;
}
.badge-draft { background: #f2f0eb; color: var(--ink-soft); }
.badge-published { background: var(--ok-soft); color: var(--ok); }
.badge-closed { background: var(--warn-soft); color: var(--warn); }
.badge-spam { background: var(--danger-soft); color: var(--danger); }
.badge-partial { background: var(--accent-soft); color: var(--accent); }

.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------ menus, modals, toasts */

.menu {
  position: fixed; z-index: 90; min-width: 168px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
  padding: 5px; font-size: 13.5px;
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 7px 11px;
  border-radius: 5px; color: var(--ink-soft);
}
.menu button:hover { background: #f6f4f0; color: var(--ink); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 5px 0; }

.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(28, 26, 23, 0.32);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 20px 20px;
  animation: fadeIn 0.14s ease;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-pop);
  width: 100%; max-width: 460px; padding: 26px;
  animation: popIn 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-height: 82vh; overflow: auto;
}
.modal h2 { font-size: 16.5px; margin-bottom: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.modal-wide { max-width: 640px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.97) translateY(6px); } }

#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--ink); color: #f5f3ef; font-size: 13px;
  padding: 9px 18px; border-radius: 99px; box-shadow: var(--shadow-pop);
  display: flex; gap: 12px; align-items: center;
  animation: toastIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.toast button { color: #b7cdf3; font-weight: 570; }
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

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

.empty {
  text-align: center; padding: 70px 30px; color: var(--muted);
}
.empty h3 { color: var(--ink-soft); font-size: 15.5px; margin-bottom: 6px; font-weight: 560; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto 18px; }

.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  padding: 1px 5px; border-radius: 4px; background: var(--surface);
}

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
}
.tabs a, .tabs button {
  padding: 9px 14px; font-size: 13.5px; font-weight: 530; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover, .tabs button:hover { color: var(--ink-soft); }
.tabs a.on, .tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }

.seg {
  display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface);
}
.seg button { padding: 5px 13px; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button + button { border-left: 1px solid var(--line); }

/* auth pages */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 30px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; margin-bottom: 30px; font-size: 17px; }
.auth-card .card { padding: 30px; }
.auth-card h1 { font-size: 18px; margin-bottom: 20px; text-align: center; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .v { font-size: 24px; font-weight: 580; letter-spacing: -0.02em; margin-top: 3px; }
.stat .k { font-size: 11px; font-weight: 620; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.bar-row { display: flex; align-items: center; gap: 12px; margin: 7px 0; font-size: 13px; }
.bar-row .bl { width: 180px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { display: block; flex: 1; height: 17px; background: #f2f0ea; border-radius: 4px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--ink); border-radius: 4px; min-width: 2px; transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar-row .num { width: 90px; flex: none; text-align: right; color: var(--muted); font-size: 12.5px; }

@media (max-width: 720px) {
  .container { padding: 22px 16px 70px; }
  .topbar { padding: 0 16px; }
  .bar-row .bl { width: 110px; }
}

/* Questions arriving from the assistant onto an empty canvas. The form is
   already saved by the time this runs — the stagger is a reveal, not progress. */
@keyframes blkReveal {
  from { opacity: 0; transform: translateY(9px) scale(.995); }
}
.blk.reveal { animation: blkReveal .38s cubic-bezier(.22,.68,.3,1) both; }
@media (prefers-reduced-motion: reduce) {
  .blk.reveal { animation: none; }
}

/* Empty canvas while the assistant is writing the first draft. */
.building-canvas .building-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.building-canvas .building-dots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: seedPulse 1.15s ease-in-out infinite;
}
.building-canvas .building-dots i:nth-child(2) { animation-delay: .16s; }
.building-canvas .building-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes seedPulse {
  0%, 80%, 100% { opacity: .25; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .building-canvas .building-dots i { animation: none; opacity: .6; } }
