:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --ink-dim: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --accent: #2563eb;
  --done: #16a34a;
  --danger: #dc2626;
  --focus: #b45309;
  --font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: var(--font); color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }

/* ---------- Auth gate ---------- */
.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { text-align: center; max-width: 380px; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-card p { color: var(--ink-dim); margin: 0 0 24px; }
.auth-error { color: var(--danger); min-height: 1em; margin-top: 14px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); padding: 5px 10px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { color: var(--ink); }

/* ---------- Shell: rail | chips | tasks | inset ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.shell {
  flex: 1; display: grid; grid-template-columns: auto auto 1fr 230px; gap: 22px;
  max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 20px; align-items: start;
}
@media (max-width: 860px) { .shell { grid-template-columns: 1fr; gap: 12px; } }
.rail { display: flex; flex-direction: column; gap: 8px; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.rail .btn-ghost { align-self: flex-start; }

/* ---------- Chips (left column, vertical) ---------- */
.chips { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
@media (max-width: 860px) { .chips { flex-direction: row; flex-wrap: wrap; } }
.tab {
  background: #fff; border: 1px solid var(--line); color: var(--ink-dim);
  padding: 3px 10px; border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); border-color: #cbd5e1; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.toplevel { font-weight: 600; color: var(--ink); }
.tab.toplevel.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.horizon { border-color: #fcd9a8; color: var(--focus); }
.tab.horizon.active { background: var(--focus); border-color: var(--focus); color: #fff; }
.tab.drop { outline: 2px dashed var(--accent); outline-offset: 1px; }

/* ---------- Tasks column ---------- */
.tasks { min-width: 0; }
.col-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-dim); margin: 16px 0 6px; }
.col-title:first-child { margin-top: 0; }
.items { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--ink-dim); font-size: 14px; }

/* ---------- Item: aligned grid (2.1 handle · 2.2 checkbox · 2.3 task · trailing) ---------- */
.item { display: grid; grid-template-columns: 14px 18px minmax(0,1fr) auto; align-items: center; column-gap: 9px;
  padding: 4px 2px; border-bottom: 1px solid var(--line-soft); transition: opacity .2s, transform .2s; }
.item.leaving { opacity: 0; transform: translateX(20px); }
.item.dragover { box-shadow: inset 0 2px 0 var(--accent); }
.handle { width: 14px; cursor: grab; color: #c0c6d0; font-size: 13px; line-height: 1; user-select: none; }
.handle:active { cursor: grabbing; }
.trailing { display: inline-flex; align-items: center; gap: 2px; justify-self: end; }
.caret { background: transparent; border: none; color: var(--ink-dim); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; opacity: 0; transition: transform .15s; }
.item:hover .caret { opacity: 1; }
.caret.open { opacity: 1; transform: rotate(180deg); }
/* classification panel spans the full row width */
.expand { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0 8px 23px; }
.etag { font-size: 12px; background: #eef2ff; color: #3a4a7a; border-radius: 999px; padding: 2px 4px 2px 9px; display: inline-flex; align-items: center; gap: 4px; }
.etag b { cursor: pointer; color: #8893b5; font-weight: 700; }
.etag b:hover { color: var(--danger); }
.ehz { display: inline-flex; gap: 2px; }
.ehz button { font-size: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink-dim); border-radius: 6px; padding: 1px 8px; cursor: pointer; }
.ehz button.on { background: var(--focus); border-color: var(--focus); color: #fff; }
.eadd { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; width: 110px; }
.eadd:focus { outline: none; border-color: var(--accent); }
.checkbox { flex: none; width: 18px; height: 18px; border-radius: 5px; border: 2px solid #cbd5e1; background: #fff; cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.checkbox:hover { border-color: var(--done); }
.checkbox.filling, .checkbox.checked { background: var(--done); border-color: var(--done); }
.checkbox svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
.checkbox.filling svg, .checkbox.checked svg { opacity: 1; }
.item-text { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text .struck { text-decoration: line-through; color: var(--ink-dim); }
.items.done .item-text { color: var(--ink-dim); }
.item-del { flex: none; background: transparent; border: none; color: var(--ink-dim); cursor: pointer; font-size: 17px; line-height: 1; padding: 2px 4px; opacity: 0; }
.item:hover .item-del { opacity: 1; }
.item-del:hover { color: var(--danger); }

/* ---------- Long-term inset (right box) ---------- */
.inset { border: 1px solid #fcd9a8; background: #fffaf2; border-radius: 12px; padding: 12px 14px; position: sticky; top: 18px; }
.focus-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--focus); margin: 0 0 6px; }
.focus-cards { display: flex; flex-direction: column; }
.focus-card { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.focus-card .item-text { font-size: 14px; font-weight: 500; }
.focus-card.leaving { opacity: 0; transform: translateX(20px); transition: all .2s; }

/* ---------- Command bar ---------- */
.cmdbar { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--bg); max-width: 920px; margin: 0 auto; width: 100%; }
#cmd-input { flex: 1; background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
#cmd-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 50; }
