:root {
  --ink: #12181f;
  --panel: #1b232c;
  --panel-2: #212b35;
  --border: #33424c;
  --paper: #eef3f1;
  --dim: #8fa39c;
  --teal: #2f8f7a;
  --amber: #e0a83e;
  --coral: #d9694f;
  --danger: #e05a4e;
  --grid-dot: rgba(255, 255, 255, 0.06);
  --weekend: rgba(255, 255, 255, 0.035);
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --ink: #f3f1e8;
  --panel: #ffffff;
  --panel-2: #ece7d8;
  --border: #d7d0bb;
  --paper: #1c231f;
  --dim: #6d7266;
  --grid-dot: rgba(0, 0, 0, 0.08);
  --weekend: rgba(0, 0, 0, 0.035);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--teal); }

button, select, input, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--paper);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

button {
  cursor: pointer;
}
button:hover { border-color: var(--teal); }
button.primary { background: var(--teal); border-color: var(--teal); color: var(--ink); font-weight: 700; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { border-color: var(--border); }

header.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

header.top h1 {
  font-size: 18px;
  margin: 0;
  white-space: nowrap;
  cursor: default;
}
header.top h1 .prefill-anchor { cursor: pointer; }

#themeToggle { font-size: 15px; padding: 5px 8px; }

.spacer { flex: 1; }

nav.views {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
nav.views button {
  border: none;
  background: transparent;
  border-radius: 6px;
}
nav.views button.active {
  background: var(--teal);
  color: var(--ink);
  font-weight: 700;
}

.overdue-badge {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 6px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }

/* --- board toolbar --- */
.board-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.board-toolbar .zoom-controls { display: flex; gap: 4px; align-items: center; }

/* --- inbox strip inside board view --- */
.inbox-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.inbox-strip .hint { color: var(--dim); font-size: 12px; align-self: center; }
.inbox-chip {
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: grab;
}
.inbox-chip.task { border-color: var(--amber); }
.tag-chip {
  display: inline-block;
  color: var(--teal);
  font-size: 11px;
  background: rgba(47,143,122,.15);
  border-radius: 4px;
  padding: 0 4px;
}

/* --- timeline (canvas) --- */
.timeline-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 180px 28px;
  cursor: default;
  /* one-finger pan stays native scroll; disallowing native pinch-zoom here
     (it's not in this list) is what leaves two-finger gestures free for our
     own pinch-to-zoom handler below instead of the browser page-zooming */
  touch-action: pan-x pan-y;
}
.timeline-scroll.panning { cursor: grabbing; }
.timeline-inner {
  position: relative;
}
.canvas-grid {
  position: absolute;
  top: 28px;
  left: 180px;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
.canvas-grid .weekend-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--weekend);
}
.canvas-grid .grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--border);
  opacity: 0.35;
}
.canvas-grid .grid-line.major { opacity: 0.6; }
.ruler {
  display: flex;
  position: sticky;
  top: 0;
  height: 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 3;
}
.ruler-spacer {
  position: sticky;
  left: 0;
  width: 180px;
  min-width: 180px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 4;
}
.ruler-ticks { position: relative; flex: 1; }
.ruler-ticks .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--border);
  font-size: 10px;
  color: var(--dim);
  padding-left: 4px;
  white-space: nowrap;
}
.ruler-ticks .tick.major { border-left-color: var(--dim); font-weight: 700; }
.today-line {
  position: absolute;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--coral);
  z-index: 2;
  pointer-events: none;
}
.today-line::after {
  content: "today";
  position: absolute;
  top: 0;
  left: 4px;
  font-size: 10px;
  color: var(--coral);
}

.lane-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.lane-row.drag-over { outline: 2px dashed var(--teal); outline-offset: -2px; }
.lane-header {
  position: sticky;
  left: 0;
  width: 180px;
  min-width: 180px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  border-left: 3px solid transparent;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: grab;
}
.lane-header .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lane-header .title { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-header .menu-btn { font-size: 11px; padding: 2px 6px; }
.lane-body {
  position: relative;
  flex: 1;
  min-height: 64px;
}
.lane-body.collapsed { display: none; }

.item-bar {
  position: absolute;
  top: 10px;
  height: 26px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  color: #0c1116;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.2);
  transition: box-shadow .12s ease, transform .12s ease;
}
.item-bar:hover { box-shadow: 0 3px 10px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.25); transform: translateY(-1px); }
.item-bar.overdue { outline: 2px solid var(--danger); }
.item-bar .handle {
  position: absolute;
  top: 0; bottom: 0; width: 8px;
  cursor: ew-resize;
}
.item-bar .handle.left { left: 0; }
.item-bar .handle.right { right: 0; }

.item-event {
  position: absolute;
  top: 14px;
  width: 14px;
  height: 14px;
  transform: translateX(-50%) rotate(45deg);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.item-event.overdue { outline: 2px solid var(--danger); }
.item-label-out {
  position: absolute;
  top: 10px;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  padding-left: 12px;
  pointer-events: none;
}

.segment-strip {
  position: absolute;
  top: 40px;
  height: 10px;
  border-radius: 4px;
  opacity: 0.75;
}
.marker-tick {
  position: absolute;
  top: 4px;
  width: 2px;
  height: 46px;
  background: var(--paper);
  opacity: 0.6;
}
.marker-tick::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
}

.add-lane-row { padding: 10px 16px; }

/* --- outline view --- */
.outline-view { flex: 1; overflow: auto; padding: 16px 24px; }
.outline-view ul { list-style: none; margin: 0; padding-left: 18px; }
.outline-view > ul { padding-left: 0; }
.outline-view li { margin: 4px 0; }
.outline-view .lane-line { font-weight: 700; color: var(--teal); }
.outline-view .item-line { cursor: pointer; }
.outline-view .item-line:hover { color: var(--teal); }
.outline-view .meta { color: var(--dim); font-size: 12px; margin-left: 6px; }
.outline-view input[type=checkbox] { margin-right: 6px; }

/* --- inbox view --- */
.inbox-view { flex: 1; overflow: auto; padding: 16px 24px; display: flex; gap: 24px; }
.inbox-view textarea { width: 100%; min-height: 160px; resize: vertical; }
.inbox-view .capture-col { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 8px; }
.inbox-view .list-col { flex: 1; min-width: 280px; }
.inbox-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inbox-card .title { flex: 1; }
.inbox-card .due { color: var(--amber); font-size: 11px; }
.inbox-card select { font-size: 11px; padding: 2px 4px; }

/* --- tasks view --- */
.tasks-view { flex: 1; overflow: auto; padding: 16px 24px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-row:hover { background: var(--panel-2); }
.task-row .lane-tag { font-size: 11px; color: var(--dim); }
.task-row .title { flex: 1; }
.task-row.overdue .due { color: var(--danger); font-weight: 700; }
.task-row.soon .due { color: var(--amber); font-weight: 700; }
.task-row.done .title { text-decoration: line-through; color: var(--dim); }

/* --- modal: an inspector panel docked to the right edge, canvas-app style --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: stretch; justify-content: flex-end;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: auto;
  box-shadow: -10px 0 28px rgba(0,0,0,.35);
  animation: inspector-slide-in .16s ease-out;
}
@keyframes inspector-slide-in {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 640px) {
  .modal { max-width: 100%; }
}

.modal .swatch-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 0; }
.modal .swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #0c1116;
}
.modal .swatch.match {
  width: auto; border-radius: 11px; padding: 0 8px;
  background: var(--panel-2) !important; border: 1px dashed var(--border);
  font-size: 10px; color: var(--dim);
}
.modal .swatch.selected { border-color: var(--paper); box-shadow: 0 0 0 2px var(--panel); }
.modal h2 { margin-top: 0; font-size: 16px; }
.modal .row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.modal label { font-size: 12px; color: var(--dim); display: block; margin-bottom: 3px; }
.modal label[style*="flex"] { white-space: nowrap; width: auto; }
.modal .field { flex: 1; min-width: 140px; }
.modal input, .modal textarea, .modal select { width: 100%; }
.modal textarea { min-height: 70px; resize: vertical; }
.modal .notes-preview {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--paper);
}
.modal .notes-preview code { background: var(--ink); padding: 0 4px; border-radius: 3px; }
.modal .sub-list-item {
  display: flex; gap: 6px; align-items: center; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px;
}
.modal .sub-list-item input { flex: 1; min-width: 0; }
.modal .actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.modal .actions .right { display: flex; gap: 8px; }
.modal hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* --- footer --- */
footer.site {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 12px;
  color: var(--dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}
footer.site a { color: var(--dim); text-decoration: underline; }
footer.site a:hover { color: var(--teal); }
footer.site .gdpr { flex-basis: 100%; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .lane-header { width: 120px; min-width: 120px; }
  .inbox-view { flex-direction: column; }
}
