/* ===========================================================================
   Cascade — GTD × Kanban
   Visual idea: GTD calls its ideal state "mind like water." The board reads as
   a calm current — a cool paper field, ink text, one clear water-blue accent,
   and a thin gradient flowline whose colours are the stage dots in order, so
   the pipeline itself looks like water moving left to right.
   =========================================================================== */

:root {
  /* Ink */
  --ink: #18212b;
  --ink-soft: #5a6675;
  --ink-faint: #8a94a3;

  /* Surfaces */
  --paper: #e9edf1;
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --line: #dde3ea;
  --line-soft: #e7ecf1;

  /* Accent (water-blue) */
  --accent: #2f6df0;
  --accent-ink: #1b4fd0;
  --accent-wash: #eaf1fe;

  --danger: #e5484d;
  --danger-wash: #fdecec;

  /* Stage hues — also the segments of the flowline, in pipeline order */
  --stage-inbox: #8a94a3;
  --stage-next: #2f6df0;
  --stage-pending: #e8a23d;
  --stage-projects: #9b6dd6;
  --stage-maybe: #3bb39b;
  --ok: #46b06a; /* success accent (quick two-minute tasks) */

  --radius-card: 10px;
  --radius-col: 14px;
  --radius-btn: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lift: 0 8px 24px rgba(16, 24, 40, 0.16);
  --shadow-pop: 0 18px 50px rgba(16, 24, 40, 0.22);

  --sans: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, #eef3f8 0%, transparent 60%),
    var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ----- Top bar ----------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 9px; }
.brand__mark {
  align-self: center;
  width: 16px; height: 16px;
  border-radius: 5px;
  background: linear-gradient(150deg, var(--stage-inbox), var(--stage-next) 35%, var(--stage-pending) 62%, var(--stage-maybe));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.brand__name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.brand__sub {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ----- Capture ----------------------------------------------------------- */
.capture {
  flex: 1 1 340px;
  display: flex;
  gap: 8px;
  min-width: 260px;
}
.capture__input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.capture__input::placeholder { color: var(--ink-faint); }
.capture__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.capture__btn {
  height: 40px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-btn);
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.capture__btn:hover { background: var(--accent-ink); }
.capture__btn:active { transform: translateY(1px); }

/* ----- Toolbar ----------------------------------------------------------- */
.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 2px;
}
.select {
  height: 34px;
  padding: 0 30px 0 10px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238a94a3' stroke-width='2'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  appearance: none;
  cursor: pointer;
  max-width: 200px;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

.btn {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--ink-faint); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface); }
.btn--icon { width: 34px; padding: 0; font-size: 15px; color: var(--ink-soft); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger:hover { background: var(--danger-wash); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-wash); }

/* ----- Flowline signature ------------------------------------------------ */
.flowline {
  height: 3px;
  flex: 0 0 auto;
  background: linear-gradient(
    90deg,
    var(--stage-inbox) 0%, var(--stage-inbox) 19%,
    var(--stage-next) 21%, var(--stage-next) 39%,
    var(--stage-pending) 41%, var(--stage-pending) 59%,
    var(--stage-projects) 61%, var(--stage-projects) 79%,
    var(--stage-maybe) 81%, var(--stage-maybe) 100%
  );
  opacity: 0.9;
}

/* ----- Board ------------------------------------------------------------- */
.board {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 20px 22px 28px;
  overflow-x: auto;
  align-items: flex-start;
}

.column {
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-col);
}

.column__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line-soft);
}
.column__dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.column__title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.column__purpose {
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 2px;
}
.column__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  min-width: 26px;
  text-align: center;
}
.column__count.is-over {
  color: #fff;
  background: var(--stage-pending);
  border-color: var(--stage-pending);
  animation: pulse 1.6s ease-in-out infinite;
}

.column__list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 60px;
}
.column__list.is-drop { background: var(--accent-wash); outline: 2px dashed rgba(47,109,240,0.4); outline-offset: -6px; border-radius: 10px; }

.column__empty {
  margin: 6px 4px;
  padding: 18px 12px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

/* Per-column dot colours */
.column[data-status="inbox"]    .column__dot { background: var(--stage-inbox); }
.column[data-status="next"]     .column__dot { background: var(--stage-next); }
.column[data-status="pending"]  .column__dot { background: var(--stage-pending); }
.column[data-status="projects"] .column__dot { background: var(--stage-projects); }
.column[data-status="maybe"]    .column__dot { background: var(--stage-maybe); }

/* ----- Card -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 11px 12px;
  box-shadow: var(--shadow-card);
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.05s, border-color 0.15s;
}
.card:hover { border-color: #cfd7e1; }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: 0.45; box-shadow: var(--shadow-lift); }
.card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

.card__title { font-size: 14px; line-height: 1.4; color: var(--ink); }
.card.is-done .card__title { color: var(--ink-soft); text-decoration: line-through; }

.card__tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.chip {
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.chip--context { background: var(--accent-wash); color: var(--accent-ink); }
.chip--project {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line);
}
.chip--project .dot { width: 7px; height: 7px; border-radius: 50%; }

.card__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-size: 11px;
  color: var(--ink-faint);
}
.card__time { display: inline-flex; align-items: center; gap: 4px; }
.card__time.is-quick { color: var(--ok); font-weight: 600; }
.card__waiting { color: var(--stage-projects); font-weight: 500; }
.card__age { margin-left: auto; }
.card__age.is-stale { color: var(--danger); font-weight: 600; }

.card__clarify {
  margin-top: 10px;
  width: 100%;
  height: 32px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-btn);
  transition: background 0.15s;
}
.card__clarify:hover { background: var(--accent-ink); }

/* ----- Modal ------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  z-index: 60;
  background: rgba(20, 28, 38, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px;
  overflow-y: auto;
  animation: fade 0.16s ease;
}
.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  animation: rise 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}
.modal__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.modal__eyebrow {
  font-family: var(--sans);
  font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 4px;
}
.modal__title { font-family: var(--sans); font-weight: 600; font-size: 17px; line-height: 1.3; }
.modal__close {
  margin-left: auto; flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: var(--surface-2); color: var(--ink-soft); font-size: 16px;
}
.modal__close:hover { background: var(--line-soft); }
.modal__body { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }

.frm { display: flex; flex-direction: column; gap: 6px; }
.frm__label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); }
.frm__hint { font-size: 12px; color: var(--ink-soft); line-height: 1.45; }
.input, .textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
}
.textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.chipset { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-toggle {
  font-size: 12px; padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  transition: all 0.12s;
}
.chip-toggle:hover { border-color: var(--ink-faint); }
.chip-toggle.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-toggle--add { color: var(--accent); border-style: dashed; font-weight: 600; }

/* Clarify decision routes */
.routes { display: flex; flex-direction: column; gap: 9px; }
.route {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color 0.12s, background 0.12s, transform 0.05s;
}
.route:hover { border-color: var(--accent); background: var(--accent-wash); }
.route:active { transform: translateY(1px); }
.route__icon {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-2);
}
.route__text { display: flex; flex-direction: column; gap: 1px; }
.route__name { font-weight: 600; font-size: 14px; color: var(--ink); }
.route__desc { font-size: 12px; color: var(--ink-soft); }
.route--accent .route__icon { background: var(--accent-wash); }
.route--good .route__icon { background: #e8f6ec; }
.route--mute .route__icon { background: var(--surface-2); }
.route--danger:hover { border-color: var(--danger); background: var(--danger-wash); }
.route--danger .route__icon { background: var(--danger-wash); }

.divider { height: 1px; background: var(--line-soft); margin: 2px 0; }

.modal__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px 18px;
}
.modal__foot .spacer { flex: 1; }

.note {
  font-size: 12.5px; line-height: 1.5; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 11px 13px;
}
.note strong { color: var(--ink); font-weight: 600; }

/* Review */
.review-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px;
}
.stat__num { font-family: var(--sans); font-weight: 700; font-size: 24px; line-height: 1; }
.stat__lbl { font-size: 11px; color: var(--ink-faint); margin-top: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.review-list { display: flex; flex-direction: column; gap: 7px; }
.review-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink);
  padding: 9px 11px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 9px;
}
.review-item .tag { margin-left: auto; font-size: 11px; color: var(--ink-faint); }

/* ----- Toast ------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 80;
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lift);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----- Motion / responsive ----------------------------------------------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 162, 61, 0.5); } 50% { box-shadow: 0 0 0 5px rgba(232, 162, 61, 0); } }

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 12px 14px; }
  .toolbar { width: 100%; }
  .field, .select { flex: 1; max-width: none; }
  .board { padding: 16px 14px 24px; gap: 12px; }
  .column { flex-basis: 84vw; max-height: none; }
  .review-grid { grid-template-columns: repeat(3, 1fr); }
}

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

/* ----- Auth gate --------------------------------------------------------- */
/* While the app is gated, keep the board out of view so it never flashes
   behind the sign-in screen. */
body.app-hidden .topbar,
body.app-hidden .flowline,
body.app-hidden .board { display: none; }

.auth {
  position: fixed; inset: 0;
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 80% -10%, #eef3f8 0%, transparent 60%),
    var(--paper);
  animation: fade 0.18s ease;
}
.auth__card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  padding: 28px 26px 24px;
  animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.auth__brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.auth__brand .brand__name { font-size: 20px; }
.auth__title { font-family: var(--sans); font-weight: 600; font-size: 18px; line-height: 1.3; }
.auth__sub { font-size: 13px; color: var(--ink-soft); margin-top: 4px; line-height: 1.45; }
.auth__form { display: flex; flex-direction: column; gap: 13px; margin-top: 18px; }
.auth__field { display: flex; flex-direction: column; gap: 6px; }
.auth__field label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-faint);
}
.auth__submit {
  height: 42px; width: 100%; margin-top: 2px;
  font-size: 14px; font-weight: 600;
}
.auth__error {
  font-size: 12.5px; color: var(--danger);
  background: var(--danger-wash);
  border: 1px solid #f6d4d5; border-radius: 8px;
  padding: 8px 11px; line-height: 1.4;
}
.auth__toggle {
  margin-top: 16px; padding-top: 15px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px; color: var(--ink-soft); text-align: center;
}
.auth__toggle button {
  background: none; border: none; padding: 0;
  font-size: 13px; font-weight: 600; color: var(--accent);
}
.auth__toggle button:hover { color: var(--accent-ink); text-decoration: underline; }

/* ----- Account control (top bar) ----------------------------------------- */
.account { display: flex; align-items: center; gap: 9px; margin-left: 4px; }
.account__name {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account__dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ok);
}

/* ----- Complete affordance ----------------------------------------------- */
.card__row { display: flex; align-items: flex-start; gap: 10px; }
.card__body { flex: 1; min-width: 0; }
.card__check {
  flex: 0 0 auto;
  margin-top: 1px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: transparent;
  font-size: 11px; line-height: 1;
  display: grid; place-items: center;
  transition: border-color 0.12s, background 0.12s, color 0.12s, transform 0.05s;
}
.card__check::after { content: "\2713"; font-weight: 700; }
.card:hover .card__check { border-color: var(--ink-faint); }
.card__check:hover { border-color: var(--ok); background: var(--ok); color: #fff; }
.card__check:active { transform: scale(0.9); }
.card__check:focus-visible { outline: none; border-color: var(--ok); box-shadow: 0 0 0 3px rgba(70, 176, 106, 0.25); }

/* success button — Complete */
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { background: #3c9a5b; border-color: #3c9a5b; }

/* toast action — Undo */
.toast__action {
  margin-left: 12px; padding: 0;
  background: transparent; border: none;
  color: #cfe3ff; font-weight: 700; font-size: 13px;
}
.toast__action:hover { color: #fff; text-decoration: underline; }
