/* APD Dashboard styles */

:root {
  --bg: #0a0a0c;
  --bg-elev: #14141a;
  --bg-elev-2: #1c1c25;
  --fg: #e8e8ec;
  --fg-muted: #8e8e9c;
  --fg-dim: #5a5a68;
  --accent: #ff8d4a;
  --accent-dim: #c66f3a;
  --good: #6dd49e;
  --warn: #f0b86e;
  --bad: #e36b6b;
  --border: #2a2a35;
  --mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Consolas', monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--fg-muted);
  font-size: 0.85em;
}

#loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--fg-muted);
  font-family: var(--mono);
}

#error {
  background: var(--bg-elev);
  border-left: 3px solid var(--bad);
  padding: 16px 20px;
  margin: 20px 0;
  font-family: var(--mono);
  color: var(--bad);
  white-space: pre-wrap;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  font-family: var(--mono);
  font-size: 13px;
}

.header-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.separator {
  color: var(--fg-dim);
}

/* Top metrics row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.metric-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-family: var(--mono);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 32px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--fg);
  line-height: 1;
}

.metric-sub {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 6px;
}

.metric.streak .metric-value { color: var(--accent); }
.metric.energy .metric-value { color: var(--good); }
.metric.ntu .metric-value { color: var(--good); }

.energy-bar {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.energy-bar .bar-segment {
  height: 6px;
  flex: 1;
  background: var(--bg-elev-2);
  border-radius: 2px;
}

.energy-bar .bar-segment.filled {
  background: var(--good);
}

/* Tracks */
section h2 {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  font-family: var(--mono);
  margin-bottom: 12px;
  font-weight: 500;
}

.tracks {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.track {
  margin-bottom: 16px;
}

.track:last-child {
  margin-bottom: 0;
}

.track-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 13px;
}

.track-icon {
  font-size: 14px;
}

.track-name {
  font-weight: 600;
  color: var(--fg);
  min-width: 110px;
}

.track-detail {
  flex: 1;
  color: var(--fg-muted);
  font-size: 12px;
}

.track-pct {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.track-bar {
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.track-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.track-meta {
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: 26px;
  font-family: var(--mono);
}

.toptal-track .track-fill {
  background: linear-gradient(90deg, var(--warn), var(--accent));
}

/* Status grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.status-cell {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

.status-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  font-family: var(--mono);
  margin-bottom: 4px;
}

.status-value {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--fg);
}

#dwatch-cell.has-trigger {
  border-left: 3px solid var(--bad);
}

#dwatch-cell.has-trigger .status-value {
  color: var(--bad);
}

#dwatch-cell.has-warn {
  border-left: 3px solid var(--warn);
}

/* Narrative */
.narrative {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.narrative-row {
  display: grid;
  grid-template-columns: 24px 90px 1fr;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.narrative-row:last-child {
  margin-bottom: 0;
}

.narrative-row strong {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.narrative-row span:last-child {
  color: var(--fg);
}

/* Carries */
.carries {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.carry-block {
  margin-bottom: 16px;
}

.carry-block:last-child {
  margin-bottom: 0;
}

.carry-block h3 {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-family: var(--mono);
  margin-bottom: 8px;
  font-weight: 500;
}

.carry-block ul {
  list-style: none;
  padding: 0;
}

.carry-block li {
  padding: 6px 0 6px 20px;
  position: relative;
  font-size: 13px;
  color: var(--fg);
}

.carry-block li::before {
  content: "⏳";
  position: absolute;
  left: 0;
}

/* Anchors and Curiosity Debt */
.anchors, .curiosity-debt {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.anchors ul, .curiosity-debt ul {
  list-style: none;
  padding: 0;
}

.anchors li, .curiosity-debt li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}

.anchors li:last-child, .curiosity-debt li:last-child {
  border-bottom: none;
}

.anchors .anchor-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-right: 8px;
}

.anchors .anchor-content {
  color: var(--fg);
  font-style: italic;
}

.curiosity-debt .ck-topic {
  color: var(--fg);
}

.curiosity-debt .ck-revisit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  margin-left: 8px;
}

/* Footer */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
}

button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
}

button:hover {
  background: var(--bg-elev);
  border-color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
  .metrics-row, .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .narrative-row {
    grid-template-columns: 24px 1fr;
  }

  .narrative-row strong {
    grid-column: span 2;
    margin-top: 4px;
  }

  .track-name {
    min-width: 80px;
  }
}

/* ------------------------------------------------------------------- */
/* v1.1 additions: day banner, break tokens, today's protocol, tomorrow */
/* ------------------------------------------------------------------- */

/* Day type banner ---------------------------------------------------- */
.day-banner {
  margin-bottom: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--bg-elev);
  overflow: hidden;
}

.day-banner-inner {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
}

.day-banner-icon {
  font-size: 28px;
  text-align: center;
}

.day-banner-body {
  min-width: 0;
}

.day-banner-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.day-banner-label .day-banner-sep {
  margin: 0 8px;
  color: var(--fg-dim);
}

.day-banner-label #day-banner-type-label {
  color: var(--fg);
  font-weight: 600;
}

.day-banner-note {
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
}

.day-banner-streak {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.flag-no-count {
  color: var(--warn);
  border-color: var(--warn);
  background: rgba(240, 184, 110, 0.08);
}

.flag-count {
  color: var(--good);
  border-color: var(--good);
  background: rgba(109, 212, 158, 0.08);
}

/* Day type accents — left-border + icon tint */
.day-banner.type-sysdev    { border-left-color: var(--accent); }
.day-banner.type-sysdev    .day-banner-icon { color: var(--accent); }
.day-banner.type-revision  { border-left-color: #6aaedb; }
.day-banner.type-revision  .day-banner-icon { color: #6aaedb; }
.day-banner.type-challenge { border-left-color: var(--bad); }
.day-banner.type-challenge .day-banner-icon { color: var(--bad); }
.day-banner.type-rail2     { border-left-color: #b59cd9; }
.day-banner.type-rail2     .day-banner-icon { color: #b59cd9; }
.day-banner.type-rest      { border-left-color: var(--good); }
.day-banner.type-rest      .day-banner-icon { color: var(--good); }
.day-banner.type-excused   { border-left-color: var(--fg-dim); }
.day-banner.type-excused   .day-banner-icon { color: var(--fg-dim); }

/* Break tokens metric cell ------------------------------------------ */
.metric.break-tokens .metric-value {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.metric.break-tokens.has-tokens .metric-value {
  color: var(--good);
}

.metric.break-tokens .metric-sub {
  color: var(--fg-muted);
  font-size: 11px;
}

/* Today's protocol --------------------------------------------------- */
.today-protocol {
  margin-bottom: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 16px 20px;
}

.today-protocol-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.today-protocol-icon {
  font-size: 18px;
}

.today-protocol-header h2 {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--fg);
  margin: 0;
}

.today-protocol-suggested-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}

.today-protocol-summary {
  font-size: 14px;
  color: var(--fg);
  margin-bottom: 12px;
  line-height: 1.5;
}

.today-protocol-steps {
  list-style: decimal inside;
  padding-left: 4px;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.6;
}

.today-protocol-steps li {
  margin-bottom: 4px;
}

.today-protocol-steps li::marker {
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 12px;
}

.today-protocol.type-sysdev    { border-left-color: var(--accent); }
.today-protocol.type-revision  { border-left-color: #6aaedb; }
.today-protocol.type-challenge { border-left-color: var(--bad); }
.today-protocol.type-rail2     { border-left-color: #b59cd9; }

/* Tomorrow preview --------------------------------------------------- */
.tomorrow-preview {
  margin-bottom: 24px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: start;
}

.tomorrow-preview-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  padding-top: 2px;
}

.tomorrow-preview-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: var(--fg);
  margin-bottom: 4px;
}

.tomorrow-preview-day {
  font-family: var(--mono);
  font-weight: 600;
}

.tomorrow-preview-sep {
  color: var(--fg-dim);
}

.tomorrow-preview-type {
  font-weight: 500;
}

.tomorrow-preview-note {
  flex-basis: 100%;
  color: var(--fg-muted);
  font-size: 12px;
}

.tomorrow-preview-priority {
  grid-column: 2;
  font-size: 13px;
  color: var(--fg);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.tomorrow-preview.type-sysdev    { border-left: 3px solid var(--accent); }
.tomorrow-preview.type-revision  { border-left: 3px solid #6aaedb; }
.tomorrow-preview.type-challenge { border-left: 3px solid var(--bad); }
.tomorrow-preview.type-rail2     { border-left: 3px solid #b59cd9; }

/* System-dev carries block ------------------------------------------ */
#sysdev-block h3 {
  color: var(--accent);
}

/* Responsive override — break-tokens cell stacks on narrow screens */
@media (max-width: 1024px) {
  .metrics-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .metric.break-tokens {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .day-banner-inner {
    grid-template-columns: 40px 1fr;
  }
  .day-banner-streak {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
  }
  .tomorrow-preview {
    grid-template-columns: 1fr;
  }
  .tomorrow-preview-priority {
    grid-column: 1;
  }
}

/* ------------------------------------------------------------------- */
/* v1.2 additions: field metrics (CEI/S/info_proxy), memory cards     */
/* ------------------------------------------------------------------- */

.field-metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.field-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.field-metric-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.field-metric-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  margin-bottom: 2px;
}

.field-metric-S .field-metric-value {
  color: #b59cd9;
}

.field-metric-info .field-metric-value {
  color: #6aaedb;
}

.field-metric-sub {
  font-size: 10px;
  color: var(--fg-muted);
}

/* Active memories panel */
.memory-section {
  margin-bottom: 24px;
}

.memory-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.memory-section-header h2 {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--fg);
  margin: 0;
}

.memory-section-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.memory-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.memory-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.memory-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.memory-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.memory-card-type {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.memory-card-id {
  font-family: var(--mono);
  font-size: 10px;
  margin-left: auto;
}

.memory-card-salience {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.memory-card-content {
  color: var(--fg);
  margin-bottom: 6px;
}

.memory-card-meta {
  font-family: var(--mono);
  font-size: 10px;
}

/* Type-specific accent colors */
.memory-card.mem-anchor      { border-left-color: var(--accent); }
.memory-card.mem-decision    { border-left-color: var(--good); }
.memory-card.mem-trait       { border-left-color: #b59cd9; }
.memory-card.mem-debt        { border-left-color: var(--warn); }
.memory-card.mem-error       { border-left-color: var(--bad); }
.memory-card.mem-prediction  { border-left-color: #6aaedb; }

.memory-card.mem-anchor      .memory-card-icon { color: var(--accent); }
.memory-card.mem-decision    .memory-card-icon { color: var(--good); }
.memory-card.mem-trait       .memory-card-icon { color: #b59cd9; }
.memory-card.mem-debt        .memory-card-icon { color: var(--warn); }
.memory-card.mem-error       .memory-card-icon { color: var(--bad); }
.memory-card.mem-prediction  .memory-card-icon { color: #6aaedb; }

/* Stale anchors */
.stale-section {
  margin-bottom: 24px;
  background: rgba(240, 110, 110, 0.04);
  border: 1px solid rgba(240, 110, 110, 0.25);
  border-radius: 6px;
  padding: 12px 16px;
}

.stale-heading {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--bad);
  margin: 0 0 10px 0;
}

.stale-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stale-item {
  display: grid;
  grid-template-columns: 180px 110px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}

.stale-item:last-child { border-bottom: none; }

.stale-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.stale-days {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--bad);
}

.stale-content { color: var(--fg); }

.stale-action { grid-column: 3; font-size: 10px; }

@media (max-width: 1024px) {
  .field-metrics-row { grid-template-columns: repeat(3, 1fr); }
  .memory-list { grid-template-columns: 1fr; }
  .stale-item { grid-template-columns: 1fr; }
  .stale-action { grid-column: 1; }
}

@media (max-width: 768px) {
  .field-metrics-row { grid-template-columns: repeat(2, 1fr); }
}

/* ─────────────────────────────────────────────────────────────
   v2 INTERACTIVITY: sync badge, energy pips, tick buttons
   ───────────────────────────────────────────────────────────── */

/* Sync badge --------------------------------------------------- */
.sync-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}
.sync-badge.sync-live    { color: #46d160; }
.sync-badge.sync-saving  { color: #f5b301; animation: pulse 1.4s ease-in-out infinite; }
.sync-badge.sync-error   { color: #ff5f5f; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* Energy pips -------------------------------------------------- */
.energy-setter {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  align-items: center;
}
.energy-pip {
  width: 1.6rem;
  height: 1.6rem;
  min-width: 1.6rem;
  border-radius: 50%;
  border: 2px solid var(--fg-muted, rgba(255,255,255,0.3));
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.energy-pip:hover {
  border-color: var(--accent, #f5b301);
  background: rgba(245, 179, 1, 0.08);
}
.energy-pip:active {
  transform: scale(0.92);
}
.energy-pip.filled {
  background: var(--accent, #f5b301);
  border-color: var(--accent, #f5b301);
}
.energy-sub {
  margin-top: 0.3rem;
  font-size: 0.78rem;
}

/* Task tick buttons -------------------------------------------- */
.carry-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.25rem 0;
  transition: opacity 0.35s ease;
}
.carry-item.done {
  opacity: 0.45;
}
.carry-item.done .carry-text {
  text-decoration: line-through;
}
.tick-btn {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  border-radius: 50%;
  border: 1.5px solid var(--fg-muted, rgba(255,255,255,0.3));
  background: transparent;
  color: var(--fg-muted, rgba(255,255,255,0.4));
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  transition: all 0.15s ease;
}
.tick-btn:hover {
  border-color: #46d160;
  color: #46d160;
}
.tick-btn:active {
  transform: scale(0.9);
}
.tick-btn.ticked {
  background: #46d160;
  border-color: #46d160;
  color: #fff;
}
.carry-text {
  flex: 1;
  word-break: break-word;
}
.carry-empty {
  color: var(--fg-muted, rgba(255,255,255,0.4));
  font-style: italic;
  padding-left: 1.95rem;
}

/* Mobile responsive tweaks ------------------------------------ */
@media (max-width: 600px) {
  .metrics-row { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .metric.energy { grid-column: span 2; }
  .energy-pip { width: 2rem; height: 2rem; min-width: 2rem; }
  .tick-btn   { width: 1.7rem; height: 1.7rem; min-width: 1.7rem; font-size: 1.1rem; }
  header { flex-wrap: wrap; gap: 0.4rem; }
  .header-right { flex-basis: 100%; }
}

/* ─────────────────────────────────────────────────────────────
   v2.1: site header, loading state, protocol panel, mobile
   ───────────────────────────────────────────────────────────── */

/* Site title block ----------------------------------------------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.2rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.site-name {
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent, #f5b301);
  letter-spacing: 0.15em;
  line-height: 1;
  margin: 0;
}
.site-tagline {
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 0.72rem;
  color: var(--fg-muted, rgba(255,255,255,0.45));
  letter-spacing: 0.04em;
  margin: 0.35rem 0 0 0;
}
.site-header-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.reload-btn {
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  color: var(--fg, #e6e6e6);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, border-color 0.15s ease;
}
.reload-btn:hover {
  border-color: var(--accent, #f5b301);
  transform: rotate(180deg);
}

/* Loading state -------------------------------------------------- */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}
.loading-inner {
  text-align: center;
}
.loading-logo {
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent, #f5b301);
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
}
.loading-text {
  color: var(--fg-muted, rgba(255,255,255,0.5));
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 0.85rem;
  animation: loading-pulse 1.5s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* Today's Protocol panel ---------------------------------------- */
.today-protocol {
  background: var(--bg-elev, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-left: 4px solid var(--accent, #f5b301);
  border-radius: 0.5rem;
  padding: 1.2rem 1.4rem;
  margin: 0.8rem 0 1.2rem 0;
}
.today-protocol-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: start;
  margin-bottom: 0.8rem;
}
.today-protocol-icon {
  font-size: 1.6rem;
  line-height: 1;
}
.today-protocol-title {
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent, #f5b301);
  margin: 0;
  line-height: 1.2;
}
.today-protocol-summary {
  font-size: 0.88rem;
  color: var(--fg, #e6e6e6);
  margin: 0.2rem 0 0 0;
  line-height: 1.4;
}
.today-protocol-time {
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 0.72rem;
  color: var(--fg-muted, rgba(255,255,255,0.5));
  white-space: nowrap;
  align-self: center;
}
.today-protocol-steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
}
.today-protocol-steps li {
  counter-increment: step;
  padding: 0.5rem 0 0.5rem 2.2rem;
  position: relative;
  font-size: 0.92rem;
  line-height: 1.5;
  border-top: 1px dashed var(--border, rgba(255,255,255,0.08));
}
.today-protocol-steps li:first-child { border-top: none; }
.today-protocol-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 1.5px solid var(--accent, #f5b301);
  color: var(--accent, #f5b301);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Day-type colour variants */
.today-protocol.type-challenge { border-left-color: #ff7b29; }
.today-protocol.type-challenge .today-protocol-title,
.today-protocol.type-challenge .today-protocol-steps li::before { color: #ff7b29; border-color: #ff7b29; }

.today-protocol.type-rail2 { border-left-color: #6aa6ff; }
.today-protocol.type-rail2 .today-protocol-title,
.today-protocol.type-rail2 .today-protocol-steps li::before { color: #6aa6ff; border-color: #6aa6ff; }

.today-protocol.type-revision { border-left-color: #b39ddb; }
.today-protocol.type-revision .today-protocol-title,
.today-protocol.type-revision .today-protocol-steps li::before { color: #b39ddb; border-color: #b39ddb; }

.today-protocol.type-sysdev { border-left-color: #46d160; }
.today-protocol.type-sysdev .today-protocol-title,
.today-protocol.type-sysdev .today-protocol-steps li::before { color: #46d160; border-color: #46d160; }

/* Mobile responsive --------------------------------------------- */
@media (max-width: 1024px) {
  .metrics-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  #app { padding: 16px; }
  .site-name { font-size: 1.2rem; }
  .site-tagline { font-size: 0.65rem; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .metric.energy { grid-column: span 2; }
  .day-banner-inner { grid-template-columns: 36px 1fr; gap: 10px; }
  .day-banner-streak { grid-column: 2; justify-self: start; margin-top: 3px; }
  .today-protocol-header { grid-template-columns: auto 1fr; }
  .today-protocol-time { grid-column: 1 / -1; margin-top: 0.4rem; }
  .energy-pip { width: 2.2rem; height: 2.2rem; min-width: 2.2rem; }
  .tick-btn { width: 1.9rem; height: 1.9rem; min-width: 1.9rem; font-size: 1.1rem; }
  header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .header-right { align-self: flex-start; }
}

@media (max-width: 480px) {
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 1.4rem; }
  .site-header { flex-direction: column; gap: 0.6rem; }
  .site-header-right { align-self: flex-start; }
  .today-protocol { padding: 1rem; }
  .today-protocol-steps li { padding-left: 1.9rem; font-size: 0.86rem; }
  .today-protocol-steps li::before { width: 1.4rem; height: 1.4rem; font-size: 0.7rem; }
}
