:root {
  color-scheme: dark;
  --bg: #02060d;
  --panel: rgba(5, 17, 31, 0.72);
  --panel-strong: rgba(4, 14, 27, 0.94);
  --line: rgba(104, 220, 255, 0.22);
  --line-strong: rgba(104, 220, 255, 0.58);
  --cyan: #70e1ff;
  --cyan-soft: #b9f3ff;
  --violet: #8b70ff;
  --violet-soft: #d7ceff;
  --success: #73ffd3;
  --danger: #ff7199;
  --warning: #ffd37a;
  --text: #edfaff;
  --muted: #7f9aaa;
  --shadow: 0 18px 80px rgba(0, 0, 0, 0.42), inset 0 0 50px rgba(32, 112, 182, 0.035);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(26, 98, 168, .15), transparent 34%),
    radial-gradient(circle at 84% 8%, rgba(95, 61, 192, .13), transparent 29%),
    linear-gradient(140deg, #01050b 0%, #04101c 48%, #02060d 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.ambient { position: fixed; pointer-events: none; z-index: -2; border-radius: 50%; filter: blur(90px); opacity: .18; }
.ambient-one { width: 420px; height: 420px; left: -110px; top: 14%; background: #1c8cff; }
.ambient-two { width: 360px; height: 360px; right: -70px; top: 4%; background: #7048ff; }
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .035;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, #8fe8ff 4px);
  mix-blend-mode: screen;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(7, 23, 40, .78), rgba(3, 12, 23, .68));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
}

.app-shell { width: min(1540px, calc(100% - 34px)); margin: 18px auto 42px; }
.topbar {
  min-height: 80px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand h1 { margin: 2px 0 0; letter-spacing: .16em; font-size: clamp(1.08rem, 2vw, 1.45rem); font-weight: 770; white-space: nowrap; }
.eyebrow { margin: 0; color: var(--cyan); font-size: .62rem; font-weight: 800; letter-spacing: .19em; }
.system-mark { width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid var(--line-strong); transform: rotate(45deg); display: grid; place-items: center; box-shadow: 0 0 22px rgba(112, 225, 255, .15), inset 0 0 18px rgba(112, 225, 255, .08); }
.system-mark span { width: 16px; height: 16px; border: 2px solid var(--cyan); transform: rotate(45deg); filter: drop-shadow(0 0 7px var(--cyan)); }
.top-stats { display: flex; align-items: stretch; gap: 8px; }
.mini-stat { min-width: 72px; padding: 8px 11px; text-align: center; background: rgba(2, 11, 21, .56); border: 1px solid rgba(112, 225, 255, .11); }
.mini-stat span, .mini-stat small { display: block; color: var(--muted); font-size: .52rem; letter-spacing: .11em; }
.mini-stat strong { display: inline-block; margin-top: 2px; color: var(--cyan-soft); font-size: 1rem; }
.icon-button {
  min-width: 42px; min-height: 42px; border: 1px solid var(--line); background: rgba(3, 14, 26, .76); color: var(--cyan); cursor: pointer;
  display: grid; place-items: center; font-size: 1rem;
}
.icon-button:hover { border-color: var(--line-strong); background: rgba(12, 41, 68, .76); }
.install-button { color: var(--success); }

.week-strip { display: flex; align-items: stretch; gap: 9px; padding: 9px; margin-top: 11px; }
.today-button, .week-day {
  border: 1px solid rgba(112, 225, 255, .11); background: rgba(2, 12, 22, .58); color: var(--muted); cursor: pointer;
}
.today-button { min-width: 86px; color: var(--cyan); font-size: .65rem; font-weight: 800; letter-spacing: .14em; }
.week-days { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(78px, 1fr)); gap: 5px; min-width: 0; }
.week-day { position: relative; padding: 8px 10px; min-height: 48px; text-align: left; }
.week-day span { display: block; font-size: .55rem; letter-spacing: .12em; }
.week-day strong { display: block; margin-top: 3px; color: var(--text); font-size: .8rem; }
.week-day::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 4px; height: 2px; opacity: 0; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.week-day.today { border-color: rgba(112, 225, 255, .35); }
.week-day.selected { color: var(--cyan); background: rgba(14, 49, 79, .62); }
.week-day.selected::after { opacity: 1; }
.week-day.complete::before, .week-day.partial::before { content: ""; position: absolute; right: 7px; top: 7px; width: 6px; height: 6px; border-radius: 50%; }
.week-day.complete::before { background: var(--success); box-shadow: 0 0 8px var(--success); }
.week-day.partial::before { background: var(--violet); box-shadow: 0 0 8px var(--violet); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .72fr); gap: 12px; margin-top: 12px; align-items: start; }
.quest-panel { padding: 23px; min-width: 0; }
.panel-heading, .section-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
h2, h3, h4, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: .015em; }
.badge-stack { display: flex; align-items: stretch; gap: 6px; }
.rank-badge, .difficulty-badge { padding: 8px 10px; border: 1px solid var(--line-strong); font-size: .61rem; font-weight: 800; letter-spacing: .11em; white-space: nowrap; }
.difficulty-badge { color: var(--violet-soft); border-color: rgba(139, 112, 255, .45); background: rgba(77, 56, 164, .13); }
.rank-badge { color: var(--cyan); }
.xp-track { height: 7px; margin-top: 19px; overflow: hidden; border: 1px solid rgba(112, 225, 255, .16); background: rgba(1, 7, 14, .82); }
.xp-fill { width: 0; height: 100%; background: linear-gradient(90deg, #2d75b3, var(--cyan), var(--violet)); box-shadow: 0 0 14px rgba(112, 225, 255, .48); transition: width .35s ease; }
.xp-track.compact { height: 5px; margin-top: 8px; }
.progress-copy { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--muted); font-size: .64rem; }
.progress-copy span:last-child { color: var(--cyan); font-weight: 700; }

.active-quest { margin-top: 22px; display: grid; grid-template-columns: 80px minmax(0, 1fr); min-height: 156px; border: 1px solid rgba(112, 225, 255, .2); background: linear-gradient(100deg, rgba(9, 37, 62, .68), rgba(36, 27, 84, .34)); position: relative; overflow: hidden; }
.active-quest::after { content: ""; position: absolute; width: 220px; height: 220px; right: -125px; top: -80px; border: 1px solid rgba(112, 225, 255, .12); transform: rotate(45deg); }
.quest-number { display: grid; place-items: center; color: rgba(112, 225, 255, .28); font-size: 2.45rem; font-weight: 800; border-right: 1px solid rgba(112, 225, 255, .15); }
.quest-main { padding: 22px 24px; min-width: 0; }
.quest-kicker-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.exercise-tier { padding: 4px 7px; color: var(--violet-soft); border: 1px solid rgba(139, 112, 255, .35); font-size: .54rem; letter-spacing: .12em; }
.quest-main h3 { margin: 8px 0 5px; font-size: clamp(1.32rem, 3vw, 2rem); }
.exercise-note { margin-bottom: 0; color: var(--muted); line-height: 1.48; font-size: .78rem; max-width: 880px; }
.set-pills { display: flex; gap: 6px; margin-top: 17px; flex-wrap: wrap; }
.set-pill { width: 32px; height: 4px; background: rgba(112, 225, 255, .15); }
.set-pill.current { background: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.set-pill.complete { background: var(--success); box-shadow: 0 0 8px rgba(115, 255, 211, .45); }

.rep-console { margin-top: 10px; padding: 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid rgba(139, 112, 255, .25); background: rgba(4, 13, 26, .72); }
.rep-readout { margin-top: 5px; display: flex; align-items: baseline; gap: 8px; }
.rep-readout strong { color: var(--cyan); font-size: 2.25rem; line-height: 1; font-variant-numeric: tabular-nums; }
.rep-readout span { color: var(--muted); font-size: .7rem; letter-spacing: .1em; }
.weight-field { min-width: 126px; }
.weight-field > span { display: block; color: var(--muted); font-size: .53rem; letter-spacing: .12em; margin-bottom: 5px; }
.weight-field > div { display: flex; align-items: center; border: 1px solid rgba(112, 225, 255, .17); background: rgba(1, 8, 16, .72); }
.weight-field input { width: 92px; min-width: 0; border: 0; background: transparent; color: var(--text); padding: 8px; outline: 0; }
.weight-field b { color: var(--muted); font-size: .65rem; padding-right: 8px; }
.rep-actions { display: flex; gap: 8px; align-items: stretch; }
.small-action, .primary-action, .secondary-actions button, .text-button, .danger-button, .import-label {
  border: 1px solid var(--line); background: rgba(7, 22, 39, .75); cursor: pointer; border-radius: 2px;
}
.small-action { min-width: 50px; padding: 10px; color: var(--cyan); font-weight: 800; }
.primary-action { padding: 11px 20px; border-color: var(--line-strong); background: linear-gradient(105deg, rgba(28, 105, 171, .82), rgba(62, 52, 142, .82)); color: white; font-weight: 800; letter-spacing: .08em; box-shadow: inset 0 0 18px rgba(100, 221, 255, .1), 0 0 20px rgba(52, 140, 255, .1); }
.primary-action:hover, .small-action:hover, .text-button:hover { filter: brightness(1.16); }
.secondary-actions { margin-top: 9px; display: flex; gap: 7px; flex-wrap: wrap; }
.secondary-actions button { padding: 8px 10px; color: var(--muted); font-size: .66rem; }
.secondary-actions button:hover { color: var(--text); border-color: rgba(100, 221, 255, .42); }
.text-button { padding: 7px 9px; color: var(--cyan); font-size: .65rem; }
.wide-button { width: 100%; margin-top: 12px; padding: 9px; }
.danger-button { padding: 11px 14px; color: var(--danger); border-color: rgba(255, 111, 145, .32); }

.progression-card { margin-top: 13px; padding: 14px; border: 1px solid rgba(139, 112, 255, .24); background: linear-gradient(100deg, rgba(47, 34, 103, .19), rgba(4, 14, 26, .5)); display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 18px; align-items: center; }
.progression-card strong { display: block; margin-top: 5px; font-size: .86rem; }
.progression-card p:last-child { margin: 4px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.42; }
.progression-meter { height: 7px; border: 1px solid rgba(139, 112, 255, .35); background: rgba(2, 8, 17, .7); }
.progression-meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--cyan)); box-shadow: 0 0 10px rgba(139, 112, 255, .5); transition: width .3s ease; }

.quest-list-section { margin-top: 22px; }
.quest-list { display: grid; gap: 6px; margin-top: 9px; }
.quest-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-left: 2px solid transparent; background: rgba(4, 14, 26, .52); color: var(--muted); cursor: pointer; }
.quest-item:hover { background: rgba(9, 28, 48, .7); }
.quest-item.current { border-left-color: var(--cyan); background: rgba(13, 44, 75, .52); color: var(--text); }
.quest-item.complete { color: rgba(112, 255, 210, .78); }
.quest-item .quest-index { font-size: .68rem; color: rgba(100, 221, 255, .55); }
.quest-item h4 { margin: 0; font-size: .82rem; font-weight: 650; color: inherit; }
.quest-item p { margin: 3px 0 0; font-size: .62rem; }
.quest-item .quest-state { font-size: .59rem; letter-spacing: .1em; text-align: right; }

.side-column { display: grid; gap: 12px; }
.status-panel, .meal-panel, .daily-note, .sync-panel { padding: 20px; }
.status-orb { width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 50%; box-shadow: inset 0 0 16px rgba(100, 221, 255, .22), 0 0 16px rgba(100, 221, 255, .15); position: relative; }
.status-orb::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.level-row { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .65rem; }
.level-row b { color: var(--cyan); }
.level-row strong { color: var(--text); }
.next-rank-text { margin: 8px 0 0; color: var(--muted); font-size: .63rem; }
.status-grid { margin-top: 17px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-grid div { padding: 12px; background: rgba(3, 13, 24, .58); border: 1px solid rgba(100, 221, 255, .1); }
.status-grid span { color: var(--muted); display: block; font-size: .6rem; }
.status-grid strong { display: block; margin-top: 3px; color: var(--text); font-size: 1.06rem; }
.meal-note { margin-top: 15px; padding: 11px; border-left: 2px solid var(--violet); background: rgba(54, 42, 118, .16); color: var(--muted); font-size: .73rem; line-height: 1.45; }
.meal-note strong { color: #d9d4ff; }
.meal-list { display: grid; gap: 8px; margin-top: 12px; }
.meal-card { padding: 12px; border: 1px solid rgba(100, 221, 255, .13); background: rgba(3, 13, 24, .6); cursor: pointer; transition: border-color .2s ease, opacity .2s ease; }
.meal-card:hover { border-color: rgba(100, 221, 255, .42); }
.meal-card.done { opacity: .5; border-color: rgba(112, 255, 210, .34); }
.meal-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meal-card span { color: var(--cyan); font-size: .59rem; letter-spacing: .13em; }
.meal-card b { color: var(--success); font-size: .63rem; }
.meal-card p { margin: 6px 0 0; color: var(--text); font-size: .76rem; line-height: 1.38; }
.daily-note { border-color: rgba(139, 108, 255, .25); }
.daily-note > p:last-child { margin: 8px 0 0; color: #cbd9e3; line-height: 1.5; font-size: .78rem; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 8px rgba(127, 154, 170, .4); }
.sync-dot.online { background: var(--success); box-shadow: 0 0 9px var(--success); }
.sync-dot.syncing { background: var(--warning); box-shadow: 0 0 9px var(--warning); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--danger); box-shadow: 0 0 9px var(--danger); }
.sync-status { margin: 12px 0 0; color: var(--muted); line-height: 1.45; font-size: .72rem; }

.rest-view { margin-top: 22px; min-height: 420px; display: grid; place-items: center; text-align: center; border: 1px solid rgba(100, 221, 255, .18); background: radial-gradient(circle, rgba(31, 102, 165, .15), transparent 62%); }
.rest-content { max-width: 520px; padding: 30px; }
.rest-symbol { width: 92px; height: 92px; margin: 0 auto 23px; border: 1px solid rgba(100, 221, 255, .5); transform: rotate(45deg); display: grid; place-items: center; box-shadow: inset 0 0 28px rgba(100, 221, 255, .09); }
.rest-symbol span { transform: rotate(-45deg); color: var(--cyan); font-size: 2rem; }
.rest-content h3 { font-size: 1.85rem; }
.rest-content p { margin-top: 12px; color: var(--muted); line-height: 1.55; }
.rest-actions { margin-top: 24px; display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.hidden { display: none !important; }

.system-dialog { width: min(700px, calc(100% - 24px)); max-height: min(90vh, 900px); overflow: auto; color: var(--text); padding: 0; border-radius: 4px; border-color: var(--line-strong); background: var(--panel-strong); }
.system-dialog::backdrop { background: rgba(0, 3, 8, .78); backdrop-filter: blur(5px); }
.dialog-content { padding: 22px; }
.settings-dialog { width: min(660px, calc(100% - 24px)); }
.settings-section { margin-top: 18px; padding: 15px; border: 1px solid rgba(112, 225, 255, .12); background: rgba(2, 10, 19, .44); }
.settings-heading { margin: 0; color: var(--cyan); font-size: .63rem; letter-spacing: .15em; font-weight: 800; }
.settings-copy { margin: 9px 0 0; color: var(--muted); font-size: .71rem; line-height: 1.48; }
.field-label { display: grid; gap: 6px; margin-top: 15px; font-size: .8rem; color: var(--text); }
.field-label span { color: var(--muted); font-size: .67rem; }
.field-label input, .field-label select { width: 100%; padding: 10px 11px; color: var(--text); border: 1px solid var(--line); background: rgba(2, 10, 19, .8); outline: none; }
.field-label input:focus, .field-label select:focus { border-color: var(--line-strong); box-shadow: 0 0 12px rgba(100, 221, 255, .1); }
.sync-actions, .settings-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.storage-note { margin: 13px 0 0; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.import-label { display: inline-flex; align-items: center; padding: 10px; color: var(--cyan); font-weight: 800; font-size: .7rem; }
.import-label input { display: none; }

.calendar-toolbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin-top: 20px; text-align: center; }
.calendar-toolbar strong { font-size: 1rem; letter-spacing: .05em; }
.calendar-week-labels, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-week-labels { margin-top: 18px; color: var(--muted); text-align: center; font-size: .55rem; letter-spacing: .1em; }
.calendar-grid { margin-top: 8px; }
.calendar-day { position: relative; min-height: 64px; padding: 8px; border: 1px solid rgba(112, 225, 255, .09); background: rgba(2, 10, 19, .58); color: var(--muted); cursor: pointer; text-align: left; }
.calendar-day:hover { border-color: var(--line-strong); }
.calendar-day.empty { visibility: hidden; pointer-events: none; }
.calendar-day strong { color: var(--text); font-size: .78rem; }
.calendar-day small { display: block; margin-top: 11px; font-size: .52rem; letter-spacing: .07em; }
.calendar-day.today { outline: 1px solid var(--cyan); outline-offset: -3px; }
.calendar-day.complete { border-color: rgba(115, 255, 211, .45); background: linear-gradient(145deg, rgba(31, 107, 89, .28), rgba(2, 13, 21, .6)); }
.calendar-day.partial { border-color: rgba(139, 112, 255, .42); background: linear-gradient(145deg, rgba(73, 52, 151, .26), rgba(2, 13, 21, .6)); }
.calendar-day.recovery { border-color: rgba(112, 225, 255, .3); background: linear-gradient(145deg, rgba(28, 80, 116, .2), rgba(2, 13, 21, .6)); }
.calendar-day.missed { border-color: rgba(255, 113, 153, .22); background: rgba(70, 19, 35, .2); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 18px; color: var(--muted); font-size: .62rem; }
.calendar-legend span { display: flex; align-items: center; gap: 6px; }
.calendar-legend i { width: 9px; height: 9px; display: inline-block; }
.legend-complete { background: var(--success); }
.legend-partial { background: var(--violet); }
.legend-recovery { background: var(--cyan); }
.legend-missed { background: var(--danger); }
.calendar-summary { margin-top: 17px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calendar-summary div { padding: 12px; border: 1px solid rgba(112, 225, 255, .1); background: rgba(2, 10, 19, .54); }
.calendar-summary span { display: block; color: var(--muted); font-size: .56rem; letter-spacing: .1em; }
.calendar-summary strong { display: block; margin-top: 4px; }

.level-dialog { width: min(460px, calc(100% - 24px)); overflow: visible; }
.level-up-content { text-align: center; padding: 34px 24px; }
.level-up-rings { width: 132px; height: 132px; margin: 24px auto; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; box-shadow: 0 0 40px rgba(112, 225, 255, .24), inset 0 0 25px rgba(139, 112, 255, .14); position: relative; }
.level-up-rings::before, .level-up-rings::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(139, 112, 255, .38); animation: spin 8s linear infinite; }
.level-up-rings::before { inset: -14px; border-left-color: transparent; }
.level-up-rings::after { inset: 12px; border-right-color: transparent; animation-direction: reverse; }
.level-up-rings span { color: var(--cyan); font-size: 3.2rem; font-weight: 800; text-shadow: 0 0 18px rgba(112, 225, 255, .7); }
.level-up-content h2 { letter-spacing: .18em; }
.level-up-content > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.install-instructions { margin-top: 18px; display: grid; gap: 10px; color: var(--muted); line-height: 1.5; font-size: .78rem; }
.install-step { padding: 12px; border-left: 2px solid var(--cyan); background: rgba(6, 26, 43, .52); }

.mobile-nav { display: none; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; max-width: calc(100% - 28px); padding: 12px 18px; text-align: center; color: var(--text); background: rgba(4, 18, 33, .97); border: 1px solid var(--line-strong); box-shadow: 0 0 28px rgba(52, 140, 255, .25); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, 1fr); }
  .daily-note, .sync-panel { grid-column: auto; }
  .week-days { overflow-x: auto; grid-template-columns: repeat(7, minmax(105px, 1fr)); }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(76px + var(--safe-bottom)); }
  .app-shell { width: min(100% - 14px, 1540px); margin-top: 7px; }
  .topbar { min-height: 66px; padding: 10px 12px; clip-path: none; }
  .brand h1 { font-size: .96rem; }
  .system-mark { width: 36px; height: 36px; }
  .system-mark span { width: 13px; height: 13px; }
  .top-stats .mini-stat { display: none; }
  .top-stats { gap: 5px; }
  .icon-button { min-width: 38px; min-height: 38px; }
  .week-strip { flex-direction: column; padding: 7px; }
  .today-button { min-height: 34px; }
  .week-days { grid-template-columns: repeat(7, minmax(68px, 1fr)); gap: 4px; }
  .week-day { min-height: 46px; padding: 7px; }
  .quest-panel { padding: 14px; }
  .panel-heading { align-items: center; }
  .badge-stack { flex-direction: column; }
  .rank-badge, .difficulty-badge { padding: 6px 7px; font-size: .52rem; text-align: center; }
  .active-quest { grid-template-columns: 52px minmax(0, 1fr); min-height: 142px; }
  .quest-number { font-size: 1.65rem; }
  .quest-main { padding: 17px 14px; }
  .quest-main h3 { font-size: 1.35rem; }
  .rep-console { align-items: stretch; flex-direction: column; }
  .weight-field { width: 100%; }
  .weight-field > div, .weight-field input { width: 100%; }
  .rep-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .primary-action { grid-column: 1 / -1; }
  .progression-card { grid-template-columns: 1fr; }
  .progression-meter { width: 100%; }
  .quest-item { grid-template-columns: 27px minmax(0, 1fr) auto; gap: 8px; padding: 9px; }
  .side-column { grid-template-columns: 1fr; }
  .status-panel, .meal-panel, .daily-note, .sync-panel { padding: 16px; }
  .calendar-day { min-height: 53px; padding: 6px; }
  .calendar-day small { margin-top: 7px; font-size: .45rem; }
  .calendar-week-labels, .calendar-grid { gap: 4px; }
  .calendar-legend { display: grid; grid-template-columns: 1fr 1fr; }
  .mobile-nav { position: fixed; z-index: 80; left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); height: 58px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px; }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; gap: 1px; font-size: .58rem; }
  .mobile-nav button span { color: var(--cyan); font-size: 1rem; }
  .mobile-nav button.active { color: var(--text); background: rgba(17, 53, 85, .5); }
  .toast { bottom: calc(80px + var(--safe-bottom)); }
}

@media (max-width: 430px) {
  .eyebrow { font-size: .56rem; }
  .week-day span { font-size: .48rem; }
  .week-day strong { font-size: .7rem; }
  .quest-main h3 { font-size: 1.16rem; }
  .exercise-note { font-size: .71rem; }
  .calendar-day { min-height: 47px; }
  .calendar-day small { display: none; }
  .calendar-summary { grid-template-columns: 1fr; }
}

/* v2.2 body, weight and calorie tracking */
.health-panel { margin-top: 12px; padding: 23px; }
.health-heading { align-items: center; }
.health-subtitle { margin: 7px 0 0; color: var(--muted); font-size: .72rem; }
.health-tabs { display: flex; border: 1px solid rgba(112, 225, 255, .18); background: rgba(2, 10, 19, .66); padding: 4px; gap: 4px; }
.health-tab { border: 1px solid transparent; background: transparent; color: var(--muted); padding: 9px 14px; cursor: pointer; font-size: .63rem; font-weight: 800; letter-spacing: .12em; }
.health-tab.active { color: var(--cyan); border-color: rgba(112, 225, 255, .34); background: rgba(16, 56, 91, .54); box-shadow: inset 0 0 15px rgba(112, 225, 255, .06); }
.health-tab-panel { margin-top: 20px; }
.calorie-overview { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: center; }
.calorie-gauge { --calorie-percent: 0deg; width: 168px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--cyan) 0 var(--calorie-percent), rgba(112, 225, 255, .09) var(--calorie-percent) 360deg); position: relative; box-shadow: 0 0 24px rgba(112, 225, 255, .12); }
.calorie-gauge::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: linear-gradient(145deg, rgba(5, 20, 36, .98), rgba(3, 11, 22, .98)); border: 1px solid rgba(112, 225, 255, .18); }
.calorie-gauge.over { background: conic-gradient(var(--danger) 0 var(--calorie-percent), rgba(255, 113, 153, .09) var(--calorie-percent) 360deg); box-shadow: 0 0 24px rgba(255, 113, 153, .16); }
.calorie-gauge-inner { position: relative; z-index: 1; text-align: center; }
.calorie-gauge-inner strong { display: block; color: var(--cyan-soft); font-size: 2.15rem; line-height: 1; }
.calorie-gauge.over .calorie-gauge-inner strong { color: var(--danger); }
.calorie-gauge-inner span { display: block; margin-top: 8px; color: var(--muted); font-size: .58rem; letter-spacing: .08em; }
.calorie-gauge-inner b { color: var(--text); }
.calorie-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.calorie-summary div { min-height: 82px; padding: 15px; border: 1px solid rgba(112, 225, 255, .12); background: rgba(2, 11, 21, .55); }
.calorie-summary span { display: block; color: var(--muted); font-size: .57rem; letter-spacing: .11em; }
.calorie-summary strong { display: block; margin-top: 8px; font-size: clamp(.84rem, 1.5vw, 1.2rem); }
.calorie-track { margin-top: 15px; }
.health-note { margin: 10px 0 0; color: var(--muted); font-size: .66rem; line-height: 1.5; }
.food-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(250px, .75fr); gap: 11px; margin-top: 18px; }
.food-search-card, .manual-food-card, .food-log-card, .weight-chart-card, .weight-history-card, .weight-entry-card { padding: 16px; border: 1px solid rgba(112, 225, 255, .12); background: rgba(2, 10, 19, .52); }
.food-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.food-search-row input, .compact-field input, .weight-input-row { width: 100%; padding: 11px; color: var(--text); border: 1px solid var(--line); background: rgba(2, 10, 19, .82); outline: none; }
.food-search-row input:focus, .compact-field input:focus { border-color: var(--line-strong); }
.food-results { display: grid; gap: 7px; margin-top: 12px; }
.food-result { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid rgba(112, 225, 255, .11); background: rgba(4, 16, 28, .64); }
.food-result-image { width: 46px; height: 46px; object-fit: contain; background: rgba(255,255,255,.04); border: 1px solid rgba(112,225,255,.08); }
.food-result-placeholder { width: 46px; height: 46px; display: grid; place-items: center; color: var(--cyan); background: rgba(16, 56, 91, .35); border: 1px solid rgba(112,225,255,.12); }
.food-result-copy { min-width: 0; }
.food-result-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.food-result-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: .62rem; }
.food-result-actions { display: flex; align-items: center; gap: 6px; }
.food-amount { width: 74px; padding: 8px; border: 1px solid rgba(112,225,255,.18); color: var(--text); background: rgba(1,8,16,.85); }
.food-result-actions small { color: var(--muted); font-size: .59rem; }
.food-result-actions button { padding: 8px 10px; }
.food-source-badge { display: inline-block; margin-left: 6px; padding: 2px 5px; border: 1px solid rgba(139,112,255,.28); color: var(--violet-soft); font-size: .48rem; letter-spacing: .08em; }
.compact-field { margin-top: 11px; }
.manual-food-card .wide-button { margin-top: 12px; }
.food-log-card { margin-top: 11px; }
.food-log-total { color: var(--cyan); }
.food-log-list { display: grid; gap: 6px; margin-top: 12px; }
.food-log-empty, .weight-empty { padding: 14px; color: var(--muted); font-size: .7rem; text-align: center; border: 1px dashed rgba(112,225,255,.14); }
.food-log-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px; background: rgba(4,16,28,.56); border-left: 2px solid rgba(112,225,255,.38); }
.food-log-item strong { display: block; font-size: .75rem; }
.food-log-item span { display: block; margin-top: 3px; color: var(--muted); font-size: .6rem; }
.food-log-item > b { color: var(--cyan-soft); white-space: nowrap; }
.remove-entry { border: 1px solid rgba(255,113,153,.25); background: rgba(70,19,35,.24); color: var(--danger); cursor: pointer; min-width: 34px; min-height: 34px; }
.weight-overview { display: grid; grid-template-columns: minmax(240px, .7fr) minmax(300px, 1fr); gap: 11px; }
.weight-stat-main { padding: 24px; border: 1px solid rgba(139,112,255,.22); background: radial-gradient(circle at 15% 20%, rgba(95,61,192,.2), transparent 50%), rgba(2,10,19,.56); }
.weight-stat-main span { color: var(--muted); font-size: .59rem; letter-spacing: .12em; }
.weight-stat-main strong { display: block; margin-top: 9px; color: var(--cyan-soft); font-size: 2.35rem; }
.weight-stat-main small { display: block; margin-top: 7px; color: var(--muted); }
.weight-input-row { display: flex; align-items: center; padding: 0; }
.weight-input-row input { flex: 1; min-width: 0; padding: 11px; border: 0; color: var(--text); background: transparent; outline: none; }
.weight-input-row b { padding-right: 11px; color: var(--muted); font-size: .7rem; }
.weight-entry-card .primary-action { width: 100%; margin-top: 13px; }
.weight-chart-card { margin-top: 11px; }
.weight-chart { display: block; width: 100%; min-height: 220px; margin-top: 12px; overflow: visible; }
.weight-chart .chart-grid { stroke: rgba(112,225,255,.1); stroke-width: 1; }
.weight-chart .chart-line { fill: none; stroke: var(--cyan); stroke-width: 3; filter: drop-shadow(0 0 4px rgba(112,225,255,.55)); }
.weight-chart .chart-area { fill: url(#weightAreaGradient); }
.weight-chart .chart-point { fill: var(--violet-soft); stroke: var(--violet); stroke-width: 2; }
.weight-chart .chart-label { fill: var(--muted); font-size: 11px; }
.weight-history-card { margin-top: 11px; }
.weight-history { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 7px; margin-top: 12px; }
.weight-history-item { position: relative; padding: 11px; border: 1px solid rgba(112,225,255,.1); background: rgba(4,16,28,.56); }
.weight-history-item span { display: block; color: var(--muted); font-size: .58rem; }
.weight-history-item strong { display: block; margin-top: 4px; color: var(--text); }
.weight-history-item button { position: absolute; right: 6px; top: 6px; border: 0; background: transparent; color: var(--danger); cursor: pointer; }

@media (max-width: 1080px) {
  .calorie-overview { grid-template-columns: 170px minmax(0, 1fr); }
  .food-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .health-panel { padding: 15px; }
  .health-heading { align-items: flex-start; flex-direction: column; }
  .health-tabs { width: 100%; }
  .health-tab { flex: 1; }
  .calorie-overview { grid-template-columns: 1fr; justify-items: center; }
  .calorie-summary { width: 100%; grid-template-columns: 1fr 1fr; }
  .calorie-summary div:last-child { grid-column: 1 / -1; }
  .food-search-row { grid-template-columns: 1fr; }
  .food-search-row .primary-action { grid-column: auto; }
  .food-result { grid-template-columns: 40px minmax(0, 1fr); }
  .food-result-image, .food-result-placeholder { width: 40px; height: 40px; }
  .food-result-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .food-log-item { grid-template-columns: minmax(0, 1fr) auto; }
  .food-log-item .remove-entry { grid-column: 1 / -1; width: 100%; }
  .weight-overview { grid-template-columns: 1fr; }
  .weight-chart { min-height: 170px; }
  .mobile-nav { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 430px) {
  .calorie-summary { grid-template-columns: 1fr; }
  .calorie-summary div:last-child { grid-column: auto; }
  .calorie-gauge { width: 150px; }
  .weight-stat-main strong { font-size: 2rem; }
}
