:root {
  --bg: #080c14;
  --bg-secondary: #0c1220;
  --surface: rgba(8,12,20,0.92);
  --grid-color: #131d2e;
  --border: #1e2a3a;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1a3a5c;
  --accent-glow: rgba(88,166,255,0.4);
  --green: #16c79a;
  --green-dim: #0a3d2e;
  --red: #ff6b6b;
  --red-dim: #3d1a1a;
  --yellow: #f0c929;
  --yellow-dim: #3d3210;
  --orange: #f0a030;
  --orange-dim: #3d2a0a;
  --purple: #b388ff;
  --purple-dim: #2d1b50;
  --cyan: #00bcd4;
  --cyan-dim: #0a2d33;

  --radius: 12px;
  --radius-sm: 8px;
  --tap-min: 48px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

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

/* Nav tabs */
.nav {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 4px;
}

.nav-tab {
  flex: 1;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  padding: 8px 4px;
  letter-spacing: 0.02em;
}

.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-tab svg { flex-shrink: 0; }

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

/* ============ CAPTURE VIEW ============ */
.capture-view {
  padding: 16px;
  gap: 12px;
}

.capture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.capture-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.chip-row {
  display: flex;
  gap: 8px;
}

.chip {
  flex: 1;
  min-height: var(--tap-min);
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0 12px;
}

.chip.active[data-kind="idea"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.chip.active[data-kind="goal"] {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}
.chip.active[data-kind="instruction"] {
  background: var(--yellow-dim);
  border-color: var(--yellow);
  color: var(--yellow);
}

.capture-input-wrap {
  position: relative;
}

.capture-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  padding: 14px 16px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

.capture-textarea:focus { border-color: var(--accent); }
.capture-textarea::placeholder { color: var(--text-muted); }

.capture-actions {
  display: flex;
  gap: 10px;
}

.btn-add {
  flex: 1;
  min-height: 56px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #080c14;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

.btn-add:active { transform: scale(0.97); opacity: 0.9; }
.btn-add:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-voice {
  width: 56px;
  height: 56px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-voice.recording {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--green);
  color: #080c14;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 100px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--red);
  color: #fff;
}

/* Queue badge */
.queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: 100px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  margin-top: 4px;
}

/* Setup banner */
.setup-banner {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  width: 100%;
}

.setup-input:focus { border-color: var(--accent); }

.btn-sm {
  min-height: var(--tap-min);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #080c14;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
}

/* ============ KANBAN VIEWS ============ */
.kanban-view {
  overflow-y: auto;
  padding: 12px;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.kanban-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}

.kanban-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.btn-refresh {
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Section accordion */
.section-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  min-height: var(--tap-min);
  border-bottom: 1px solid transparent;
  transition: background 0.1s;
}

.section-header:active { background: var(--grid-color); }

.section-header.open { border-bottom-color: var(--border); }

.section-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--grid-color);
  border-radius: 100px;
  padding: 2px 8px;
}

.section-chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.section-header.open .section-chevron { transform: rotate(90deg); }

.section-items {
  display: none;
}

.section-items.open { display: block; }

/* Cards */
.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--grid-color);
  cursor: pointer;
  transition: background 0.1s;
  min-height: var(--tap-min);
}

.card:last-child { border-bottom: none; }
.card:active { background: var(--grid-color); }

.card-state {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  font-size: 11px;
}

.card-state.done {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.card-state.wip {
  background: var(--yellow-dim);
  border-color: var(--yellow);
  color: var(--yellow);
}

.card-body { flex: 1; min-width: 0; }

.card-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Goals columns */
.goals-columns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-col {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.goal-col-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-height: var(--tap-min);
}

.goal-col-header[data-col="Queued"] { color: var(--text-muted); }
.goal-col-header[data-col="In-Progress"] { color: var(--accent); }
.goal-col-header[data-col="Needs-Attention"] { color: var(--yellow); }
.goal-col-header[data-col="Completed"] { color: var(--green); }

.goal-col-items { display: none; }
.goal-col-items.open { display: block; }

.goal-card {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid-color);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
}

.goal-card:last-child { border-bottom: none; }

.goal-card-text { flex: 1; word-break: break-word; }
.goal-card-date { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  padding-bottom: env(safe-area-inset-bottom);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 80dvh;
  overflow-y: auto;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin: 0 auto;
}

.modal-text-edit {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  min-height: 80px;
}

.modal-text-edit:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-btn {
  flex: 1;
  min-width: 80px;
  min-height: var(--tap-min);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.modal-btn:active { opacity: 0.8; }
.modal-btn.primary { background: var(--accent); color: #080c14; }
.modal-btn.danger { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.modal-btn.neutral { background: var(--grid-color); color: var(--text-muted); }
.modal-btn.success { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }

/* Move section selector */
.move-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  min-height: var(--tap-min);
}

/* Loading state */
.loading-msg {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 32px;
}

/* Stale badge */
.stale-badge {
  background: var(--orange-dim);
  border: 1px solid var(--orange);
  border-radius: var(--radius-sm);
  color: var(--orange);
  font-size: 12px;
  padding: 4px 10px;
  margin-bottom: 8px;
  text-align: center;
}

/* Offline banner */
.offline-banner {
  display: none;
  background: var(--yellow-dim);
  border-bottom: 1px solid var(--yellow);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 6px;
  position: sticky;
  top: 49px;
  z-index: 99;
}

body.offline .offline-banner { display: block; }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f0f2f5;
    --bg-secondary: #e8eaed;
    --surface: rgba(255,255,255,0.95);
    --grid-color: #d8dce3;
    --border: #c0c8d4;
    --text: #1f2328;
    --text-muted: #656d76;
    --accent: #2563eb;
    --accent-dim: #dbeafe;
    --accent-glow: rgba(37,99,235,0.2);
    --green: #059669;
    --green-dim: #d1fae5;
    --red: #dc2626;
    --red-dim: #fee2e2;
    --yellow: #d97706;
    --yellow-dim: #fef3c7;
    --orange: #ea580c;
    --orange-dim: #ffedd5;
    --purple: #7c3aed;
    --purple-dim: #ede9fe;
    --cyan: #0891b2;
    --cyan-dim: #cffafe;
  }
}
