:root {
  --bg: #0b0c0e;
  --panel: #17191c;
  --panel-raised: #1e2124;
  --border: #2c2f33;
  --text: #f2f2f2;
  --muted: #9aa0a6;

  --accent: #33d17a;
  --accent-soft: rgba(51, 209, 122, 0.08);

  --negative: #ff6b6b;
  --negative-soft: rgba(255, 107, 107, 0.08);
  --negative-soft-strong: rgba(255, 107, 107, 0.14);

  --future: #5aa0ff;
  --future-soft: rgba(90, 160, 255, 0.06);

  --today: #ffc400;
  --today-soft: rgba(255, 196, 0, 0.18);

  --gold-bg: #2a2712;
  --gold-border: #55501f;

  --radius-container: 12px;
  --radius-control: 8px;
  --radius-control-sm: 6px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  --transition: 160ms ease;

  --font-size-base: 19px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.4;
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-8);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  padding: 0.9rem 0;
}

nav.tabs {
  display: flex;
  gap: var(--space-1);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--text); }

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

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.75rem var(--space-6) 4rem;
}

h2 {
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 0 var(--space-4);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-container);
  padding: var(--space-6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.card-title {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.loading { animation: pulse 1.4s ease-in-out infinite; }

.error-banner {
  display: none;
  background: var(--negative-soft-strong);
  border: 1px solid var(--negative);
  color: var(--negative);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  margin-bottom: var(--space-5);
  font-size: 0.95rem;
}

.error-banner.visible { display: block; }
.error-banner::before { content: "\26A0  "; }

.hero-card {
  position: relative;
  text-align: center;
  padding: 2.75rem var(--space-6) 2.25rem;
  margin-bottom: var(--space-5);
}

.gear-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition), transform var(--transition);
}

.gear-btn:hover {
  color: var(--text);
  border-color: var(--text);
  transform: rotate(30deg);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--transition), border-color var(--transition), transform var(--transition);
}

.icon-btn:hover { color: var(--text); border-color: var(--text); }
.icon-btn.expanded { transform: rotate(90deg); }

.icon-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stopwatch-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.stopwatch-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-right: auto;
}

.stopwatch-title { margin-bottom: 0; }

.stopwatch-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--muted);
}

.stopwatch-status.running { color: var(--accent); border-color: var(--accent); }
.stopwatch-status.paused { color: var(--today); border-color: var(--today); }

.stopwatch-last-session {
  color: var(--muted);
  font-size: 0.85rem;
}

.stopwatch-motivation {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.stopwatch-motivation.met { color: var(--accent); }

.stop-confirm-detail {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.stop-confirm-error {
  color: var(--negative);
  font-size: 0.85rem;
  margin-top: -0.5rem;
  margin-bottom: var(--space-2);
}

.stopwatch-motivation[hidden] { display: none; }

.stopwatch-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stopwatch-actions .btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.stopwatch-body {
  margin-top: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.stopwatch-body[hidden] { display: none; }

.stopwatch-display {
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 6rem;
}

.stopwatch-body input[type="text"] {
  flex: 1;
  min-width: 10rem;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.hero-label {
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.hero-value {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.hero-value.positive { color: var(--accent); }
.hero-value.negative { color: var(--negative); }

.hero-sub {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-top: 1.75rem;
}

.sub-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.sub-label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sub-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.sub-value.positive { color: var(--accent); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
  animation: fade-in var(--transition);
}

.modal-overlay[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-container);
  padding: var(--space-6);
  width: min(22rem, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.weekday-targets-title {
  margin-top: var(--space-5);
}

.weekday-targets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 1rem;
}

.weekday-targets .field-row {
  margin-bottom: 0.5rem;
}

.weekly-total-row {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.weekly-total-row .field-value {
  color: var(--accent);
}

.break-popup-panel {
  text-align: center;
  width: min(28rem, 92vw);
}

.break-popup-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: var(--space-4);
}

.break-popup-detail {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.break-popup-panel .dialog-actions { margin-top: var(--space-6); }

@keyframes break-flash {
  0%, 100% { background: rgba(0, 0, 0, 0.6); }
  50% { background: rgba(255, 107, 107, 0.5); }
}

.break-popup-overlay.flashing { animation: break-flash 1s ease-in-out infinite; }

.break-popup-overlay.flashing .break-popup-panel {
  border-color: var(--negative);
}

.dialog-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: 1.1rem;
}

.dialog-actions .btn { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-control);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition), border-color var(--transition);
}

.btn:active { transform: translateY(1px); }
.btn[hidden] { display: none; }

.btn-primary {
  background: var(--accent);
  color: #06210f;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--text); }

.load-more-btn {
  display: block;
  width: 100%;
  margin-top: var(--space-4);
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: 0.85rem;
}

.field-row label,
.field-row .field-label {
  color: var(--text);
  font-size: 0.95rem;
}

.field-row input {
  width: 6rem;
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  color: var(--text);
  border-radius: var(--radius-control-sm);
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  text-align: right;
  transition: border-color var(--transition);
}

.field-row .field-value {
  font-weight: 700;
  font-size: 1.1rem;
}

.entry-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.entry-form label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.entry-form input {
  display: block;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  transition: border-color var(--transition);
}

.entry-form input:focus-visible { border-color: var(--accent); }

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}

tr:last-child td { border-bottom: none; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0;
  margin-right: var(--space-2);
  transition: color var(--transition);
}

.link-btn:hover { color: var(--text); }
.link-btn[data-clear]:hover { color: var(--negative); }

.timeline {
  padding-top: var(--space-1);
}

.timeline-gaps {
  position: relative;
  height: 1.1rem;
  margin-bottom: 0.15rem;
}

.timeline-gap-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.timeline-track {
  position: relative;
  height: 28px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.timeline-segment {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: var(--accent);
  border-radius: 4px;
  min-width: 4px;
}

.timeline-segment.live { animation: pulse 1.4s ease-in-out infinite; }

/* The "planned" row sits above the real one, deliberately a thinner
   outlined "ghost" rather than a solid fill so it never competes with
   the actual (accent-filled) segments below it for attention. */
.timeline-objective-track {
  position: relative;
  height: 14px;
  margin-bottom: 0.3rem;
}

.timeline-objective-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--panel-raised);
  border: 1px solid var(--muted);
  border-radius: 4px;
  min-width: 4px;
}

/* Lets a school morning or a midday class be accounted for: the
   objective row normally anchors to today's first logged session (or
   "now" if nothing's logged yet), but some days that's wrong, so this
   overrides it. Scoped to today only (stored with today's date, and
   ignored once the date no longer matches) so it doesn't silently
   carry over and mislead tomorrow's plan. */
.plan-start-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: 0.8rem;
}

.plan-start-row input[type="time"] {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.plan-start-row input[type="time"]:focus-visible { border-color: var(--accent); }

.timeline-axis {
  position: relative;
  height: 1.2rem;
  margin-top: 0.4rem;
}

.timeline-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.timeline-tick:first-child { transform: translateX(0); }
.timeline-tick:last-child { transform: translateX(-100%); }

.day-row {
  cursor: pointer;
  transition: filter var(--transition);
}

.day-row:hover { filter: brightness(1.15); }

.day-row.met td:nth-child(3) { color: var(--accent); font-weight: 700; }
.day-row.short td:nth-child(3) { color: var(--negative); font-weight: 700; }

.debt-cell.positive { color: var(--accent); font-weight: 700; }
.debt-cell.negative { color: var(--negative); font-weight: 700; }
.day-row.met { background: var(--accent-soft); }
.day-row.short { background: var(--negative-soft); }
.day-row.future { background: var(--future-soft); color: var(--muted); }
.day-row.today {
  background: var(--today-soft);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--today);
}

/* Performance dashboard */

.perf-empty {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: var(--space-6) 0;
}

.perf-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.perf-kpi {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: var(--space-4);
  text-align: center;
}

.perf-kpi-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-1);
}

.perf-kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}

.perf-kpi-value.positive { color: var(--accent); }
.perf-kpi-value.negative { color: var(--negative); }

.perf-kpi-sub {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: var(--space-1);
}

.perf-chart-card {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.perf-chart-card:last-child { margin-bottom: 0; }

.perf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: 0.75rem;
}

.perf-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.perf-legend-dot.met { background: var(--accent); }
.perf-legend-dot.short { background: var(--negative); }
.perf-legend-dot.nodata { background: var(--border); }
.perf-legend-dot.objective { background: var(--panel-raised); border: 1px solid var(--muted); }

.balance-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.balance-chart-wrap .perf-point { cursor: default; }
.balance-chart-wrap .perf-point:hover { r: 5; }

.balance-chart-wrap .perf-end-label {
  font-size: 12px;
  font-weight: 700;
}

.balance-chart-wrap .perf-end-label.positive { fill: var(--accent); }
.balance-chart-wrap .perf-end-label.negative { fill: var(--negative); }

.balance-chart-wrap .perf-axis-label {
  font-size: 9px;
  fill: var(--muted);
}

/* Bar charts (last-30-days & day-of-week) share this structure:
   .bar-chart > .bar-chart-plot > .bar-col (one per bar) > .bar-scale
   (the fixed-height coordinate space bars/ticks position against) >
   .bar-fill / .bar-target-tick, plus a label below the column. */

.bar-chart-plot {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
}

.bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.bar-scale {
  position: relative;
  width: 100%;
  flex: 1;
}

.bar-fill {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 24px;
  transform: translateX(-50%);
  border-radius: 4px 4px 0 0;
  transition: filter var(--transition);
}

.bar-fill.met { background: var(--accent); }
.bar-fill.short { background: var(--negative); }
.bar-fill.nodata {
  width: 3px;
  max-width: 3px;
  height: 3px !important;
  border-radius: 2px;
  background: var(--border);
}

.bar-col:hover .bar-fill.met,
.bar-col:hover .bar-fill.short { filter: brightness(1.2); }

.bar-target-tick {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--muted);
  opacity: 0.6;
}

.bar-col.today .bar-target-tick { background: var(--today); opacity: 1; }

.bar-col-label {
  margin-top: var(--space-2);
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

.bar-col.today .bar-col-label { color: var(--today); font-weight: 700; }

.day-row .chevron {
  color: var(--muted);
  text-align: right;
  width: 1.5rem;
}

.day-detail-row td {
  padding: var(--space-4) var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.mini-timeline {
  margin-bottom: var(--space-4);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.session-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.session-time { color: var(--text); min-width: 11rem; }
.session-minutes { color: var(--muted); min-width: 4rem; }
.session-note { color: var(--muted); flex: 1; min-width: 6rem; }

.session-empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.session-row.editing input {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control-sm);
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.session-row.editing input:focus-visible { border-color: var(--accent); }

.session-row.editing input[type="text"] { flex: 1; min-width: 6rem; }

.log-view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.view-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-control-sm);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.view-toggle-btn:hover { color: var(--text); }

.view-toggle-btn.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.calendar-month-label {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 10rem;
  text-align: center;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: var(--space-2);
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-control-sm);
  border: 1px solid var(--border);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--panel-raised);
}

.calendar-cell.outside {
  border-color: transparent;
  background: none;
}

.calendar-cell.met { background: var(--accent-soft); border-color: var(--accent); }
.calendar-cell.short { background: var(--negative-soft); border-color: var(--negative); }
.calendar-cell.future { background: var(--future-soft); }

.calendar-cell.today {
  background: var(--today-soft);
  border-color: var(--today);
  font-weight: 700;
}

.calendar-daynum {
  font-size: 0.85rem;
  color: var(--muted);
}

.calendar-cell.met .calendar-daynum,
.calendar-cell.short .calendar-daynum,
.calendar-cell.today .calendar-daynum { color: var(--text); }

.calendar-hours {
  font-size: 0.9rem;
  font-weight: 700;
  align-self: flex-end;
}

.calendar-cell.met .calendar-hours { color: var(--accent); }
.calendar-cell.short .calendar-hours { color: var(--negative); }

.habits-add-form { margin-bottom: var(--space-4); }
.habits-close-btn { width: 100%; }

.habit-list {
  display: flex;
  flex-direction: column;
}

.habit-block {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.habit-block:last-child { border-bottom: none; }

.habit-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.habit-backfill-wrap {
  margin-left: calc(2.75rem + var(--space-4));
  margin-top: var(--space-2);
}

.habit-backfill-form {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.habit-backfill-input {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}

.habit-backfill-toggle {
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
}

.habit-backfill-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.habit-backfill-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.habit-toggle {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.3rem;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.habit-toggle:hover { border-color: var(--accent); }

.habit-toggle.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #06210f;
}

.habit-info {
  min-width: 9rem;
  flex-shrink: 0;
}

.habit-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.habit-streak {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.habit-grid {
  display: flex;
  gap: 3px;
  flex: 1;
  overflow-x: auto;
  padding-bottom: 2px;
}

.habit-cell {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 4px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: filter var(--transition);
}

.habit-cell:hover { filter: brightness(1.3); }

.habit-cell.done { background: var(--accent); border-color: var(--accent); }
.habit-cell.today { box-shadow: 0 0 0 2px var(--today); }

.habits-manage-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  max-height: 16rem;
  overflow-y: auto;
}

.habit-manage-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.habit-manage-row .habit-manage-label { flex: 1; }

.habit-manage-row input[type="text"] {
  flex: 1;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-control-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.habit-empty {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: var(--space-6) 0;
}

.notes-add-form input[type="text"] {
  flex: 1;
  min-width: 12rem;
}

.notes-list {
  display: flex;
  flex-direction: column;
}

.note-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

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

.note-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.note-text {
  flex: 1;
  font-size: 1rem;
}

.note-row.done .note-text {
  color: var(--muted);
  text-decoration: line-through;
}

/* Focus mode: a full-screen takeover (above the header/nav, below
   modals) for a permanently-displayed screen - deliberately the
   opposite of the rest of the dashboard: one number, no ticking
   seconds, no motion, nothing that updates more than once a minute. */
.focus-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6);
}

.focus-mode-overlay[hidden] { display: none; }

.focus-exit {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--transition);
}

.focus-exit:hover { opacity: 1; }

.focus-status {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
}

.focus-status.running { color: var(--accent); }

/* Hidden by default - the time is a deliberate tap away, not something
   sitting on screen to watch. Sized and colored to be an obvious,
   easy target despite being understated, per "accessible easily". */
.focus-time-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.focus-time-toggle:hover { color: var(--text); border-color: var(--text); }

.focus-time-reveal {
  margin-top: var(--space-6);
  animation: fade-in var(--transition);
}

.focus-time-reveal[hidden] { display: none; }

.focus-minutes {
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.focus-minutes-label {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: var(--space-2);
}

.focus-message {
  color: var(--muted);
  font-size: 1.05rem;
  margin-top: var(--space-5);
  min-height: 1.4em;
}

.focus-message.met { color: var(--accent); font-weight: 600; }

.focus-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.focus-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  opacity: 0.8;
}

.focus-btn:hover { opacity: 1; border-color: var(--text); color: var(--text); }

.lockin-card {
  text-align: center;
  padding: 3rem var(--space-6);
}

.lockin-display {
  font-size: 3.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-6);
}

.lockin-btn {
  font-size: 1.1rem;
  padding: 0.9rem 2.2rem;
}

.notes-empty {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: var(--space-6) 0;
}

/* Phone layout. Everything above already uses relative units and a
   handful of flex-wrap/overflow-x escape hatches, so this only needs
   to fix the spots that genuinely break at phone width: the nav bar
   (four tabs plus the brand overflow a ~375-430px screen at full
   size), and padding/type sizes that eat too much of a narrow
   screen's width to be worth their normal desktop generosity. */
@media (max-width: 640px) {
  .app-header {
    flex-wrap: wrap;
    padding: 0 var(--space-3);
    gap: var(--space-1);
  }

  .brand { padding: 0.6rem 0; font-size: 1.05rem; }

  nav.tabs {
    flex-wrap: wrap;
    width: 100%;
    gap: 0;
    padding-bottom: 0.3rem;
  }

  .tab-btn { padding: 0.55rem 0.7rem; font-size: 0.95rem; }

  main { padding: 1.25rem 1rem 3rem; }

  .card { padding: var(--space-4); }

  .hero-card { padding: 2rem 1rem 1.75rem; }

  .hero-value { font-size: 2.75rem; }

  .hero-sub { gap: var(--space-4) var(--space-5); flex-wrap: wrap; }

  .modal-panel { padding: var(--space-4); }

  .lockin-card { padding: 2rem 1rem; }

  .lockin-display { font-size: 2.5rem; }

  .focus-minutes { font-size: 4.5rem; }
}
