/* ==========================================================================
   Offline Kanban — design system
   Warm paper light theme / deep ink dark theme, per-column accents,
   tactile cards, legible drag motion. No web fonts, no remote assets.
   ========================================================================== */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f1ea;
  --bg-grain: #ece8de;
  --panel: #fbf9f4;
  --column: #efece3;
  --card: #ffffff;
  --inset: #f3f0e8;
  --ink: #262a31;
  --ink-2: #5c6470;
  --ink-3: #8b93a0;
  --line: #e2ddcf;
  --line-strong: #cfc9b8;
  --accent: #c96f4a;
  --accent-soft: #c96f4a26;
  --accent-ink: #ffffff;
  --danger: #b3452f;
  --danger-soft: #b3452f1f;
  --ok: #4f7d52;
  --warn: #9a7020;
  --ring: #c96f4a66;
  --shadow-1: 0 1px 2px rgba(38, 42, 49, 0.06), 0 1px 6px rgba(38, 42, 49, 0.05);
  --shadow-2: 0 4px 10px rgba(38, 42, 49, 0.09), 0 12px 32px rgba(38, 42, 49, 0.12);
  --shadow-drag: 0 18px 40px rgba(38, 42, 49, 0.28);

  --acc-terra: #c96f4a;
  --acc-olive: #7d8b52;
  --acc-slate: #5b7d9d;
  --acc-plum: #8f6a9e;
  --acc-amber: #bd8f3c;
  --acc-teal: #459484;

  --radius-s: 7px;
  --radius-m: 10px;
  --radius-l: 14px;
  --speed: 160ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #15181e;
  --bg-grain: #101318;
  --panel: #1c2028;
  --column: #1a1e25;
  --card: #22262f;
  --inset: #191d24;
  --ink: #e8e6df;
  --ink-2: #a8aeb8;
  --ink-3: #767d89;
  --line: #2b303a;
  --line-strong: #3a4150;
  --accent: #d98a63;
  --accent-soft: #d98a6329;
  --accent-ink: #221a14;
  --danger: #e07a5f;
  --danger-soft: #e07a5f26;
  --ok: #7db884;
  --warn: #d3a94c;
  --ring: #d98a6377;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 6px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 10px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-drag: 0 18px 40px rgba(0, 0, 0, 0.6);

  --acc-terra: #d98a63;
  --acc-olive: #a3b273;
  --acc-slate: #7fa5c4;
  --acc-plum: #b292c0;
  --acc-amber: #d4a95c;
  --acc-teal: #6cb5a4;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--bg-grain), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

:focus { outline: none; }

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

.hidden { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

::selection { background: var(--accent-soft); }

/* ---------- header ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 5;
  flex-wrap: wrap;
}

.brand {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 72%, #000 12%));
  box-shadow: var(--shadow-1);
  flex: none;
}

.board-id {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-right: auto;
}

.board-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(46vw, 460px);
  padding: 3px 8px 3px 6px;
  margin-left: -6px;
  border-radius: var(--radius-s);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.012em;
  color: var(--ink);
  transition: background var(--speed) var(--ease);
}

.board-title:hover { background: var(--accent-soft); }
.board-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-title .kb-icon { opacity: 0.45; }

.board-subtitle {
  font-size: 12px;
  color: var(--ink-3);
  padding-left: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-weight: 560;
  font-size: 13.5px;
  box-shadow: var(--shadow-1);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
    background var(--speed) var(--ease), border-color var(--speed) var(--ease);
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); box-shadow: none; }

.btn-primary {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #000));
  border-color: color-mix(in srgb, var(--accent) 75%, #000);
  color: var(--accent-ink);
}

.btn-primary:hover { filter: brightness(1.05); border-color: color-mix(in srgb, var(--accent) 60%, #000); }

.btn-ghost-danger {
  color: var(--danger);
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}
.btn-ghost-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn.btn-disabled-look { opacity: 0.55; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-m);
  border: 1px solid transparent;
  color: var(--ink-2);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
    transform var(--speed) var(--ease);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--ink);
  transform: translateY(-1px);
}

.icon-btn:active { transform: scale(0.94); }

/* ---------- save status ---------- */

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.save-status .kb-icon { color: var(--ok); }

.save-status.save-error { color: var(--danger); border-color: var(--danger); }
.save-status.save-error .kb-icon { color: var(--danger); }

.save-pulse { animation: save-pulse 480ms var(--ease); }

@keyframes save-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  60% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- storage banner ---------- */

.storage-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 18px 0;
  padding: 10px 14px;
  border-radius: var(--radius-m);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  color: var(--ink);
  font-size: 13px;
}

.storage-banner .kb-icon { color: var(--warn); flex: none; }
.storage-banner-text { flex: 1; }

/* ---------- board ---------- */

.board-region {
  flex: 1;
  min-height: 0;
  display: flex;
}

.board-scroller {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 18px 18px;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.board-scroller::-webkit-scrollbar { height: 10px; }
.board-scroller::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.board-scroller::-webkit-scrollbar-track { background: transparent; }

.board-columns {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  height: 100%;
  width: max-content;
  min-width: 100%;
}

/* ---------- column ---------- */

.column {
  display: flex;
  flex-direction: column;
  width: clamp(272px, 25vw, 336px);
  min-height: 180px;
  max-height: 100%;
  background: linear-gradient(180deg, var(--column), color-mix(in srgb, var(--column) 92%, var(--bg)));
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.column.drop-target {
  border-color: var(--acc, var(--accent));
  box-shadow: inset 0 0 0 1px var(--acc, var(--accent)), var(--shadow-1);
}

.column.drop-target-cross {
  border-color: var(--acc, var(--accent));
  box-shadow:
    inset 0 0 0 1px var(--acc, var(--accent)),
    0 0 0 4px color-mix(in srgb, var(--acc, var(--accent)) 28%, transparent),
    var(--shadow-1);
}

.accent-terra { --acc: var(--acc-terra); }
.accent-olive { --acc: var(--acc-olive); }
.accent-slate { --acc: var(--acc-slate); }
.accent-plum { --acc: var(--acc-plum); }
.accent-amber { --acc: var(--acc-amber); }
.accent-teal { --acc: var(--acc-teal); }

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 10px 9px 14px;
  cursor: grab;
  touch-action: none;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.column-head:active { cursor: grabbing; }

.column-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--acc, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc, var(--accent)) 20%, transparent);
  flex: none;
}

.column-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 13.5px;
  font-weight: 680;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 3px 6px;
  border-radius: 6px;
}

.column-title:hover { background: var(--accent-soft); color: var(--ink); }
.column-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.column-count {
  flex: none;
  min-width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--line) 55%, transparent);
}

.column-quick-add { width: 28px; height: 28px; }
.column-head .icon-btn { width: 28px; height: 28px; }

.column-cards {
  flex: 1;
  min-height: 64px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.column-empty {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-m);
  padding: 18px 14px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.column-foot { padding: 8px 10px 10px; }

.column-add-card {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-m);
  color: var(--ink-3);
  font-weight: 550;
  font-size: 13.5px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.column-add-card:hover { background: var(--accent-soft); color: var(--ink); }

/* add column */

.column-add-wrap { display: flex; height: 100%; }

.column-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 260px;
  min-height: 120px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-l);
  color: var(--ink-3);
  font-weight: 560;
  transition: all var(--speed) var(--ease);
}

.column-add:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.column-composer {
  width: 260px;
  padding: 14px;
  gap: 10px;
  border-color: var(--accent);
}

.column-composer-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.column-composer-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-m);
  border: 1.5px solid var(--accent);
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

/* ---------- cards ---------- */

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 10px 12px 11px;
  box-shadow: var(--shadow-1);
  cursor: grab;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  transition: box-shadow var(--speed) var(--ease), transform var(--speed) var(--ease),
    border-color var(--speed) var(--ease);
}

.card:hover {
  border-color: color-mix(in srgb, var(--acc, var(--accent)) 55%, var(--line));
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.card:focus-visible {
  outline: 2px solid var(--acc, var(--accent));
  outline-offset: 2px;
}

.card:active { cursor: grabbing; }

.card-face {
  font-size: 13.5px;
  max-height: 12.5rem;
  overflow: hidden;
  position: relative;
}

.card-face.is-clamped::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2.6rem;
  background: linear-gradient(180deg, transparent, var(--card) 78%);
  pointer-events: none;
}

.card-tools {
  position: absolute;
  top: 7px; right: 7px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.card:hover .card-tools,
.card:focus-within .card-tools { opacity: 1; transform: translateY(0); }

.card-tools .icon-btn {
  width: 26px; height: 26px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(4px);
}

.card-tools .card-tool-delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.card-tasks {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.task-bar {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  overflow: hidden;
}

.task-bar-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--acc, var(--accent)), color-mix(in srgb, var(--acc, var(--accent)) 70%, var(--ok)));
  transition: width 300ms var(--ease);
}

.card-tasks-count {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.flip-enter { animation: card-enter 320ms var(--ease); }

@keyframes card-enter {
  0% { opacity: 0; transform: translateY(6px) scale(0.97); }
  100% { opacity: 1; transform: none; }
}

/* ---------- card composer ---------- */

.card-composer {
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-m);
  padding: 8px;
  box-shadow: var(--shadow-2);
  animation: card-enter 200ms var(--ease);
}

.card-composer-input {
  width: 100%;
  min-height: 58px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 4px 6px;
}

.card-composer-input:focus { outline: none; }

.card-composer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.card-composer-hint {
  margin-top: 7px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}

/* ---------- inline inputs ---------- */

.inline-input {
  width: 100%;
  min-width: 120px;
  padding: 2px 6px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
}

/* ---------- hero (empty board) ---------- */

.hero-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.hero {
  max-width: 460px;
  text-align: center;
  padding: 36px 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
  animation: card-enter 360ms var(--ease);
}

.hero-mark {
  display: grid;
  place-items: center;
  width: 62px; height: 62px;
  margin: 0 auto 18px;
  border-radius: 18px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000 15%));
  box-shadow: var(--shadow-2);
}

.hero-title {
  margin: 0 0 10px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.hero-copy {
  margin: 0 0 22px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-footnote {
  margin: 20px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

/* ---------- markdown ---------- */

.md { font-size: inherit; color: inherit; }

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }

.md p { margin: 0 0 0.5em; }

.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 0.75em 0 0.35em;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.md h1 { font-size: 1.16em; }
.md h2 { font-size: 1.09em; }
.md h3 { font-size: 1.03em; }
.md h4 { font-size: 1em; }
.md h5, .md h6 { font-size: 0.95em; color: var(--ink-2); }

.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }

.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.34em;
  word-break: break-word;
}

.md-code {
  position: relative;
  margin: 0.6em 0;
}

.md-code pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow-x: auto;
}

.md-code pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.84em;
  line-height: 1.55;
  white-space: pre;
}

.md-code-lang {
  position: absolute;
  top: -8px;
  right: 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0 7px;
}

.md-code-open::after {
  content: "unclosed";
  position: absolute;
  bottom: -8px;
  left: 10px;
  font-size: 9.5px;
  color: var(--ink-3);
  background: var(--card);
  padding: 0 5px;
}

.md blockquote {
  margin: 0.55em 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--acc, var(--accent));
  color: var(--ink-2);
}

.md ul, .md ol {
  margin: 0.3em 0 0.6em;
  padding-left: 1.35em;
}

.md li { margin: 0.14em 0; }

.md ul.md-task-list, .md li.md-flat { list-style: none; }

.md li.md-task {
  list-style: none;
  margin-left: -1.25em;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.md li.md-task.done > :not(.md-check) { opacity: 0.55; }

.md-check {
  appearance: none;
  -webkit-appearance: none;
  width: 15px; height: 15px;
  margin: 3px 0 0;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-radius: 4.5px;
  background: var(--card);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  position: relative;
}

.md-check:hover { border-color: var(--acc, var(--accent)); }

.md-check:checked {
  background: var(--acc, var(--accent));
  border-color: var(--acc, var(--accent));
}

.md-check:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.md-check:disabled { cursor: default; opacity: 0.6; }

.md a {
  color: var(--acc, var(--accent));
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--acc, var(--accent)) 40%, transparent);
  word-break: break-word;
}

.md a:hover { border-bottom-color: var(--acc, var(--accent)); }

.md-link-unsafe {
  border-bottom: 1px dotted var(--ink-3);
  cursor: help;
}

.md hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.7em 0;
}

.md del { color: var(--ink-3); }

/* ---------- drag & drop ---------- */

body.is-dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

body.is-dragging .card:hover { transform: none; }

.drag-ghost-wrap {
  position: fixed;
  left: 0; top: 0;
  z-index: 1000;
  pointer-events: none;
  will-change: transform;
}

.drag-ghost {
  transform: rotate(1.6deg) scale(1.03);
  box-shadow: var(--shadow-drag);
  opacity: 0.96;
  border-radius: var(--radius-m);
  overflow: hidden;
  max-height: 60vh;
  overflow-y: hidden;
}

.drag-ghost .column-cards { max-height: 34vh; overflow: hidden; }
.drag-ghost .card-tools, .drag-ghost .column-add-card, .drag-ghost .column-foot { display: none; }

.drag-placeholder {
  border-radius: var(--radius-m);
  border: 2px dashed var(--acc, var(--accent));
  background:
    linear-gradient(color-mix(in srgb, var(--acc, var(--accent)) 12%, transparent), transparent);
  animation: placeholder-in 180ms var(--ease);
  flex: none;
}

.drag-placeholder-column {
  border-radius: var(--radius-l);
  width: clamp(272px, 25vw, 336px);
  min-height: 160px;
  height: auto !important;
}

@keyframes placeholder-in {
  0% { opacity: 0; transform: scale(0.97); }
  100% { opacity: 1; transform: none; }
}

.drag-source { display: none; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1200;
  pointer-events: none;
  width: min(94vw, 560px);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px 10px 14px;
  border-radius: var(--radius-m);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  animation: toast-in 220ms var(--ease);
}

.toast .kb-icon { color: var(--ok); flex: none; }
.toast-message { flex: 1; min-width: 0; }

.toast-warn .kb-icon { color: var(--warn); }
.toast-error .kb-icon { color: var(--danger); }
.toast-error { border-color: var(--danger); }

.toast-action {
  flex: none;
  font-weight: 680;
  color: var(--accent);
  padding: 5px 10px;
  border-radius: var(--radius-s);
}

.toast-action:hover { background: var(--accent-soft); }

.toast-dismiss { width: 26px; height: 26px; color: var(--ink-3); }

.toast-out { opacity: 0; transform: translateY(6px); transition: all 160ms var(--ease); }

@keyframes toast-in {
  0% { opacity: 0; transform: translateY(10px) scale(0.98); }
  100% { opacity: 1; transform: none; }
}

/* ---------- modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 27, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 900;
  opacity: 0;
  transition: opacity 140ms var(--ease);
}

.modal-overlay.modal-in { opacity: 1; }

.modal {
  width: min(560px, 100%);
  max-height: min(86dvh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-drag);
  transform: translateY(8px) scale(0.985);
  transition: transform 160ms var(--ease);
  outline: none;
}

.modal-overlay.modal-in .modal { transform: none; }

.modal-wide, .modal-card { width: min(860px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head .kb-icon { color: var(--accent); }

.modal-title {
  margin: 0;
  font-size: 16.5px;
  letter-spacing: -0.01em;
  flex: 1;
}

.modal > .confirm-body,
.modal > .import-body,
.modal > .export-body,
.modal > .help-body,
.modal > .card-detail {
  padding: 16px 18px;
  overflow-y: auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

.modal-foot-spacer { flex: 1; }

.confirm-message { margin: 0 0 6px; font-size: 14px; }
.confirm-detail { margin: 0; font-size: 12.5px; color: var(--ink-3); }

/* ---------- segmented ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-m);
  background: var(--inset);
  border: 1px solid var(--line);
}

.seg-button {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 620;
  color: var(--ink-2);
  transition: all var(--speed) var(--ease);
}

.seg-button:hover { color: var(--ink); }

.seg-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ---------- menus ---------- */

.menu {
  position: fixed;
  z-index: 1100;
  min-width: 200px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-drag);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transition: opacity 130ms var(--ease), transform 130ms var(--ease);
}

.menu.menu-in { opacity: 1; transform: none; }

.menu-row { display: flex; align-items: center; }

.menu-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  text-align: left;
  color: var(--ink);
}

.menu-item:hover:not([disabled]), .menu-item:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.menu-item[disabled] { opacity: 0.45; cursor: default; }

.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover:not([disabled]) { background: var(--danger-soft); }

.menu-sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--line);
}

.menu-heading {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}

.swatch-row {
  display: flex;
  gap: 8px;
  padding: 8px 10px 10px;
}

.swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--acc);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px var(--panel);
  transition: transform var(--speed) var(--ease), outline-color var(--speed) var(--ease);
}

.swatch:hover { transform: scale(1.12); }

.swatch-active {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* ---------- card detail ---------- */

.card-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 640;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
}

.chip .column-dot { width: 7px; height: 7px; box-shadow: none; }

.card-detail-time {
  font-size: 12px;
  color: var(--ink-3);
}

.card-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-move-select {
  padding: 6px 10px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}

.card-detail-content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px 18px;
  font-size: 14.5px;
  min-height: 120px;
}

.card-detail-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}

.card-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}

.editor-tool {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all var(--speed) var(--ease);
}

.editor-tool:hover { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }
.tool-bold { font-weight: 800; }
.tool-italic { font-style: italic; }
.tool-strike { text-decoration: line-through; }
.tool-heading { font-weight: 800; }
.tool-code { font-family: var(--font-mono); font-size: 11.5px; }

.card-editor-panes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-height: 0;
}

@media (min-width: 900px) {
  .card-editor-panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.card-editor {
  width: 100%;
  min-height: 260px;
  max-height: 52dvh;
  resize: vertical;
  padding: 14px 16px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.card-editor:focus { border-color: var(--accent); outline: none; }

.card-editor-preview {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-m);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-editor-preview-head {
  padding: 6px 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-bottom: 1px dashed var(--line);
  background: var(--inset);
}

.card-editor-preview-body {
  padding: 12px 14px;
  overflow-y: auto;
  font-size: 14px;
  flex: 1;
  max-height: 52dvh;
}

/* ---------- import / export ---------- */

.dialog-copy {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
}

.export-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.export-summary-counts { font-size: 12px; color: var(--ink-3); }

.export-preview {
  width: 100%;
  height: 260px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
}

.import-tabs { margin-bottom: 14px; }

.import-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-l);
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}

.import-dropzone:hover, .import-dropzone.dropzone-hot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.import-dropzone .kb-icon { color: var(--accent); }
.import-dropzone-title { font-weight: 650; font-size: 14px; color: var(--ink); }
.import-dropzone-copy { font-size: 12px; color: var(--ink-3); max-width: 340px; }

.import-paste {
  width: 100%;
  height: 160px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  resize: vertical;
}

.import-paste-row { display: flex; justify-content: flex-end; margin-top: 10px; }

.import-result { margin-top: 14px; }

.import-status {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--inset);
  align-items: flex-start;
}

.import-status-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.import-status-ok .kb-icon { color: var(--ok); }
.import-status-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.import-status-error .kb-icon { color: var(--danger); }
.import-status-copy { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

.import-errors {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.import-errors li {
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-size: 12.5px;
  padding: 8px 11px;
  border-radius: var(--radius-s);
  background: var(--danger-soft);
}

.import-error-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
  border-radius: 5px;
  padding: 1px 6px;
  flex: none;
}

.import-error-more { color: var(--ink-3); background: none; }

.import-preview-columns {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-preview-columns li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
}

.import-column-name { flex: 1; font-weight: 560; }
.import-column-count { font-size: 11.5px; color: var(--ink-3); }
.import-column-more { color: var(--ink-3); background: none; border: none; }

.import-warnings {
  margin: 12px 0 0;
  padding: 10px 12px 10px 28px;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--ink-2);
  font-size: 12px;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ---------- help ---------- */

.help-body h3 {
  margin: 4px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.help-body h3:not(:first-child) { margin-top: 20px; }

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.help-table th {
  text-align: left;
  font-weight: 600;
  padding: 7px 12px 7px 0;
  white-space: nowrap;
  color: var(--ink);
  vertical-align: top;
}

.help-table td {
  padding: 7px 0;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
}

.help-table tr:first-child th, .help-table tr:first-child td { border-top: none; }

.help-table code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
}

.help-footnote { margin-top: 18px; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .btn-label { display: none; }

  .btn { padding: 7px 10px; }

  .app-header { padding: 8px 12px; gap: 8px; }

  .board-title { font-size: 15.5px; max-width: 52vw; }

  .board-subtitle { display: none; }
}

@media (max-width: 719px) {
  .board-scroller {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 90px;
    -webkit-overflow-scrolling: touch;
  }

  .board-columns {
    flex-direction: column;
    width: 100%;
    height: auto;
    align-items: stretch;
  }

  .column {
    width: auto;
    max-height: none;
  }

  .column-cards {
    overflow: visible;
    max-height: none;
  }

  .column-add-wrap { width: 100%; }

  .column-add, .column-composer { width: 100%; min-height: 54px; }

  .modal { width: 100%; }

  .card-face { max-height: 9.5rem; }

  .toasts { bottom: 12px; }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- print (hidden chrome) ---------- */

@media print {
  .app-header, .toasts, .card-tools, .column-foot, .column-add-wrap { display: none !important; }
  .board-scroller { overflow: visible; }
  .board-columns { flex-wrap: wrap; width: auto; height: auto; }
}
