:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-muted: #f0f1f4;
  --surface-elevated: rgba(255, 255, 255, 0.96);
  --text: #1d1d1f;
  --text-soft: #6e6e73;
  --text-faint: #98989d;
  --line: rgba(60, 60, 67, 0.13);
  --line-strong: rgba(60, 60, 67, 0.2);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.11);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.12);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.13);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.12);
  --purple: #af52de;
  --purple-soft: rgba(175, 82, 222, 0.12);
  --shadow: 0 16px 46px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 26px rgba(15, 23, 42, 0.055);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 17px;
  --radius-sm: 13px;
  --sidebar-width: 242px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08090b;
  --surface: rgba(26, 27, 31, 0.86);
  --surface-solid: #17181c;
  --surface-muted: #212328;
  --surface-elevated: rgba(29, 30, 35, 0.97);
  --text: #f5f5f7;
  --text-soft: #a1a1a6;
  --text-faint: #74747a;
  --line: rgba(235, 235, 245, 0.1);
  --line-strong: rgba(235, 235, 245, 0.18);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.17);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --purple: #bf5af2;
  --purple-soft: rgba(191, 90, 242, 0.16);
  --shadow: 0 16px 52px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.23);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 4%, rgba(0, 122, 255, 0.085), transparent 25rem),
    radial-gradient(circle at 44% 92%, rgba(175, 82, 222, 0.065), transparent 29rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}
::selection { background: var(--accent-soft); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  padding: 26px 17px 22px;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
}
.brand {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0 8px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: white;
  font-weight: 760;
  font-size: 20px;
  background: linear-gradient(145deg, #1689ff, #0062df 62%, #164a9c);
  box-shadow: 0 10px 24px rgba(0, 122, 255, 0.28), inset 0 1px 0 rgba(255,255,255,.32);
}
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 17px; letter-spacing: -0.025em; }
.brand-copy small { color: var(--text-soft); font-size: 12px; }
.side-nav { display: grid; gap: 5px; }
.nav-item {
  min-height: 46px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 580;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item:active { transform: scale(.985); }
.nav-item.is-active { color: var(--accent); background: var(--accent-soft); }
.nav-icon, .nav-item svg { width: 21px; height: 21px; flex: none; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 13px; }
.privacy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.3;
}
.privacy-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 92px;
  padding: 18px clamp(24px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
.topbar-copy { min-width: 0; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 640;
  letter-spacing: .055em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.045em; line-height: 1.05; }
h2 { font-size: 25px; letter-spacing: -.035em; }
h3 { font-size: 18px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .primary-button, .secondary-button, .danger-button, .chip-button, .segmented-button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, opacity .16s ease, box-shadow .16s ease;
}
.icon-button:active, .primary-button:active, .secondary-button:active, .danger-button:active, .chip-button:active { transform: scale(.965); }
.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.icon-button svg { width: 20px; height: 20px; }
.primary-button, .secondary-button, .danger-button {
  min-height: 45px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-weight: 660;
}
.primary-button { color: #fff; background: var(--accent); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 25%, transparent); }
.primary-button:hover { box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 34%, transparent); }
.primary-button.compact { min-height: 42px; padding-inline: 15px; }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 18px; height: 18px; }
.secondary-button { color: var(--text); background: var(--surface-muted); }
.danger-button { color: var(--red); background: var(--red-soft); }
.is-hidden { display: none !important; }

.main-content { padding: 28px clamp(24px, 4vw, 58px) 80px; max-width: 1550px; margin: 0 auto; }
.view-enter { animation: viewEnter .28s cubic-bezier(.22,.72,.22,1); }
@keyframes viewEnter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.dashboard-main { grid-template-columns: minmax(0, 1.65fr) minmax(315px, .75fr); align-items: start; }
.grid.dashboard-main > *, .stack, .card { min-width: 0; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; }
.section-gap { margin-top: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}
.card.pad { padding: 22px; }
.card.pad-lg { padding: clamp(22px, 3vw, 32px); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.card-header h2, .card-header h3 { margin-bottom: 4px; }
.card-header p { margin-bottom: 0; color: var(--text-soft); font-size: 13px; line-height: 1.45; }
.card-action { color: var(--accent); background: transparent; border: 0; font-weight: 620; cursor: pointer; white-space: nowrap; }

.metric-card { min-height: 150px; padding: 21px; position: relative; overflow: hidden; }
.metric-card::after {
  content: "";
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  right: -32px;
  top: -36px;
  background: var(--metric-tint, var(--accent-soft));
  filter: blur(1px);
}
.metric-label { position: relative; z-index: 1; color: var(--text-soft); font-size: 12px; font-weight: 690; letter-spacing: .045em; text-transform: uppercase; }
.metric-value { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 6px; margin-top: 22px; font-size: clamp(27px, 3vw, 36px); font-weight: 740; letter-spacing: -.05em; }
.metric-value small { font-size: 14px; color: var(--text-soft); font-weight: 600; letter-spacing: 0; }
.metric-foot { position: relative; z-index: 1; margin-top: 8px; color: var(--text-soft); font-size: 12px; line-height: 1.35; }
.metric-accent { color: var(--accent); }
.metric-green { color: var(--green); }
.metric-orange { color: var(--orange); }
.metric-purple { color: var(--purple); }

.hero-card { min-height: 320px; display: grid; grid-template-columns: minmax(250px, .75fr) minmax(0, 1.35fr); overflow: hidden; }
.hero-progress {
  padding: 29px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(150deg, var(--surface-solid), color-mix(in srgb, var(--accent-soft) 55%, var(--surface-solid)));
  border-right: 1px solid var(--line);
}
.hero-progress h2 { margin-bottom: 8px; }
.hero-progress p { color: var(--text-soft); line-height: 1.5; }
.progress-ring {
  --value: 0deg;
  width: 178px;
  aspect-ratio: 1;
  align-self: center;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--value), var(--surface-muted) 0);
  position: relative;
  box-shadow: inset 0 0 0 1px var(--line), 0 16px 34px rgba(0, 122, 255, .12);
}
.progress-ring::before { content: ""; width: 132px; aspect-ratio: 1; border-radius: 50%; background: var(--surface-elevated); box-shadow: inset 0 0 0 1px var(--line); }
.progress-ring-copy { position: absolute; text-align: center; }
.progress-ring-copy strong { display: block; font-size: 32px; letter-spacing: -.05em; }
.progress-ring-copy small { color: var(--text-soft); font-size: 12px; }
.hero-chart { padding: 27px; min-width: 0; }
.chart-wrap { position: relative; width: 100%; height: 225px; }
.chart-wrap.tall { height: 295px; }
canvas { display: block; width: 100%; height: 100%; }
.empty-chart {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
}

.today-card { padding: 23px; }
.score-row { display: flex; align-items: center; gap: 17px; }
.score-badge {
  width: 86px;
  height: 86px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 27px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -.05em;
}
.score-copy h3 { margin-bottom: 5px; }
.score-copy p { margin-bottom: 0; color: var(--text-soft); font-size: 13px; line-height: 1.45; }
.recommendation-box { margin-top: 20px; padding: 17px; border-radius: 17px; background: var(--surface-muted); }
.recommendation-box .mini-label { color: var(--text-soft); font-size: 11px; font-weight: 720; letter-spacing: .05em; text-transform: uppercase; }
.recommendation-box p { margin: 8px 0 0; line-height: 1.52; font-size: 14px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.quick-action {
  min-height: 76px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.quick-action:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.quick-action-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--accent); background: var(--accent-soft); }
.quick-action-icon svg { width: 19px; height: 19px; }
.quick-action strong { display: block; font-size: 13px; }
.quick-action small { display: block; margin-top: 3px; color: var(--text-soft); font-size: 11px; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.week-day { min-height: 112px; padding: 14px 10px; border-radius: 17px; background: var(--surface-muted); border: 1px solid transparent; text-align: center; }
.week-day.is-today { border-color: color-mix(in srgb, var(--accent) 48%, transparent); background: var(--accent-soft); }
.week-day strong { display: block; font-size: 12px; color: var(--text-soft); text-transform: uppercase; }
.week-day .day-number { margin-top: 8px; font-size: 20px; font-weight: 730; }
.week-day .day-plan { margin-top: 8px; font-size: 10px; line-height: 1.3; color: var(--text-soft); }
.day-markers { min-height: 14px; display: flex; justify-content: center; gap: 4px; margin-top: 8px; }
.day-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.day-dot.run { background: var(--green); }
.day-dot.food { background: var(--orange); }
.day-dot.warning { background: var(--red); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 7px; min-height: 31px; padding: 0 11px; border-radius: 999px; background: var(--surface-muted); color: var(--text-soft); font-size: 12px; font-weight: 610; }
.pill.good { color: var(--green); background: var(--green-soft); }
.pill.warn { color: var(--orange); background: var(--orange-soft); }
.pill.bad { color: var(--red); background: var(--red-soft); }
.pill.accent { color: var(--accent); background: var(--accent-soft); }

/* Calendar */
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 18px; align-items: start; }
.calendar-card { padding: 22px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.calendar-toolbar h2 { margin: 0; text-transform: capitalize; }
.calendar-nav { display: flex; gap: 8px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.calendar-weekdays { margin-bottom: 7px; }
.calendar-weekdays span { color: var(--text-faint); font-size: 11px; font-weight: 690; text-transform: uppercase; text-align: center; }
.calendar-cell {
  min-height: 105px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.calendar-cell:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.calendar-cell.is-muted { opacity: .42; }
.calendar-cell.is-today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.calendar-cell.is-selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 62%, transparent); }
.calendar-date { font-weight: 700; font-size: 13px; }
.calendar-cell .cell-plan { display: block; margin-top: 7px; color: var(--text-soft); font-size: 9px; line-height: 1.25; }
.calendar-cell .day-markers { justify-content: flex-start; position: absolute; left: 10px; bottom: 9px; }
.day-detail { position: sticky; top: 116px; padding: 22px; }
.day-detail h2 { margin-bottom: 4px; }
.day-detail .detail-date { color: var(--text-soft); font-size: 13px; text-transform: capitalize; }
.timeline { display: grid; gap: 12px; margin-top: 20px; }
.timeline-item { display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 12px; align-items: start; }
.timeline-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-muted); color: var(--accent); }
.timeline-icon svg { width: 18px; height: 18px; }
.timeline-copy { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.timeline-copy strong { display: block; font-size: 13px; }
.timeline-copy p { margin: 4px 0 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }

/* Journal */
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-muted); overflow-x: auto; max-width: 100%; }
.segmented-button { min-height: 34px; padding: 0 13px; border-radius: 11px; background: transparent; color: var(--text-soft); white-space: nowrap; font-size: 12px; font-weight: 640; }
.segmented-button.is-active { color: var(--text); background: var(--surface-solid); box-shadow: 0 3px 10px rgba(15,23,42,.06); }
.entry-list { display: grid; gap: 10px; }
.entry-row {
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 14px;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: var(--surface-solid);
}
.entry-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: var(--accent); background: var(--accent-soft); }
.entry-icon.run { color: var(--green); background: var(--green-soft); }
.entry-icon.food { color: var(--orange); background: var(--orange-soft); }
.entry-icon.habit { color: var(--red); background: var(--red-soft); }
.entry-icon svg { width: 21px; height: 21px; }
.entry-main strong { display: block; font-size: 14px; }
.entry-main p { margin: 5px 0 0; color: var(--text-soft); font-size: 12px; line-height: 1.4; }
.entry-meta { text-align: right; color: var(--text-soft); font-size: 11px; }
.entry-actions { display: flex; align-items: center; gap: 7px; }
.mini-button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; border: 0; background: var(--surface-muted); color: var(--text-soft); cursor: pointer; }
.mini-button.danger { color: var(--red); }
.mini-button svg { width: 15px; height: 15px; }
.empty-state { min-height: 260px; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--text-soft); }
.empty-state-icon { width: 64px; height: 64px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 22px; background: var(--surface-muted); color: var(--text-faint); }
.empty-state-icon svg { width: 29px; height: 29px; }
.empty-state h3 { margin-bottom: 7px; color: var(--text); }
.empty-state p { margin-bottom: 17px; max-width: 390px; font-size: 13px; line-height: 1.55; }

/* Progress & photos */
.goal-bar { height: 11px; border-radius: 999px; overflow: hidden; background: var(--surface-muted); }
.goal-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--green))); }
.stat-list { display: grid; gap: 0; }
.stat-line { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.stat-line:last-child { border-bottom: 0; }
.stat-line span { color: var(--text-soft); font-size: 13px; }
.stat-line strong { font-size: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.photo-tile { aspect-ratio: 3/4; border-radius: 18px; overflow: hidden; position: relative; background: var(--surface-muted); border: 1px solid var(--line); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile span { position: absolute; left: 10px; bottom: 10px; min-height: 28px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 650; background: rgba(0,0,0,.44); backdrop-filter: blur(10px); }
.photo-placeholder { width: 100%; height: 100%; display: grid; place-items: center; text-align: center; padding: 12px; color: var(--text-faint); font-size: 11px; }
.achievement-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.achievement { padding: 15px; display: flex; align-items: center; gap: 12px; border-radius: 17px; background: var(--surface-muted); }
.achievement.is-locked { opacity: .47; filter: grayscale(.5); }
.achievement-badge { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 15px; background: var(--orange-soft); color: var(--orange); font-size: 21px; }
.achievement strong { display: block; font-size: 12px; }
.achievement small { display: block; margin-top: 3px; color: var(--text-soft); font-size: 10px; }

/* Habits */
.habit-hero { min-height: 225px; padding: 25px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.habit-hero::after { content: ""; position: absolute; width: 230px; height: 230px; border-radius: 50%; right: -75px; top: -85px; background: var(--habit-soft); }
.habit-hero > * { position: relative; z-index: 1; }
.habit-hero .habit-symbol { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 18px; color: var(--habit-color); background: var(--habit-soft); }
.habit-hero .habit-symbol svg { width: 25px; height: 25px; }
.habit-streak { font-size: 38px; font-weight: 760; letter-spacing: -.055em; }
.habit-streak small { font-size: 14px; color: var(--text-soft); font-weight: 600; }
.habit-hero p { margin: 5px 0 0; color: var(--text-soft); font-size: 13px; }
.heatmap { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface-muted); border: 1px solid var(--line); }
.heatmap-cell.clean { background: var(--green-soft); border-color: transparent; }
.heatmap-cell.bad { background: var(--red); border-color: transparent; }
.heatmap-cell.unknown { opacity: .55; }
.legend { display: flex; gap: 13px; flex-wrap: wrap; margin-top: 12px; color: var(--text-soft); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--surface-muted); }
.legend i.clean { background: var(--green-soft); }
.legend i.bad { background: var(--red); }

/* Assistant */
.ai-status { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 650; }
.ai-status i { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 5px var(--orange-soft); }
.ai-status.online i { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.ai-message { padding: 18px; border-radius: 18px; background: var(--surface-muted); line-height: 1.55; font-size: 14px; }
.ai-message strong { display: block; margin-bottom: 7px; }
.prompt-box { width: 100%; min-height: 220px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--surface-solid); resize: vertical; line-height: 1.5; }

/* Forms */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 22px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(780px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  border-radius: 27px;
  overflow: hidden;
  background: var(--surface-elevated);
  border: 1px solid var(--line-strong);
  box-shadow: 0 34px 90px rgba(0,0,0,.28);
  animation: modalIn .24s cubic-bezier(.22,.72,.22,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 22px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin-bottom: 0; }
.modal-content { padding: 20px 22px 26px; overflow: auto; overscroll-behavior: contain; }
.form-tabs { display: flex; gap: 7px; padding-bottom: 15px; overflow-x: auto; scrollbar-width: none; }
.form-tabs::-webkit-scrollbar { display: none; }
.chip-button { min-height: 38px; padding: 0 13px; border-radius: 13px; color: var(--text-soft); background: var(--surface-muted); font-size: 12px; font-weight: 660; white-space: nowrap; }
.chip-button.is-active { color: #fff; background: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label, .field-label { color: var(--text-soft); font-size: 12px; font-weight: 650; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-solid);
}
.form-field textarea { min-height: 112px; padding-block: 12px; resize: vertical; line-height: 1.5; }
.form-field input::placeholder, .form-field textarea::placeholder { color: var(--text-faint); }
.form-help { color: var(--text-faint); font-size: 10px; line-height: 1.45; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.check-card { position: relative; }
.check-card input { position: absolute; opacity: 0; pointer-events: none; }
.check-card span { min-height: 43px; padding: 0 10px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-solid); color: var(--text-soft); font-size: 12px; font-weight: 620; cursor: pointer; }
.check-card input:checked + span { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.upload-zone {
  min-height: 145px;
  padding: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--surface-muted);
  color: var(--text-soft);
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone img { max-width: 100%; max-height: 230px; border-radius: 13px; object-fit: contain; }
.upload-zone svg { width: 28px; height: 28px; margin-bottom: 8px; }
.upload-zone strong { display: block; color: var(--text); font-size: 13px; }
.upload-zone small { display: block; margin-top: 5px; font-size: 10px; }
.ai-panel { margin-top: 15px; padding: 15px; border-radius: 17px; background: var(--purple-soft); color: var(--text); }
.ai-panel p { margin: 5px 0 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
.loading-shimmer { position: relative; overflow: hidden; }
.loading-shimmer::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.26), transparent); animation: shimmer 1.15s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Settings */
.settings-list { display: grid; gap: 0; }
.settings-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { display: block; font-size: 14px; }
.settings-row p { margin: 4px 0 0; color: var(--text-soft); font-size: 11px; line-height: 1.4; }
.settings-value { color: var(--text-soft); font-size: 13px; text-align: right; }
.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-muted); transition: .2s; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.toggle span::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0,0,0,.18); transition: .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::before { transform: translateX(20px); }

.toast-region { position: fixed; z-index: 200; right: 22px; bottom: calc(22px + var(--safe-bottom)); display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 390px; padding: 13px 15px; border-radius: 15px; color: var(--text); background: var(--surface-elevated); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; animation: toastIn .25s ease; }
.toast.good { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.toast.bad { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.bottom-nav { display: none; }

@media (max-width: 1180px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.dashboard-main { grid-template-columns: 1fr; }
  .calendar-layout { grid-template-columns: 1fr; }
  .day-detail { position: static; }
}

@media (max-width: 850px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 78px; padding: calc(12px + env(safe-area-inset-top, 0px)) 17px 12px; }
  .topbar .eyebrow { display: none; }
  h1 { font-size: 27px; }
  .topbar-actions .icon-button:first-child { display: grid; }
  .primary-button.compact span:last-child { display: none; }
  .primary-button.compact { width: 42px; padding: 0; }
  .main-content { padding: 18px 14px calc(106px + var(--safe-bottom)); }
  .bottom-nav {
    position: fixed;
    z-index: 40;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: calc(100vw - 20px);
    bottom: calc(8px + var(--safe-bottom));
    height: 69px;
    padding: 7px 12px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
    box-shadow: 0 16px 44px rgba(0,0,0,.18);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
  }
  .bottom-nav-item, .bottom-add { min-width: 0; border: 0; background: transparent; cursor: pointer; }
  .bottom-nav-item { display: grid; justify-items: center; gap: 3px; color: var(--text-faint); font-size: 9px; }
  .bottom-nav-item svg { width: 21px; height: 21px; }
  .bottom-nav-item.is-active { color: var(--accent); }
  .bottom-add { width: 51px; height: 51px; place-self: center; display: grid; place-items: center; border-radius: 18px; color: #fff; background: var(--accent); box-shadow: 0 9px 22px color-mix(in srgb, var(--accent) 34%, transparent); }
  .bottom-add svg { width: 25px; height: 25px; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 93vh; border-radius: 27px 27px 0 0; padding-bottom: var(--safe-bottom); }
  .modal-header { padding: 18px 17px 14px; }
  .modal-content { padding: 16px 17px 24px; }
}

@media (max-width: 680px) {
  .view-enter, .grid.dashboard-main, .grid.dashboard-main > .stack, .hero-card, .today-card, .week-strip, .card-header { min-width: 0; max-width: 100%; }
  .card-header { flex-wrap: wrap; }
  .card-header > * { min-width: 0; }
  .grid.metrics, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .metric-card { min-height: 128px; }
  .metric-value { margin-top: 16px; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-progress { border-right: 0; border-bottom: 1px solid var(--line); }
  .progress-ring { width: 156px; }
  .progress-ring::before { width: 116px; }
  .hero-chart { min-height: 290px; }
  .week-strip { grid-template-columns: repeat(7, minmax(48px, 1fr)); overflow-x: auto; padding-bottom: 5px; }
  .week-day { min-width: 58px; padding-inline: 6px; }
  .calendar-card { padding: 15px; }
  .calendar-weekdays, .calendar-grid { gap: 4px; }
  .calendar-cell { min-height: 75px; padding: 7px; border-radius: 12px; }
  .calendar-cell .cell-plan { display: none; }
  .calendar-cell .day-markers { left: 7px; bottom: 7px; gap: 3px; }
  .day-dot { width: 5px; height: 5px; }
  .form-grid { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .photo-grid { grid-template-columns: 1fr; }
  .photo-tile { aspect-ratio: 4/5; }
  .achievement-grid { grid-template-columns: 1fr; }
  .entry-row { grid-template-columns: 44px minmax(0,1fr); }
  .entry-meta, .entry-actions { grid-column: 2; text-align: left; }
  .toast-region { left: 14px; right: 14px; bottom: calc(91px + var(--safe-bottom)); }
  .toast { min-width: 0; max-width: none; }
}

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