:root {
  color-scheme: only light;
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #eceae4;
  --text: #151412;
  --muted: #6f6b65;
  --line: #e2ded6;
  --accent: #ff5b1f;
  --accent-ink: #ffffff;
  --accent-soft: #ffe6da;
  --ok: #1d9a55;
  --danger: #d93c2b;
  --radius: 8px;
  --radius-sm: 6px;
  --display: "Unbounded", "Manrope", sans-serif;
  --body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d;
    --surface: #181816;
    --surface-2: #22221f;
    --text: #f3f1ec;
    --muted: #9c978f;
    --line: #2c2b28;
    --accent: #ff6a33;
    --accent-ink: #120a06;
    --accent-soft: #3a1d10;
    --ok: #3ccf7f;
    --danger: #ff6b5a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d;
  --surface: #181816;
  --surface-2: #22221f;
  --text: #f3f1ec;
  --muted: #9c978f;
  --line: #2c2b28;
  --accent: #ff6a33;
  --accent-ink: #120a06;
  --accent-soft: #3a1d10;
  --ok: #3ccf7f;
  --danger: #ff6b5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }

.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.nav a { padding: 7px 16px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--muted); }
.nav a:hover { color: var(--text); }
.nav a.active { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--text); }
.nav-form { margin: 0; display: flex; }
.nav-form button { padding: 7px 16px; border: 0; border-radius: var(--radius-sm); background: transparent; font: inherit; font-weight: 600; font-size: 0.95rem; color: var(--muted); cursor: pointer; }
.nav-form button:hover { color: var(--text); }

.page { max-width: 1240px; margin: 0 auto; padding: 20px 24px 48px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.button:hover { opacity: 0.88; }
.button:active { transform: scale(0.98); }
.button-wide { width: 100%; padding: 15px 20px; font-size: 1.02rem; background: var(--accent); color: var(--accent-ink); }
.button-ghost, .button-secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.button-danger { background: transparent; color: var(--danger); padding-left: 0; }
.button-danger:hover { text-decoration: underline; }

.eyebrow { margin: 0 0 12px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.display { font-family: var(--display); font-weight: 700; font-size: clamp(1.7rem, 3.2vw, 2.4rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 16px; }
h1 { font-family: var(--display); font-weight: 700; font-size: 1.8rem; letter-spacing: -0.03em; margin: 0 0 8px; }
h2 { font-family: var(--display); font-weight: 500; font-size: 1.2rem; letter-spacing: -0.02em; margin: 0 0 14px; }
h3 { font-weight: 700; font-size: 1rem; margin: 18px 0 10px; }

.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
  margin-bottom: 28px;
}
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.tile-hero { grid-column: 1 / -1; grid-row: auto; display: flex; flex-direction: column; gap: 12px; }
.tile-hero .display { margin-bottom: 4px; }
.tile-steps { grid-column: 1 / -1; grid-row: auto; }
.tile-accent { grid-column: 3 / 5; grid-row: 1; background: var(--accent); color: var(--accent-ink); border-color: transparent; display: flex; flex-direction: column; justify-content: space-between; }
.tile-plain { grid-column: 3 / 5; grid-row: 2; display: flex; flex-direction: column; justify-content: space-between; }
.tile p { margin: 0; }
.big { font-family: var(--display); font-weight: 700; font-size: 2.6rem; letter-spacing: -0.04em; line-height: 1; }
.tile-accent p { font-weight: 600; }
.tile-plain p { color: var(--muted); }

.dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 22%, transparent); margin-right: 8px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.steps li { font-weight: 600; }
.steps b { display: block; font-family: var(--display); font-weight: 500; color: var(--accent); margin-bottom: 6px; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone.pasted { background: var(--accent-soft); border-color: var(--accent); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-title { font-weight: 700; font-size: 1.05rem; }
.dropzone-hint { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.upload-actions { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: 12px; align-items: stretch; }
.mode-dropdown { position: relative; min-width: 0; }
.mode-select, .mode-dropdown-toggle { width: 100%; min-width: 0; height: 64px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.mode-select { padding: 10px 14px; text-overflow: ellipsis; }
.mode-select:hover, .mode-dropdown-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.mode-select:focus, .mode-dropdown-toggle:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-dropdown-toggle { padding: 10px 16px 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.mode-dropdown-toggle[hidden] { display: none; }
.mode-dropdown-toggle > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-dropdown-toggle > svg { flex: none; width: 16px; height: 16px; color: var(--accent); transition: transform 0.15s; }
.mode-dropdown-toggle[aria-expanded="true"] > svg { transform: rotate(180deg); }
.mode-dropdown-menu { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: max-content; min-width: 260px; max-width: calc(100vw - 32px); padding: 6px; gap: 4px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18); transform-origin: top right; }
.mode-dropdown-menu[hidden] { display: none; }
.mode-dropdown-menu:not([hidden]) { display: grid; animation: mode-menu-in 0.16s ease-out; }
.mode-dropdown-option { width: 100%; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mode-dropdown-option:hover, .mode-dropdown-option:focus-visible { background: var(--surface-2); outline: none; }
.mode-dropdown-option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.mode-option-copy { display: flex; flex-direction: column; gap: 2px; }
.mode-option-title { font-weight: 700; font-size: 0.9rem; }
.mode-option-hint { color: var(--muted); font-size: 0.76rem; }
.mode-option-check { flex: none; color: var(--accent); font-weight: 700; visibility: hidden; }
.mode-dropdown-option[aria-selected="true"] .mode-option-check { visibility: visible; }
@keyframes mode-menu-in { from { opacity: 0; transform: translateY(-5px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.upload-actions .button { min-height: 64px; }
@media (max-width: 720px) {
  .upload-actions { gap: 8px; }
  .mode-select, .mode-dropdown-toggle { font-size: 0.78rem; }
  .mode-dropdown-toggle { padding: 8px 11px 8px 12px; }
  .mode-dropdown-toggle > svg { width: 14px; height: 14px; }
}

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-title { font-family: var(--display); font-weight: 700; font-size: 1.5rem; letter-spacing: -0.03em; margin: 0; }
.link-more { font-weight: 600; color: var(--muted); text-decoration: none; }
.link-more:hover { color: var(--text); }

.scene-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.scene-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; }
.scene-card:hover { border-color: var(--muted); }
.scene-thumb { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.scene-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-card-body { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px; }
.card.empty { text-align: center; padding: 48px; color: var(--muted); }

.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; margin: 0; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.message { padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; margin-bottom: 8px; }
.message-success { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }
.message-warning { color: #b7791f; }
.message-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }

.scene-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge { padding: 4px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.badge-saved { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }

.scene-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; margin-top: 16px; }
.scene-side { background: var(--surface-2); border-radius: var(--radius-sm); padding: 18px; }
.scene-figure { position: relative; margin: 0; line-height: 0; }
.scene-figure img { width: 100%; height: auto; border-radius: var(--radius-sm); }

.box { position: absolute; border: 2.5px solid var(--box-color); border-radius: 6px; }
.box-label {
  position: absolute;
  left: -2.5px;
  bottom: 100%;
  padding: 2px 7px;
  background: var(--box-color);
  color: #111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  border-radius: 6px 6px 6px 0;
}

.save-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.save-form label { font-weight: 600; font-size: 0.9rem; }
input[type=text], input[type=number], input[type=password], input[type=email], select, .save-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.counts td { padding: 8px 2px; }
.counts .total td, .fruits .total td { font-weight: 700; border-bottom: 0; }
.count-name { display: flex; align-items: center; }
.counts tr.zero td { color: var(--muted); }
.counts tr.zero .dot { opacity: 0.4; }
.table-scroll { overflow-x: auto; }

.mass-input { width: 96px; padding: 7px 10px; }
.hint { display: block; color: var(--muted); font-size: 0.76rem; margin-top: 2px; }

.nutrition-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 14px; }
.nutrition-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.reference { list-style: none; margin: 16px 0 8px; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.reference b { color: var(--text); font-weight: 600; }
.mass-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.unsaved { font-size: 0.88rem; color: var(--accent); font-weight: 600; }
.hint[hidden], .unsaved[hidden] { display: none; }

.history-scene { display: flex; align-items: center; gap: 12px; font-weight: 600; text-decoration: none; }
.history-thumb { width: 56px; height: 42px; border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-2); }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.history input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

.footer { border-top: 1px solid var(--line); }
.footer-inner { max-width: 1240px; margin: 0 auto; padding: 20px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: 0.85rem; color: var(--muted); }

@media (max-width: 1000px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-hero, .tile-steps { grid-column: 1 / -1; grid-row: auto; }
  .tile-accent, .tile-plain { grid-column: auto; grid-row: auto; }
  .scene-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .scene-layout { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 20px 16px 48px; }
  .topbar-inner { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .bento { grid-template-columns: 1fr; }
  .tile-hero, .tile-steps, .tile-accent, .tile-plain { grid-column: auto; }
  .scene-grid { grid-template-columns: 1fr; }
}
.nutrition td:first-child, .fruits td:nth-child(2) { white-space: nowrap; }

.iiks { color: var(--text); line-height: 0; flex: none; text-decoration: none; }
.iiks-logo { display: block; height: 92px; width: auto; }
.iiks-small .iiks-logo { height: 48px; }
.footer-brand { display: inline-flex; align-items: center; gap: 10px; }

.detects { margin: 0 0 32px; padding: 0; }
.detects-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 24px; font-size: 1.05rem; font-weight: 500; }
.detects-list li { padding: 6px 0; }
@media (max-width: 720px) {
  .detects-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .detects-list { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .iiks-logo { height: 72px; }
}

.header-right { display: flex; align-items: center; gap: 10px; }
.wordmark { display: block; flex: 1; min-width: 0; color: var(--accent); text-decoration: none; line-height: 0; }
.wordmark svg { display: block; width: 100%; height: auto; max-height: 96px; }
.wordmark text { font-family: var(--display); font-weight: 700; font-size: 150px; fill: currentColor; }
.logo-group { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; margin-right: 24px; }
.theme-toggle { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
@media (max-width: 520px) {
  .nav a { padding: 7px 11px; }
}


.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.info-btn { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.15s; }
.info-btn svg { width: 22px; height: 22px; }
.info-btn:hover { background: var(--accent); color: var(--accent-ink); transform: scale(1.06); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scene-header .info-btn { margin-left: auto; }

.info-dialog { width: min(600px, 100vw - 32px); max-width: none; max-height: min(88dvh, 920px); margin: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); overflow: auto; overscroll-behavior: contain; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28); }
.info-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.info-dialog[open] { display: block; animation: info-in 0.18s ease-out; }
.info-body { padding: 26px 28px 24px; font-size: 1rem; }
.info-body h2 { font-family: var(--display); font-weight: 700; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.03em; margin: 0 52px 16px 0; }
.info-body p { margin: 0 0 14px; }
.info-body .reference { font-size: 1rem; margin: 18px 0; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 600; word-break: break-word; }
.info-close { position: absolute; z-index: 1; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.info-close:hover { border-color: var(--accent); color: var(--accent); }
@keyframes info-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }

.auth-card { max-width: 440px; margin: 24px auto; padding: 32px; }
.auth-card h1 { margin-bottom: 20px; }
.auth-card form p { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; font-weight: 600; font-size: 0.92rem; }
.auth-card input { width: 100%; }
.auth-card .helptext, .auth-card ul { font-weight: 400; font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; padding-left: 18px; }
.auth-card .errorlist { color: var(--danger); font-weight: 600; list-style: none; padding: 0; margin: 0 0 10px; }
.auth-card .button-wide { margin-top: 6px; }
.auth-card > p { margin: 16px 0 0; text-align: center; }
.auth-card > p a { color: var(--accent); font-weight: 600; }

.fruit-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fruit-list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; font-family: var(--display); font-weight: 500; font-size: 1.1rem; letter-spacing: -0.02em; }
.fruit-list a:hover { border-color: var(--accent); }
.fruit-row-note { font-family: var(--body); font-size: 0.9rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.fruit-list a:hover .fruit-row-note { color: var(--accent); }

.page-title { font-family: var(--display); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -0.03em; margin: 0 0 10px; }
.page-intro { color: var(--muted); font-size: 1.1rem; margin: 0 0 24px; max-width: 720px; }
.reading-page { max-width: 820px; margin: 0 auto; }
.prose p, .prose li { line-height: 1.6; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--accent); }
.fruit-photo { margin: 8px 0 18px; max-width: 520px; }
.fruit-photo img { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--surface-2); }
.fruit-photo figcaption { margin-top: 6px; font-size: 0.82rem; }
.nutrition-facts { max-width: 520px; margin: 8px 0 12px; padding: 0; }
.nutrition-facts div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.nutrition-facts dt { color: var(--muted); }
.nutrition-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.info-body .fruit-photo { max-width: none; margin: 0 0 14px; }
.info-body .fruit-photo img { width: 100%; height: auto; max-height: 38dvh; object-fit: contain; background: #fff; }
.fruit-basis, .data-source { color: var(--muted); font-size: 0.9rem; }
.stat-totals { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 20px; }
.stat-totals > * { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 18px; }
.statistics-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

@media (max-width: 1000px) { .fruit-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .fruit-list { grid-template-columns: 1fr; } }

@font-face { font-family: "Cakra"; src: url("fonts/cakra-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
:root { --accent-font: "Cakra", "Unbounded", sans-serif; }
.display, .page-title, .section-title, .card h1, .card h2, .info-body h2, .fruit-list a > span:first-child, .steps b {
  font-family: var(--accent-font);
  font-weight: 400;
  letter-spacing: 0;
}

.export-bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin: 14px 0; }
.export-bar .mode-dropdown { min-width: 150px; }
.export-format { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.export-hint { flex-basis: 100%; margin: 2px 0 0; font-size: 0.88rem; }
.history .select-all { width: 18px; height: 18px; accent-color: var(--accent); }
.reanalyze-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.reanalyze-label { font-weight: 600; font-size: 0.9rem; }
.reanalyze-form .mode-select, .reanalyze-form .mode-dropdown-toggle { height: 48px; }
.reanalyze-form .mode-dropdown-menu { left: 0; right: auto; width: 100%; min-width: 0; transform-origin: top left; }
.reanalyze-form .button-wide { min-height: 56px; font-size: 1.08rem; }
.button[disabled] { cursor: progress; opacity: 0.85; }
.button .spinner { display: inline-block; width: 1em; height: 1em; margin-right: 10px; vertical-align: -0.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.is-busy { position: relative; }
.is-busy::after { content: ""; position: absolute; inset: 0; z-index: 5; border-radius: var(--radius-sm); background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--accent) 28%, transparent) 50%, transparent 70%) 0 0 / 250% 100%, color-mix(in srgb, var(--bg, #000) 35%, transparent); animation: scan 1.2s linear infinite; pointer-events: none; }
@keyframes scan { from { background-position: 125% 0, 0 0; } to { background-position: -125% 0, 0 0; } }
.reanalyze-form + .button, .reanalyze-form + .actions { margin-top: 14px; }
.nav a.nav-cta { background: var(--accent); color: var(--accent-ink); }
.nav a.nav-cta:hover { color: var(--accent-ink); opacity: 0.88; }
.box { cursor: pointer; transition: opacity 0.15s, border-width 0.15s, box-shadow 0.15s; }
.scene-figure.has-selection .box:not(.selected) { opacity: 0.3; }
.box.selected { z-index: 2; border-width: 4px; backdrop-filter: brightness(1.43); box-shadow: 0 0 0 2px #fff, 0 0 18px 2px var(--box-color); }
.scene-figure img { transition: filter 0.15s; }
.scene-figure.has-selection img { filter: brightness(0.7); }
.box.selected .box-label { left: -4px; font-size: 14px; }
.fruit-row { cursor: pointer; transition: background 0.15s; }
.fruit-row:hover { background: var(--surface-2); }
.fruit-row.selected { background: var(--accent-soft); }
.fruit-row.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.fruit-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav a.nav-cta.active { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 2px var(--text); }
.info-body .nutrition-facts { max-width: none; }
.mode-toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.15; }
.mode-caption { font-size: 0.68rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.mode-toggle-text [data-mode-label] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle { display: none; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle .nav-toggle-close { display: none; }
.topbar.nav-open .nav-toggle .nav-toggle-open { display: none; }
.topbar.nav-open .nav-toggle .nav-toggle-close { display: inline; }

@media (max-width: 720px) {
  .topbar-inner { position: relative; flex-wrap: nowrap; gap: 10px; padding: 10px 16px; }
  .logo-group { flex: 1; min-width: 0; gap: 10px; margin-right: 0; }
  .iiks-logo { height: 48px; }
  .wordmark svg { max-height: 40px; }
  .header-right { flex: none; gap: 8px; }
  .nav-toggle { display: grid; }
  .nav { display: none; position: absolute; top: calc(100% + 1px); left: 0; right: 0; flex-direction: column; gap: 2px; padding: 8px 12px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--bg); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12); }
  .topbar.nav-open .nav { display: flex; }
  .nav a, .nav-form button { width: 100%; padding: 13px 14px; font-size: 1.02rem; text-align: left; }
  .nav-form { display: block; }

  .upload-actions { grid-template-columns: 1fr; }
  .upload-actions .mode-dropdown { order: -1; }
  .mode-select, .mode-dropdown-toggle { height: 54px; font-size: 0.95rem; }
  .mode-dropdown-toggle { padding: 8px 16px; }
  .mode-dropdown-menu { left: 0; right: 0; width: auto; min-width: 0; transform-origin: top center; }
  .upload-actions .button { min-height: 56px; }

  .box-label { font-size: 10px; padding: 1px 4px; }
  .box.selected .box-label { font-size: 11px; }
  .card { padding: 16px 14px; }
  .scene-side { padding: 14px; }
  .info-body { padding: 20px 18px 18px; }
  .info-dialog { width: calc(100vw - 20px); max-height: 90dvh; }
}

@media (max-width: 720px) {
  .fruits thead, .nutrition thead { display: none; }
  .fruits, .nutrition, .fruits tbody, .nutrition tbody { display: block; width: 100%; }
  .fruits tr, .nutrition tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 10px; padding: 12px 10px; border-bottom: 1px solid var(--line); }
  .fruits td, .nutrition td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
  .fruits td[data-title]::before, .nutrition td[data-title]::before { content: attr(data-title); display: block; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .fruits td:nth-child(1) { grid-column: 1; font-weight: 700; align-self: center; }
  .fruits td:nth-child(2) { grid-column: 2 / 3; align-self: center; font-weight: 600; white-space: nowrap; }
  .fruits td:nth-child(3) { grid-column: 3 / 5; text-align: right; }
  .fruits td:nth-child(3)::before { text-align: right; }
  .fruits .mass-cell { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .fruits .mass-cell::before { flex-basis: 100%; }
  .fruits .mass-cell .mass-input { flex: 1; max-width: 180px; height: 44px; font-size: 1rem; }
  .fruits .total td.empty-cell { display: none; }
  .fruits .total td:nth-child(2) { grid-column: 1 / 3; }
  .fruits .total .total-mass { grid-column: 3 / 5; text-align: right; font-weight: 700; }
  .fruits tr.selected td:first-child { box-shadow: none; }
  .fruits tr.selected { box-shadow: inset 3px 0 0 var(--accent); }
  .nutrition td:nth-child(1) { grid-column: 1 / 3; align-self: center; font-weight: 600; white-space: nowrap; }
  .nutrition td:nth-child(2) { grid-column: 3; }
  .nutrition td:nth-child(3) { grid-column: 4; }
  .nutrition .total td { font-weight: 700; }
}

@media (max-width: 720px) {
  h1, .section-title, .page-title { font-size: 1.45rem; overflow-wrap: anywhere; }
  .history thead tr { display: flex; align-items: center; gap: 10px; padding: 0 4px 10px; }
  .history thead th { display: none; padding: 0; border: 0; }
  .history thead th:first-child { display: block; }
  .history thead th:first-child::after { content: "Выбрать все"; margin-left: 10px; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; vertical-align: 3px; }
  .history, .history tbody { display: block; width: 100%; }
  .history thead { display: block; }
  .history tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 4px 12px 40px; border-top: 1px solid var(--line); }
  .history td { display: block; padding: 0; border: 0; }
  .history .history-pick { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); }
  .history .history-name { flex: 1 1 62%; min-width: 0; }
  .history .history-date { flex: none; font-size: 0.8rem; text-align: right; white-space: nowrap; }
  .history .history-count, .history .history-total { display: inline-flex; gap: 4px; font-size: 0.85rem; }
  .history .history-count.zero { display: none; }
  .history .history-count::before, .history .history-total::before { content: attr(data-title); color: var(--muted); }
  .history .history-count:nth-child(4) { margin-left: 0; }
  .history .history-date + td { margin-left: 0; }
  .export-bar { flex-direction: column; }
  .export-bar > *, .export-bar .button { width: 100%; }
}
.stat-totals dt { font-size: 0.85rem; color: var(--muted); }
.stat-totals dd { margin: 4px 0 0; font-family: var(--display); font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.statistics-table tbody th { text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 500; color: var(--text); }
@media (max-width: 720px) {
  .stat-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-totals > * { padding: 12px 14px; }
}
