:root {
  color-scheme: light;
  --bg: #f3f6f3;
  --surface: #fffdf9;
  --surface-2: #eef3ef;
  --surface-3: #e5ece7;
  --ink: #203436;
  --muted: #687a78;
  --line: #dbe5de;
  --green: #21756b;
  --green-deep: #155f58;
  --green-soft: #dceee8;
  --blue: #356f92;
  --blue-soft: #e1edf3;
  --coral: #d96851;
  --coral-soft: #fbe7e1;
  --amber: #b87f25;
  --amber-soft: #f9efd8;
  --red: #c24d4d;
  --red-soft: #f8e3e3;
  --shadow: 0 12px 34px rgba(35, 63, 56, 0.08);
  --radius: 8px;
  --font: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  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 8% 2%, rgba(33, 117, 107, 0.08), transparent 26rem),
    radial-gradient(circle at 96% 18%, rgba(242, 162, 95, 0.1), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: var(--green);
}

svg {
  display: block;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.boot-screen strong {
  color: var(--ink);
  font-size: 1.3rem;
}

.boot-screen p {
  margin: 0;
}

.brand-mark {
  position: relative;
  width: 56px;
  height: 64px;
  border-radius: 28px 28px 26px 26px;
  background: var(--green);
  transform: rotate(45deg);
}

.brand-mark span {
  position: absolute;
  width: 26px;
  height: 26px;
  inset: 19px;
  border-radius: 50% 50% 50% 10px;
  background: #f2a25f;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 460px);
  align-items: stretch;
  padding: clamp(18px, 4vw, 56px);
  gap: clamp(24px, 5vw, 76px);
}

.auth-story {
  align-self: center;
  max-width: 640px;
}

.auth-story .eyebrow,
.kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-story h1 {
  max-width: 11ch;
  margin: 0;
  color: #173638;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(2.7rem, 5.4vw, 5.5rem);
  font-weight: 700;
  line-height: 1.03;
}

.auth-story > p:not(.eyebrow) {
  max-width: 33rem;
  margin: 24px 0 0;
  color: #536865;
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  line-height: 1.8;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.auth-points span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.68);
  color: #4f625e;
  font-size: 0.83rem;
}

.auth-panel {
  align-self: center;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid #d8e2dc;
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--shadow);
}

.auth-panel .logo-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-panel .logo-line .brand-mark {
  width: 38px;
  height: 44px;
  border-radius: 20px;
}

.auth-panel .logo-line .brand-mark span {
  width: 18px;
  height: 18px;
  inset: 13px;
}

.auth-panel h2 {
  margin: 0;
  font-size: 1.3rem;
}

.auth-panel .helper {
  margin-top: 4px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 24px;
  border-right: 1px solid var(--line);
  background: rgba(249, 251, 248, 0.86);
  backdrop-filter: blur(18px);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  margin-bottom: 32px;
}

.side-brand .brand-mark {
  width: 34px;
  height: 40px;
  border-radius: 18px;
}

.side-brand .brand-mark span {
  width: 16px;
  height: 16px;
  inset: 12px;
}

.side-brand strong {
  display: block;
  font-size: 1.04rem;
}

.side-brand small {
  color: var(--muted);
  font-size: 0.7rem;
}

.side-nav {
  display: grid;
  gap: 5px;
}

.nav-button {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #5d706d;
  text-align: left;
}

.nav-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.nav-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-button.active {
  background: var(--green-soft);
  color: var(--green-deep);
  font-weight: 700;
}

.side-foot {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 24px;
  display: grid;
  gap: 10px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
}

.connection-pill::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.connection-pill.offline::before {
  background: var(--amber);
}

.main-shell {
  min-width: 0;
  padding: 30px clamp(18px, 4vw, 56px) 54px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.topbar h1 {
  margin: 0;
  color: #1b393b;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1.08;
}

.topbar p {
  margin: 9px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button svg,
.button svg {
  width: 18px;
  height: 18px;
}

.button.primary {
  background: var(--green);
  color: white;
}

.button.primary:hover {
  background: var(--green-deep);
}

.button.secondary {
  border-color: #b9cec7;
  background: var(--surface);
  color: var(--green-deep);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.button.danger {
  border-color: #ebc4c0;
  background: var(--coral-soft);
  color: var(--red);
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.button.wide {
  width: 100%;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.96);
  box-shadow: 0 4px 14px rgba(33, 63, 55, 0.035);
}

.card-body {
  padding: 20px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-head h2,
.card-head h3 {
  margin: 0;
  font-size: 1.06rem;
}

.card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-width: 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.metric-label svg {
  width: 15px;
  height: 15px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  line-height: 1.1;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.today-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 4vw, 32px);
  background:
    linear-gradient(110deg, rgba(33, 117, 107, 0.96), rgba(46, 100, 117, 0.9)),
    var(--green);
  color: #f9fffb;
}

.today-hero::after {
  position: absolute;
  width: 240px;
  height: 240px;
  right: -80px;
  top: -90px;
  border: 60px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
}

.today-hero .kicker {
  color: #c9eee7;
}

.today-hero h2 {
  max-width: 22ch;
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.25;
}

.today-hero p {
  max-width: 47rem;
  margin: 12px 0 0;
  color: rgba(245, 255, 252, 0.82);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.hero-actions .button {
  position: relative;
  z-index: 1;
}

.hero-actions .button.secondary {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.quick-action {
  display: grid;
  min-height: 104px;
  align-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.quick-action:hover {
  border-color: #aec7be;
  background: #f9fcfa;
}

.quick-action svg {
  width: 22px;
  height: 22px;
  color: var(--green);
}

.quick-action strong {
  display: block;
  margin-top: 15px;
  font-size: 0.92rem;
}

.quick-action span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.73rem;
}

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

.list-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.list-row .row-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--green);
}

.list-row .row-icon svg {
  width: 17px;
  height: 17px;
}

.list-row strong {
  display: block;
  font-size: 0.88rem;
}

.list-row p,
.list-row small {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
}

.list-row .row-actions {
  margin-left: auto;
  display: flex;
  gap: 5px;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed #c8d8d1;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(238, 243, 239, 0.46);
}

.empty-state strong {
  display: block;
  color: var(--ink);
}

.empty-state p {
  margin: 7px 0 14px;
  font-size: 0.82rem;
  line-height: 1.6;
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(35, 60, 55, 0.09);
}

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

.search-box {
  position: relative;
  flex: 1;
}

.search-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  padding-left: 42px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cbd8d2;
  border-radius: var(--radius);
  background: #fffefb;
  color: var(--ink);
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 117, 107, 0.11);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field > span,
.field > label {
  color: #405653;
  font-size: 0.8rem;
  font-weight: 700;
}

.field small,
.helper {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.choice-chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}

.choice-chip.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-deep);
}

.food-grid,
.recipe-grid,
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.food-card,
.recipe-card,
.exercise-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.food-card {
  padding: 16px;
}

.food-card header,
.recipe-card header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.food-card h3,
.recipe-card h3,
.exercise-card h3 {
  margin: 0;
  font-size: 0.96rem;
}

.food-card .category,
.recipe-card .category {
  color: var(--muted);
  font-size: 0.72rem;
}

.grade {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.grade.green {
  background: var(--green-soft);
  color: var(--green-deep);
}

.grade.amber {
  background: var(--amber-soft);
  color: #7f591c;
}

.grade.coral {
  background: var(--coral-soft);
  color: #a54838;
}

.food-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 14px 0;
}

.food-stats div {
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-2);
}

.food-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
}

.food-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 0.84rem;
}

.food-card p,
.recipe-card p,
.exercise-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.65;
}

.food-card footer,
.recipe-card footer,
.exercise-card footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.recipe-media {
  position: relative;
  aspect-ratio: 16 / 8.5;
  overflow: hidden;
  background: var(--surface-2);
}

.recipe-media img,
.exercise-card video,
.exercise-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-media::after {
  position: absolute;
  inset: auto 0 0;
  height: 50%;
  background: linear-gradient(transparent, rgba(18, 45, 42, 0.54));
  content: "";
}

.recipe-media .recipe-label {
  position: absolute;
  z-index: 1;
  left: 12px;
  bottom: 10px;
  color: white;
  font-size: 0.73rem;
}

.recipe-card .card-content,
.exercise-card .card-content {
  padding: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #58706b;
  font-size: 0.66rem;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.line-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.line-chart text {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 10px;
}

.line-chart .grid-line {
  stroke: #dfe8e2;
  stroke-width: 1;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-legend span::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.chart-legend .cgm::before {
  background: var(--blue);
}

.chart-legend .finger::before {
  background: var(--coral);
}

.notice {
  padding: 11px 12px;
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--blue-soft);
  color: #46616d;
  font-size: 0.78rem;
  line-height: 1.6;
}

.notice.warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: #715322;
}

.notice.danger {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: #7f3a3a;
}

.notice.success {
  border-left-color: var(--green);
  background: var(--green-soft);
  color: var(--green-deep);
}

.tabs {
  display: flex;
  gap: 5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}

.tabs button.active {
  background: var(--green-soft);
  color: var(--green-deep);
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.setting-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.setting-line:last-child {
  border-bottom: 0;
}

.setting-line strong {
  display: block;
  font-size: 0.86rem;
}

.setting-line small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.switch {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
}

.switch input {
  width: 40px;
  min-height: auto;
  height: 22px;
  accent-color: var(--green);
}

.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.device-row .device-type {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.68rem;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bottom-nav {
  display: none;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 38, 37, 0.46);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(620px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  border: 1px solid #d4dfd8;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(14, 38, 36, 0.24);
}

.modal.wide {
  width: min(880px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.modal-body {
  max-height: calc(86vh - 140px);
  overflow-y: auto;
  padding: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.modal-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.modal-close svg {
  width: 16px;
  height: 16px;
  margin: auto;
}

.calendar-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #6d5224;
  font-size: 0.77rem;
  line-height: 1.6;
}

.ai-panel {
  display: grid;
  gap: 12px;
}

.ai-history {
  display: grid;
  gap: 9px;
  max-height: 330px;
  overflow-y: auto;
}

.ai-message {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: #435653;
  font-size: 0.83rem;
  line-height: 1.7;
}

.ai-message.user {
  margin-left: 15%;
  background: var(--green-soft);
  color: var(--green-deep);
}

.ai-message.assistant {
  margin-right: 8%;
}

.recipe-detail-media {
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
}

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

.detail-stat {
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.detail-stat strong {
  display: block;
  margin-top: 4px;
}

.ordered-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: #405653;
  line-height: 1.75;
}

.inline-code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--green-deep);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 20px;
  bottom: 22px;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  border: 1px solid #c6dad2;
  border-radius: var(--radius);
  background: #173f3b;
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.5;
}

.toast.error {
  background: #733b35;
}

.busy-overlay {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(244, 248, 245, 0.72);
  backdrop-filter: blur(3px);
}

.busy-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.print-report {
  color: #1f3334;
}

.print-report h2 {
  margin: 0 0 4px;
  font-family: "Songti SC", "STSong", serif;
}

.print-report .report-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.print-report section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.print-report section h3 {
  margin: 0 0 9px;
  font-size: 0.92rem;
}

.print-report p,
.print-report li {
  font-size: 0.82rem;
  line-height: 1.7;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.report-table th,
.report-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.offline-banner {
  margin-bottom: 16px;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #6f5020;
  font-size: 0.77rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1080px) {
  .content-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .food-grid,
  .recipe-grid,
  .exercise-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .auth-page {
    grid-template-columns: 1fr;
    align-content: center;
    padding: 22px 16px 34px;
  }

  .auth-story {
    display: none;
  }

  .auth-panel {
    padding: 24px 20px;
  }

  .app-shell {
    display: block;
    padding-bottom: 76px;
  }

  .side-rail {
    display: none;
  }

  .main-shell {
    padding: 20px 14px 28px;
  }

  .topbar {
    margin-bottom: 18px;
  }

  .topbar h1 {
    font-size: 1.75rem;
  }

  .topbar p {
    max-width: 27ch;
    font-size: 0.8rem;
    line-height: 1.55;
  }

  .top-actions .button span {
    display: none;
  }

  .top-actions .button {
    width: 42px;
    padding: 0;
  }

  .bottom-nav {
    position: fixed;
    z-index: 80;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.94);
    backdrop-filter: blur(16px);
  }

  .bottom-nav .nav-button {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 5px 3px;
    font-size: 0.66rem;
  }

  .bottom-nav .nav-button svg {
    width: 20px;
    height: 20px;
  }

  .content-grid,
  .stack {
    gap: 12px;
  }

  .card-body {
    padding: 16px;
  }

  .today-hero {
    padding: 22px 18px;
  }

  .today-hero h2 {
    font-size: 1.55rem;
  }

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

  .quick-action {
    min-height: 92px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:last-child {
    grid-column: 1 / -1;
  }

  .food-grid,
  .recipe-grid,
  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .segmented button {
    flex: 1 0 auto;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal,
  .modal.wide {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
  }

  .modal-body {
    max-height: calc(92vh - 132px);
    padding: 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast-region {
    right: 12px;
    bottom: 84px;
  }
}

@media print {
  body {
    background: white;
  }

  .modal-backdrop {
    position: static;
    display: block;
    padding: 0;
    background: white;
    backdrop-filter: none;
  }

  .modal {
    width: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .modal-header .modal-close,
  .modal-actions,
  .no-print,
  .bottom-nav,
  .side-rail,
  .topbar,
  .toast-region {
    display: none !important;
  }

  .modal-body {
    max-height: none;
    overflow: visible;
    padding: 0;
  }
}
