:root {
  --bg: #14141c;
  --bg-raised: #1c1c26;
  --bg-card: #22222e;
  --border: #33333f;
  --text: #eceef2;
  --text-dim: #9294a3;
  --accent: #e8b649;
  --accent-dim: #7a6534;
  --urgent: #e05a5a;
  --important: #5a8fe0;
  --done: #4caf6a;
  --danger: #e05a5a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  padding: 6px;
  cursor: pointer;
}

#app {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(90px + var(--safe-bottom));
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  padding: 10px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.tab-icon { font-size: 18px; line-height: 1; }

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

section.view { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }

h2.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.empty-note {
  color: var(--text-dim);
  font-size: 14px;
  padding: 10px 2px;
  line-height: 1.5;
}

/* quick add / dump */
.quick-add {
  display: flex;
  gap: 8px;
}

input[type="text"], textarea, select, input[type="date"] {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 90px; }

button.primary {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

button.ghost {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
}

button:disabled { opacity: 0.4; cursor: not-allowed; }

/* task rows */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.task-row:last-child { border-bottom: none; }

.checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
}

.checkbox.done {
  background: var(--done);
  border-color: var(--done);
  color: #fff;
}

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

.task-text {
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.task-text.done { text-decoration: line-through; color: var(--text-dim); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.tag.urgent { background: rgba(224,90,90,0.18); color: var(--urgent); }
.tag.important { background: rgba(90,143,224,0.18); color: var(--important); }
.tag.goal { background: rgba(232,182,73,0.15); color: var(--accent); }
.tag.streak { background: rgba(76,175,106,0.15); color: var(--done); }

.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* matrix */
.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.matrix-quad {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 110px;
}

.matrix-quad h3 {
  font-size: 11.5px;
  margin: 0 0 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.matrix-quad.q-ui h3 { color: var(--urgent); }
.matrix-quad.q-i h3 { color: var(--important); }
.matrix-quad.q-u h3 { color: #d0a24a; }

.mini-task {
  font-size: 13px;
  padding: 7px 8px;
  background: var(--bg-raised);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  line-height: 1.35;
}

/* goal card */
.goal-card { display: flex; flex-direction: column; gap: 6px; }
.goal-name { font-size: 16px; font-weight: 700; }
.goal-vision { font-size: 13px; color: var(--text-dim); font-style: italic; line-height: 1.5; }
.goal-progress-bar {
  height: 6px;
  background: var(--bg-raised);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.goal-progress-fill { height: 100%; background: var(--accent); }
.goal-meta { font-size: 12px; color: var(--text-dim); }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.modal-sheet {
  background: var(--bg-raised);
  width: 100%;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(24px + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-sheet h3 { margin: 0 0 4px; font-size: 17px; }

.field-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: block;
}

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

.toggle-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.toggle-btn.on-urgent { background: rgba(224,90,90,0.18); color: var(--urgent); border-color: var(--urgent); }
.toggle-btn.on-important { background: rgba(90,143,224,0.18); color: var(--important); border-color: var(--important); }
.toggle-btn.selected { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.weekday-row { display: flex; gap: 6px; justify-content: space-between; }

.weekday-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.weekday-btn.on { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.modal-actions { display: flex; gap: 8px; margin-top: 6px; }
.modal-actions button { flex: 1; }

.stat-row {
  display: flex;
  gap: 10px;
}

.stat-box {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.stat-num { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.limit-note {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 2px 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
}
