:root {
  --bg: #0e1013;
  --side: #14161b;
  --panel: #17191f;
  --col: #14161b;
  --border: #24272e;
  --fg: #e8eaee;
  --muted: #8b909a;
  --faint: #636874;
  --accent: #8ab4f8;
  --accent-soft: rgba(138, 180, 248, 0.12);
  --todo: #8ab4f8;
  --doing: #fbbf24;
  --done: #34d399;
  --danger: #f0708a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── top bar ─── */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--fg); letter-spacing: -0.01em; }
.brand span { color: var(--accent); }

.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 15px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg button:hover { color: var(--fg); }
.seg button.active { background: var(--accent); color: #0b0d10; font-weight: 600; }

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--faint);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--fg); font: inherit; font-size: 0.88rem; }
.search input::placeholder { color: var(--faint); }

.new {
  background: var(--accent);
  color: #0b0d10;
  border: 0;
  border-radius: 8px;
  padding: 7px 13px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.new:hover { filter: brightness(1.1); }
.count { color: var(--faint); font-size: 0.78rem; white-space: nowrap; }

/* ─── body ─── */
.body { flex: 1; min-height: 0; display: flex; }

.library { display: flex; flex: 1; min-width: 0; min-height: 0; }

/* ─── sidebar ─── */
.sidebar {
  --side-w: 300px;
  width: var(--side-w);
  flex: none;
  position: relative;
  background: var(--side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: width 0.18s ease;
}
.side-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.side-head .new { flex: 1; }
.side-head .icon-btn.on { color: var(--accent); }
.resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
}
.resizer:hover, .resizer.dragging { background: rgba(138, 180, 248, 0.35); }
.sidebar.collapsed { width: 44px; }
.sidebar.collapsed .side-head { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .side-head .new,
.sidebar.collapsed .list,
.sidebar.collapsed .side-foot,
.sidebar.collapsed .resizer { display: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .sidebar { transition: none; }
.list { flex: 1; overflow-y: auto; padding: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--fg);
  transition: background 0.12s ease;
}
.row:hover { background: rgba(255, 255, 255, 0.04); }
.row.active { background: var(--accent-soft); }

.row .dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3e46; flex: none; }
.row .dot[data-color="red"]    { background: #f87171; }
.row .dot[data-color="orange"] { background: #fb923c; }
.row .dot[data-color="yellow"] { background: #fbbf24; }
.row .dot[data-color="green"]  { background: #34d399; }
.row .dot[data-color="teal"]   { background: #2dd4bf; }
.row .dot[data-color="blue"]   { background: #60a5fa; }
.row .dot[data-color="purple"] { background: #a78bfa; }
.row .dot[data-color="pink"]   { background: #f472b6; }

.row .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .t { font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .m { font-size: 0.7rem; color: var(--faint); }
.row .badges { display: flex; gap: 5px; flex: none; }
.row .b { font-size: 0.72rem; opacity: 0.7; }
.row .b.k { color: var(--accent); }

.side-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--faint);
  display: flex;
  gap: 8px;
}
.side-foot a { color: var(--muted); text-decoration: none; }
.side-foot a:hover { color: var(--fg); }

/* ─── editor ─── */
.editor { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.empty-editor { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--faint); gap: 10px; }
.empty-editor .big { font-size: 2.2rem; }
.empty-editor p { font-size: 0.9rem; margin: 0; }
.empty-editor strong { color: var(--muted); }

.editor-inner { flex: 1; display: flex; flex-direction: column; padding: 20px 28px 24px; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }

.toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  padding: 5px 11px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle:hover { color: var(--fg); }
.toggle.on { color: #0b0d10; background: var(--accent); border-color: var(--accent); }

.del { background: transparent; border: 0; color: var(--danger); font: inherit; font-size: 0.82rem; cursor: pointer; padding: 5px 8px; }
.del:hover { text-decoration: underline; }

#title {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font: inherit;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
#content {
  flex: 1;
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: #c6cad2;
  font: inherit;
  font-size: 1rem;
  line-height: 1.7;
}
#title::placeholder, #content::placeholder { color: var(--faint); }
.saved { font-size: 0.74rem; color: var(--faint); min-height: 1.2em; margin-top: 8px; }

/* ─── swatches ─── */
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch { width: 17px; height: 17px; border-radius: 50%; border: 0; cursor: pointer; padding: 0; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.swatch:hover { transform: scale(1.18); }
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.swatch[data-color="default"] { background: #3a3e46; border: 1px solid #4a4f59; }
.swatch[data-color="red"]    { background: #f87171; }
.swatch[data-color="orange"] { background: #fb923c; }
.swatch[data-color="yellow"] { background: #fbbf24; }
.swatch[data-color="green"]  { background: #34d399; }
.swatch[data-color="teal"]   { background: #2dd4bf; }
.swatch[data-color="blue"]   { background: #60a5fa; }
.swatch[data-color="purple"] { background: #a78bfa; }
.swatch[data-color="pink"]   { background: #f472b6; }

/* ─── board ─── */
.board {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 18px;
}
@media (max-width: 720px) {
  .board { grid-template-columns: 1fr; overflow-y: auto; }
  .library { flex-direction: column; }
  .sidebar { width: 100%; height: 42vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .resizer { display: none; }
  .editor { height: 58vh; }
  #title { font-size: 1.4rem; }
}

.col {
  display: flex;
  flex-direction: column;
  background: var(--col);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.col.over { border-color: var(--accent); background: rgba(138, 180, 248, 0.06); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.cdot { width: 9px; height: 9px; border-radius: 50%; }
.c-todo { background: var(--todo); }
.c-doing { background: var(--doing); }
.c-done { background: var(--done); }
.col-head .n { margin-left: auto; color: var(--faint); font-size: 0.74rem; }
.col-new {
  margin-left: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.col-new:hover { color: var(--fg); border-color: var(--accent); }
.cards { flex: 1; overflow-y: auto; padding: 4px 10px 14px; display: flex; flex-direction: column; gap: 10px; }

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid #3a3e46;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: grab;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.8); }
.card:active { cursor: grabbing; }
.card[data-color="red"]    { border-left-color: #f87171; }
.card[data-color="orange"] { border-left-color: #fb923c; }
.card[data-color="yellow"] { border-left-color: #fbbf24; }
.card[data-color="green"]  { border-left-color: #34d399; }
.card[data-color="teal"]   { border-left-color: #2dd4bf; }
.card[data-color="blue"]   { border-left-color: #60a5fa; }
.card[data-color="purple"] { border-left-color: #a78bfa; }
.card[data-color="pink"]   { border-left-color: #f472b6; }

.card .pin { position: absolute; top: 8px; right: 8px; font-size: 0.8rem; }
.card .title { font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; padding-right: 20px; overflow-wrap: anywhere; }
.card:not(.has-title) .title { display: none; }
.card .body { color: #c3c7cf; font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.card .meta { margin-top: 8px; font-size: 0.7rem; color: var(--faint); }

/* ─── modal ─── */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); z-index: 40; }
.modal { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 20px 20px; z-index: 50; }
.modal-card {
  width: 100%;
  max-width: 600px;
  background: #1a1c22;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  animation: pop 0.16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.status-row { display: flex; gap: 8px; margin-bottom: 14px; }
.status-row button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.status-row button:hover { color: var(--fg); }
.status-row button.on[data-status="todo"] { color: var(--todo); border-color: var(--todo); background: rgba(138,180,248,0.1); }
.status-row button.on[data-status="doing"] { color: var(--doing); border-color: var(--doing); background: rgba(251,191,36,0.1); }
.status-row button.on[data-status="done"] { color: var(--done); border-color: var(--done); background: rgba(52,211,153,0.1); }

.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 5px 8px; }
.icon-btn:hover { color: var(--fg); }

.modal input, .modal textarea { width: 100%; background: transparent; border: 0; outline: 0; color: var(--fg); font: inherit; }
.modal input { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 8px; }
.modal textarea { min-height: 34vh; resize: none; font-size: 0.93rem; line-height: 1.6; }
.modal ::placeholder { color: var(--faint); }

.modal-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.danger { background: transparent; border: 0; color: var(--danger); font: inherit; font-size: 0.82rem; cursor: pointer; padding: 4px 2px; }
.danger:hover { text-decoration: underline; }
.saved { flex: 1; text-align: right; color: var(--faint); font-size: 0.74rem; }
.primary {
  background: var(--accent);
  color: #0b0d10;
  border: 0;
  border-radius: 7px;
  padding: 7px 16px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.1); }

/* ─── toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #22252b;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.86rem;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  z-index: 60;
}
