@font-face {
  font-family: Inter;
  src: url("./assets/fonts/InterVariable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #ededed;
  --ink: #2e3646;
  --muted: #59606c;
  --line: #d3d5d8;
  --white: #fff;
  --radius: 10px;
  font: 16px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button { border: 0; background: none; font-weight: 600; }
button:disabled { cursor: default; }
a, summary { color: var(--ink); text-underline-offset: .19em; }
:focus-visible { outline: 3px solid #376693; outline-offset: 2px; }
input:focus { outline: 0; }
svg {
  display: inline-block; width: 21px; height: 21px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round;
}
.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.bar-inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  max-width: 1200px; margin-inline: auto; padding: max(12px, env(safe-area-inset-top)) 24px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0; justify-self: start; text-align: start; }
.brand img { width: 50px; height: 50px; object-fit: contain; }
.brand span { font-weight: 690; font-size: 1.12rem; letter-spacing: -.045em; }
.head-btn, .unit-pill, .nav button, .segments button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 30px;
}
.head-btn {
  justify-self: end; padding: 0 16px; min-height: 42px;
  background: var(--ink); color: white; font-size: .82rem;
}
.head-btn svg { width: 17px; height: 17px; }
.nav > div {
  display: flex; align-items: stretch; gap: 3px; padding: 4px;
  background: white; border-radius: 32px;
}
.nav button { min-height: 40px; padding: 6px 16px; color: var(--muted); font-size: .86rem; }
.nav button svg { width: 18px; height: 18px; }
.audience {
  position: fixed; z-index: 3; inset-inline: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  padding: 6px 12px max(8px, env(safe-area-inset-bottom)); text-align: center;
  background: var(--paper); color: var(--muted); font-size: .875rem; line-height: 1.4;
}
.audience-group { display: inline-flex; align-items: center; }
.audience-separator { margin-inline: .5em; }
.audience strong { color: var(--ink); font-weight: 600; }
.author-link { display: inline-flex; align-items: center; min-height: 28px; white-space: nowrap; }
.nav button[aria-current="page"], .segments button[aria-pressed="true"] { background: var(--ink); color: white; }

main { max-width: 1048px; margin-inline: auto; padding: 0 24px calc(60px + env(safe-area-inset-bottom)); }
.pagehead { margin: 29px 0 30px; text-align: center; }
h1, h2, .xe-value { font-optical-sizing: auto; }
h1 { font-size: clamp(1.75rem, 4vw, 2.65rem); font-weight: 700; letter-spacing: -.055em; line-height: 1.15; }
h2 { font-size: 1.38rem; font-weight: 680; letter-spacing: -.045em; line-height: 1.22; }
h3 { font-size: 1.02rem; font-weight: 660; letter-spacing: -.022em; }
.calcgrid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.card { background: var(--white); border-radius: var(--radius); }
.input-card, .meal-card, .photo-card { padding: 22px 24px; }
.input-card { padding-bottom: 0; }
.card-heading, .dialog-head, .list-info, .meal-total, .result-head, .result-values {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-heading h2, .dialog-head h2, .entrytext b, .meal-total b { min-width: 0; overflow-wrap: anywhere; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 50%; padding: 6px; color: var(--muted);
}
#rename { background: var(--paper); width: 44px; height: 44px; }
#rename svg { width: 18px; height: 18px; }
.segments { display: flex; gap: 3px; padding: 3px; background: var(--paper); border-radius: 28px; width: max-content; max-width: 100%; }
.segments button { min-height: 42px; padding: 5px 15px; color: var(--muted); font-size: .86rem; }
.wide { width: 100%; }
.wide button { flex: 1; }
.basis { margin: 12px 0 14px; }
.food-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 69px; border-top: 1px solid var(--line); }
.food-field label { font-weight: 530; }
.number-input {
  display: flex; align-items: baseline; gap: 6px; width: clamp(95px, 30%, 160px); padding: 5px 12px;
  background: #fafafa; border: 1px solid #afb4bc; border-radius: 8px;
}
.number-input input {
  width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; text-align: right;
  font-size: 1.35rem; font-weight: 590; font-variant-numeric: tabular-nums;
}
.number-input input::placeholder { color: #737984; opacity: 1; }
.number-input > span, .muted, .small, .list-info, .empty p { color: var(--muted); }
.number-input:focus-within, .search:focus-within, .form-input:focus {
  border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink);
}

.result {
  margin: 12px -24px 0; padding: 12px 24px 19px; border-radius: var(--radius);
  color: white; background: var(--ink);
}
.result-head { font-weight: 550; font-size: .95rem; }
.unit-pill {
  min-height: 44px; padding: 0 8px; margin-right: -8px;
  color: #eef0f3; font-size: .79rem; font-weight: 500;
}
.unit-pill svg { width: 14px; height: 14px; }
.unit-pill:focus-visible { outline-color: white; }
.result-values { align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.xe-value { font-size: clamp(2.5rem, 4vw, 3.25rem); font-weight: 650; line-height: 1.1; letter-spacing: -.06em; }
.xe-value small { font-size: .48em; font-weight: 540; letter-spacing: -.035em; }
.result-carbs {
  display: inline-block; padding: 5px 10px; border-radius: 8px; border: 1px solid #666e7e;
  font-size: .84rem; font-weight: 450; color: #f5f6f7;
}
.result-carbs strong { font-weight: 650; }
.actions, #photo-buttons, .dialog-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.primary, .secondary, .quiet, .text-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  padding: 9px 16px; border-radius: var(--radius); font-size: .93rem;
}
.primary { background: var(--ink); color: white; }
.secondary { background: white; border: 1px solid #a2a7af; }
.primary:disabled { background: #d4d6d9; color: #555d6b; }
.secondary:disabled { background: transparent; color: #626975; border-color: #b3b7bd; }
.actions > button { flex: 1; }
.nutrition-note { margin: 8px 2px 0; color: var(--muted); font-size: .82rem; line-height: 1.42; }
.quiet, .text-action { padding-inline: 2px; text-align: left; }
.quiet svg { width: 14px; height: 14px; }
.small, .list-info { font-size: .9rem; }
.dish-icon { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: var(--paper); }
.dish-icon svg { width: 23px; height: 23px; }
.meal-card .small { margin: 14px 0 19px; max-width: 34ch; }
.browse { width: 100%; justify-content: space-between; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0 0; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li, .library-card { display: flex; align-items: center; gap: 8px; }
.item-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.entrytext { flex: 1; min-width: 0; padding: 6px 0; min-height: 44px; text-align: left; }
.entrytext b, .entrytext small { display: block; }
.entrytext b { font-size: 1rem; font-weight: 620; }
.entrytext small { color: var(--muted); font-size: .85rem; margin-top: 3px; font-weight: 430; }
.item-list .icon-btn svg { width: 17px; }
.meal-total { margin: 15px 0 2px; flex-wrap: wrap; }

.library-body, .photo-body { max-width: 670px; margin-inline: auto; }
.library-body > .segments { background: white; }
.search {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; padding: 9px 14px;
  background: white; border: 1px solid #b5b8be; border-radius: var(--radius); color: var(--muted);
}
.search input { width: 100%; min-width: 0; border: 0; background: transparent; min-height: 28px; }
.list-info { margin: 14px 0 10px; }
.list-info select { max-width: 62%; min-height: 38px; border: 0; background: transparent; font-size: .85rem; }
.library-card { padding: 9px 16px; margin-bottom: 6px; }
.empty { padding: 24px; }
.empty h2 { margin-bottom: 8px; }
.photo-body { display: grid; gap: 12px; }
.photo-card > p.muted { margin: 18px 0 8px; }
.photo-privacy { margin: 0 0 18px; color: var(--muted); font-size: .88rem; }
.photo-picker {
  position: relative; overflow: hidden; display: grid; place-items: center; min-height: 175px;
  text-align: center; color: white; background: var(--ink); border-radius: var(--radius); cursor: pointer;
}
.photo-picker:focus-within { outline: 3px solid #376693; outline-offset: 2px; }
#pick-label { display: grid; justify-items: center; gap: 7px; padding: 22px; }
.photo-picker svg { width: 36px; height: 36px; }
.photo-picker small { font-size: .83rem; color: #e0e3e7; }
.photo-picker input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.photo-picker img { width: 100%; max-height: 260px; object-fit: contain; }
.photo-body > .quiet { justify-self: start; }
#photo-status:not(:empty), details { margin-top: 12px; }
.photo-choice { padding: 14px 0; border-bottom: 1px solid var(--line); }
#ocr-text { white-space: pre-wrap; font-size: .9rem; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
  max-width: min(440px, calc(100% - 24px)); width: 100%; max-height: 85vh; max-height: 85dvh;
  background: white; color: var(--ink);
}
dialog::backdrop { background: rgb(30 34 42 / 45%); }
#onboarding { padding: 24px; }
.onboarding-brand { display: flex; align-items: center; gap: 8px; font-weight: 690; letter-spacing: -.035em; }
.onboarding-brand img { width: 44px; height: 44px; object-fit: contain; }
.onboarding-step { margin: 22px 0 8px; color: var(--muted); font-size: .82rem; }
#onboarding-title { outline-offset: 4px; }
#onboarding-text { margin-top: 10px; color: var(--muted); }
.onboarding-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }
.onboarding-nav { display: flex; gap: 8px; }
.onboarding-actions .primary { text-align: center; }
@media (max-width: 360px) { .onboarding-actions { flex-wrap: wrap; } .onboarding-nav { margin-left: auto; } }
.dialog-head { margin-bottom: 12px; }
.form-label { display: block; margin: 12px 0 4px; font-size: .92rem; }
.form-input { border: 1px solid #a4a9b2; border-radius: 8px; padding: 9px 12px; width: 100%; min-height: 44px; background: white; }
.help { margin: 8px 0; color: var(--muted); font-size: .88rem; }
.error { margin: 4px 0; color: #902f2a; }
.danger { color: #902f2a; }
.settings-group { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.settings-group button { margin-right: 10px; }
.notice {
  position: fixed; z-index: 5; bottom: calc(52px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: var(--radius); background: var(--ink); color: white; max-width: min(92vw, 550px); width: max-content;
}
.legal-links { display: grid; }
.legal-links a { padding: 9px 0; }
#legal-dialog { width: min(680px, calc(100% - 20px)); max-width: none; padding: 0; }
#legal-dialog form { display: flex; justify-content: flex-end; padding: 1px 18px; border-bottom: 1px solid var(--line); }
#legal-content iframe { display: block; width: 100%; height: 65vh; height: min(68dvh, 720px); border: 0; background: white; }
.legal-page { background: white; }
.legal-page main { max-width: 44rem; margin: 0 auto; padding: clamp(18px, 4vw, 38px); }
.legal-page .edition { color: var(--muted); font-size: .85rem; }
.legal-page h1 { font-size: clamp(1.65rem, 5vw, 2.25rem); margin: .5em 0; overflow-wrap: anywhere; }
.legal-page h2 { margin: 1.35em 0 .45em; }
.legal-page p { line-height: 1.55; margin: 0 0 .7em; overflow-wrap: anywhere; }

@media (hover: hover) {
  .head-btn:hover, .primary:hover:enabled { background: #1d2431; }
  .secondary:hover:enabled, .icon-btn:hover, .nav button:not([aria-current]):hover, .segments button[aria-pressed="false"]:hover { background: #dedfe1; }
  .quiet:hover, .text-action:hover { text-decoration: underline; text-underline-offset: .18em; }
  .unit-pill:hover { background: #424b5b; }
}
@media (max-width: 760px) {
  .bar-inner { grid-template-columns: 1fr auto; padding: max(7px, env(safe-area-inset-top)) 16px 7px; }
  .vk-container .bar-inner { row-gap: 6px; }
  .vk-container .brand { grid-column: 1 / -1; max-width: calc(100% - 96px); }
  .vk-container #settings { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .brand img { width: 44px; height: 44px; }
  .brand { gap: 4px; }
  .brand span { font-size: 1rem; }
  .head-btn { min-height: 44px; padding-inline: 13px; font-size: .76rem; }
  main { max-width: 620px; padding: 0 16px calc(118px + env(safe-area-inset-bottom)); }
  .pagehead { margin: 15px 0 18px; }
  .calcgrid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .input-card, .meal-card, .photo-card { padding: 16px 18px; }
  .input-card { padding-bottom: 0; }
  h2 { font-size: 1.24rem; }
  .basis { margin: 8px 0 12px; }
  .food-field { min-height: 58px; }
  .result { margin: 8px -18px 0; padding: 7px 18px 15px; }
  .meal-card .small { margin: 10px 0; }
  .nav {
    position: fixed; z-index: 3; bottom: 0; inset-inline: 0; background: white;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  }
  .nav > div { max-width: 470px; margin-inline: auto; justify-content: space-between; gap: 4px; padding: 0; }
  .nav button { flex: 1; gap: 5px; min-height: 46px; padding: 5px 6px; font-size: .78rem; }
  .audience { position: static; padding: 0 0 3px; background: transparent; font-size: .78rem; }
  .notice { bottom: calc(100px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  main { padding-bottom: calc(138px + env(safe-area-inset-bottom)); }
  .notice { bottom: calc(120px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .bar-inner, main { padding-inline: 10px; }
  .head-btn { padding-inline: 10px; gap: 5px; }
  .pagehead { margin: 10px 0 15px; }
  .input-card, .photo-card, .meal-card { padding-inline: 14px; }
  .result { margin-inline: -14px; padding-inline: 14px; }
  .food-field { gap: 8px; }
  .actions { gap: 6px; }
  .actions button { padding-inline: 6px; font-size: .86rem; }
  .nav button { gap: 4px; font-size: .75rem; }
}
