/* ============================================================
   Light Kanban — Operate-mode design system
   One accent (iris), warm-neutral canvas, drawn depth, themed
   browser surfaces. Space Grotesk (display) / Inter Tight (UI)
   / IBM Plex Mono (data).
   ============================================================ */
:root {
  --font-display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --pane: #eef0f4;
  --pane-head: #e7e9ef;
  --border: #e5e7ec;
  --border-strong: #d6d9e0;
  --ink: #1a1c22;
  --muted: #565c67;   /* ~6.3:1 on canvas */
  --faint: #6b7079;   /* ~4.5:1 on canvas — safe for placeholders/timestamps */

  --accent: #5b5bd6;
  --accent-hover: #4a4ac4;
  --accent-soft: #edecfb;
  --accent-ink: #3b39b0;

  --danger: #dc3d43;
  --danger-soft: #fcebec;
  --success: #2f9e6b;
  --warn: #c77d1a;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;

  --sh-1: 0 1px 2px rgba(24, 27, 34, .06), 0 1px 1px rgba(24, 27, 34, .04);
  --sh-2: 0 2px 4px rgba(24, 27, 34, .07), 0 4px 12px rgba(24, 27, 34, .06);
  --sh-3: 0 12px 28px rgba(24, 27, 34, .16), 0 4px 10px rgba(24, 27, 34, .10);
  --sh-drag: 0 16px 32px rgba(24, 27, 34, .24), 0 3px 8px rgba(24, 27, 34, .14);

  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* Dark tokens apply when the OS is dark (unless the user forced light),
   and always when the user explicitly forces dark via the top-bar toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151a;
    --surface: #1d1f26;
    --pane: #191b21;
    --pane-head: #21242c;
    --border: #2b2e37;
    --border-strong: #3a3e49;
    --ink: #eceef3;
    --muted: #a7adb9;
    --faint: #838a97;
    --accent: #8b8bf0;
    --accent-hover: #9d9df4;
    --accent-soft: #26264a;
    --accent-ink: #b9b9f7;
    --danger: #f16a6f;
    --danger-soft: #3a2224;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .45);
    --sh-3: 0 14px 32px rgba(0, 0, 0, .6);
    --sh-drag: 0 16px 34px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  --bg: #14151a;
  --surface: #1d1f26;
  --pane: #191b21;
  --pane-head: #21242c;
  --border: #2b2e37;
  --border-strong: #3a3e49;
  --ink: #eceef3;
  --muted: #a7adb9;
  --faint: #838a97;
  --accent: #8b8bf0;
  --accent-hover: #9d9df4;
  --accent-soft: #26264a;
  --accent-ink: #b9b9f7;
  --danger: #f16a6f;
  --danger-soft: #3a2224;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 2px 6px rgba(0, 0, 0, .45);
  --sh-3: 0 14px 32px rgba(0, 0, 0, .6);
  --sh-drag: 0 16px 34px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; }

/* themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ── loading ── */
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 22vh 20px; color: var(--muted); font-family: var(--font-mono); font-size: 12px;
  letter-spacing: .08em; text-transform: uppercase; }
.spinner { width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── buttons ── */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  padding: 8px 15px; border-radius: var(--radius-sm); font: 500 13px var(--font-sans);
  display: inline-flex; align-items: center; gap: 6px; transition: background .14s, border-color .14s, box-shadow .14s, transform .06s;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 5%, var(--surface)); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--sh-1); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }

/* ── inputs ── */
input, textarea, select {
  font: inherit; width: 100%; padding: 9px 11px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); transition: border-color .14s, box-shadow .14s;
  caret-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
label.field { display: block; margin: 14px 0 5px; font-weight: 500; font-size: 12px;
  letter-spacing: .01em; color: var(--muted); }
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
.error { color: var(--danger); margin: 8px 0; font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 11px 22px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; white-space: nowrap; }
.topbar > a.crumb, .topbar .btn { flex-shrink: 0; }
.topbar .spacer { flex: 1; }
.crumb { color: var(--muted); }
.crumb:hover { color: var(--ink); text-decoration: none; }
.crumb-sep { color: var(--faint); }
.crumb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ── auth ── */
.auth-wrap { max-width: 384px; margin: 9vh auto; padding: 34px 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--sh-2); animation: rise .5s var(--ease) both; }
.auth-wrap h2 { margin: 0; font-size: 24px; }
.auth-wrap > p { margin: 4px 0 18px; color: var(--muted); }
.auth-wrap .switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ── board list ── */
.list-head { padding: 30px 26px 6px; }
.list-head h2 { margin: 0; font-size: 22px; }
.list-head p { margin: 4px 0 0; color: var(--muted); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px; padding: 18px 26px 32px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--sh-1); cursor: pointer; position: relative; overflow: hidden;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s; }
.board-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); border-color: var(--accent); }
.board-card h3 { margin: 0 0 6px; font-size: 16px; }
.board-card p { margin: 0; color: var(--muted); font-size: 13px; }
.board-card .stat { margin-top: 12px; font-family: var(--font-mono); font-size: 11px;
  color: var(--faint); letter-spacing: .03em; }
.board-card.add { display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); border-style: dashed; box-shadow: none; background: transparent; font-weight: 500; }
.board-card.add:hover { color: var(--accent-ink); border-color: var(--accent); transform: none; }
.board-card.add::before { display: none; }

/* ── board toolbar ── */
.board-toolbar { display: flex; gap: 9px; align-items: center; padding: 14px 22px; flex-wrap: wrap; }
.board-toolbar .search { max-width: 230px; }
.board-toolbar select { width: auto; }

/* ── columns ── */
.columns { display: flex; gap: 14px; padding: 2px 22px 26px; align-items: flex-start;
  overflow-x: auto; height: calc(100vh - 128px); }
.column { background: var(--pane); border: 1px solid var(--border); border-radius: var(--radius);
  width: 296px; flex: 0 0 296px; display: flex; flex-direction: column; max-height: 100%;
  animation: rise .4s var(--ease) both; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.column-head .name { font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  letter-spacing: -0.01em; flex: 1; }
.column-head .name-input { flex: 1; padding: 3px 6px; font: 600 13.5px var(--font-display); }
.column-head .count { font-family: var(--font-mono); color: var(--muted); font-size: 11px;
  background: var(--pane-head); padding: 1px 7px; border-radius: 20px; }
.column-head .col-del { opacity: 0; transition: opacity .14s; }
.column:hover .col-del { opacity: 1; }
.card-list { padding: 4px 10px 6px; overflow-y: auto; flex: 1; min-height: 12px; }
.card-list.empty-hint { position: relative; }
.card-list.empty-hint::after { content: "Drop cards here"; display: block; text-align: center;
  color: var(--faint); font-size: 12px; padding: 14px 0; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); margin: 2px; }
.column-foot { padding: 4px 10px 10px; }
.column-foot .add-card-btn { width: 100%; justify-content: flex-start; color: var(--muted); }
.add-column { flex: 0 0 232px; }
.add-column .btn { width: 100%; justify-content: center; border-style: dashed; color: var(--muted); background: transparent; }
.add-column .btn:hover { color: var(--accent-ink); border-color: var(--accent); }

/* card composer (inline) */
.composer textarea { min-height: 62px; margin-bottom: 6px; box-shadow: var(--sh-1); }
.composer .row { display: flex; gap: 6px; }

/* ── card ── */
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--sh-1); cursor: pointer;
  transition: box-shadow .15s var(--ease), transform .1s var(--ease), border-color .15s;
  animation: cardin .32s var(--ease) both; }
@keyframes cardin { from { opacity: 0; transform: translateY(6px); } }
.kcard:hover { box-shadow: var(--sh-2); border-color: var(--border-strong); transform: translateY(-1px); }
.kcard .title { font-weight: 500; line-height: 1.4; }
.kcard .labels { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.project-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.project-badge .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.theme-toggle { font-size: 15px; line-height: 1; padding: 6px 9px; }
.status-badge { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px;
  letter-spacing: .02em; display: inline-block; }
.status-badge.active { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.status-badge.pending { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.chip { font-size: 11px; padding: 2px 9px; border-radius: 20px; color: #fff; font-weight: 600;
  letter-spacing: .02em; line-height: 1.5; }
.kcard .meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.kcard .meta .spacer { flex: 1; }
.avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
  font-family: var(--font-sans); flex: none; }
.due { font-family: var(--font-mono); font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--pane-head); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.due.overdue { background: var(--danger-soft); color: var(--danger); }
.sortable-ghost { opacity: 0; }
.sortable-drag, .kcard.sortable-chosen { box-shadow: var(--sh-drag) !important; }
.column.sortable-ghost { opacity: .35; }

/* ── modal ── */
.overlay { position: fixed; inset: 0; background: rgba(20, 21, 28, .5);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 50; overflow-y: auto; animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 660px; box-shadow: var(--sh-3); animation: pop .28s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 20px 22px 6px; }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-head input { border: 1px solid transparent; background: transparent; font: 600 18px var(--font-display);
  letter-spacing: -0.02em; padding: 5px 8px; margin: -5px -8px; }
.modal-head input:hover { border-color: var(--border); }
.modal-body { padding: 6px 22px 22px; }
.modal-body .cols { display: grid; grid-template-columns: 1fr 172px; gap: 20px; }
.close { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--faint);
  cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.close:hover { background: var(--pane-head); color: var(--ink); }

.timeline { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.event { display: flex; gap: 9px; margin-bottom: 12px; font-size: 13px; align-items: flex-start; }
.event .who { font-weight: 600; }
.event.activity { color: var(--muted); align-items: center; }
.event.activity .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong);
  margin: 0 8px 0 8px; flex: none; }
.event .when { color: var(--faint); font-size: 11px; font-family: var(--font-mono); }
.comment-box { display: flex; gap: 8px; margin-top: 12px; }

.settings-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row .grow { flex: 1; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
section.board-card { animation: none; }
section.board-card h3 { font-size: 16px; margin: 0 0 4px; }
table th { font-family: var(--font-sans); font-weight: 600; }

/* ── empty states ── */
.empty { text-align: center; padding: 12vh 20px; color: var(--muted); }
.empty h3 { font-size: 18px; margin: 0 0 6px; color: var(--ink); }
.empty p { margin: 0 0 18px; }

/* ── toast ── */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--sh-3); font-size: 13px; font-weight: 500; max-width: 90vw;
  animation: toastin .3s var(--ease) both; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(14px); } }

/* ── responsive ── */
@media (max-width: 640px) {
  .topbar { padding: 9px 12px; gap: 6px; flex-wrap: nowrap; }
  .topbar h1 { font-size: 15px; }
  .topbar .user-name { display: none; }
  .topbar .btn.small { padding: 5px 9px; }
  .board-grid { grid-template-columns: 1fr; padding: 14px 12px 28px; }
  .list-head { padding: 20px 12px 4px; }
  .board-toolbar { padding: 10px 12px; gap: 8px; row-gap: 8px; }
  .board-toolbar .search { max-width: none; flex: 1 1 100%; order: -1; }
  .board-toolbar select { flex: 1 1 40%; }
  .board-toolbar > .spacer { display: none; }
  .board-toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .columns { padding: 2px 12px 20px; height: auto; min-height: calc(100dvh - 150px);
    scroll-snap-type: x proximity; }
  .column { width: 86vw; flex-basis: 86vw; max-height: none; scroll-snap-align: start; }
  .card-list { overflow-y: visible; }
  .modal { border-radius: 12px; }
  .modal-body .cols { grid-template-columns: 1fr; gap: 8px; }
  .auth-wrap { margin: 5vh auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
