:root {
  --bg: #f3eee6;
  --bg-elev: #fffdf9;
  --col: #e8e0d4;
  --ink: #1c1714;
  --muted: #6d645b;
  --line: #ddd3c4;
  --accent: #e04f1a;
  --accent-ink: #fff8f4;
  --banner: #fff4e5;
  --danger: #9f1239;
  --shadow: 0 12px 32px rgba(62, 38, 16, 0.06);
  --serif: "Nimbus Roman", "Liberation Serif", "Times New Roman", serif;
  --sans: "iA Writer Quattro S", "Liberation Sans", "Noto Sans", system-ui, sans-serif;
  color-scheme: light;
  --spark: #e04f1a;
  --shape: #1d4ed8;
  --build: #0f766e;
  --shipped: #3f6212;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --bg-elev: #221f1b;
    --col: #1b1916;
    --ink: #f4ece3;
    --muted: #b5aa9e;
    --line: #3c352d;
    --accent: #ff7a45;
    --accent-ink: #1c0f0a;
    --banner: #2c241b;
    --danger: #fda4af;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
    --spark: #ff7a45;
    --shape: #93c5fd;
    --build: #5eead4;
    --shipped: #bef264;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  background:
    radial-gradient(880px 260px at 0% -8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 58%),
    var(--bg);
}

.wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.brand { display: flex; gap: 12px; align-items: center; }

.brand img { width: 36px; height: 36px; border-radius: 9px; }

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

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

.search input,
input,
textarea,
select,
button,
.btn {
  font: inherit;
  color: inherit;
}

.search input,
#title,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
}

textarea { resize: vertical; min-height: 72px; }

.search input { width: 11rem; }

button,
.btn {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 0 14px;
  cursor: pointer;
}

button.primary,
#composer button[type="submit"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

button.danger { color: var(--danger); }

.file { position: relative; display: inline-flex; align-items: center; }

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

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

#composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  margin-bottom: 4px;
}

#title { grid-column: 1; grid-row: 1; }

#composer button[type="submit"] { grid-column: 2; grid-row: 1; padding-inline: 18px; }

#note-toggle {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 36px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding-inline: 4px;
}

#note { grid-column: 1 / -1; }

.form-error {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-error:empty { display: none; }

.banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--banner);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.banner p { margin: 0; flex: 1 1 200px; }

.banner .link {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.tabs { display: none; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  margin-top: 12px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  padding: 12px;
  border-radius: 18px;
  background: var(--col);
  background: color-mix(in srgb, var(--col) 88%, transparent);
  border-top: 3px solid var(--rail, var(--line));
}

.column[data-col="spark"] { --rail: var(--spark); }
.column[data-col="shape"] { --rail: var(--shape); }
.column[data-col="build"] { --rail: var(--build); }
.column[data-col="shipped"] { --rail: var(--shipped); }

.column.is-drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

.col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 2px 4px 4px;
}

.col-head h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.col-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }

.count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 8px;
  box-shadow: var(--shadow);
  cursor: grab;
}

.card:hover { border-color: color-mix(in srgb, var(--rail, var(--accent)) 55%, var(--line)); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.45; }

.card h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card .note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-actions { display: flex; justify-content: space-between; gap: 8px; }

.card-actions button {
  min-height: 36px;
  padding-inline: 10px;
  background: transparent;
  font-size: 0.82rem;
}

.empty {
  margin: 0;
  padding: 16px 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.empty-all {
  grid-column: 1 / -1;
  margin: 24px 0;
  text-align: center;
  color: var(--muted);
}

.status, .keys {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.status.is-bad { color: var(--danger); }
.keys { margin-top: 4px; }

dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(20, 16, 12, 0.48); }

dialog h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
}

dialog label { display: block; margin: 10px 0 4px; font-size: 0.85rem; color: var(--muted); }

.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.grow { flex: 1; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.noscript {
  margin: 16px;
  padding: 12px;
  background: var(--banner);
}

@media (max-width: 800px) {
  .wrap { width: min(100% - 24px, 720px); padding-top: 16px; }
  .brand h1 { font-size: 1.7rem; }
  .search { flex: 1 1 140px; }
  .search input { width: 100%; }
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
  .tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 6px 4px;
    border-radius: 12px;
    font-size: 0.78rem;
  }
  .tabs button em { font-style: normal; color: var(--muted); font-size: 0.75rem; }
  .tabs button.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .tabs button.is-on em { color: inherit; }
  .board { grid-template-columns: 1fr; }
  .column { display: none; }
  .column.is-on { display: flex; }
  .card-actions button { min-height: 44px; flex: 1; }
  .keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
