:root {
  color-scheme: light;
  --bg: #eeebe6;
  --bg-alt: #f6f1eb;
  --bg-glow: rgba(255, 255, 255, 0.7);
  --surface: #fdfcf9;
  --sidebar: #e8e4de;
  --ink: #1a1714;
  --muted: #9a9088;
  --faint: #c0b8af;
  --line: rgba(26, 23, 20, 0.08);
  --line-strong: rgba(26, 23, 20, 0.13);
  --accent: #1c4a3e;
  --accent-soft: rgba(28, 74, 62, 0.09);
  --amber: #9e5c1e;
  --amber-soft: rgba(158, 92, 30, 0.1);
  --rose: #8a3c2b;
  --rose-soft: rgba(138, 60, 43, 0.09);
  --sky: #2a5472;
  --sky-soft: rgba(42, 84, 114, 0.09);
  --panel-shadow: 0 2px 16px rgba(26, 23, 20, 0.05);
  --tab-track: rgba(26, 23, 20, 0.09);
  --tab-active-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --field-bg: rgba(255, 255, 255, 0.7);
  --field-bg-focus: rgba(255, 255, 255, 0.96);
  --field-focus: rgba(28, 74, 62, 0.55);
  --btn-ink: #edf5f0;
  --btn-soft-bg: rgba(26, 23, 20, 0.08);
  --btn-soft-hover: rgba(26, 23, 20, 0.13);
  --btn-danger-ink: #fff3ef;
  --sidebar-hover: rgba(26, 23, 20, 0.04);
  --card-hover: rgba(26, 23, 20, 0.025);
  --pill-neutral-bg: rgba(26, 23, 20, 0.07);
  --radius-xl: 18px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 5px;
  --t: 0.12s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121311;
    --bg-alt: #181a17;
    --bg-glow: rgba(88, 116, 106, 0.18);
    --surface: #1d1f1b;
    --sidebar: #171915;
    --ink: #ece4d9;
    --muted: #a99f91;
    --faint: #7f786d;
    --line: rgba(236, 228, 217, 0.08);
    --line-strong: rgba(236, 228, 217, 0.13);
    --accent: #88bea8;
    --accent-soft: rgba(136, 190, 168, 0.14);
    --amber: #e0aa6d;
    --amber-soft: rgba(224, 170, 109, 0.15);
    --rose: #df917e;
    --rose-soft: rgba(223, 145, 126, 0.14);
    --sky: #8db8d6;
    --sky-soft: rgba(141, 184, 214, 0.14);
    --panel-shadow: 0 20px 40px rgba(0, 0, 0, 0.22);
    --tab-track: rgba(236, 228, 217, 0.08);
    --tab-active-shadow: 0 14px 32px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(236, 228, 217, 0.05);
    --field-bg: rgba(236, 228, 217, 0.05);
    --field-bg-focus: rgba(236, 228, 217, 0.09);
    --field-focus: rgba(136, 190, 168, 0.5);
    --btn-ink: #0f1512;
    --btn-soft-bg: rgba(236, 228, 217, 0.08);
    --btn-soft-hover: rgba(236, 228, 217, 0.13);
    --btn-danger-ink: #21100d;
    --sidebar-hover: rgba(236, 228, 217, 0.04);
    --card-hover: rgba(236, 228, 217, 0.03);
    --pill-neutral-bg: rgba(236, 228, 217, 0.08);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at top left, var(--bg-glow), transparent 34%),
    linear-gradient(180deg, var(--bg-alt), var(--bg));
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ── Shell ────────────────────────────────────────────────── */
.shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 32px 56px;
}

/* ── Panel (used only inside workspace — reset there) ───── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow);
}

/* ── Hero (no box, no panel) ─────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto;
  gap: 48px;
  padding: 0 0 40px;
  align-items: end;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.eyebrow {
  display: inline-block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.section-kicker {
  display: inline-block;
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.hero h1 {
  font-family: "Cormorant Garamond", serif;
  margin: 16px 0 16px;
  max-width: 14ch;
  font-size: clamp(2.8rem, 6.5vw, 5rem);
  font-weight: 400;
  line-height: 0.93;
  letter-spacing: -0.015em;
}

h2, .metric-value, .card-title {
  font-family: "Cormorant Garamond", serif;
  letter-spacing: -0.015em;
  font-weight: 400;
}

.hero p {
  margin: 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.8;
}

.hero-aside {
  display: grid;
  gap: 14px;
  align-content: end;
  padding-bottom: 4px;
}

/* ── Tab switcher ─────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 11px;
  background: var(--tab-track);
  border: none;
}

.tab {
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all var(--t);
  letter-spacing: 0.01em;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--tab-active-shadow);
}

/* ── Hero note ────────────────────────────────────────────── */
.hero-note {
  display: grid;
  gap: 3px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}

.hero-note strong {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  font-weight: 700;
}

.hero-note span {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Summary strip ───────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.summary-card {
  padding: 18px 24px;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 0;
}

.summary-card:last-child {
  border-right: none;
}

.summary-card strong {
  display: block;
  color: var(--faint);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.metric-value {
  display: block;
  margin-top: 4px;
  font-size: 2.2rem;
  line-height: 1.1;
}

.metric-copy {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.78rem;
}

/* ── Workspace ──────────────────────────────────────────── */
.workspace { display: none; }
.workspace.active { display: block; }

.workspace-grid {
  display: grid;
  gap: 0;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  overflow: hidden;
}

.tasks-grid {
  grid-template-columns: 270px minmax(0, 1fr) 390px;
}

.purchases-grid {
  grid-template-columns: 270px minmax(0, 1fr) 390px;
}

/* Reset all panel styling inside workspace */
.workspace-grid .panel {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

/* Sidebar columns: tinted background */
.workspace-grid > aside {
  background: var(--sidebar);
}

.workspace-grid > aside:first-child {
  border-right: 1px solid var(--line-strong);
}

.workspace-grid > aside:last-child {
  border-left: 1px solid var(--line-strong);
}

/* ── Stack ──────────────────────────────────────────────── */
.stack {
  display: grid;
  gap: 14px;
  padding: 22px;
}

/* Inside workspace: no default padding or gap */
.workspace-grid .stack {
  padding: 0;
  gap: 0;
}

/* Forms inside workspace keep their own spacing */
.workspace-grid form.stack {
  padding: 20px 24px;
  gap: 12px;
}

/* Inset card form override */
.workspace-grid form.stack.inset-card {
  padding: 18px 24px;
  gap: 12px;
}

/* ── Scroll ─────────────────────────────────────────────── */
.scroll {
  max-height: 62vh;
  overflow: auto;
}

.workspace-grid .scroll {
  max-height: 58vh;
  padding: 0;
}

/* ── Section head ───────────────────────────────────────── */
.section-head,
.mini-head,
.card-top,
.inline-meta,
.actions,
.subtask-actions {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.workspace-grid .section-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-strong);
}

.section-head h2 {
  margin: 6px 0 0;
  font-size: 1.7rem;
  line-height: 1;
}

/* ── Mini head ──────────────────────────────────────────── */
.mini-head {
  flex-direction: column;
  align-items: start;
}

.workspace-grid .mini-head {
  padding: 16px 24px 12px;
  border-top: 1px solid var(--line-strong);
}

.mini-head strong {
  font-size: 0.86rem;
  font-weight: 600;
}

.mini-head span,
.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Status ─────────────────────────────────────────────── */
.status {
  color: var(--muted);
  font-size: 0.8rem;
}

.workspace-grid .status {
  padding: 6px 24px;
}

.workspace-grid .status:empty {
  display: none;
}

.status.error { color: var(--rose); }
.status.success { color: var(--accent); }

/* ── Divider (hidden in workspace — mini-head has border) ── */
.divider {
  height: 1px;
  background: var(--line-strong);
}

.workspace-grid .divider {
  display: none;
}

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar,
.field-grid {
  display: grid;
  gap: 10px;
}

.toolbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toolbar.wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.workspace-grid .toolbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line-strong);
}

/* ── Fields ─────────────────────────────────────────────── */
.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  font-size: 0.64rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.inline-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--field-bg);
  color: var(--ink);
  padding: 9px 12px;
  font-size: 0.84rem;
  transition: border-color var(--t), background var(--t);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus {
  outline: none;
  border-color: var(--field-focus);
  background: var(--field-bg-focus);
}

.field textarea {
  min-height: 78px;
  resize: vertical;
}

.field.full {
  grid-column: 1 / -1;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 7px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--btn-ink);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  transition: opacity var(--t);
}

.btn:hover { opacity: 0.85; }

.btn.btn-soft {
  background: var(--btn-soft-bg);
  color: var(--ink);
}

.btn.btn-soft:hover {
  background: var(--btn-soft-hover);
  opacity: 1;
}

.btn.btn-danger {
  background: var(--rose-soft);
  color: var(--rose);
}

.btn.btn-danger:hover {
  background: var(--rose);
  color: var(--btn-danger-ink);
  opacity: 1;
}

/* ── Actions row ────────────────────────────────────────── */
.actions {
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  justify-content: flex-start;
}

/* ── Sidebar rows (list style) ──────────────────────────── */
.sidebar-row {
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--line);
  transition: background var(--t);
  font-size: 0.86rem;
  color: var(--ink);
}

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

.sidebar-row:hover {
  background: var(--sidebar-hover);
}

.sidebar-row.active {
  background: var(--accent-soft);
  border-bottom-color: var(--line);
  color: var(--accent);
  font-weight: 600;
}

/* ── Task / item cards (list rows) ─────────────────────── */
.task-card,
.item-card {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 0;
  background: transparent;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t);
  text-align: left;
}

.task-card:last-child,
.item-card:last-child {
  border-bottom: none;
}

.task-card:hover,
.item-card:hover {
  background: var(--card-hover);
}

/* ── Card elements ──────────────────────────────────────── */
.card-title {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
}

.card-copy {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.79rem;
}

/* ── Pills ──────────────────────────────────────────────── */
.pill-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.61rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.pill.pending  { background: var(--amber-soft); color: var(--amber); }
.pill.done,
.pill.purchased,
.pill.active   { background: var(--accent-soft); color: var(--accent); }
.pill.archived,
.pill.skipped  { background: var(--pill-neutral-bg); color: var(--muted); }
.pill.info     { background: var(--sky-soft); color: var(--sky); }

/* ── Inline meta ────────────────────────────────────────── */
.inline-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* ── Empty state ────────────────────────────────────────── */
.empty {
  padding: 28px 24px;
  color: var(--faint);
  text-align: center;
  font-size: 0.82rem;
}

/* ── Inline form (subtask add) ──────────────────────────── */
.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 24px 16px;
}

/* ── Subtask rows ───────────────────────────────────────── */
.subtask-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 24px;
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}

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

.subtask-copy strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
}

.subtask-copy span {
  color: var(--muted);
  font-size: 0.76rem;
}

.subtask-actions {
  align-items: center;
  gap: 6px;
}

/* ── Sidebar row with actions ───────────────────────────── */
.sidebar-row-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

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

.sidebar-row-wrap .sidebar-row {
  flex: 1;
  border-bottom: none;
}

.sidebar-row-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px 0 4px;
  opacity: 0;
  transition: opacity var(--t);
  flex-shrink: 0;
}

.sidebar-row-wrap:hover .sidebar-row-actions,
.sidebar-row-wrap:focus-within .sidebar-row-actions {
  opacity: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--t), color var(--t);
  line-height: 1.4;
  white-space: nowrap;
}

.icon-btn:hover {
  background: var(--btn-soft-hover);
  color: var(--ink);
}

.icon-btn.icon-btn-danger:hover {
  background: var(--rose-soft);
  color: var(--rose);
}

/* ── Inset card (new category / list form) ──────────────── */
.inset-card {
  border: none;
  border-radius: 0;
  background: transparent;
  border-top: 1px solid var(--line-strong);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1240px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .tasks-grid,
  .purchases-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid > aside:first-child {
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
  }

  .workspace-grid > aside:last-child {
    border-left: none;
    border-top: 1px solid var(--line-strong);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
  }

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

  .scroll,
  .workspace-grid .scroll {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 20px 16px 40px;
  }

  .hero {
    padding-bottom: 28px;
  }

  .toolbar,
  .toolbar.wide,
  .two-up,
  .inline-form {
    grid-template-columns: 1fr;
  }
}
