:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-soft: #e6edf5;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --ink: #091524;
  --muted: #4a6078;
  --soft: #cbd5e1;
  --line: rgba(9, 21, 36, 0.1);
  --brand: #0c3150;
  --brand-2: #0f8fb2;
  --brand-dark: #061829;
  --amber: #f7b733;
  --accent: #0f8fb2;
  --danger: #b94848;
  --shadow: 0 24px 70px rgba(6, 24, 41, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(15, 143, 178, 0.2), transparent 32rem),
    radial-gradient(circle at 90% 8%, rgba(247, 183, 51, 0.26), transparent 28rem),
    radial-gradient(circle at 30% 100%, rgba(15, 143, 178, 0.08), transparent 32rem),
    linear-gradient(160deg, #fbfdff 0%, var(--bg) 52%, #dfe8f2 100%);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img {
  max-width: 100%;
  display: block;
}

.screen {
  min-height: 100dvh;
  padding: 18px;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-weight: 800;
  background: var(--accent);
  box-shadow: 0 12px 26px rgba(15, 143, 178, 0.28);
}

.brand-copy strong {
  display: block;
  font-size: 1.18rem;
  letter-spacing: -0.03em;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-title {
  margin: 0 0 8px;
  font-size: clamp(2.1rem, 11vw, 4rem);
  line-height: 0.96;
  letter-spacing: -0.07em;
}

.hero-title span {
  color: var(--accent);
}

.lede {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border-radius: 999px;
  background: var(--bg-soft);
  margin-bottom: 18px;
}

.tabs button {
  padding: 11px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tabs button.active {
  color: #fff;
  background: var(--accent);
}

.form {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-help {
  margin: -3px 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.username-status {
  min-height: 1rem;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}

.username-status.available {
  color: #168451;
}

.username-status.unavailable {
  color: var(--danger);
}

.username-status.checking {
  color: var(--accent);
}

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(15, 143, 178, 0.48);
  box-shadow: 0 0 0 4px rgba(15, 143, 178, 0.14);
  background: #fff;
}

.category-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.category-picker {
  position: relative;
  min-width: 0;
}

.category-trigger {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 800;
  text-align: left;
}

.field .category-trigger span {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.category-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 7px);
  z-index: 60;
  display: none;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(6, 24, 41, 0.16);
}

.category-picker.open .category-menu {
  display: grid;
  gap: 4px;
}

.category-option {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.field .category-option span {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.category-option strong {
  color: var(--accent);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.category-option:hover,
.category-option.active {
  background: rgba(15, 143, 178, 0.1);
}

.category-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.category-add-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(15, 143, 178, 0.22);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(15, 143, 178, 0.24);
}

.button.secondary {
  color: var(--ink);
  background: var(--bg-soft);
  box-shadow: none;
}

.button.ghost {
  color: var(--accent);
  background: transparent;
  box-shadow: none;
}

.button.danger {
  background: var(--danger);
  box-shadow: none;
}

.alert {
  padding: 12px 14px;
  border-radius: 15px;
  color: var(--danger);
  background: rgba(185, 72, 72, 0.1);
  border: 1px solid rgba(185, 72, 72, 0.16);
  font-size: 0.92rem;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding-bottom: 96px;
}

.topbar {
  display: grid;
  gap: 14px;
  padding: 10px;
  border: 1px solid rgba(9, 21, 36, 0.09);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 16px 45px rgba(6, 24, 41, 0.1);
  backdrop-filter: blur(20px);
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.topbar .brand-lockup {
  margin: 0;
  min-width: 0;
}

.topbar .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: var(--accent);
}

.topbar .brand-copy span {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-nav {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(230, 237, 245, 0.86);
}

.top-nav button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 900;
}

.top-nav .nav-icon {
  display: none;
}

.top-nav button.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(15, 143, 178, 0.2);
}

.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(230, 237, 245, 0.92);
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(6, 24, 41, 0.12);
}

.calc-menu-button {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 28px rgba(15, 143, 178, 0.24);
}

.calc-menu-button span {
  display: grid;
  gap: 1px;
  text-align: left;
  line-height: 1;
}

.calc-menu-button small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.62rem;
}

.calc-menu-button strong {
  font-size: 0.95rem;
}

.logout-menu-button {
  color: var(--danger);
  background: rgba(185, 72, 72, 0.1);
}

.header-tools {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  margin: 20px 0 20px;
}

.categories-tools {
  width: fit-content;
  justify-content: flex-start;
}

.search-panel.header-search-panel {
  flex: 0 1 clamp(18rem, 34vw, 34rem);
  width: clamp(18rem, 34vw, 34rem);
  max-width: 100%;
  margin: 0;
}

.search-panel.header-search-panel input {
  min-height: 48px;
  height: 48px;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.92);
}

.search-panel.header-search-panel::after {
  top: 31px;
}

.add-food-fab {
  min-height: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 28px rgba(15, 143, 178, 0.24);
  font-weight: 900;
}

.add-food-fab span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 1.2rem;
  line-height: 1;
}

.page-head {
  display: grid;
  gap: 8px;
  margin: 22px 0 18px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 1;
  letter-spacing: -0.065em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.search-panel {
  position: relative;
  margin-bottom: 16px;
}

.search-panel input {
  min-height: 58px;
  padding-left: 48px;
  border-radius: 22px;
  font-weight: 700;
}

.search-panel::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-58%);
  opacity: 0.72;
}

.search-panel::after {
  content: "";
  position: absolute;
  left: 31px;
  top: 36px;
  width: 8px;
  height: 2px;
  border-radius: 99px;
  background: var(--muted);
  transform: rotate(45deg);
  opacity: 0.72;
}

.quick-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 0 20px;
  scrollbar-width: none;
}

.quick-row::-webkit-scrollbar {
  display: none;
}

.cat-row-mobile {
  display: none;
}

@media (max-width: 719px) {
  .cat-row-desktop { display: none; }
  .cat-row-mobile { display: flex; }
  .logout-menu-button { display: none; }
  .mobile-hide { display: none !important; }
  .mobile-show { display: inline-flex !important; }
}

.chip-filter-btn {
  color: var(--accent);
  border-color: rgba(15, 143, 178, 0.3);
  background: rgba(15, 143, 178, 0.08);
}

.cat-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(circle at top left, rgba(15, 143, 178, 0.2), transparent 32rem),
    radial-gradient(circle at 90% 8%, rgba(247, 183, 51, 0.26), transparent 28rem),
    radial-gradient(circle at 30% 100%, rgba(15, 143, 178, 0.08), transparent 32rem),
    linear-gradient(160deg, #fbfdff 0%, #f4f7fb 52%, #dfe8f2 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cat-overlay-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}

.cat-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: transparent;
}

.cat-overlay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cat-overlay-item {
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
  text-align: center;
  font-size: 0.9rem;
}

.cat-overlay-item.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent);
}

.chip {
  flex: 0 0 auto;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.chip.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent);
}

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

.category-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}

.category-grid .empty {
  grid-column: 1 / -1;
}

.food-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: start;
  row-gap: 24px;
}

.food-card, .category-card, .panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(6, 24, 41, 0.07);
  overflow: hidden;
}

.food-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
}

.thumb {
  position: relative;
  width: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 143, 178, 0.2), rgba(15, 143, 178, 0.08)),
    var(--bg-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 900;
  font-size: 1.6rem;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(6, 24, 41, 0.18), rgba(6, 24, 41, 0.78));
}

.thumb-initial {
  display: none;
}

.thumb-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 16px 16px 44px;
  color: #fff;
  text-align: center;
}

.food-tag-left {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  max-width: calc(100% - 52px);
}

.food-tag-left span {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  background: rgba(6, 24, 41, 0.48);
  backdrop-filter: blur(10px);
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-settings-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  background: rgba(6, 24, 41, 0.48);
  backdrop-filter: blur(10px);
}

.thumb-overlay h3 {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  font-size: 1.08rem;
  line-height: 1.08;
  letter-spacing: -0.04em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  line-height: 1.2;
}

.food-body {
  flex: 1;
  min-width: 0;
  padding: 12px 16px 16px;
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 140px;
}

.food-detail-tabs {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 4;
  width: max-content;
  max-width: calc(100% - 24px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(6, 24, 41, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}

.food-detail-tabs button {
  min-height: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.05;
  white-space: nowrap;
  transition: color 160ms ease, opacity 160ms ease;
}

.food-detail-tabs button::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: transparent;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.food-detail-tabs button.active {
  color: #fff;
}

.food-detail-tabs button.active::before {
  border-color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18), 0 0 12px rgba(15, 143, 178, 0.5);
}

.food-title-row {
  display: grid;
  gap: 6px;
}

.food-title-main {
  min-width: 0;
}

.carb-badge {
  justify-self: start;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 12px;
  color: #07536a;
  background: rgba(15, 143, 178, 0.16);
  font-size: 0.74rem;
  font-weight: 900;
}

.meta-line {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.nutrition-block {
  display: grid;
  gap: 7px;
  padding: 0;
}

.nutrition-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}

.nutrition-title {
  display: flex;
  align-items: center;
  min-height: 18px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.photo-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--muted);
}

.photo-tick {
  color: #22c55e;
  font-weight: 900;
}

.photo-cross {
  color: var(--danger);
  font-weight: 900;
}

.photo-view-link {
  color: var(--accent);
  background: transparent;
  font-size: 0.62rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

.nutrition-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.15;
}

.nutrition-row strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
}

.nutrition-formula {
  display: flex;
  align-items: center;
  min-height: 0;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.15;
}

.ratio-panel {
  display: grid;
  gap: 7px;
  padding: 0;
}

.ratio-mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 18px;
  padding: 0;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.mode-btn .mode-dot {
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--muted);
  border-radius: 999px;
  background: transparent;
}

.mode-btn.active {
  color: var(--ink);
}

.mode-btn.active .mode-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 143, 178, 0.14);
}

.ratio-input {
  width: 90px;
  height: 22px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: right;
  line-height: 1;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  align-self: center;
}

.ratio-input:focus {
  border-color: rgba(15, 143, 178, 0.48);
  box-shadow: 0 0 0 3px rgba(15, 143, 178, 0.14);
  background: #fff;
}

.ratio-result-row {
  align-items: center;
}

.ratio-result-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-mini {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: none;
}

.add-mini:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  letter-spacing: -0.04em;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

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

.quantity-toggle-row {
  gap: 10px;
}

.custom-amount-row {
  justify-content: space-between;
}

.serving-meta {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--muted);
}

.custom-amount-row .ratio-input {
  margin-left: auto;
}

.category-card {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-card > div:first-child {
  min-width: 0;
}

.category-card strong {
  display: block;
  overflow: hidden;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.category-card-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-card-actions .button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  box-shadow: none;
}

.category-settings-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(15, 143, 178, 0.12);
  border-radius: 14px;
  color: var(--accent);
  background: rgba(15, 143, 178, 0.1);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.category-settings-btn:hover {
  transform: translateY(-1px);
  background: rgba(15, 143, 178, 0.16);
  box-shadow: 0 12px 26px rgba(6, 24, 41, 0.1);
}

.empty {
  padding: 24px;
  border: 1px dashed rgba(22, 32, 20, 0.18);
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
}

.loading-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
}

.loading-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 16px;
}

.loading-copy {
  min-width: 0;
  flex: 1;
}

.loading-copy p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.loading-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.loading-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 22;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 -18px 45px rgba(6, 24, 41, 0.13);
  backdrop-filter: blur(20px);
}

.bottom-nav button {
  min-height: 58px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.bottom-nav .nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.bottom-nav .nav-icon svg {
  width: 22px;
  height: 22px;
}

.bottom-nav .nav-label {
  display: block;
}

.bottom-nav button.active {
  color: var(--accent);
  background: rgba(15, 143, 178, 0.1);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 20, 10, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 41;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 72px);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 28px;
  background: var(--panel-solid);
  box-shadow: 0 24px 70px rgba(22, 32, 20, 0.26);
  transform: translate(-50%, -44%) scale(0.98);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.7,.2,1), opacity 180ms ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}

.drawer.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 43;
  background: rgba(6, 24, 41, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  backdrop-filter: blur(0);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(5px);
}

.modal-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 44;
  width: min(calc(100% - 28px), 540px);
  max-height: min(86dvh, 760px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 30px 90px rgba(6, 24, 41, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.98);
  transition: opacity 180ms ease, transform 180ms cubic-bezier(.2,.7,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sheet.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.category-settings-sheet {
  width: min(calc(100% - 28px), 420px);
}

.category-settings-sheet .account-actions {
  margin-top: 2px;
}

.quick-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(6, 24, 41, 0.2);
  backdrop-filter: blur(4px);
}

.quick-modal-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 46;
  width: min(calc(100% - 36px), 390px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 80px rgba(6, 24, 41, 0.22);
  transform: translate(-50%, -50%);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.05em;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.9rem;
}

.modal-scroll {
  min-height: 0;
  overflow: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 143, 178, 0.24) transparent;
}

.modal-scroll::-webkit-scrollbar {
  width: 8px;
}

.modal-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.modal-scroll::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: rgba(15, 143, 178, 0.24);
}

.modal-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 143, 178, 0.36);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.drawer-head h2 {
  margin: 0;
  letter-spacing: -0.05em;
}

.drawer-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.close-button {
  flex: 0 0 auto;
  width: 42px;
  padding: 0;
}

.total-card {
  flex: 0 0 auto;
  padding: 16px;
  border-radius: 22px;
  color: #fff;
  background: var(--accent);
  margin-bottom: 12px;
}

.total-card span {
  color: rgba(255,255,255,0.7);
  font-weight: 700;
}

.total-card strong {
  display: block;
  margin-top: 4px;
  font-size: 2.25rem;
  letter-spacing: -0.08em;
}

.drawer-list {
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.drawer-footer {
  flex: 0 0 auto;
  padding-top: 12px;
}

.drawer-footer .button {
  width: 100%;
}

.calc-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.86);
}

.calc-item strong {
  display: block;
}

.calc-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.small-link {
  color: var(--accent);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.photo-preview {
  width: 100%;
  max-height: 180px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.photo-preview-large {
  width: 100%;
  border-radius: 16px;
  object-fit: contain;
}

.edit-photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.edit-photo-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.edit-photo-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.edit-photo-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.edit-divider {
  width: 100%;
  margin: 16px 0;
  border: 0;
  border-top: 1px dashed var(--line);
}

.hidden { display: none !important; }
.card-row-ghost { visibility: hidden; pointer-events: none; }

.card-panels { display: grid; grid-template-columns: 1fr; min-width: 0; }
.card-panels > div { grid-area: 1/1; min-width: 0; }
.card-panel-hidden { visibility: hidden; pointer-events: none; }

/* Skeleton shimmer */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--soft) 25%, rgba(223, 232, 220, 0.4) 50%, var(--soft) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 10px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(100% - 36px, 440px);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.92rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(22, 32, 20, 0.18);
  animation: toastIn 260ms ease forwards;
  pointer-events: auto;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success {
  background: rgba(15, 143, 178, 0.94);
  color: #fff;
}

.toast.error {
  background: rgba(185, 72, 72, 0.94);
  color: #fff;
}

/* Account page polish */
.account-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.account-panel:first-of-type {
  margin-top: 18px;
}

.account-panel + .account-panel {
  margin-top: 14px;
}

.account-panel h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
}

.account-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.account-email {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.account-header .lede {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.account-form {
  max-width: 460px;
}

.danger-copy {
  max-width: 560px;
  margin: -6px 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 700;
}

.warning-box {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(185, 72, 72, 0.18);
  border-radius: 16px;
  color: var(--danger);
  background: rgba(185, 72, 72, 0.08);
}

.warning-box strong {
  font-size: 0.88rem;
}

.warning-box span {
  color: #7a2f2f;
  line-height: 1.4;
  font-size: 0.9rem;
  font-weight: 700;
}

.confirm-sheet {
  width: min(calc(100% - 28px), 430px);
}

/* Floating help menu */
.float-trigger {
  position: fixed;
  right: 0;
  bottom: 28%;
  z-index: 901;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  padding: 16px 7px;
  border-radius: 10px 0 0 10px;
  background: rgba(12, 49, 80, 0.7);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
  backdrop-filter: blur(8px);
}

.float-trigger:hover,
.float-trigger.open {
  background: var(--brand-dark);
  color: #fff;
  transform: translateX(-2px);
}

.float-backdrop {
  position: fixed;
  inset: 0;
  z-index: 899;
}

.float-menu-items {
  position: fixed;
  right: 36px;
  bottom: 28%;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.float-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  transition: transform 150ms ease, box-shadow 150ms ease;
  background: var(--amber);
  color: var(--brand-dark);
}

.float-menu-item:hover {
  transform: translateX(-4px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.float-menu-item.float-menu-support {
  background: var(--accent);
  color: #fff;
}

/* Feedback panels */

.feedback-backdrop {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(6, 24, 41, 0.32);
  backdrop-filter: blur(3px);
}

.feedback-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  width: min(calc(100vw - 2.5rem), 420px);
  max-height: 86dvh;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: 0 28px 80px rgba(6, 24, 41, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feedback-panel-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
}

.feedback-panel-title {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.feedback-x {
  width: 36px;
  height: 36px;
  padding: 0;
  min-height: 36px;
  flex: 0 0 auto;
}

.feedback-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 143, 178, 0.2) transparent;
}

.feedback-panel-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.feedback-panel-footer-split {
  justify-content: space-between;
}

.feedback-stars {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 10px 0 4px;
}

.feedback-star {
  background: transparent;
  padding: 4px;
  border-radius: 8px;
  line-height: 0;
  transition: transform 140ms ease;
}

.feedback-star:hover {
  transform: scale(1.25);
}

.feedback-star-field {
  text-align: center;
}

.feedback-pill-group {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.feedback-pill {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  font-size: 0.9rem;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.feedback-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(15, 143, 178, 0.1);
}

.fb-progress {
  height: 4px;
  background: var(--line);
  flex: 0 0 auto;
}

.fb-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 300ms ease;
}

.fb-step-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.fb-step {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fb-heading {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.fb-sub {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.feedback-done {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 12px 0;
}

.feedback-done-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(15, 143, 178, 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 900;
}

.feedback-done-heading {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.feedback-done-sub {
  margin: -6px 0 4px;
  color: var(--muted);
}

.field-opt {
  font-weight: 400;
  opacity: 0.7;
  font-style: normal;
  font-size: 0.78rem;
}

.button-ghost {
  background: var(--bg-soft);
  color: var(--muted);
  box-shadow: none;
}

@media (max-width: 719px) {
  .feedback-trigger {
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
    transform: none;
  }

  .feedback-trigger:hover {
    transform: translateX(-4px);
  }

  .feedback-panel-mobile {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
    background:
      radial-gradient(circle at top left, rgba(15, 143, 178, 0.2), transparent 32rem),
      radial-gradient(circle at 90% 8%, rgba(247, 183, 51, 0.26), transparent 28rem),
      linear-gradient(160deg, #fbfdff 0%, var(--bg) 52%, #dfe8f2 100%);
    z-index: 1000;
  }

  .feedback-panel-mobile .feedback-panel-nav,
  .feedback-panel-mobile .feedback-panel-footer {
    background: rgba(255, 255, 255, 0.88);
  }

  .feedback-panel-mobile .fb-heading {
    font-size: 1.8rem;
  }

  .feedback-panel-mobile .feedback-stars {
    justify-content: flex-start;
    padding: 12px 0 8px;
  }

  .feedback-panel-mobile .feedback-star svg {
    width: 44px;
    height: 44px;
  }

  .float-trigger {
    bottom: calc(76px + env(safe-area-inset-bottom) + 12px);
  }

  .float-menu-items {
    bottom: calc(76px + env(safe-area-inset-bottom) + 12px);
  }
}

.account-help-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.account-help-row .button {
  display: flex;
  align-items: center;
  gap: 7px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.account-actions {
  display: grid;
  gap: 10px;
}

.account-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* Optimistic states */
.food-card.optimistic,
.category-card.optimistic {
  opacity: 0.72;
  pointer-events: auto;
}

.food-card.optimistic .thumb,
.category-card.optimistic .skeleton {
  animation-duration: 0.8s;
}

/* Button spinner */
.button-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

/* Image preview row */
.preview-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-row img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
}

/* File input polish */
input[type="file"].input {
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

input[type="file"].input::file-selector-button {
  border: 0;
  border-radius: 10px;
  padding: 6px 12px;
  margin-right: 10px;
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

/* Photo picker */
.photo-picker {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* Mobile: two-column Camera + Library layout */
@media (hover: none) and (pointer: coarse) {
  .photo-picker {
    grid-template-columns: 1fr 1fr;
  }
}

.photo-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.photo-action-btn:hover,
.photo-action-btn:active {
  background: rgba(15, 143, 178, 0.08);
  border-color: rgba(15, 143, 178, 0.3);
  color: var(--accent);
}

/* Desktop: hide mobile-only buttons; Mobile: hide desktop-only button */
.photo-mobile-btn { display: none; }

@media (hover: none) and (pointer: coarse) {
  .photo-desktop-btn { display: none; }
  .photo-mobile-btn { display: inline-flex; }
}

/* Desktop: compact form buttons (auto-width instead of grid-stretch) */
@media (hover: hover) and (pointer: fine) {
  .form .button,
  .form-grid .button {
    justify-self: start;
  }
  .photo-picker {
    width: fit-content;
  }
}

.photo-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Sticky feedback banner */
.feedback-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 10px 18px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  backdrop-filter: blur(16px);
  animation: bannerSlide 240ms ease;
}

@keyframes bannerSlide {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@media (min-width: 720px) {
  .screen { padding: 24px; }
  .app-shell { padding-bottom: 34px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .food-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
  .page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
  .side-panel { position: sticky; top: 116px; }
  .drawer { width: min(440px, calc(100vw - 48px)); }
}

@media (max-width: 560px) {
  body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
  .screen { padding: 0; }
  .app-shell { width: 100%; padding: 0 20px 104px; }
  .topbar { margin: 0 -20px; padding: 16px 20px; border-right: 0; border-left: 0; border-radius: 0; }
  .topbar-main { gap: 10px; }
  .topbar .brand-copy strong { font-size: 1rem; }
  .topbar .brand-copy span { max-width: 86px; font-size: 0.78rem; }
  .icon-button { min-height: 40px; padding: 0 11px; }
  .logout-text, .calc-menu-button small { display: none; }
  .calc-menu-button span { display: block; }
  .header-tools { width: 100%; display: flex; flex-wrap: nowrap; margin: 16px 0 16px; }
  .quick-row { padding: 0 0 12px; margin-bottom: 4px; }
  .food-grid { grid-template-columns: 1fr; gap: 16px; }
  .field span { font-size: 0.88rem; font-weight: 700; line-height: 1.25; }
  .username-status { font-size: 0.86rem; line-height: 1.35; }
  .input, .select, .textarea { font-size: 1rem; line-height: 1.35; }
  .button { font-size: 0.98rem; line-height: 1.2; }
  .panel { padding: 18px 16px; }
  .account-header { align-items: flex-start; gap: 14px; margin-bottom: 20px; }
  .account-header h2 { font-size: 1.28rem; line-height: 1.18; letter-spacing: -0.03em; }
  .account-email, .account-header .lede { font-size: 0.96rem; line-height: 1.38; }
  .account-panel h2 { font-size: 1.28rem; line-height: 1.2; }
  .danger-copy { font-size: 0.96rem; line-height: 1.55; }
  .search-panel.header-search-panel { flex: 1 1 auto; width: auto; min-width: 0; }
  .add-food-fab { width: 3.125rem; padding: 0; }
  .add-food-fab strong { display: none; }
  .category-card { padding: 14px; }
  .category-card-actions .button { min-height: 38px; padding: 0 12px; }
  .category-settings-btn { width: 38px; height: 38px; border-radius: 13px; }
  .page-head { margin-top: 18px; }
  .food-card { min-height: 0; border-radius: 18px; flex-direction: row; }
  .food-card .thumb { flex: 0 0 45%; aspect-ratio: unset; border-bottom: 0; border-right: 1px solid var(--line); }
  .food-body { flex: 1; min-width: 0; padding: 12px 14px 14px; height: 220px; overflow: hidden; }
  .thumb-overlay { padding: 20px 8px 32px; }
  .thumb-overlay h3 { font-size: 1rem; }
  .food-tag-left span { font-size: 0.64rem; padding: 4px 7px; }
  .card-settings-btn { width: 28px; height: 28px; border-radius: 9px; }
  .brand-sub { font-size: 0.7rem; }
  .food-detail-tabs { left: 50%; right: auto; bottom: 8px; gap: 8px; padding: 6px 9px; }
  .food-detail-tabs button { min-height: 0; padding: 0; font-size: 0.7rem; }
  .food-detail-tabs button::before { width: 8px; height: 8px; border-width: 1.5px; }
  .nutrition-block { gap: 6px; padding: 0; }
  .ratio-panel { gap: 6px; padding: 0; }
  .ratio-result-wrap { flex-shrink: 0; gap: 6px; }
  .nutrition-header { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; }
  .nutrition-title { font-size: 0.8rem; font-weight: 900; }
  .photo-status { font-size: 0.64rem; }
  .nutrition-row { flex-direction: column; align-items: flex-start; gap: 1px; min-height: 0; font-size: 0.72rem; }
  .nutrition-row span { font-weight: 700; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nutrition-row strong { font-size: 0.92rem; font-weight: 900; line-height: 1.2; overflow-wrap: break-word; word-break: break-word; }
  .nutrition-formula { font-size: 0.72rem; display: block; overflow-wrap: break-word; word-break: break-word; min-height: 0; }
  .ratio-mode-row { gap: 14px; }
  .mode-btn { font-size: 0.94rem; }
  .mode-btn .mode-dot { width: 10px; height: 10px; }
  .ratio-input { width: 82px; height: 30px; min-height: 30px; padding: 0 8px; font-size: 0.9rem; }
  .add-mini { width: 34px; height: 34px; font-size: 1.2rem; }
  .custom-amount-row { flex-wrap: wrap; gap: 6px; }
  .custom-amount-row .ratio-input { flex: 0 0 100%; width: 100%; margin-left: 0; }
  .ratio-result-row { flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (max-width: 380px) {
  .topbar { gap: 8px; padding: 8px; }
  .topbar .brand-lockup { gap: 8px; }
  .topbar .brand-copy span { display: none; }
  .row-actions { gap: 6px; }
  .icon-button { padding: 0 10px; }
  .calc-menu-button strong { font-size: 0.88rem; }
}

/* Toggle switch */
.field-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.toggle-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--soft);
  transition: background 180ms ease;
  cursor: pointer;
}

.toggle-track::after {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  margin: 3px;
  transition: transform 180ms ease;
}

.toggle-input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* Discover */
.discover-creator-row {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.discover-creator-name {
  color: var(--brand-2);
  font-weight: 600;
}

.discover-load-more {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.card-added-btn {
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  background: rgba(6, 24, 41, 0.48) !important;
  cursor: default;
}
