:root {
  --bg: #f3f0ea;
  --bg-muted: #eae6dd;
  --surface: #fffdf8;
  --surface-2: #f7f3eb;
  --ink: #1c1916;
  --ink-soft: #6f6a63;
  --line: #e4dfd6;
  --line-strong: #d4cec2;
  --accent: #1f4e3d;
  --accent-2: #2a6a53;
  --accent-soft: #e5efe8;
  --warm: #d4a054;
  --danger: #9b2c2c;
  --danger-soft: #f8e8e6;
  --shadow: 0 1px 2px rgba(28, 25, 22, 0.05), 0 10px 30px rgba(28, 25, 22, 0.05);
  --shadow-lg: 0 18px 50px rgba(28, 25, 22, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Figtree", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --nav-h: 64px;
  --bottom-nav: 72px;
  --pad: 20px;
}

html[data-theme="dark"] {
  --bg: #121410;
  --bg-muted: #1a1c18;
  --surface: #1c1e1a;
  --surface-2: #242722;
  --ink: #f1ede4;
  --ink-soft: #a39e94;
  --line: #2c2f29;
  --line-strong: #3a3e36;
  --accent: #8fbf9a;
  --accent-2: #b7d7bd;
  --accent-soft: #243028;
  --warm: #e0b36a;
  --danger: #f0a8a0;
  --danger-soft: #3a2422;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  color-scheme: dark;
}

body {
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
  appearance: none;
  -webkit-appearance: none;
}

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

a {
  color: inherit;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
}

.shell {
  min-height: 100dvh;
  min-height: 100svh;
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--pad) 8px;
  padding-top: max(16px, env(safe-area-inset-top));
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  color: #1f4e3d;
}

.logo-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

html[data-theme="dark"] .logo-mark {
  color: #8fbf9a;
}

.brand .wordmark {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  flex: none;
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
  background: transparent;
}

.theme-switch button.active {
  background: var(--accent);
  color: var(--bg);
}

.theme-switch.compact .theme-label {
  display: none;
}

.theme-switch.compact button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.field .theme-switch {
  width: 100%;
}

.field .theme-switch button {
  flex: 1;
}

.onboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.onboard-head > .brand {
  margin-bottom: 0;
}

.nav-btn,
.icon-btn,
.btn,
.chip,
.seg button {
  border: 0;
  background: transparent;
  transition: 0.15s ease;
}

.nav-btn {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 550;
  font-size: 14px;
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-btn:hover {
  border-color: var(--line-strong);
}

.page {
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 18px;
  flex-wrap: wrap;
}

.page-head h2 {
  font-size: 15px;
  font-weight: 600;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-nav .label {
  min-width: 160px;
  text-align: center;
  font-weight: 600;
}

.week {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.day-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 12px;
  min-height: 420px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  container-type: inline-size;
  container-name: day;
}

.day-card.selected {
  display: flex;
  flex-direction: column;
}

.day-card.today {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.day-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: none;
  overflow: visible;
}

.day-meta {
  min-width: 0;
  width: 100%;
  flex: none;
}

.shift-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.3;
}

.day-kicker {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.3;
}

.day-num {
  font-family: var(--serif);
  font-size: 42px;
  line-height: 0.95;
  margin: 4px 0 10px;
}

.shift-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.times {
  color: var(--ink-soft);
  font-weight: 500;
}

.ring {
  position: relative;
  width: min(var(--size, 180px), 100%);
  height: auto;
  max-width: 100%;
  aspect-ratio: 1;
  flex: none;
  overflow: hidden;
  margin-top: 2px;
  box-sizing: border-box;
  padding: 0;
}

.day-card .ring {
  width: min(280px, 72vw);
  max-width: 100%;
  align-self: center;
  margin: 8px auto 0;
}

.ring svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.ring .track {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}

.ring .value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s ease;
}

.ring span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(16px, 5vw, 28px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ring.mini span {
  font-size: clamp(9px, 2.6vw, 13px);
}

.habits {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  scrollbar-width: thin;
}

.panel > .habits {
  max-height: min(62vh, 540px);
}

.habit {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 12px;
  flex: none;
}

.habit:hover {
  background: var(--surface-2);
}

.habit.auto .check:disabled {
  opacity: 1;
  cursor: default;
}

.auto-tag {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.habit.done .habit-name {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.check {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1.5px solid var(--ink-soft);
  display: grid;
  place-items: center;
  background: var(--surface);
  flex: none;
  padding: 0;
  margin-top: 1px;
}

.habit.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.habit-name {
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font-weight: 550;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  min-width: 0;
}

.habit-name-input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
}

.ghost {
  opacity: 0.35;
}

.add-habit {
  margin-top: 8px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  flex: none;
}

.add-habit input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 12px;
  padding: 11px 12px;
  text-overflow: ellipsis;
}

.add-habit .icon-btn,
.add-habit .btn {
  flex: 0 0 auto;
}

@container day (max-width: 200px) {
  .times,
  .auto-tag,
  .day-card .x {
    display: none;
  }

  .day-kicker {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .day-num {
    font-size: 28px;
  }

  .shift-pill {
    font-size: 12px;
    padding: 5px 8px;
    gap: 6px;
  }

  .habit-name {
    font-size: 13px;
  }

  .add-habit {
    gap: 6px;
  }

  .add-habit input {
    font-size: 12px;
    padding: 8px 8px;
  }

  .add-habit .icon-btn {
    width: 34px;
    height: 34px;
  }
}

.tiny {
  font-size: 12px;
  color: var(--ink-soft);
}

@media (max-width: 739px) {
  .day-card.selected .habits {
    max-height: min(36vh, 280px);
  }

  .month-grid,
  .dow {
    gap: 4px;
  }

  .theme-switch.compact .theme-label {
    display: none;
  }
}

.month {
  margin-top: 28px;
  display: block;
}

.month h3 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 12px;
}

.dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}

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

.mday {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  aspect-ratio: 1;
  min-height: 0;
  min-width: 0;
  padding: 4px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.mday .bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
}

.mday.in-week {
  background: var(--surface-2);
}

.mday.out {
  opacity: 0.38;
}

.mday.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mday.today .n {
  background: var(--ink);
  color: var(--bg);
}

.mday .n {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.mday .ring {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0;
}

.mday .ring span {
  padding-top: 12px;
  font-size: clamp(8px, 2.4vw, 12px);
}

.mday .mini {
  --size: 100%;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.bottom-nav {
  position: relative;
  z-index: 20;
  flex: none;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  padding: 8px 2px;
  border-radius: 12px;
  background: transparent;
}

.bottom-nav button.active {
  color: var(--accent);
  background: var(--accent-soft);
}

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

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

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.seg button {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.seg button.active {
  background: var(--accent);
  color: var(--bg);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}

.strip-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  overflow: hidden;
}

.strip-day strong {
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.strip-day.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.habit-setup {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 14px;
  margin-bottom: 8px;
}

.habit-setup-top {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.habit-setup-top input {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
}

.habit-setup-top input[type="date"] {
  flex: 0 0 148px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.since-strip {
  margin: 0 0 16px;
}

.since-strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.text-link {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  padding: 0;
}

.since-pills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.since-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: baseline;
}

.since-pill span {
  font-size: 13px;
  font-weight: 650;
}

.since-pill strong {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  grid-row: 1 / span 2;
}

.since-pill em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-soft);
}

.since-add {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.since-grid {
  display: grid;
  gap: 12px;
}

.since-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.bmi-card {
  margin-bottom: 0;
}

.habit-targets {
  display: grid;
  gap: 8px;
}

.target-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.target-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  min-width: 64px;
  color: var(--ink-soft);
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: center;
  margin: 8px 0 20px;
}

.stat-value {
  font-family: var(--serif);
  font-size: 48px;
  line-height: 0.95;
}

.muted {
  color: var(--ink-soft);
}

.bar-track {
  height: 8px;
  background: var(--bg-muted);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

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

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
}

.row b {
  font-weight: 650;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.chip:hover,
.chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 650;
  font-size: 14px;
  background: var(--accent);
  color: var(--bg);
  border: 0;
}

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-grid {
  display: grid;
  gap: 0 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 10, 0.55);
  display: grid;
  place-items: end center;
  z-index: 40;
  padding: 12px;
}

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 16px 16px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-height: min(90dvh, 760px);
  overflow: auto;
  isolation: isolate;
}

.modal h3 {
  font-family: var(--serif);
  font-size: 28px;
  margin-bottom: 6px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.food-item,
.history-item {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 0;
  border-radius: 14px;
  padding: 12px;
}

.macros {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.macro-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.macro-card .ring {
  width: min(148px, 42vw);
  max-width: 100%;
}

.pattern {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface-2);
}

.pattern-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 650;
  font-size: 13px;
}

.x {
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 99px;
}

.settings-block {
  margin-bottom: 22px;
}

.settings-block h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.shift-edit {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 40px;
  grid-template-areas:
    "color name del"
    "times times times";
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.shift-edit:not(:has(.shift-del)) {
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-areas:
    "color name"
    "times times";
}

.shift-edit .color {
  grid-area: color;
}

.shift-edit .shift-name {
  grid-area: name;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
}

.shift-times {
  grid-area: times;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.shift-times input[type="time"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.shift-times input[type="time"]::-webkit-datetime-edit {
  display: flex;
  width: 100%;
  padding: 0;
}

.shift-times input[type="time"]::-webkit-datetime-edit-fields-wrapper {
  display: flex;
  align-items: center;
}

.shift-times input[type="time"]::-webkit-datetime-edit-ampm-field {
  margin-left: 4px;
  padding: 0 1px;
}

.shift-del {
  grid-area: del;
  justify-self: end;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.color {
  width: 28px;
  height: 28px;
  border: 0;
  padding: 0;
  background: none;
}

.onboard {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  overflow: auto;
}

.onboard-card {
  width: min(480px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 0 8px;
  box-shadow: none;
  max-height: none;
  overflow: visible;
}

.onboard-card > .brand {
  margin-bottom: 22px;
}

.onboard-body {
  flex: 1 1 auto;
}

.onboard-card h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.08;
  margin: 0 0 12px;
}

.login-card h1 {
  font-size: clamp(28px, 7vw, 38px);
  margin-bottom: 10px;
}

.login-card > .muted {
  margin: 0 0 22px;
}

.login-forgot {
  margin: 18px 0 0;
  text-align: center;
}

.login-card form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.sync-banner {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.auth-note {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 12px;
}

.btn.google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  margin-bottom: 16px;
}

.auth-split {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 4px 0 16px;
}

.auth-split::before,
.auth-split::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.login-card .actions,
.onboard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 24px;
}

.login-card .actions .btn,
.onboard-actions .btn {
  flex: 1;
  min-height: 46px;
}

.onboard-actions > span {
  flex: 1;
}

.btn.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 650;
}

.steps {
  display: flex;
  gap: 6px;
  margin: 0 0 22px;
}

.steps i {
  height: 4px;
  flex: 1;
  border-radius: 99px;
  background: var(--line);
}

.steps i.on {
  background: var(--accent);
}

.empty {
  color: var(--ink-soft);
  padding: 18px 4px;
  text-align: center;
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.qty {
  width: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface);
}

.swipe-hint {
  display: block;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: -6px;
  margin-bottom: 10px;
}

@media (min-width: 740px) {
  .overlay {
    place-items: center;
  }

  .modal {
    border-radius: 22px;
  }

  .bottom-nav {
    display: none;
  }

  .nav-desktop {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .nav-btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  .since-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page {
    padding-bottom: 40px;
    overflow: visible;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .form-grid.two,
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .stat-row {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .week-strip,
  .swipe-hint,
  .extra-only {
    display: none;
  }

  .week {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .day-card,
  .day-card.selected {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 12px 10px 10px;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .day-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
  }

  .week .ring,
  .day-card .ring {
    width: min(100%, 160px);
    max-width: 100%;
    padding: 0;
    margin: 6px auto 0;
    align-self: center;
  }

  .week .ring span,
  .day-card .ring span {
    font-size: clamp(16px, 2vw, 22px);
  }

  .week .habits {
    max-height: 200px;
    min-height: 88px;
  }

  .day-card .habit-name {
    font-size: 14px;
    line-height: 1.35;
  }

  .day-card .add-habit input {
    font-size: 13px;
    padding: 8px 10px;
  }

  .nav-btn {
    padding: 8px 12px;
  }

  .day-num {
    font-size: 32px;
  }

  .habits {
    margin-top: 12px;
  }

  .habit {
    padding: 8px 4px;
  }
}

@media (min-width: 760px) {
  .brand .wordmark {
    font-size: 18px;
  }

  .onboard {
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
  }

  .onboard-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
    width: min(520px, 100%);
    flex: none;
  }

  .shift-edit {
    grid-template-columns: 32px minmax(96px, 1.2fr) minmax(9.5rem, 1fr) minmax(9.5rem, 1fr) 40px;
    grid-template-areas: "color name start end del";
  }

  .shift-edit:not(:has(.shift-del)) {
    grid-template-columns: 32px minmax(96px, 1.2fr) minmax(9.5rem, 1fr) minmax(9.5rem, 1fr);
    grid-template-areas: "color name start end";
  }

  .shift-times {
    display: contents;
  }

  .shift-times input[data-shift-field="startTime"] {
    grid-area: start;
  }

  .shift-times input[data-shift-field="endTime"] {
    grid-area: end;
  }
}

@media (min-width: 980px) {
  :root {
    --pad: 28px;
  }

  .day-num {
    font-size: 34px;
  }
}

.chart-stack {
  display: grid;
  gap: 14px;
}

.chart-card h3 {
  margin-bottom: 8px;
}

.chart-frame {
  min-width: 0;
}

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

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--ink-soft);
  font-size: 11px;
  font-family: var(--font);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
}

.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
}

.chart-key i {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
