@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-ext-500.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-ext-600.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-ext-700.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/plus-jakarta-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f6f7f3;
  --surface: #fff;
  --primary: #426b50;
  --secondary: #668f70;
  --primary-subtle: #eaf1e7;
  --text: #23382d;
  --muted: #68786e;
  --border: #e4eae3;
  --protein: #719d82;
  --carbs: #c5a16b;
  --fat: #b88780;
  --shadow: 0 1px 2px rgba(35, 56, 45, 0.04), 0 8px 24px rgba(35, 56, 45, 0.05);
  --radius: 20px;
  --radius-sm: 14px;
  --space: 8px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

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

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

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

svg {
  display: block;
}

.shell {
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.workspace {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) 0 8px;
  background: var(--bg);
}

.wordmark,
.sidebar-mark {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--primary);
  background: var(--primary-subtle);
  border: 0;
  border-radius: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  min-height: calc(64px + env(safe-area-inset-bottom));
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar button,
.side-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.tabbar svg,
.side-nav svg,
.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar button[aria-current="page"],
.side-nav button[aria-current="page"] {
  color: var(--primary);
}

.tabbar .tab-scan {
  width: 52px;
  height: 52px;
  margin: -18px 12px 0;
  color: #fff;
  background: var(--primary);
  border-radius: 16px;
}

.tabbar .tab-scan[aria-current="page"] {
  color: #fff;
  background: #365842;
}

main {
  display: grid;
  gap: 16px;
}

.today {
  display: grid;
  gap: 16px;
}

.week {
  display: grid;
  gap: 12px;
}

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

.week-top h2 {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: left;
}

.week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-height: 56px;
  padding: 6px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 14px;
  font-size: 0.68rem;
  font-weight: 600;
}

.day strong {
  color: var(--text);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.day.is-today {
  background: var(--primary-subtle);
}

.day.is-selected {
  background: var(--primary);
  color: #fff;
}

.day.is-selected strong {
  color: #fff;
}

.icon-btn,
.date-jump {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.date-jump {
  position: relative;
  overflow: hidden;
}

.date-jump input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.back-today {
  justify-self: center;
  padding: 0;
  color: var(--primary);
  background: none;
  border: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.summary {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 16px;
  align-items: center;
}

.ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
}

.ring {
  width: 100%;
  height: 100%;
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 8;
}

.ring-track {
  stroke: var(--primary-subtle);
}

.ring-value {
  stroke: var(--primary);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 200ms ease;
}

.ring-value.over {
  stroke: var(--fat);
}

.ring-copy {
  position: absolute;
  inset: 22px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.ring-copy strong {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ring-copy span,
.goal-label,
.macro span,
.meal-kcal,
.muted {
  color: var(--muted);
}

.summary-copy {
  display: grid;
  gap: 12px;
  min-width: 0;
}

#kcal-rest {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary.is-over #kcal-rest {
  color: #8d645e;
}

.goal-label {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.goal-label input {
  width: 100%;
  max-width: 8rem;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.macros {
  display: grid;
  gap: 8px;
}

.macro {
  display: inline-grid;
  grid-template-columns: 8px auto auto;
  gap: 8px;
  align-items: center;
  width: max-content;
  font-size: 0.85rem;
}

.macro i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
}

.macro b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.macro.protein i { background: var(--protein); }
.macro.carbs i { background: var(--carbs); }
.macro.fat i { background: var(--fat); }

.meals-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meals-bar h2,
.page-head h2,
.auth h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.today-meals,
.meals {
  display: grid;
  gap: 12px;
}

.meal-card,
.card,
.panel,
.row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.meal-card {
  overflow: hidden;
}

.meal-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 12px;
}

.meal-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
}

.meal-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--primary);
  background: var(--primary-subtle);
  border-radius: 12px;
}

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

.meal-title {
  display: block;
  font-weight: 600;
}

.meal-kcal {
  display: block;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.meal-toggle .chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 180ms ease;
}

.meal-toggle[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.meal-body {
  display: grid;
  border-top: 1px solid var(--border);
}

.entry {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  user-select: none;
  -webkit-touch-callout: none;
}

.entry:last-child {
  border-bottom: 0;
}

.entry:active,
.entry.holding {
  background: var(--primary-subtle);
}

.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.entry-top .name,
.name {
  font-weight: 600;
}

.entry-top span:last-child,
.kcal {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.entry .muted,
.row .muted {
  font-size: 0.82rem;
}

.entry.removing,
.row.removing {
  background: #f6ebe8;
  color: #6e4a45;
}

.empty {
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.page {
  display: grid;
  gap: 16px;
}

.page-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.search input {
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border: 0;
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.stack,
.list,
.import-list {
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  box-shadow: none;
}

button.row {
  width: 100%;
  text-align: left;
}

.grow {
  flex: 1;
  min-width: 0;
}

.auth {
  display: grid;
  gap: 16px;
  max-width: 420px;
  margin: 8vh auto 0;
}

.eyebrow {
  color: var(--secondary);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scan-page .finder {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 62dvh;
  overflow: hidden;
  background: #23382d;
  border-radius: 20px;
}

.finder video,
#qr-reader,
#qr-reader video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#qr-reader {
  border: 0 !important;
}

.finder .status {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  margin: 0;
  padding: 8px 12px;
  color: #fff;
  background: rgba(35, 56, 45, 0.72);
  border-radius: 12px;
  font-size: 0.9rem;
}

.finder::after {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  pointer-events: none;
}

.card,
.panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.panel {
  border-radius: 24px 24px 0 0;
  max-height: min(92dvh, 760px);
  overflow: auto;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: none;
}

.panel::before {
  content: "";
  width: 36px;
  height: 4px;
  margin: 4px auto 8px;
  background: var(--border);
  border-radius: 99px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 107, 80, 0.16);
}

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

.factor-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.actions,
.sheet-actions {
  display: grid;
  gap: 8px;
}

.actions {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}

.actions .btn,
.sheet-actions .btn {
  width: 100%;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-weight: 600;
}

.btn.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.btn.quiet,
.btn.ghost,
.text-btn {
  color: var(--primary);
  background: var(--primary-subtle);
  border-color: transparent;
}

.btn.ghost,
.text-btn {
  background: transparent;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px;
  font-weight: 600;
}

.text-btn svg {
  width: 18px;
  height: 18px;
}

.btn.small {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.btn.danger {
  color: #6e4a45;
  background: #f6ebe8;
  border-color: transparent;
}

.btn.cancel {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}

.btn.wide {
  width: 100%;
}

.btn.icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: var(--surface);
  border-radius: 14px;
}

.btn:disabled {
  opacity: 0.55;
}

.link,
.account-nick {
  font-weight: 600;
}

.account-nick {
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.preview,
.grams-info {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.error {
  color: #8d645e;
}

.error:empty {
  display: none;
}

.import-day {
  margin-top: 4px;
  font-size: 0.92rem;
}

#import-edit-form,
.import-edit {
  display: grid;
  gap: 12px;
}

button.import-edit {
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
}

#fitatu-status:empty,
#fitatu-preview:empty {
  display: none;
}

.skeletons {
  display: grid;
  gap: 8px;
}

.skeletons span {
  display: block;
  height: 64px;
  background: var(--primary-subtle);
  border-radius: 16px;
  animation: pulse 1.1s ease-in-out infinite;
}

.move-menu {
  position: fixed;
  z-index: 30;
  display: grid;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.move-menu p {
  margin: 4px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.move-menu button {
  padding: 10px 12px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 10px;
}

.move-menu button:hover,
.move-menu button:focus-visible {
  background: var(--primary-subtle);
}

dialog {
  width: 100%;
  max-width: 100%;
  max-height: min(92dvh, 760px);
  margin: auto 0 0;
  padding: 0;
  background: transparent;
  border: 0;
}

dialog::backdrop {
  background: rgba(35, 56, 45, 0.4);
}

dialog[open] {
  display: flex;
}

@starting-style {
  dialog[open] {
    transform: translateY(16px);
    opacity: 0;
  }
}

dialog[open] {
  transition: transform 200ms ease, opacity 200ms ease;
}

.toast {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 8;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 14px;
  color: #fff;
  background: var(--text);
  border-radius: 14px;
  transform: translateX(-50%);
  font-size: 0.9rem;
}

.toast:empty {
  display: none;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

.desk-banner,
.offline-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  background: var(--primary-subtle);
  border-radius: 16px;
}

.offline-note {
  background: #f6ebe8;
}

.admin-page {
  display: grid;
  gap: 16px;
}

.admin-card h3 {
  margin: 0;
}

.password-set {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.change-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.change-line p {
  margin: 4px 0 0;
}

.change-line .btn {
  flex: none;
}

@media (min-width: 720px) {
  dialog {
    width: min(440px, calc(100vw - 48px));
    margin: auto;
  }

  .panel {
    border-radius: 24px;
    padding: 24px;
  }

  .panel::before {
    display: none;
  }
}

@media (min-width: 960px) {
  .shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 24px 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }

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

  .side-nav button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    font-size: 0.95rem;
  }

  .side-nav button[aria-current="page"] {
    background: var(--primary-subtle);
  }

  .tabbar {
    display: none;
  }

  .workspace {
    padding: 0 32px 32px;
  }

  .wordmark {
    display: none;
  }

  .today {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    align-items: start;
  }

  .week {
    grid-column: 1 / -1;
  }

  .summary {
    grid-column: 1;
    grid-row: 2;
  }

  .today-meals {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    gap: 16px;
    align-content: start;
  }

  .toast {
    bottom: 24px;
  }
}

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