:root, html[data-theme="light"] {
  --surface-l0: #ecece8;
  --surface-l1: #f8f7f4;
  --surface-l2: #f0efea;
  --surface-l3: #fdfcf9;
  --surface-input: #f2efe8;
  --surface-track: #ddd7ca;
  --surface-hover: rgba(20, 20, 19, 0.055);
  --border-subtle: #dcd8ce;
  --border-default: #bfb8aa;
  --border-control: #706a60;
  --text-primary: #121211;
  --text-secondary: #413f3a;
  --text-muted: #5f5c55;
  --accent-primary: #b55130;
  --accent-primary-hover: #9c4326;
  --accent-subtle: rgba(181, 81, 48, 0.11);
  --on-accent: #faf9f5;
  --success: #1f5e3c;
  --success-subtle: #e1ece5;
  --danger: #a62b2b;
  --warning: #804e09;
  --cal-work: #2c5c84;
  --cal-personal: #8c476f;
  --cal-deep: #244e73;
  color-scheme: light;
}

html[data-theme="dark"] {
  --surface-l0: #111110;
  --surface-l1: #161614;
  --surface-l2: #1c1b19;
  --surface-l3: #23221f;
  --surface-input: #161614;
  --surface-track: #302d28;
  --surface-hover: rgba(250, 249, 245, 0.06);
  --border-subtle: #2e2c28;
  --border-default: #44413b;
  --border-control: #878278;
  --text-primary: #f5f2ea;
  --text-secondary: #c9c3b8;
  --text-muted: #a8a398;
  --accent-primary: #d97757;
  --accent-primary-hover: #e38a6c;
  --accent-subtle: rgba(217, 119, 87, 0.15);
  --on-accent: #141413;
  --success: #64c488;
  --success-subtle: #16291e;
  --danger: #ec7b72;
  --warning: #e5a946;
  --cal-work: #79a7cc;
  --cal-personal: #c98cb0;
  --cal-deep: #5e8bb0;
  color-scheme: dark;
}

html[data-theme="oled"] {
  --surface-l0: #000000;
  --surface-l1: #11100e;
  --surface-l2: #191715;
  --surface-l3: #22201d;
  --surface-input: #161614;
  --surface-track: #292622;
  --surface-hover: rgba(250, 249, 245, 0.06);
  --border-subtle: #292622;
  --border-default: #3a3631;
  --border-control: #878278;
  --text-primary: #f5f2ea;
  --text-secondary: #c9c3b8;
  --text-muted: #a8a398;
  --accent-primary: #d97757;
  --accent-primary-hover: #e38a6c;
  --accent-subtle: rgba(217, 119, 87, 0.15);
  --on-accent: #141413;
  --success: #64c488;
  --success-subtle: #0f1e15;
  --danger: #ec7b72;
  --warning: #e5a946;
  --cal-work: #79a7cc;
  --cal-personal: #c98cb0;
  --cal-deep: #5e8bb0;
  color-scheme: dark;
}

:root {
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-serif: "Literata", Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-l0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 236px;
  flex-shrink: 0;
  background: var(--surface-l1);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand {
  padding: 2px 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}
.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.nav-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.nav-btn.active {
  background: var(--surface-l2);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
  .nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
  }
}

.rail-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  overflow: hidden;
}

.theme-opt {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 4px;
  cursor: pointer;
}
.theme-opt:last-child { border-right: 0; }
.theme-opt.active {
  background: var(--surface-l3);
  color: var(--text-primary);
  font-weight: 600;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 28px 72px;
  max-width: 1240px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.day-heading {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--text-muted);
  margin-right: 6px;
  vertical-align: middle;
}
.dot.green { background: var(--success); }
.dot.amber { background: var(--warning); }
.dot.red { background: var(--danger); }
.dot.work { background: var(--cal-work); }
.dot.personal { background: var(--cal-personal); }
.dot.accent { background: var(--accent-primary); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  background: var(--accent-primary);
  color: var(--on-accent);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  padding: 7px 13px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 150ms var(--ease), opacity 150ms var(--ease);
}

.btn.sec {
  background: var(--surface-l1);
  color: var(--text-primary);
  border: 1px solid var(--border-control);
  font-weight: 500;
}

.btn.active-demo {
  background: var(--success-subtle);
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}

.btn.mobile-only { display: none; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--accent-primary-hover); }
  .btn.sec:hover { background: var(--surface-l2); }
}

/* Calendar Hub 7-Day Week Strip */
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.day-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-l1);
  color: var(--text-secondary);
}
.day-chip.today {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--on-accent);
}
.day-chip-wd {
  font-size: 12px;
  text-transform: lowercase;
}
.day-chip-num {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.grid-hero {
  display: grid;
  grid-template-columns: 368px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--border-subtle);
}

.wf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--surface-l1);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 16px 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Studio Hero Dial */
.hero-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pillar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.pillar-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 7px 4px 9px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pillar-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

.hero-dial-box {
  position: relative;
  width: 236px;
  height: 236px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

.hero-dial-center {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-dial-kicker {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-dial-num {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 4px 0;
}

.hero-dial-sub {
  font-size: 12px;
  font-weight: 600;
}

.pillar-strip {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border-subtle);
  margin-top: 10px;
  padding-top: 10px;
}

.pillar-cell {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-align: center;
  cursor: pointer;
  padding: 2px 4px;
}
.pillar-cell:last-child { border-right: 0; }
.pillar-cell-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}
.pillar-cell-lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.kpi-num {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}
.stat-strip-cell {
  padding: 10px 10px;
  border-right: 1px solid var(--border-subtle);
}
.stat-strip-cell:last-child { border-right: 0; }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.list-row:last-child { border-bottom: 0; }

.corridor-track {
  position: relative;
  height: 8px;
  background: var(--surface-track);
  border-radius: 2px;
  margin: 8px 0 6px;
}
.corridor-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--cal-work) 30%, transparent);
  border-radius: 2px;
}
.corridor-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--cal-work);
  border-radius: 2px;
}
.corridor-needle {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 14px;
  background: var(--accent-primary);
  border-radius: 1px;
  transform: translateX(-50%);
}

.vital-cell {
  padding: 12px 12px 4px;
  border-right: 1px solid var(--border-subtle);
}
.vital-cell:last-child { border-right: 0; }
.range-bar {
  position: relative;
  height: 5px;
  background: var(--surface-track);
  border-radius: 2px;
  margin: 8px 0 6px;
}
.range-dot {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.bar-track {
  height: 7px;
  background: var(--surface-track);
  border-radius: 2px;
  overflow: hidden;
  flex: 1;
  margin: 0 10px;
}
.bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--cal-work);
  transition: width 200ms var(--ease);
}

.stage-bar {
  display: flex;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
  margin: 12px 0;
  background: var(--surface-track);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

input, select {
  background: var(--surface-input);
  border: 1px solid var(--border-control);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.tag-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-input);
  border: 1px solid var(--border-control);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.tag-btn.on {
  border-color: var(--success);
  color: var(--text-primary);
  background: var(--success-subtle);
  font-weight: 600;
}

.breath-circle {
  width: 94px;
  height: 94px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 2px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  transition: transform 250ms var(--ease);
}

.wf-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wf-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: #000000;
  border: 1px solid var(--border-subtle);
  object-fit: contain;
}

.mobile-nav { display: none; }

@media (max-width: 1080px) {
  .grid-hero { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vital-cell { border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: 10px 4px; }
}

@media (max-width: 920px) {
  .grid-3, .grid-2, .grid-5, .wf-grid, .stat-strip { grid-template-columns: 1fr; }
  .stat-strip-cell { border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: 9px 2px; }
  .stat-strip-cell:last-child, .vital-cell:last-child { border-bottom: 0; }
  .rail { display: none; }
  .btn.mobile-only { display: inline-flex; }
  .main { padding: 16px 14px 82px; }
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-l1);
    border-top: 1px solid var(--border-subtle);
    z-index: 20;
    overflow-x: auto;
    padding: 0 6px;
  }
  .mobile-nav button {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    border-top: 2px solid transparent;
    color: var(--text-muted);
    padding: 12px 11px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
  }
  .mobile-nav button.active {
    color: var(--accent-primary);
    border-top-color: var(--accent-primary);
    font-weight: 600;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
