/* ===== Monochrome design system (B&W) ===== */
:root {
  /* Light palette: white paper + ink */
  --bg: #FFFFFF;
  --bg-alt: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F2F2F2;
  --border: #E4E4E4;
  --border-strong: #CCCCCC;

  --text: #111111;
  --text-soft: #3A3A3A;
  --text-muted: #8A8A8A;

  --accent: #111111;
  --accent-hover: #000000;
  --accent-soft: rgba(17, 17, 17, 0.07);
  --accent-line: rgba(17, 17, 17, 0.30);

  --health: #555555;
  --nutrition: #777777;
  --mental: #999999;
  --physical: #BBBBBB;

  --good: #2E2E2E;
  --warn: #757575;
  --bad: #000000;

  --mini-today: #E5484D;  /* red marker for the current day in mini-heatmaps */

  --shadow-sm: 0 1px 2px rgba(31, 30, 29, 0.04);
  --shadow: 0 2px 8px rgba(31, 30, 29, 0.06);
  --shadow-lg: 0 8px 24px rgba(31, 30, 29, 0.08);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --font: ui-serif, "Charter", "Iowan Old Style", "Apple Garamond", Baskerville, Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --font-mono: "SF Mono", Menlo, ui-monospace, "Roboto Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0F0F0F;
  --bg-alt: #141414;
  --surface: #1A1A1A;
  --surface-2: #242424;
  --border: #2E2E2E;
  --border-strong: #454545;

  --text: #F2F2F2;
  --text-soft: #D0D0D0;
  --text-muted: #8C8C8C;

  --accent: #F2F2F2;
  --accent-hover: #FFFFFF;
  --accent-soft: rgba(242, 242, 242, 0.10);
  --accent-line: rgba(242, 242, 242, 0.35);

  --health: #C8C8C8;
  --nutrition: #A8A8A8;
  --mental: #888888;
  --physical: #686868;

  --good: #D6D6D6;
  --warn: #9A9A9A;
  --bad: #FFFFFF;

  --mini-today: #FF5A5F;  /* brighter red for dark background */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.40);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--font);
  color: var(--text);
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 0 0 12px;
}
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

p { margin: 0 0 14px; }

/* ===== Icons ===== */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  color: currentColor;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 32px; height: 32px; }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 28px 18px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
  padding: 0 4px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  padding: 4px 6px;
  border-radius: 10px;
  transition: background 0.15s;
}
.brand-link:hover { background: var(--surface-2); text-decoration: none; }
.brand-mark {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(31, 30, 29, 0.10), 0 0 0 1px rgba(184, 86, 54, 0.18) inset;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.brand-mark-svg {
  width: 22px; height: 22px;
  color: #FFFFFF;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
  position: relative;
  z-index: 1;
}
[data-theme="dark"] .brand-mark { box-shadow: 0 1px 2px rgba(0,0,0,0.30), 0 0 0 1px rgba(255,255,255,0.06) inset; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.brand-name {
  font-family: var(--font);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-top: 3px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.theme-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

.main {
  padding: 36px 40px 60px;
  width: 100%;
  display: flex;
  justify-content: center;
}
.main-inner {
  width: 100%;
  max-width: 1000px;
}

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
}
.page-title { margin: 0; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

@media (max-width: 980px) {
  .main { padding: 28px 28px 48px; }
}

/* ===== Mobile shell: slim top bar + fixed bottom tab nav ===== */
.mobile-topbar, .mobile-nav { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: none; background: transparent; color: var(--text-soft);
  border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mobile-actions { display: flex; align-items: center; gap: 2px; }
.mobile-actions form { display: flex; margin: 0; }

@media (max-width: 768px) {
  .app { display: block; min-height: 0; }
  .sidebar { display: none; }

  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    height: 54px; padding: 0 10px 0 14px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .mobile-brand .brand-mark-svg { width: 18px; height: 18px; }
  .mobile-brand .brand-name {
    font-family: var(--font); font-weight: 600; font-size: 17px; letter-spacing: -0.02em; color: var(--text);
  }

  .mobile-nav {
    display: flex; justify-content: space-around; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 8px 2px 7px; min-height: 54px;
    color: var(--text-muted); text-decoration: none;
    font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em;
  }
  .mobile-nav a .icon { width: 21px; height: 21px; }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav a:active { background: var(--surface-2); }

  .main { padding: 16px 15px calc(74px + env(safe-area-inset-bottom, 0px)); }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-sub { color: var(--text-muted); font-size: 13px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ===== Stat tiles ===== */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-tile .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.stat-tile .value {
  font-family: var(--font);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-tile .value.accent { color: var(--accent); }

.stat-tile .label .icon.flame-active {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(17, 17, 17, 0.30));
}
[data-theme="dark"] .stat-tile .label .icon.flame-active {
  filter: drop-shadow(0 0 6px rgba(242, 242, 242, 0.40));
}

/* Range selector chips */
.range-chips { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.range-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.range-chip:hover { color: var(--text); }
.range-chip.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Linear progress */
.bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block; height: 100%;
  background: var(--ring-color, var(--accent));
  border-radius: 999px;
  transition: width 0.3s;
}

/* Category tile */
.cat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.cat-head { display: flex; align-items: center; justify-content: space-between; }
.cat-name {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
}
.cat-name .icon { color: var(--ring-color, var(--accent)); }
.cat-num { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
}
.pill.muted { background: var(--surface-2); color: var(--text-muted); }
.pill.good { background: rgba(17, 17, 17, 0.08); color: var(--good); }
[data-theme="dark"] .pill.good { background: rgba(242, 242, 242, 0.10); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
[data-theme="dark"] .btn-primary { color: #111111; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #FFFFFF; }
[data-theme="dark"] .btn-primary:hover { color: #111111; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; gap: 6px; }

/* Habit row */
.toggle-form { display: block; width: 100%; position: relative; }
.toggle-form button.habit-row { padding-right: 44px; }
.habit-info-btn {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.habit-info-btn:hover { background: var(--surface); color: var(--accent); border-color: var(--border); }
.habit-row.done + .habit-info-btn,
.toggle-form .habit-row.done ~ .habit-info-btn { color: var(--accent); }
.habit-edit-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  margin-left: 6px;
  transition: all 0.15s;
}
.habit-edit-btn:hover { background: var(--surface-2); color: var(--accent); text-decoration: none; }

/* Habit description modal */
dialog.habit-modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
dialog.habit-modal::backdrop { background: rgba(31, 30, 29, 0.45); }
[data-theme="dark"] dialog.habit-modal::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog.habit-modal .modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
dialog.habit-modal .modal-head h2 { margin: 0; font-family: var(--font); font-size: 22px; }
dialog.habit-modal .modal-head .kicker { margin-bottom: 4px; }
dialog.habit-modal .modal-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
dialog.habit-modal .modal-close:hover { background: var(--surface-2); color: var(--text); }
dialog.habit-modal .modal-body {
  padding: 18px 22px 22px;
  max-height: 70vh;
  overflow-y: auto;
}
.habit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  transition: all 0.15s;
}
.habit-row:hover { background: var(--surface-2); }
.habit-row.done {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
button.habit-row {
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
button.habit-row:focus { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.habit-row .check {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s;
}
.habit-row.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
[data-theme="dark"] .habit-row.done .check { color: #111111; }
.habit-row .check .icon { width: 14px; height: 14px; }

.habit-row .name { font-size: 14px; font-weight: 500; flex: 1; }
.habit-row .meta { font-size: 12px; color: var(--text-muted); }

/* Auto habit: non-interactive, set from journal entries */
.habit-row.habit-auto {
  cursor: default;
  position: relative;
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
}
.habit-row.habit-auto:hover { background: transparent; }
.habit-row.habit-auto.done {
  background: var(--accent-soft);
  border-style: solid;
  border-color: var(--accent-line);
}
.habit-row.habit-auto.has-info { padding-right: 44px; }
.habit-auto-badge {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
.habit-row.habit-auto.has-info .habit-auto-badge { margin-right: 4px; }
.habit-auto-badge .icon { width: 14px; height: 14px; }

/* Habit streak badge */
.streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.streak-badge .icon { width: 13px; height: 13px; }
.streak-badge.active { color: var(--accent); }
.streak-badge.active .icon { color: var(--accent); }

/* Calendar heatmap */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heat-cell {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--border);
}
.heat-cell.l1 { background: rgba(17,17,17,0.20); }
.heat-cell.l2 { background: rgba(17,17,17,0.42); }
.heat-cell.l3 { background: rgba(17,17,17,0.65); }
.heat-cell.l4 { background: var(--accent); }
[data-theme="dark"] .heat-cell.l1 { background: rgba(242,242,242,0.18); }
[data-theme="dark"] .heat-cell.l2 { background: rgba(242,242,242,0.40); }
[data-theme="dark"] .heat-cell.l3 { background: rgba(242,242,242,0.65); }
[data-theme="dark"] .heat-cell.l4 { background: var(--accent); }

.heat-legend {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  margin-top: 8px;
}
.heat-legend .heat-cell { width: 11px; height: 11px; }

/* Note item */
.note-item {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
}
.note-item:hover { background: var(--surface-2); text-decoration: none; }
.note-item .meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.note-item .title { font-family: var(--font); font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.note-item .preview {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Manifesto */
.manifesto-page {
  max-width: 760px;
  margin: 0 auto;
}
/* Manifesto header: title centred, Edit-btn anchored top-right. */
.manifesto-header {
  position: relative;
  text-align: center;
  margin-bottom: 36px;
  padding: 0 80px; /* leave room for the absolute Edit button */
}
.manifesto-header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.manifesto-header .kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.manifesto-title {
  font-family: var(--font);
  font-size: 42px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.manifesto-edit-btn {
  position: absolute;
  top: 0;
  right: 0;
}
.manifesto-body {
  /* Slightly more generous reading rhythm for the single source document. */
  font-size: 16px;
}
.manifesto-footer {
  text-align: center;
  font-style: italic;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
@media (max-width: 720px) {
  .manifesto-header { padding: 0; }
  .manifesto-edit-btn {
    position: static;
    margin-top: 14px;
  }
  .manifesto-title { font-size: 32px; }
}
/* Legacy section blocks (kept for any historical pages; no longer used by
   manifesto.html — body now renders entirely through .prose.md). */
.manifesto-section { margin-bottom: 36px; }
.manifesto-section h2 {
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.manifesto-section .body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
}

/* Day list */
.day-row {
  display: grid;
  grid-template-columns: 160px 1fr 60px 60px;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  text-decoration: none; color: inherit;
}
.day-row:last-child { border-bottom: none; }
.day-row:hover { background: var(--surface-2); text-decoration: none; }
.day-row .date { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.day-row .stats { display: flex; gap: 6px; flex-wrap: wrap; }
.day-row .has-note { color: var(--text-muted); display: flex; justify-content: center; }
.day-row .has-note .icon { color: var(--accent); }
.day-row .total { font-family: var(--font); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.cat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cat-chip.has { background: var(--accent-soft); color: var(--accent); }
/* Phase 20: overachievement chip (done > goal) — green pill so the user sees
   the day went past the daily goal at a glance, distinct from the regular .has
   accent (orange/copper). */
.cat-chip.over {
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
  font-weight: 500;
}
[data-theme="dark"] .cat-chip.over {
  background: color-mix(in srgb, var(--good) 28%, transparent);
  color: color-mix(in srgb, var(--good) 70%, white);
}
.cat-chip .icon { width: 12px; height: 12px; }

/* Search/filter inputs */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Custom <select class="input"> — appearance:none + SVG chevron-down (Lucide).
   The chevron stays themable through two SVGs (muted for light, slightly
   lighter for dark) since data: URLs can't read CSS custom properties.
   On desktop the JS widget (custom-select.js) wraps every <select.input>
   into .select-wrapper / .select-trigger / .select-popup — that path uses
   icon-chevron-down from the sprite. On mobile / coarse pointer the JS
   bails out and the native <select> below is used as-is. */
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23837C75' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
[data-theme="dark"] select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238C8A82' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
}
select.input:disabled { cursor: not-allowed; opacity: 0.6; }

/* Best-effort: paint options in our palette where the OS allows it
   (Chromium honors this for dark theme; Safari/Firefox mostly ignore).
   On desktop the JS widget below replaces this with a fully styled popup. */
select.input option,
select.input optgroup {
  background-color: var(--surface);
  color: var(--text);
}

/* Compact width modifier (replaces ad-hoc inline `style="width:auto;..."`). */
.input.select-sm {
  width: auto;
  min-width: 160px;
}

/* ===== Custom dropdown widget (Phase 14.1, JS-enhanced) =====
   When custom-select.js wraps a <select class="input">, it hides the native
   element and renders the .select-wrapper structure below. Native select
   stays in the DOM (form-functional) but visually hidden. */

.select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  vertical-align: middle;
}
.select-wrapper.select-sm { width: auto; min-width: 160px; }

/* Hide native select but keep it focusable for screen readers / form. */
.select-native-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  inset: 0;
  margin: 0;
}

.select-trigger {
  /* Inherit .input visuals — same surface/border/radius/typography. */
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.select-trigger:hover { border-color: var(--border-strong); }
.select-trigger:focus,
.select-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select-trigger[disabled],
.select-trigger.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.select-trigger .select-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-trigger .select-label.placeholder { color: var(--text-muted); }
.select-trigger .select-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.15s, color 0.15s;
}
.select-trigger[aria-expanded="true"] .select-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.select-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
.select-popup[hidden] { display: none; }
.select-popup .select-option {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}
.select-popup .select-option[aria-disabled="true"] {
  color: var(--text-muted);
  cursor: not-allowed;
}
.select-popup .select-option:hover,
.select-popup .select-option.is-active {
  background: var(--surface-2);
  color: var(--text);
}
.select-popup .select-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.select-popup .select-option[aria-selected="true"].is-active,
.select-popup .select-option[aria-selected="true"]:hover {
  background: var(--accent);
  color: #FFFFFF;
}
[data-theme="dark"] .select-popup .select-option[aria-selected="true"].is-active,
[data-theme="dark"] .select-popup .select-option[aria-selected="true"]:hover {
  color: #111111;
}

/* Mobile / coarse pointer: JS bails out → native <select> is the affordance.
   Make sure the (unused) wrapper styles never collide. */
@media (max-width: 720px), (pointer: coarse) {
  /* Wrappers shouldn't exist here (JS skips init), but be defensive. */
  .select-trigger { display: none; }
  .select-popup { display: none; }
  .select-native-hidden {
    position: static;
    opacity: 1;
    pointer-events: auto;
    height: auto;
    width: 100%;
  }
}

/* ===== Scrollbars (Phase 15) =====
   Claude-palette scrollbars across light/dark via existing CSS vars
   (palette names from the design system, no new vars introduced):
     track   → `--surface-2`  (subtle, sits inside the page surface)
     thumb   → `--accent-line` (35% accent — visible but not loud)
     hover   → `--accent`      (full accent on interaction)
     corner  → `--bg`          (matches outer page bg)
   The 2px transparent border on the thumb shrinks it visually inside
   the 10px track for a "thin pill" look without losing hit-target. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--accent-line);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background: var(--accent-hover);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: var(--bg); }

/* Firefox / standard CSS scrollbar tinting. Applied on html so it inherits
   through the document tree; named scrollable containers below get the
   same colors explicitly (Firefox doesn't inherit `scrollbar-color`
   through `iframe` / `details` / certain shadow contexts reliably). */
html {
  scrollbar-color: var(--accent-line) var(--surface-2);
  scrollbar-width: thin;
}
.sidebar,
.week-strip,
.select-popup,
.heatmap,
.chart-box,
.shopping-list,
pre,
textarea,
dialog.habit-modal .modal-body {
  scrollbar-color: var(--accent-line) var(--surface-2);
  scrollbar-width: thin;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty .icon-xl { color: var(--border-strong); margin-bottom: 10px; }

/* Roadmap stage */
.stage {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 18px;
  margin-bottom: 22px;
}
.stage h3 { margin-bottom: 4px; font-family: var(--font); }
.stage .period { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stage .body { font-size: 14px; color: var(--text-soft); margin-top: 8px; }

/* Markdown-ish for notes detail */
.prose {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose code { font-family: var(--font-mono); font-size: 14px; padding: 1px 5px; background: var(--surface-2); border-radius: 4px; }

/* When .prose hosts rendered markdown, drop pre-wrap and style block elements. */
.prose.md { white-space: normal; }
.prose.md p { margin: 0 0 14px; }
.prose.md h1, .prose.md h2, .prose.md h3, .prose.md h4 {
  font-family: var(--font);
  margin: 22px 0 10px;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.prose.md h1 { font-size: 28px; }
.prose.md h2 { font-size: 22px; }
.prose.md h3 { font-size: 18px; }
.prose.md h4 { font-size: 16px; color: var(--text-soft); }
.prose.md ul, .prose.md ol { margin: 0 0 14px; padding-left: 24px; }
.prose.md li { margin-bottom: 4px; }
.prose.md li > input[type="checkbox"] { margin-right: 8px; }
.prose.md blockquote {
  margin: 14px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
  font-style: italic;
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
}
.prose.md hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.prose.md pre {
  background: var(--surface-2);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 14px;
}
.prose.md pre code { background: transparent; padding: 0; font-size: inherit; }
.prose.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose.md table {
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 15px;
}
.prose.md th, .prose.md td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.prose.md th { background: var(--surface-2); font-weight: 600; }

/* Headline above page */
.kicker {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Misc */
.muted { color: var(--text-muted); }
.row { display: flex; align-items: center; gap: 14px; }
.row.between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Chart container */
.chart-box {
  position: relative;
  height: 320px;
  width: 100%;
}
.chart-box.tall { height: 420px; }

/* Mood/energy widget */
.mood-rows { display: flex; flex-direction: column; gap: 12px; }
.mood-row { display: flex; align-items: center; gap: 14px; }
.mood-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  width: 64px;
  flex-shrink: 0;
}
.mood-scale { display: flex; gap: 4px; flex: 1; }
.mood-pip {
  flex: 1;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all 0.15s;
}
.mood-pip:hover { background: var(--surface-2); border-color: var(--border-strong); }
.mood-pip.selected {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
  font-weight: 600;
}
[data-theme="dark"] .mood-pip.selected { color: #111111; }
.mood-current {
  width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
}
@media (max-width: 640px) {
  .mood-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .mood-label, .mood-current { width: auto; text-align: left; }
}

/* Habit card with mini-heatmap on /habits/ */
.habit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.habit-card .habit-line {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.habit-card .habit-line .check {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.habit-card .habit-line .check .icon { width: 12px; height: 12px; }
.habit-card .habit-line .name { flex: 1; font-size: 14px; font-weight: 500; }
.habit-mini { display: flex; align-items: center; gap: 12px; }
.mini-heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 9px);
  grid-auto-columns: 9px;
  gap: 2px;                 /* equal horizontal & vertical spacing */
  flex: 1;
  min-width: 0;
  max-width: 100%;          /* never exceed the card (matters in the mobile column layout) */
  overflow: hidden;         /* clip the oldest weeks that don't fit */
  justify-content: end;     /* pin the current week to the right; wider cards reveal more history to the left */
}
.mini-cell {
  width: 9px; height: 9px;
  border-radius: 2px;
  background: var(--border);
}
.mini-cell.on { background: var(--ring-color, var(--accent)); }
.mini-cell.blank { background: transparent; }  /* future days in the current week */
/* Current day: red outline when not done, solid red fill when done.
   Uses inset box-shadow (not border) so the 9×9 footprint stays identical. */
.mini-cell.today {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--mini-today);
}
.mini-cell.today.on {
  background: var(--mini-today);
  box-shadow: none;
}
.mini-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 980px) {
  .habit-mini { flex-direction: column; align-items: flex-start; }
  .mini-meta { white-space: normal; }
}

/* Month focus list */
.focus-list { display: flex; flex-direction: column; gap: 4px; }
.focus-toggle-form { display: block; }
button.focus-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
button.focus-row:hover { background: var(--surface-2); }
button.focus-row.done {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
button.focus-row .check {
  width: 20px; height: 20px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent;
  flex-shrink: 0;
}
button.focus-row.done .check { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
[data-theme="dark"] button.focus-row.done .check { color: #111111; }
button.focus-row .check .icon { width: 13px; height: 13px; }
button.focus-row .focus-text { flex: 1; font-size: 14px; }
button.focus-row.done .focus-text { color: var(--text-soft); text-decoration: line-through; text-decoration-color: var(--accent-line); }

/* Markdown editor: textarea + slash popup */
.md-editor { position: relative; }
textarea[data-md-editor] {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
}
.md-editor .md-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex; flex-wrap: wrap; gap: 12px;
}
.md-editor .md-hint kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.slash-menu {
  position: absolute;
  z-index: 50;
  min-width: 240px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  font-size: 14px;
}
.slash-menu .slash-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.slash-menu .slash-item .icon { color: var(--text-muted); }
.slash-menu .slash-item .label { flex: 1; }
.slash-menu .slash-item .hint { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.slash-menu .slash-item:hover,
.slash-menu .slash-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.slash-menu .slash-item:hover .icon,
.slash-menu .slash-item.active .icon { color: var(--accent); }
.slash-menu .slash-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }

/* ===== Week strip (shared planner layout) =====
   Calendar strip: 7 narrow columns, LTR order — Sunday on the left edge,
   Saturday on the right. DOM order is 0=Sun..6=Sat (set by backend), and
   default flex `row` paints DOM[0] leftmost — no reversal.
*/

.week-strip {
  display: flex;
  gap: 6px;
  align-items: stretch;
  /* No overflow-x: 7 columns must fit the viewport. Mobile falls back to
     vertical column via @media below. */
}

.week-day-card {
  flex: 1 1 0;
  min-width: 0;            /* allow flex-basis 0 to actually shrink to 1/7 */
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s;
}
.week-day-card.empty { background: transparent; border-style: dashed; }
.week-day-card.today {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px var(--accent-line), var(--shadow-sm);
}
.week-day-card.today.empty { background: var(--accent-soft); }

.week-day-card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.week-day-card.empty > header { margin-bottom: 6px; border-bottom-style: dashed; }
.week-day-card.today > header { border-bottom-color: var(--accent-line); }

.week-day-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.week-day-title .weekday {
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.week-day-card.today .week-day-title .weekday { color: var(--accent); }
.week-day-title .ymd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.week-day-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.week-day-meta [data-day-done] { color: var(--text); font-weight: 600; }

.week-day-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.week-day-empty {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  align-self: flex-start;
}

/* Strip-specific narrow Today pill (smaller than week-today-pill in headers) */
.week-day-card .week-today-pill {
  font-size: 9px;
  padding: 1px 5px;
}

/* Mobile fallback: when the strip can't fit 7 columns reasonably,
   fall back to a vertical stack — top→bottom Sun..Sat. */
@media (max-width: 720px) {
  .week-strip {
    flex-direction: column;
    gap: 10px;
  }
  .week-day-card {
    min-width: 0;
    padding: 12px 14px;
  }
  .week-day-title .weekday { font-size: 16px; }
  .week-day-title .ymd { font-size: 12px; }
}

/* ----- Drag & drop visual states (Phase 9 + Phase 10 edge strips) ----- */

/* Affordance: items that can be picked up. */
[draggable="true"][data-drag-type] {
  cursor: grab;
}
[draggable="true"][data-drag-type]:active { cursor: grabbing; }

/* The card/row currently being dragged */
.dragging { opacity: 0.4; }

/* Day-card drop target: highlight border + accent glow. */
.week-day-card.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}

/* Meal slot row drop target inside a column. */
.meal-slot-row.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Cross-week nav buttons act as drop zones. */
.week-nav .btn.drag-over {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
[data-theme="dark"] .week-nav .btn.drag-over { color: #111111; }
.week-nav .btn.drag-cross-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Phase 10: edge drop strips around the week-strip — cross-week shift.
   Wrap puts left edge | strip | right edge in one row; edges are flat slivers
   that materialize only while a drag is active (body.dragging-active). */
.week-strip-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.week-strip-wrap .week-strip { flex: 1 1 auto; min-width: 0; }

.week-edge {
  flex: 0 0 36px;
  align-self: stretch;
  border: 1px dashed transparent;
  border-radius: var(--radius);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  user-select: none;
  pointer-events: none;       /* hidden by default — no drop target */
  opacity: 0;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
  position: relative;
}
.week-edge::after {
  /* Tiny chevron hint */
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  opacity: 0.7;
}
.week-edge-left::after { transform: rotate(-135deg); }   /* ← */
.week-edge-right::after { transform: rotate(45deg); }    /* → */

body.dragging-active .week-edge {
  opacity: 1;
  pointer-events: auto;
  border-color: var(--border-strong);
  background: var(--bg-alt);
}
.week-edge.drag-over {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  border-style: solid;
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}
[data-theme="dark"] .week-edge.drag-over { color: #111111; }
.week-edge.drag-cross-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* On mobile (<=720px) the strip is vertical and HTML5 DnD is finicky on
   touch — JS turns drag off there, but kill the cursor affordance too. */
@media (max-width: 720px) {
  [draggable="true"][data-drag-type] { cursor: default; }
  .week-strip-wrap { flex-direction: column; gap: 0; }
  .week-edge { display: none; } /* edges only make sense in horizontal strip */
}

/* ----- Compact tweaks for content inside narrow strip columns -----
   Targets ~110px column width (sidebar 240 + main 1080 ⇒ ~140px each on
   desktop; ~110-120px on 1280 viewport with seven equal columns and 6px gap).
   On mobile @720px the strip flips to vertical column — these compact rules
   are reset there to give content breathing room again. */

/* Meal slot row: label above tick+name+edit (vertical stacking inside row) */
.week-strip .meal-slot-row {
  flex-wrap: wrap;
  gap: 3px 6px;
  padding: 5px 7px;
  min-height: 0;
}
.week-strip .meal-slot-row-label {
  width: auto;
  flex-basis: 100%;
  font-size: 9px;
  letter-spacing: 0.10em;
}
.week-strip .meal-eaten-tick { width: 16px; height: 16px; }
.week-strip .meal-eaten-tick .icon { width: 10px; height: 10px; }
.week-strip .meal-slot-row-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.2;
}
.week-strip .meal-slot-row-edit { width: 20px; height: 20px; }
.week-strip .meal-slot-row-edit .icon { width: 10px; height: 10px; }
.week-strip .meal-slot-row-add {
  font-size: 11px;
  flex: 1 1 auto;
  gap: 4px;
}
.week-strip .meal-slot-row-add .icon { width: 11px; height: 11px; }

/* Workout: stack label and status vertically; actions become icon-only */
.week-strip .workout-session {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.week-strip button.workout-done-btn {
  padding: 6px 8px;
  gap: 6px;
  flex-wrap: wrap;
  row-gap: 3px;
  font-size: 12px;
}
.week-strip button.workout-done-btn .check { width: 18px; height: 18px; border-width: 1px; }
.week-strip button.workout-done-btn .check .icon { width: 11px; height: 11px; }
.week-strip button.workout-done-btn .workout-label {
  flex: 1 1 auto;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.2;
  font-size: 12px;
}
.week-strip button.workout-done-btn .workout-done-text {
  flex-basis: 100%;
  padding-left: 24px;
  font-size: 9px;
}
.week-strip .workout-session-actions {
  align-self: stretch;
  justify-content: flex-end;
  gap: 4px;
}
.week-strip .workout-session-actions .btn-sm {
  padding: 3px 6px;
  font-size: 11px;
  gap: 4px;
}
/* On strip view, hide Edit-button text and keep only the icon to fit narrow column */
.week-strip .workout-session-actions .btn-sm > *:not(.icon) {
  display: none;
}
.week-strip .workout-empty-link {
  padding: 6px 8px;
  font-size: 11px;
  justify-content: center;
  gap: 4px;
}
.week-strip .workout-empty-link .icon { width: 12px; height: 12px; }

/* Mobile fallback: undo strip-mode compactions, restore comfortable sizes */
@media (max-width: 720px) {
  .week-strip .meal-slot-row { padding: 8px 12px; gap: 4px 10px; }
  .week-strip .meal-slot-row-label { font-size: 11px; }
  .week-strip .meal-slot-row-name { font-size: 14px; -webkit-line-clamp: unset; }
  .week-strip .meal-eaten-tick { width: 22px; height: 22px; }
  .week-strip .meal-eaten-tick .icon { width: 14px; height: 14px; }
  .week-strip button.workout-done-btn { font-size: 14px; padding: 10px 14px; gap: 12px; }
  .week-strip button.workout-done-btn .workout-label { font-size: 14px; -webkit-line-clamp: unset; }
  .week-strip button.workout-done-btn .check { width: 22px; height: 22px; }
  .week-strip button.workout-done-btn .check .icon { width: 14px; height: 14px; }
  .week-strip .workout-session-actions .btn-sm > *:not(.icon) { display: inline; }
}

/* ===== Week-strip planner shared bits ===== */

/* Week navigation cluster (page-header, right side) */
.week-nav { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* "Today" pill in week-strip header (shared planner chrome) */
.week-today-pill {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 2px 8px;
  font-weight: 600;
}

/* ===== Meals planner ===== */

/* Day-link inside .week-day-card header (Phase 6) */
.meals-day-link {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  flex-wrap: wrap;
}
.meals-day-link:hover { text-decoration: none; }
.meals-day-link:hover .weekday { color: var(--accent); }

/* Vertical slot-row inside .week-day-card body (Phase 6) */
.meals-day-slots-list { gap: 6px; }

.meal-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.15s;
  min-height: 40px;
}
.meal-slot-row.empty {
  border-style: dashed;
  background: transparent;
}
.meal-slot-row.eaten {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.meal-slot-row-label {
  flex-shrink: 0;
  width: 92px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  font-family: var(--font);
}
.meal-slot-row.eaten .meal-slot-row-label { color: var(--accent); }
.meal-slot-row-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-slot-row-name:hover { color: var(--accent); text-decoration: none; }
.meal-slot-row.eaten .meal-slot-row-name {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent-line);
}
.meal-slot-row-edit {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}
.meal-slot-row-edit:hover { background: var(--surface-2); color: var(--accent); text-decoration: none; }
.meal-slot-row-add {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
}
.meal-slot-row-add:hover { color: var(--accent); text-decoration: none; }
.meal-slot-row-add .icon { width: 14px; height: 14px; }

/* Tiny eaten-tick (also used inside .meal-slot-row) */
.meal-eaten-form { display: inline-flex; margin: 0; }
.meal-eaten-tick {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.meal-eaten-tick .check { color: transparent; display: inline-flex; }
.meal-eaten-tick .icon { width: 14px; height: 14px; }
.meal-eaten-tick:hover { border-color: var(--accent); }
.meal-eaten-tick.eaten {
  background: var(--accent);
  border-color: var(--accent);
}
.meal-eaten-tick.eaten .check { color: #FFFFFF; }
[data-theme="dark"] .meal-eaten-tick.eaten .check { color: #111111; }

/* Meals · day view */
.meals-day-slots {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.meal-slot { transition: border-color 0.15s; }
.meal-slot.eaten { border-color: var(--accent-line); }
.meal-slot-label {
  font-family: var(--font);
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
}
.meal-slot.eaten .meal-slot-label { color: var(--accent); }
.meal-name {
  font-family: var(--font);
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}
.meal-slot.eaten .meal-name strong {
  text-decoration: line-through;
  text-decoration-color: var(--accent-line);
  color: var(--text-soft);
}
.meal-body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-soft);
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.meal-actions { margin-top: 8px; }
.meal-empty-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s;
}
.meal-empty-link:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  text-decoration: none;
}

/* Meals · day view: eaten button */
.meal-eaten-btn { color: var(--text-muted); }
.meal-eaten-btn .icon { color: inherit; }
.meal-eaten-btn.eaten {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Meal form */
.meal-form input[type="date"].input {
  font-family: inherit;
}
.meal-form .meal-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.meal-form .meal-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Delete buttons */
.meal-delete-form { display: inline-block; margin: 0; }
.meal-delete-btn { color: var(--bad); }
.meal-delete-btn:hover { color: #FFFFFF; background: var(--bad); border-color: var(--bad); }
[data-theme="dark"] .meal-delete-btn:hover { color: #111111; }
.meal-delete-btn-text { color: var(--bad); }
.meal-delete-btn-text:hover { color: #FFFFFF; background: var(--bad); border-color: var(--bad); }
[data-theme="dark"] .meal-delete-btn-text:hover { color: #111111; }

/* Shopping list */
.shopping-add-form { padding: 14px; }
.shopping-section { padding: 18px 20px; }
.shopping-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.15s;
}
.shopping-item.bought {
  background: var(--bg-alt);
  border-style: dashed;
}
.shopping-item.bought.archived { opacity: 0.7; }
.shopping-toggle-form { display: inline-flex; margin: 0; }
.shopping-toggle-btn {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
.shopping-toggle-btn:hover { border-color: var(--accent); }
.shopping-toggle-btn .check { color: transparent; display: inline-flex; }
.shopping-toggle-btn .icon { width: 14px; height: 14px; }
.shopping-toggle-btn.bought {
  background: var(--accent);
  border-color: var(--accent);
}
.shopping-toggle-btn.bought .check { color: #FFFFFF; }
[data-theme="dark"] .shopping-toggle-btn.bought .check { color: #111111; }

.shopping-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shopping-item.bought .shopping-name {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent-line);
}
.shopping-qty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.shopping-when {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.shopping-delete-form { display: inline-flex; margin: 0; }
.shopping-delete-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
.shopping-delete-btn:hover {
  color: var(--bad);
  border-color: var(--border);
  background: var(--surface-2);
}

.shopping-archive { padding: 14px 18px; }
.shopping-archive summary {
  cursor: pointer;
  user-select: none;
  color: var(--text-soft);
  font-weight: 500;
  list-style: none;
}
.shopping-archive summary::-webkit-details-marker { display: none; }
.shopping-archive[open] summary { color: var(--text); }

@media (max-width: 720px) {
  .meals-week-table { font-size: 13px; }
  .meals-week-table .meals-day-col { width: 110px; }
  .meals-cell-wrap { padding: 4px 5px; }
  .meal-cell-name { font-size: 12px; }
  .meal-eaten-tick { width: 20px; height: 20px; }
  .shopping-add-form .row { flex-wrap: wrap; }
}

/* ===== Workouts planner =====
   Card chrome lives in shared .week-day-card. Below — only session/empty
   bits inside the card. */

.workout-session {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workout-done-form { display: block; flex: 1; min-width: 0; margin: 0; }
button.workout-done-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
button.workout-done-btn:hover { background: var(--surface-2); }
button.workout-done-btn:focus { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
button.workout-done-btn.done {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
button.workout-done-btn .check {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s;
}
button.workout-done-btn.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
[data-theme="dark"] button.workout-done-btn.done .check { color: #111111; }
button.workout-done-btn .check .icon { width: 14px; height: 14px; }
button.workout-done-btn .workout-label {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
button.workout-done-btn.done .workout-label {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent-line);
}
.workout-done-text {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  flex-shrink: 0;
}
button.workout-done-btn.done .workout-done-text { color: var(--accent); }

.workout-session-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.workout-empty-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s;
}
.workout-empty-link:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  text-decoration: none;
}

/* Session form */
.workout-session-form .workout-checkbox,
.workout-template-form .workout-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.workout-session-form .workout-checkbox input[type="checkbox"],
.workout-template-form .workout-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
/* select.input common styling lives at the top of the file. */

/* Template list */
.workout-templates {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.workout-template { transition: opacity 0.15s; }
.workout-template.archived { opacity: 0.65; border-style: dashed; }
.workout-template-body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-soft);
  white-space: pre-wrap;
}

/* Delete buttons (workouts) */
.workout-delete-form,
.workout-template-delete-form { display: inline-flex; margin: 0; }
.workout-delete-btn { color: var(--bad); }
.workout-delete-btn:hover { color: #FFFFFF; background: var(--bad); border-color: var(--bad); }
[data-theme="dark"] .workout-delete-btn:hover { color: #111111; }
.workout-delete-btn-text { color: var(--bad); }
.workout-delete-btn-text:hover { color: #FFFFFF; background: var(--bad); border-color: var(--bad); }
[data-theme="dark"] .workout-delete-btn-text:hover { color: #111111; }

@media (max-width: 720px) {
  .workout-session { gap: 8px; }
  .workout-session-actions { margin-left: auto; }
  button.workout-done-btn { flex-wrap: wrap; row-gap: 4px; }
  .workout-done-text { order: 3; width: 100%; padding-left: 34px; }
}

/* ===== Habit form (Phase 17) ===== */
.habit-form .habit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.habit-form .habit-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Shared form-level error banner (Phase 17). Reusable across any form. */
.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  color: var(--bad);
  font-size: 14px;
  line-height: 1.45;
}
[data-theme="dark"] .form-error {
  background: color-mix(in srgb, var(--bad) 18%, transparent);
}

/* ===== Habits: inline category-goal edit + habit delete (Phase 21) ===== */
/* Компактная «таблетка» goal: тихая по умолчанию, подсвечивается на hover/focus. */
.goal-edit-form {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 5px 3px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.goal-edit-form:hover,
.goal-edit-form:focus-within {
  border-color: var(--border-strong);
  color: var(--text-soft);
}
.goal-edit-form .goal-input {
  width: 28px;
  padding: 1px 2px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  border: none;
  background: transparent;
  border-radius: 6px;
  -moz-appearance: textfield;         /* убрать стрелки-спиннеры (Firefox) */
}
.goal-edit-form .goal-input::-webkit-outer-spin-button,
.goal-edit-form .goal-input::-webkit-inner-spin-button {
  -webkit-appearance: none;           /* убрать стрелки-спиннеры (WebKit) */
  margin: 0;
}
.goal-edit-form .goal-input:focus {
  outline: none;
  background: var(--surface-2);
}
/* Круглая кнопка сохранения: появляется на hover/focus, не смещая layout. */
.goal-edit-form .goal-save-btn {
  opacity: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  transition: opacity 0.15s, background 0.15s;
}
.goal-edit-form:hover .goal-save-btn,
.goal-edit-form:focus-within .goal-save-btn {
  opacity: 1;
}

.habit-delete-form { display: block; }
.habit-delete-btn-text { color: var(--bad); }
.habit-delete-btn-text:hover {
  color: #FFFFFF;
  background: var(--bad);
  border-color: var(--bad);
}
[data-theme="dark"] .habit-delete-btn-text:hover { color: #111111; }
