:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --surface: #fffdf8;
  --surface-soft: #edf6f0;
  --ink: #24302c;
  --muted: #66736d;
  --line: #d8ddd4;
  --green: #6f9b83;
  --blue: #6e93a5;
  --gold: #c5a64d;
  --rose: #bb7c7c;
  --button: #24483b;
  --button-ink: #fffdf8;
  --glow: rgba(111, 155, 131, 0.22);
  --shadow: 0 12px 30px rgba(37, 52, 44, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111715;
    --surface: #18211d;
    --surface-soft: #1d2b26;
    --ink: #f1f4ee;
    --muted: #a7b2ac;
    --line: #33423c;
    --green: #9bc5aa;
    --blue: #9dbdca;
    --gold: #d9c279;
    --rose: #daa0a0;
    --button: #bdd9c8;
    --button-ink: #111715;
    --glow: rgba(155, 197, 170, 0.13);
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 72%, transparent), transparent 320px),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 7vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

.small-button,
.tab,
.quick-actions button,
form button,
.primary,
.secondary-button,
.danger-button {
  min-height: 46px;
  border-radius: 8px;
  padding: 10px 13px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 750;
}

.small-button.active,
.tab.active,
.quick-actions button:focus,
.quick-actions button:hover,
form button,
.primary {
  background: var(--button);
  color: var(--button-ink);
  border-color: var(--button);
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.hidden {
  display: none;
}

.danger-button {
  color: #7f2f28;
  border-color: color-mix(in srgb, #a43f32 55%, var(--line));
}

@media (prefers-color-scheme: dark) {
  .danger-button {
    color: #f0aaa2;
  }
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 8px 0 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.tab {
  min-height: 40px;
  padding: 8px 6px;
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 12px;
}

.metric {
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric.wide {
  grid-column: 1 / -1;
  min-height: 86px;
}

.metric-label,
label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.daily-note {
  margin: 0 0 16px;
  padding: 15px 16px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface-soft);
}

.hero-note {
  border-left: 0;
  text-align: center;
  padding: 17px 18px;
}

.daily-note p {
  margin: 0;
  line-height: 1.45;
}

.battery-hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 8px 0 18px;
  padding: 8px 0 4px;
}

.battery-orb {
  --battery-level: 8%;
  position: relative;
  width: min(280px, 74vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--green) 36%, var(--line));
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 26%, rgba(255, 255, 255, 0.72), transparent 30%),
    color-mix(in srgb, var(--surface) 82%, var(--surface-soft));
  box-shadow: 0 24px 70px var(--glow);
}

.battery-fill {
  position: absolute;
  inset: auto 0 0;
  height: var(--battery-level);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--green) 70%, white), var(--green));
  opacity: 0.72;
  transition: height 500ms ease;
}

.battery-center {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
}

.battery-center span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.battery-center strong {
  font-size: clamp(44px, 14vw, 72px);
  line-height: 0.95;
}

#battery-caption {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.soft-metrics {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin: 0 0 14px;
}

.soft-metrics article {
  min-height: 84px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.soft-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.soft-metrics strong {
  font-size: 18px;
  line-height: 1.2;
}

.primary-actions {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}

.primary-actions button {
  min-height: 56px;
}

.morning-flow {
  margin: 0 0 18px;
}

.flow-card {
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--line));
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flow-card h2 {
  margin-bottom: 8px;
}

.flow-card p {
  color: var(--muted);
  line-height: 1.45;
}

.flow-progress {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
}

.flow-progress span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-progress div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.flow-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.flow-form {
  display: grid;
  gap: 16px;
}

.flow-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.choice {
  position: relative;
  min-height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice:has(input:checked) {
  color: var(--button-ink);
  background: var(--button);
  border-color: var(--button);
}

.choice span {
  font-size: 24px;
  font-weight: 850;
}

.choice small {
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
}

.completion-card {
  text-align: center;
}

.completion-card button {
  margin-top: 8px;
}

.notice-card {
  margin: 0 0 14px;
  padding: 15px 16px;
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--line));
  border-radius: 8px;
  background: var(--surface-soft);
}

.notice-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.notice-card p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.notice-card p:last-child {
  margin-bottom: 0;
}

.intention-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}

.cards {
  display: grid;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: clip;
}

.panel summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  padding: 0 16px 16px;
}

.form-grid.compact {
  padding: 0;
}

.form-grid .full,
.form-grid button {
  grid-column: 1 / -1;
}

.toast {
  min-height: 28px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
}

.list {
  display: grid;
  gap: 10px;
}

.row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.row h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.row p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.data-tools {
  margin-top: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.button-row button {
  flex: 1 1 150px;
}

.danger-zone {
  border-color: color-mix(in srgb, #a43f32 42%, var(--line));
}

.settings-grid textarea {
  min-height: 180px;
}

.empty {
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
}

body.simple-mode [data-extra],
body.simple-mode .optional-extra {
  display: none;
}

body.simple-mode .quick-actions {
  grid-template-columns: repeat(2, 1fr);
}

body.simple-mode .quick-actions button {
  min-height: 58px;
}

@media (max-width: 620px) {
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: start;
  }

  .small-button {
    min-width: 104px;
  }

  .tabs,
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .primary-actions,
  .soft-metrics,
  .intention-row,
  .form-grid,
  .flow-actions {
    grid-template-columns: 1fr;
  }

  .choice-grid {
    grid-template-columns: repeat(5, minmax(54px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .intention-row button {
    width: 100%;
  }
}
