:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --faint: rgba(0, 0, 0, 0.28);
  --track: rgba(120, 120, 128, 0.12);
  --hairline: rgba(0, 0, 0, 0.05);
  --thumb: #ffffff;
  --thumb-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  --card: #ffffff;
  --card-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --card-shadow-hover: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.09);
  --ring: rgba(0, 0, 0, 0.22);
  --drop: rgba(0, 122, 255, 0.08);
  --accent: #007aff;
  --danger: #ff3b30;
  --hue: 240;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: 0; }

.glow {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  filter: blur(40px);
  background: radial-gradient(45% 40% at 50% 10%, hsla(var(--hue), 85%, 62%, 0.2), transparent 70%);
  transition: background 1.2s ease;
}

main {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 20px;
}

/* ---------- pill-элементы ---------- */
.pills {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 100px;
  background: var(--track);
  box-shadow: inset 0 0 0 0.5px var(--hairline);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none;
  appearance: none;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.006em;
  padding: 7px 16px;
  border-radius: 100px;
  cursor: pointer;
  opacity: 0.5;
  white-space: nowrap;
  transition: opacity 0.25s, background 0.25s, box-shadow 0.25s;
}
.pill:hover { opacity: 0.75; }
.pill[aria-pressed="true"] { opacity: 1; background: var(--thumb); box-shadow: var(--thumb-shadow); }
.pills input {
  flex: none;
  width: 120px;
  border: 0;
  outline: 0;
  background: none;
  font-size: 13px;
  padding: 7px 14px;
  caret-color: var(--accent);
}
.pills input::placeholder { color: var(--faint); }
.pills.small .pill { font-size: 12px; padding: 5px 12px; }
.pills.small input { font-size: 12px; padding: 5px 12px; width: 130px; }
.pill .x, .menu .x { margin-left: 6px; color: var(--muted); }
.pill .x:hover, .menu button:hover .x { color: var(--danger); }

/* ---------- вход ---------- */
.auth {
  margin: auto;
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 8vh;
}
.auth h1 { margin: 0 0 6px; font-size: 30px; font-weight: 600; letter-spacing: -0.028em; }
.auth form { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.field {
  width: 100%;
  border: 0;
  outline: 0;
  border-radius: 14px;
  background: var(--track);
  padding: 12px 16px;
  font-size: 15px;
  letter-spacing: -0.012em;
  caret-color: var(--accent);
  transition: box-shadow 0.2s;
}
.field:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.field::placeholder { color: var(--faint); }
.primary {
  appearance: none;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary:hover { opacity: 0.88; }
.primary:disabled { opacity: 0.5; cursor: default; }
.error { min-height: 16px; font-size: 12px; color: var(--danger); text-align: center; }

/* ---------- шапка ---------- */
.top {
  flex: none;
  width: min(1180px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 34px;
}
.top .pills { max-width: calc(100% - 220px); }
.me {
  position: absolute;
  right: 0;
  top: 2px;
}
.me > button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 100px;
  cursor: pointer;
}
.me > button:hover { color: var(--text); background: var(--track); }
.menu {
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 5;
  width: 250px;
  padding: 8px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 12px 36px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.menu button {
  appearance: none;
  border: 0;
  background: none;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.menu button:hover { background: var(--track); }
.menu button.danger { color: var(--danger); }
.menu .hint { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); }
.menu code {
  display: block;
  padding: 4px 10px 8px;
  font: 13px ui-monospace, SFMono-Regular, Consolas, monospace;
  user-select: all;
  overflow-wrap: anywhere;
}
.menu .field { font-size: 13px; padding: 8px 10px; border-radius: 8px; margin: 2px 0; }
.menu hr { width: 100%; border: 0; border-top: 0.5px solid rgba(0, 0, 0, 0.1); margin: 4px 0; }

/* ---------- идея ---------- */
.stage {
  flex: none;
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 0 22px;
}
.stage label {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-align: center;
}
.stage label:not(:first-child) { margin-top: 16px; }
.stage textarea {
  display: block;
  width: 100%;
  max-height: 26vh;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: none;
  caret-color: var(--accent);
  text-align: center;
  text-wrap: balance;
}
.stage textarea::placeholder { color: var(--faint); }
.stage .do { font-size: clamp(24px, 3vw, 36px); line-height: 1.12; letter-spacing: -0.024em; font-weight: 600; }
.stage .see { font-size: clamp(15px, 1.6vw, 18px); line-height: 1.3; letter-spacing: -0.014em; font-weight: 500; overflow-y: auto; }
.empty { margin: auto; padding-bottom: 12vh; text-align: center; color: var(--muted); font-size: 15px; }

.dirs { flex: none; margin-bottom: 18px; max-width: 100%; }

/* ---------- доска ---------- */
.board {
  flex: 1;
  min-height: 0;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 20px;
  overflow: auto;
  padding: 4px 4px 16px;
  scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 18px;
  padding: 6px;
  transition: background 0.2s;
}
.col.over { background: var(--drop); }
.col h2 {
  margin: 0;
  padding: 4px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.006em;
  display: flex;
  justify-content: space-between;
}
.col h2 span { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 8px; }

.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: -0.012em;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.25s, opacity 0.2s;
}
.card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
.card.dragging { opacity: 0.35; }
.card.before { box-shadow: var(--card-shadow), 0 -2px 0 0 var(--accent); }
.card .check {
  flex: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  padding: 0;
  border: 1.5px solid var(--ring);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.card .check:hover { border-color: var(--accent); }
.col[data-col="doing"] .card .check { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 38%, transparent 44%); }
.card .body { flex: 1; min-width: 0; }
.card .label { outline: 0; overflow-wrap: anywhere; }
.card .sub { margin-top: 3px; font-size: 12px; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }
.card .sub.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: pre-line;
}
.card .meta { margin-top: 6px; font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.card .tag { color: var(--accent); }
.card.open, .col[data-col="done"] .card.open {
  cursor: default;
  transform: none;
  padding: 12px 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 12px 36px rgba(0, 0, 0, 0.14);
}
.card.open .label { font-weight: 600; cursor: text; }
.card .note {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: none;
  caret-color: var(--accent);
  font-size: 13px;
  line-height: 1.4;
}
.card .note::placeholder { color: var(--faint); }
.card .row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card select {
  appearance: none;
  border: 0;
  outline: 0;
  border-radius: 100px;
  background: var(--track);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  max-width: 100%;
}
.card .remove {
  appearance: none;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
}
.card .remove:hover { text-decoration: underline; }
.col[data-col="done"] .card { color: var(--muted); box-shadow: none; background: none; padding-block: 8px; }
.col[data-col="done"] .card .check { background: var(--muted); border-color: var(--muted); }
.col[data-col="done"] .card .sub, .col[data-col="done"] .card:not(.open) .meta { display: none; }

.add {
  margin-top: 8px;
  padding: 10px 14px;
  border: 0;
  outline: 0;
  border-radius: 14px;
  background: none;
  caret-color: var(--accent);
  font-size: 15px;
  letter-spacing: -0.012em;
  transition: background 0.2s;
}
.add::placeholder { color: var(--faint); }
.add:hover, .add:focus { background: var(--track); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 100px;
  background: #1d1d1f;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

@media (max-width: 720px) {
  main { padding: 16px 12px 12px; }
  .top { flex-direction: column; gap: 8px; }
  .top .pills { max-width: 100%; }
  .me { position: static; }
  .menu { right: auto; left: 50%; transform: translateX(-50%); top: auto; }
  .board { grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 10px; }
  .stage { padding: 16px 0 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .glow, .pill, .card { transition: none; }
}
.card textarea.label { margin: 0; font-size: 15px; line-height: 1.3; font-weight: 600; }
