:root {
  --ink: #24312d;
  --muted: #596863;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --line: #e6e2d8;
  --sage: #6d8c7b;
  --sage-dark: #476657;
  --sage-soft: #e2ebe4;
  --clay: #c47b5b;
  --clay-soft: #f5e6dc;
  --amber: #d6a13d;
  --amber-soft: #f7edcf;
  --red: #a9564d;
  --red-soft: #f6e4e0;
  --blue: #5b7fa3;
  --blue-soft: #e3ebf2;
  --shadow: 0 18px 50px rgba(49, 64, 57, 0.09);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 30px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(226, 235, 228, 0.9), transparent 28rem),
    var(--paper);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #52789e;
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -0.035em; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.02; }
h2 { margin-bottom: 0.35rem; font-size: 1.25rem; }
p { color: var(--muted); line-height: 1.6; }

.eyebrow {
  margin-bottom: 0.6rem;
  color: var(--sage-dark);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: var(--sage-dark);
  color: white;
}

.brand-mark svg { width: 26px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark--large { width: 64px; height: 64px; margin: 0 auto 1.5rem; border-radius: 21px; }
.brand-mark--large svg { width: 42px; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    linear-gradient(rgba(247, 245, 239, 0.45), rgba(247, 245, 239, 0.88)),
    radial-gradient(circle at 70% 10%, #dce9df 0, transparent 32rem),
    radial-gradient(circle at 10% 90%, #f3e7d8 0, transparent 28rem),
    var(--paper);
}

.login-card {
  width: min(100%, 430px);
  padding: clamp(2rem, 7vw, 3.5rem);
  text-align: center;
  border: 1px solid rgba(230, 226, 216, 0.85);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-card h1 { font-size: 2.35rem; }
.login-copy { max-width: 300px; margin: 0 auto 2rem; }
.login-form { text-align: left; }
.login-form > label, .form-field label, .habit-fields label, .preference-grid label {
  display: grid;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
}

input, select {
  width: 100%;
  min-height: 46px;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface-strong);
}

input:focus, select:focus { border-color: var(--sage); }
.password-field { position: relative; margin-top: 0.45rem; }
.password-field input { padding-right: 3.25rem; }
.password-field .icon-button { position: absolute; top: 4px; right: 4px; }
.form-error { margin: 0.6rem 0 0; color: var(--red); font-size: 0.82rem; font-weight: 700; }
.privacy-note { margin: 1.6rem 0 0; color: #65736e; font-size: 0.76rem; }
.privacy-note span { color: var(--sage); }

.primary-button, .secondary-button, .ghost-button, .quiet-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.68rem 1rem;
  border-radius: 13px;
  font-weight: 760;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button { border: 1px solid var(--sage-dark); color: #fff; background: var(--sage-dark); box-shadow: 0 8px 18px rgba(71, 102, 87, 0.18); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 11px 22px rgba(71, 102, 87, 0.24); }
.primary-button--full { width: 100%; margin-top: 1rem; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.secondary-button:hover { background: var(--sage-soft); }
.ghost-button { border: 1px solid transparent; color: var(--muted); background: transparent; }
.ghost-button:hover { color: var(--ink); background: #efede7; }
.quiet-button { min-height: 36px; padding: 0.45rem 0.8rem; border: 0; color: var(--sage-dark); background: var(--sage-soft); font-size: 0.8rem; }
button:disabled { cursor: wait; opacity: 0.62; transform: none !important; }

.icon-button, .avatar-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover { background: rgba(36, 49, 45, 0.06); }
.icon-button.bordered { border: 1px solid var(--line); background: var(--surface); }
.avatar-button { border-radius: 50%; color: white; background: var(--clay); font-weight: 850; }

.app-shell { min-height: 100vh; padding-bottom: 5.5rem; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, calc((100vw - 1120px) / 2)) 0.75rem;
  border-bottom: 1px solid rgba(230, 226, 216, 0.7);
  background: rgba(247, 245, 239, 0.87);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 0.7rem; color: var(--ink); font-size: 1.05rem; font-weight: 850; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 0.65rem; }
.content { width: min(100% - 2rem, 1080px); margin: 0 auto; }
.view { display: none; padding: clamp(2rem, 6vw, 4rem) 0; animation: rise 230ms ease both; }
.view.is-active { display: block; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.today-hero { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.hero-date { margin: 0; color: var(--muted); font-size: 1rem; text-transform: capitalize; }
.progress-ring {
  --progress: 0;
  position: relative;
  display: grid;
  width: 120px;
  height: 120px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--sage) calc(var(--progress) * 1%), var(--sage-soft) 0);
}

.progress-ring::before { position: absolute; inset: 9px; border-radius: inherit; background: var(--paper); content: ""; }
.progress-ring div { z-index: 1; display: grid; text-align: center; }
.progress-ring strong { font-size: 1.45rem; letter-spacing: -0.05em; }
.progress-ring span { color: var(--muted); font-size: 0.68rem; }

.day-message {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 2.2rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid #d6e2d8;
  border-radius: var(--radius);
  background: rgba(226, 235, 228, 0.7);
}

.day-message__icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--sage); }
.day-message div { display: grid; gap: 0.15rem; }
.day-message span:last-child { color: var(--muted); font-size: 0.86rem; }
.today-actions { display: flex; justify-content: flex-end; margin: -1.25rem 0 1.25rem; }
.today-actions .secondary-button { min-height: 40px; }

.routine-blocks { display: grid; gap: 2rem; }
.routine-block__heading { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.75rem; }
.routine-block__heading h2 { margin: 0; font-size: 0.92rem; letter-spacing: 0.06em; text-transform: uppercase; }
.routine-block__heading span { color: var(--muted); font-size: 0.75rem; }
.routine-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 24px rgba(49, 64, 57, 0.04); }

.routine-item {
  display: grid;
  grid-template-columns: 62px 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  min-height: 78px;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  transition: background 160ms ease;
}

.routine-item:last-child { border-bottom: 0; }
.routine-item:hover { background: #fbfaf5; }
.routine-item.is-done { background: rgba(226, 235, 228, 0.5); }
.routine-item.is-skipped { opacity: 0.64; }
.routine-time {
  min-height: 36px;
  padding: 0.25rem 0;
  border: 0;
  border-bottom: 1px dashed #a7aaa4;
  color: var(--muted);
  background: transparent;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}
.routine-time:hover { color: var(--sage-dark); border-color: var(--sage-dark); }
.routine-emoji { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: #efede6; font-size: 1.2rem; }
.routine-item.is-done .routine-emoji { background: var(--sage-soft); }
.routine-info { min-width: 0; }
.routine-info strong { display: block; overflow: hidden; font-size: 0.96rem; text-overflow: ellipsis; white-space: nowrap; }
.routine-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.23rem; color: var(--muted); font-size: 0.73rem; }
.routine-meta .late { color: #9a6b12; }
.routine-meta .done { color: var(--sage-dark); }
.routine-meta .skipped { color: var(--muted); }
.routine-meta .postponed { color: var(--blue); }

.check-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1.5px solid #cfcac0;
  border-radius: 50%;
  background: var(--surface-strong);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.check-button:hover { transform: scale(1.05); border-color: var(--sage); }
.is-done .check-button { border-color: var(--sage); color: white; background: var(--sage); }
.is-skipped .check-button { color: var(--muted); background: #ebe9e2; }
.is-postponed .check-button { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.page-heading h1 { font-size: clamp(2rem, 5vw, 3rem); }
.page-heading p:last-child { margin: 0; }
.week-controls { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.week-controls strong { min-width: 190px; text-align: center; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem 1.2rem; margin-bottom: 1.5rem; color: var(--muted); font-size: 0.73rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot--done { background: var(--sage); }
.status-dot--late { background: var(--amber); }
.status-dot--missed { background: var(--red); }
.status-dot--skipped { background: #8b8982; }
.status-dot--postponed { background: var(--blue); }

.week-matrix { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.week-matrix table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.week-activity-column { width: 29%; }
.week-matrix th, .week-matrix td { min-width: 0; padding: 0.75rem 0.25rem; border-bottom: 1px solid var(--line); text-align: center; }
.week-matrix th { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; }
.week-matrix thead th:not(:first-child) span, .week-matrix thead th:not(:first-child) strong { display: block; }
.week-matrix th:first-child, .week-matrix td:first-child { padding-left: 1rem; text-align: left; background: var(--surface); }
.week-matrix tr:last-child td { border-bottom: 0; }
.week-habit { display: flex; min-width: 0; align-items: center; gap: 0.55rem; }
.week-habit span { flex: 0 0 auto; }
.week-habit strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-cell { display: inline-grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 0; border-radius: 11px; font-size: 0.8rem; cursor: pointer; }
.week-cell--done { color: var(--sage-dark); background: var(--sage-soft); }
.week-cell--late { color: #8c610d; background: var(--amber-soft); }
.week-cell--missed { color: var(--red); background: var(--red-soft); }
.week-cell--skipped { color: #7e7b74; background: #ebe9e2; }
.week-cell--postponed { color: var(--blue); background: var(--blue-soft); }
.week-cell--pending { border: 1px dashed #d1cdc3; color: #a7a39a; }
.week-cell--none { color: #cbc8c0; }
.week-cell--none { cursor: default; }
.today-column { background: rgba(226, 235, 228, 0.22); }

.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.segmented button { padding: 0.5rem 0.7rem; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.segmented button.is-active { color: var(--ink); background: var(--sage-soft); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.metric-card { display: grid; min-height: 150px; align-content: center; padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric-card--accent { border-color: #d5e1d7; background: var(--sage-soft); }
.metric-card span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.metric-card strong { margin: 0.3rem 0; font-size: 2.25rem; letter-spacing: -0.06em; }
.metric-card small { color: var(--muted); line-height: 1.4; }
.chart-card, .settings-card { margin-top: 1.2rem; padding: clamp(1.15rem, 3vw, 1.7rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.35rem; }
.card-heading h2, .card-heading p { margin-bottom: 0; }
.card-heading p { font-size: 0.8rem; }
.settings-help, .compact-help { margin-bottom: 1rem; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.notification-heading { gap: 1rem; align-items: start; }
.notification-heading > div { min-width: 0; }
.status-pill { display: inline-flex; flex: 0 0 auto; align-items: center; padding: 0.38rem 0.62rem; border-radius: 999px; color: var(--muted); background: #efede7; font-size: 0.68rem; font-weight: 800; }
.status-pill--active { color: var(--sage-dark); background: var(--sage-soft); }
.status-pill--warning { color: #8c610d; background: var(--amber-soft); }
.notification-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.bar-chart { display: flex; min-height: 210px; align-items: end; gap: clamp(3px, 1vw, 10px); overflow-x: auto; padding-top: 1rem; border-bottom: 1px solid var(--line); }
.bar-column { display: grid; min-width: 8px; height: 190px; flex: 1; align-items: end; gap: 0.45rem; text-align: center; }
.bar-column i { display: block; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--sage); transition: height 400ms ease; }
.bar-column span { overflow: hidden; color: var(--muted); font-size: 0.58rem; text-overflow: clip; white-space: nowrap; }
.habit-stats { display: grid; gap: 1rem; }
.habit-stat { display: grid; grid-template-columns: minmax(130px, 220px) minmax(100px, 1fr) 42px; align-items: center; gap: 1rem; }
.habit-stat__name { display: flex; min-width: 0; align-items: center; gap: 0.55rem; }
.habit-stat__name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-track { height: 8px; overflow: hidden; border-radius: 999px; background: #ece9e1; }
.stat-track i { display: block; height: 100%; border-radius: inherit; background: var(--clay); }
.habit-stat strong { text-align: right; font-size: 0.8rem; }

.preference-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.settings-list-heading { display: flex; align-items: end; justify-content: space-between; margin: 2.5rem 0 0.8rem; }
.settings-list-heading h2, .settings-list-heading p { margin: 0; }
.settings-list-heading p, .settings-list-heading > span { color: var(--muted); font-size: 0.78rem; }
.habits-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.habit-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto 30px; align-items: center; gap: 0.9rem; width: 100%; min-height: 75px; padding: 0.7rem 1rem; border: 0; border-bottom: 1px solid var(--line); text-align: left; background: transparent; cursor: pointer; }
.habit-row:last-child { border-bottom: 0; }
.habit-row:hover { background: #fbfaf5; }
.habit-row__emoji { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: #efede6; font-size: 1.18rem; }
.habit-row__text { min-width: 0; }
.habit-row__text strong, .habit-row__text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-row__text small, .habit-row__schedule { color: var(--muted); font-size: 0.74rem; }
.habit-row.is-inactive { opacity: 0.55; }
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-state > span { display: block; margin-bottom: 0.75rem; font-size: 2.3rem; }
.empty-state p { max-width: 390px; margin-inline: auto; }

.skeleton-list { display: grid; gap: 0.8rem; }
.skeleton { min-height: 76px; border-radius: var(--radius); background: linear-gradient(90deg, #ebe8df 20%, #f6f4ee 50%, #ebe8df 80%); background-size: 220% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton--table { min-height: 350px; }
@keyframes shimmer { to { background-position: -220% 0; } }

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: calc(68px + env(safe-area-inset-bottom));
  padding: 0.45rem max(0.5rem, calc((100vw - 620px) / 2)) env(safe-area-inset-bottom);
  border-top: 1px solid rgba(230, 226, 216, 0.9);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-nav a { display: grid; place-content: center; gap: 0.12rem; border-radius: 13px; color: #64716c; text-align: center; text-decoration: none; }
.bottom-nav a span { font-size: 1.15rem; }
.bottom-nav a small { font-size: 0.64rem; font-weight: 750; }
.bottom-nav a.is-active { color: var(--sage-dark); background: var(--sage-soft); }

.modal { width: min(calc(100% - 2rem), 440px); max-height: min(92dvh, 820px); padding: 0; overflow-x: hidden; overflow-y: auto; border: 0; border-radius: var(--radius-lg); color: var(--ink); background: var(--surface); box-shadow: 0 28px 90px rgba(30, 43, 37, 0.24); overscroll-behavior: contain; }
.modal--wide { width: min(calc(100% - 2rem), 700px); }
.modal::backdrop { background: rgba(31, 40, 36, 0.5); backdrop-filter: blur(5px); }
.modal form { position: relative; padding: clamp(1.5rem, 5vw, 2.4rem); }
.modal-close { position: absolute; top: 0.8rem; right: 0.8rem; font-size: 1.5rem; }
.modal-emoji { display: grid; width: 52px; height: 52px; margin-bottom: 1rem; place-items: center; border-radius: 17px; background: var(--sage-soft); font-size: 1.5rem; }
.modal h2 { margin-bottom: 0.4rem; font-size: 1.65rem; }
.modal-copy { margin-bottom: 1.3rem; }
.form-field { margin-top: 1rem; }
.unit-field { position: relative; }
.unit-field input { padding-right: 4rem; }
.unit-field span { position: absolute; top: 14px; right: 1rem; color: var(--muted); font-size: 0.8rem; }
.checkin-actions { margin-top: 1rem; }
.split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.6rem; }
.habit-fields { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 1rem; margin: 1.3rem 0; }
.habit-fields .name-field { grid-column: span 2; }
.habit-fields .emoji-field input { text-align: center; font-size: 1.3rem; }
.schedule-editor { margin: 1.5rem 0; padding: 0; border: 0; }
.schedule-editor legend { font-weight: 800; }
.schedule-editor > p { margin-bottom: 0.8rem; font-size: 0.78rem; }
.schedule-bulk { display: grid; grid-template-columns: minmax(135px, 1fr) auto auto; align-items: end; gap: 0.55rem; margin-bottom: 0.9rem; padding: 0.8rem; border: 1px solid #d5e1d7; border-radius: var(--radius-sm); background: rgba(226, 235, 228, 0.55); }
.schedule-bulk label { display: grid; gap: 0.35rem; font-size: 0.75rem; font-weight: 800; }
.schedule-bulk input { min-height: 42px; }
.schedule-row { display: grid; grid-template-columns: 42px minmax(90px, 1fr) 120px; align-items: center; gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.schedule-row:last-child { border-bottom: 0; }
.schedule-row > span { font-size: 0.84rem; font-weight: 700; }
.schedule-row input[type="checkbox"], .toggle-row input { width: 22px; min-height: 22px; accent-color: var(--sage-dark); }
.schedule-row input[type="time"] { min-height: 40px; }
.schedule-row.is-disabled { opacity: 0.48; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border-radius: var(--radius-sm); background: #f1efe8; }
.toggle-row span { display: grid; gap: 0.18rem; }
.toggle-row small { color: var(--muted); }
.modal-footer { display: flex; justify-content: end; gap: 0.7rem; margin-top: 1.5rem; }
.modal-footer--wrap { flex-wrap: wrap; justify-content: space-between; }
.scope-options { display: grid; gap: 0.55rem; margin: 1.2rem 0; padding: 0; border: 0; }
.scope-options legend { margin-bottom: 0.55rem; font-size: 0.82rem; font-weight: 800; }
.scope-options label { display: flex; align-items: start; gap: 0.7rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.scope-options label:has(input:checked) { border-color: var(--sage); background: var(--sage-soft); }
.scope-options label:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.scope-options input { width: 20px; min-height: 20px; flex: 0 0 auto; margin: 0.15rem 0 0; accent-color: var(--sage-dark); }
.scope-options span { display: grid; gap: 0.18rem; }
.scope-options small { color: var(--muted); line-height: 1.35; }
.alarm-button { display: flex; width: 100%; align-items: center; gap: 0.75rem; padding: 0.85rem; border: 1px solid #d7c98a; border-radius: var(--radius-sm); color: #634d0d; text-align: left; background: var(--amber-soft); cursor: pointer; }
.alarm-button > span:first-child { font-size: 1.35rem; }
.alarm-button > span:last-child { display: grid; gap: 0.15rem; }
.alarm-button small { color: #7b681f; }
.alarm-button + .compact-help { margin-top: 0.55rem; }
.quick-habit-fields { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0.8rem; margin-top: 1rem; }
.quick-habit-fields label { display: grid; gap: 0.4rem; font-size: 0.8rem; font-weight: 750; }
.quick-habit-fields .emoji-field input { text-align: center; font-size: 1.25rem; }
.quick-habit-fields .time-field { grid-column: 1 / -1; }
.quick-habit-fields + .compact-help { margin-top: 0.65rem; }

.toast-region { position: fixed; z-index: 100; top: max(1rem, env(safe-area-inset-top)); right: 1rem; display: grid; gap: 0.5rem; width: min(calc(100% - 2rem), 360px); }
.toast { padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--surface-strong); box-shadow: var(--shadow); animation: toast-in 200ms ease both; }
.toast--error { border-color: #edc7c1; background: var(--red-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (min-width: 900px) {
  .app-shell { padding-bottom: 1rem; }
  .content { padding-left: 120px; }
  .bottom-nav { top: 112px; right: auto; bottom: auto; left: max(1rem, calc((100vw - 1160px) / 2)); display: flex; width: 88px; min-height: 0; flex-direction: column; gap: 0.4rem; padding: 0; border: 0; background: transparent; backdrop-filter: none; }
  .bottom-nav a { min-height: 65px; }
}

@media (max-width: 760px) {
  .content { width: min(100% - 1.2rem, 1080px); }
  .topbar { min-height: 64px; padding-inline: 0.8rem; }
  .today-hero { align-items: end; }
  .progress-ring { width: 92px; height: 92px; }
  .progress-ring strong { font-size: 1.2rem; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading > button, .page-heading .segmented { align-self: stretch; }
  .segmented button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 130px; }
  .habit-fields { grid-template-columns: 80px 1fr; }
  .habit-fields .name-field { grid-column: auto; }
  .habit-fields label:not(.emoji-field):not(.name-field) { grid-column: span 2; }
}

@media (max-width: 520px) {
  .view { padding-top: 1.7rem; }
  .today-hero h1 { max-width: 220px; }
  .progress-ring { width: 82px; height: 82px; }
  .day-message { align-items: start; }
  .routine-item { grid-template-columns: 44px 40px minmax(0, 1fr) 38px; gap: 0.55rem; padding: 0.7rem 0.65rem; }
  .routine-time { font-size: 0.7rem; }
  .routine-emoji { width: 38px; height: 38px; border-radius: 12px; }
  .check-button { width: 36px; height: 36px; }
  .metric-grid { gap: 0.6rem; }
  .metric-card { padding: 1rem; }
  .metric-card strong { font-size: 1.8rem; }
  .preference-grid { grid-template-columns: 1fr; }
  .settings-list-heading > span { display: none; }
  .habit-row { grid-template-columns: 42px minmax(0, 1fr) 24px; }
  .habit-row__schedule { display: none; }
  .habit-stat { grid-template-columns: minmax(115px, 1fr) 1fr 36px; gap: 0.5rem; }
  .schedule-row { grid-template-columns: 36px 1fr 100px; gap: 0.5rem; }
  .week-activity-column { width: 27%; }
  .week-matrix th, .week-matrix td { padding: 0.58rem 0.08rem; }
  .week-matrix th { font-size: 0.58rem; }
  .week-matrix th:first-child, .week-matrix td:first-child { padding-left: 0.4rem; }
  .week-habit { gap: 0.25rem; }
  .week-habit span { font-size: 0.72rem; }
  .week-habit strong { font-size: 0.65rem; letter-spacing: -0.01em; }
  .week-cell { width: 26px; height: 28px; border-radius: 8px; font-size: 0.72rem; }
  .schedule-bulk { grid-template-columns: 1fr 1fr; }
  .schedule-bulk label { grid-column: 1 / -1; }
  .schedule-bulk button { min-height: 40px; padding-inline: 0.5rem; font-size: 0.7rem; }
  .notification-heading { flex-wrap: wrap; }
  .notification-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .notification-actions .primary-button { grid-column: 1 / -1; }
}

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