:root {
  color-scheme: light;
  --brand-900: #052f3d;
  --brand-800: #073b4c;
  --brand-700: #0b5368;
  --brand-600: #0f6f82;
  --brand-100: #dceff3;
  --accent-500: #f4c95d;
  --accent-100: #fff5d6;
  --ink-950: #091c2a;
  --ink-900: #102a43;
  --ink-700: #334e68;
  --ink-600: #486581;
  --ink-500: #627d98;
  --surface-0: #ffffff;
  --surface-25: #fbfcfd;
  --surface-50: #f5f8fa;
  --surface-100: #eaf0f3;
  --surface-200: #d9e3e8;
  --border: #cbd8df;
  --success-700: #146c43;
  --success-100: #e6f6ed;
  --warning-800: #7a4e00;
  --warning-100: #fff3cf;
  --danger-700: #b42318;
  --danger-100: #fdecea;
  --info-700: #175cd3;
  --info-100: #eaf2ff;
  --focus: #005fcc;
  --shadow-sm: 0 1px 2px rgb(16 42 67 / 0.08), 0 4px 12px rgb(16 42 67 / 0.05);
  --shadow-md: 0 12px 32px rgb(16 42 67 / 0.12);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --control: 52px;
  --content: 1180px;
  --reading: 760px;
  --topbar-h: 76px;
  --nav-h: 76px;
  --body-size: 18px;
  --body-line: 1.55;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink-950: #f7fbfc;
  --ink-900: #eef6f8;
  --ink-700: #c3d3da;
  --ink-600: #aac0ca;
  --ink-500: #8ea9b5;
  --surface-0: #101b22;
  --surface-25: #122129;
  --surface-50: #162731;
  --surface-100: #20343e;
  --surface-200: #304852;
  --border: #3d5661;
  --brand-100: #153e49;
  --accent-100: #4a3b12;
  --success-100: #153b29;
  --warning-100: #493811;
  --danger-100: #491e1b;
  --info-100: #172e55;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .25), 0 5px 16px rgb(0 0 0 / .18);
  --shadow-md: 0 16px 36px rgb(0 0 0 / .32);
}

html[data-contrast="high"] {
  --border: currentColor;
  --shadow-sm: none;
  --shadow-md: none;
}

html[data-size="large"] { --body-size: 21px; --body-line: 1.6; }
html[data-size="extra"] { --body-size: 24px; --body-line: 1.65; }

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface-50); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--surface-50);
  color: var(--ink-900);
  font-size: var(--body-size);
  line-height: var(--body-line);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img, svg, video { display: block; max-width: 100%; }
svg { width: 1.35em; height: 1.35em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
a { color: var(--brand-700); }
p { margin: 0 0 .9rem; }
h1, h2, h3 { margin: 0; color: var(--ink-950); line-height: 1.16; text-wrap: balance; }
h1 { font-size: clamp(2rem, 4vw, 3.35rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.35rem, 2vw, 1.75rem); letter-spacing: -.02em; }
h3 { font-size: 1.15rem; }
strong { color: var(--ink-950); }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--accent-500); color: #17202a; }

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

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 16px;
  top: -80px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink-950);
  color: var(--surface-0);
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { top: 14px; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-0) 94%, transparent);
  backdrop-filter: blur(16px);
}
.topbar__inner {
  width: min(100%, calc(var(--content) + 40px));
  min-height: var(--topbar-h);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-button {
  min-height: 56px;
  padding: 5px 10px 5px 4px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}
.brand-button:hover { background: var(--surface-100); }
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--brand-800);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12);
}
.brand-mark svg { width: 34px; height: 34px; stroke-width: 2; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 1.15rem; line-height: 1.15; }
.brand-copy > span { color: var(--ink-600); font-size: .82rem; line-height: 1.2; }
.topbar__status { display: flex; align-items: center; gap: 10px; }
.status-pill, .icon-button {
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  border-radius: 999px;
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.status-pill {
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
  white-space: nowrap;
}
.icon-button { width: 48px; padding: 0; display: grid; place-items: center; }
.status-pill:hover, .icon-button:hover { border-color: var(--brand-600); background: var(--brand-100); }
.icon-button:disabled, button:disabled { opacity: .48; cursor: not-allowed; }

.main-content {
  min-height: calc(100vh - var(--topbar-h));
  padding: 38px 20px calc(var(--nav-h) + 54px + env(safe-area-inset-bottom));
}
.main-content:focus { outline: none; }
.page { width: min(100%, var(--content)); margin: 0 auto; }
.page > * + * { margin-top: 24px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-700);
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}
.page-header__copy { max-width: var(--reading); }
.page-header__copy h1 { margin-bottom: 12px; }
.page-header__copy > p:last-child, .hero__copy > p { color: var(--ink-700); max-width: 68ch; }
.back-button {
  min-height: 48px;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-0);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}
.back-button:hover { background: var(--surface-100); }

.hero {
  padding: clamp(26px, 5vw, 54px);
  border: 1px solid color-mix(in srgb, var(--brand-600) 28%, var(--border));
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 92% 15%, color-mix(in srgb, var(--accent-500) 24%, transparent) 0 12%, transparent 13%),
    linear-gradient(135deg, var(--surface-0), color-mix(in srgb, var(--brand-100) 52%, var(--surface-0)));
  box-shadow: var(--shadow-sm);
}
.hero__copy { max-width: 800px; }
.hero__copy h1 { margin-bottom: 14px; }
.hero__copy > p { font-size: 1.08em; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }

.badge, .meta-pill {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-0);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-700);
  font-size: .82rem;
  font-weight: 750;
  line-height: 1.2;
}
.badge--brand { border-color: color-mix(in srgb, var(--brand-600) 45%, var(--border)); background: var(--brand-100); color: var(--brand-900); }
.badge--success { border-color: color-mix(in srgb, var(--success-700) 35%, var(--border)); background: var(--success-100); color: var(--success-700); }
.badge--warning { border-color: color-mix(in srgb, var(--warning-800) 35%, var(--border)); background: var(--warning-100); color: var(--warning-800); }
.badge--info { border-color: color-mix(in srgb, var(--info-700) 35%, var(--border)); background: var(--info-100); color: var(--info-700); }

.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.action-tile {
  min-height: 172px;
  padding: 28px;
  border: 2px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--brand-800);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  text-align: left;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.action-tile:hover { transform: translateY(-2px); background: var(--brand-700); }
.action-tile:active { transform: translateY(0); }
.action-tile--secondary { background: var(--surface-0); color: var(--ink-950); border-color: var(--border); box-shadow: var(--shadow-sm); }
.action-tile--secondary:hover { background: var(--surface-100); border-color: var(--brand-600); }
.action-tile__icon {
  width: 82px;
  height: 82px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgb(255 255 255 / .14);
}
.action-tile--secondary .action-tile__icon { background: var(--brand-100); color: var(--brand-800); }
.action-tile__icon svg { width: 44px; height: 44px; stroke-width: 1.9; }
.action-tile strong { display: block; color: inherit; font-size: clamp(1.35rem, 2vw, 1.75rem); line-height: 1.15; margin-bottom: 8px; }
.action-tile small { display: block; color: inherit; opacity: .84; font-size: .92rem; line-height: 1.4; }
.secondary-action {
  width: 100%;
  min-height: 76px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.secondary-action:hover { border-color: var(--brand-600); background: var(--brand-100); }
.secondary-action__main { display: flex; align-items: center; gap: 14px; }
.secondary-action__main > span:first-child { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-100); color: var(--brand-800); }
.secondary-action strong { display: block; font-size: 1.05rem; }
.secondary-action small { display: block; color: var(--ink-600); margin-top: 2px; font-size: .84rem; }

.panel, .setting-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.panel--tinted { background: color-mix(in srgb, var(--brand-100) 32%, var(--surface-0)); }
.panel--warning { background: color-mix(in srgb, var(--warning-100) 55%, var(--surface-0)); border-color: color-mix(in srgb, var(--warning-800) 30%, var(--border)); }
.panel__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel__header h2 { margin-bottom: 6px; }
.panel__header p { margin: 0; color: var(--ink-600); }

.btn {
  min-height: var(--control);
  padding: 10px 18px;
  border: 2px solid var(--brand-800);
  border-radius: var(--radius-sm);
  background: var(--brand-800);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}
.btn:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn--secondary { background: var(--surface-0); color: var(--brand-800); border-color: var(--border); }
.btn--secondary:hover { background: var(--brand-100); border-color: var(--brand-600); }
.btn--ghost { background: transparent; color: var(--ink-700); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-100); border-color: var(--surface-100); }
.btn--danger { background: var(--danger-700); border-color: var(--danger-700); color: #fff; }
.btn--danger:hover { background: #8f1c13; border-color: #8f1c13; }
.btn--large { min-height: 62px; padding-inline: 24px; font-size: 1.02rem; }
.btn--compact { min-height: 44px; padding: 8px 12px; font-size: .87rem; }
.btn--full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.button-row--end { justify-content: flex-end; }

.notice {
  min-height: 54px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-50);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--ink-700);
}
.notice > svg { margin-top: 2px; }
.notice p { margin: 0; }
.notice--warning { background: var(--warning-100); border-color: color-mix(in srgb, var(--warning-800) 32%, var(--border)); color: var(--warning-800); }
.notice--success { background: var(--success-100); border-color: color-mix(in srgb, var(--success-700) 32%, var(--border)); color: var(--success-700); }
.notice--danger { background: var(--danger-100); border-color: color-mix(in srgb, var(--danger-700) 32%, var(--border)); color: var(--danger-700); }

.field { display: grid; gap: 7px; }
.field + .field { margin-top: 17px; }
.field label { color: var(--ink-950); font-weight: 800; }
.field__hint { color: var(--ink-600); font-size: .82rem; line-height: 1.45; }
.input, .textarea, .select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-0);
  color: var(--ink-950);
  padding: 12px 14px;
  box-shadow: inset 0 1px 2px rgb(16 42 67 / .05);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-500); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--focus); }
.error-text { color: var(--danger-700); font-weight: 750; }

.setting-row {
  min-height: 72px;
  padding: 13px 0;
  border-top: 1px solid var(--surface-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.setting-row > div { min-width: 0; }
.setting-row strong { display: block; }
.setting-row small { display: block; color: var(--ink-600); margin-top: 3px; font-size: .82rem; line-height: 1.35; }
.switch { position: relative; width: 58px; min-width: 58px; height: 34px; display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch > span[aria-hidden="true"] { position: absolute; inset: 0; border: 2px solid var(--ink-500); border-radius: 999px; background: var(--surface-100); transition: .18s ease; }
.switch > span[aria-hidden="true"]::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: var(--ink-600); transition: transform .18s ease, background .18s ease; }
.switch input:checked + span[aria-hidden="true"] { border-color: var(--brand-700); background: var(--brand-700); }
.switch input:checked + span[aria-hidden="true"]::after { transform: translateX(24px); background: #fff; }
.switch input:focus-visible + span[aria-hidden="true"] { outline: 3px solid var(--focus); outline-offset: 3px; }

.bottom-nav {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 760px);
  min-height: var(--nav-h);
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface-0) 96%, transparent);
  box-shadow: 0 12px 36px rgb(16 42 67 / .18);
  backdrop-filter: blur(18px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.bottom-nav__item {
  min-width: 0;
  min-height: 60px;
  padding: 7px 5px;
  border-radius: 17px;
  color: var(--ink-600);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  font-size: .73rem;
  font-weight: 750;
  line-height: 1.1;
  text-align: center;
}
.bottom-nav__item svg { width: 24px; height: 24px; }
.bottom-nav__item:hover { background: var(--surface-100); color: var(--brand-800); }
.bottom-nav__item[aria-current="page"] { background: var(--brand-100); color: var(--brand-800); }

/* Camera and image selection */
.camera-shell { max-width: 920px; }
.camera-frame { position: relative; overflow: hidden; width: min(100%, 720px); margin: 0 auto; aspect-ratio: 4 / 3; border-radius: var(--radius-xl); background: #061014; box-shadow: var(--shadow-md); }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.camera-guide { position: absolute; inset: 8%; border: 3px solid rgb(255 255 255 / .9); border-radius: 22px; box-shadow: 0 0 0 999px rgb(0 0 0 / .18); pointer-events: none; }
.camera-toolbar { width: min(100%, 430px); margin: 18px auto 0; display: grid; grid-template-columns: 56px 92px 56px; justify-content: center; align-items: center; gap: 24px; }
.camera-toolbar .icon-button { width: 56px; height: 56px; background: var(--surface-0); }
.capture-button { width: 92px; height: 92px; padding: 0; border: 6px solid var(--surface-0); border-radius: 50%; background: var(--brand-800); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--brand-800), var(--shadow-md); cursor: pointer; }
.capture-button svg { width: 42px; height: 42px; }
.capture-button:hover { background: var(--brand-600); }
.camera-note { color: var(--ink-600); font-size: .84rem; text-align: center; margin: 12px 0 0; }
.preview-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 22px; align-items: start; }
.crop-stage { position: relative; min-height: 320px; max-height: 72vh; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #0b151a; display: grid; place-items: center; touch-action: none; user-select: none; }
.crop-stage img { width: 100%; height: 100%; max-height: 72vh; object-fit: contain; }
.crop-selection { position: absolute; border: 3px solid var(--accent-500); background: rgb(244 201 93 / .12); box-shadow: 0 0 0 9999px rgb(0 0 0 / .36); pointer-events: none; border-radius: 8px; }
.crop-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.crop-presets button { min-height: 48px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-50); font-weight: 750; cursor: pointer; }
.crop-presets button:hover { border-color: var(--brand-600); background: var(--brand-100); }
.processing { max-width: 620px; min-height: 58vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.processing__mark { width: 104px; height: 104px; margin-bottom: 22px; border-radius: 30px; background: var(--brand-100); color: var(--brand-800); display: grid; place-items: center; }
.processing__mark svg { width: 54px; height: 54px; }
.processing > p { color: var(--ink-700); max-width: 48ch; }
.progress-track { width: min(100%, 420px); height: 12px; margin-top: 18px; border-radius: 999px; overflow: hidden; background: var(--surface-200); }
.progress-track span { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--brand-700); animation: progress-shuttle 1.35s ease-in-out infinite alternate; }
@keyframes progress-shuttle { from { transform: translateX(-8%); } to { transform: translateX(145%); } }
.ocr-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card { min-height: 112px; padding: 17px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-0); display: grid; gap: 4px; align-content: center; box-shadow: var(--shadow-sm); }
.stat-card span { color: var(--ink-600); font-size: .8rem; font-weight: 700; }
.stat-card strong { font-size: 1.15rem; }
.ocr-blocks { display: grid; gap: 14px; }
.ocr-block { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-50); display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.ocr-block__check { width: 28px; height: 28px; margin: 10px 0 0 3px; accent-color: var(--brand-700); }
.result-toolbar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 40; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface-0) 96%, transparent); backdrop-filter: blur(14px); display: flex; justify-content: space-between; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); }
.result-toolbar__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.segmented { min-height: 46px; padding: 4px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-100); display: inline-grid; grid-auto-flow: column; gap: 3px; }
.segmented button { min-height: 38px; padding: 6px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-600); font-weight: 800; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface-0); color: var(--brand-800); box-shadow: var(--shadow-sm); }
.text-versions { margin-bottom: 20px; }
.text-version { padding: 17px 18px; border-radius: var(--radius-md); background: var(--surface-0); border: 1px solid var(--border); }
.text-version p { margin: 12px 0 0; font-size: 1.05em; line-height: 1.65; white-space: pre-wrap; }
.transform-button { min-height: 44px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-0); color: var(--brand-800); display: inline-flex; align-items: center; gap: 7px; font-weight: 800; cursor: pointer; }
.transform-button:hover { border-color: var(--brand-600); background: var(--brand-100); }
.pictogram-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; justify-content: start; }
.pictogram-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-0); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.pictogram-card--doubtful { border: 2px solid color-mix(in srgb, var(--warning-800) 55%, var(--border)); }
.pictogram-card--unmatched { background: color-mix(in srgb, var(--warning-100) 26%, var(--surface-0)); }
.pictogram-card__visual { width: 100%; min-height: 185px; aspect-ratio: 1.18 / 1; padding: 18px; border: 0; border-bottom: 1px solid var(--surface-200); background: var(--surface-25); display: grid; place-items: center; cursor: pointer; }
.pictogram-card__visual:hover { background: var(--brand-100); }
.pictogram-card__visual img { width: 100%; height: 100%; max-width: 190px; max-height: 190px; object-fit: contain; }
.pictogram-card__body { padding: 14px 14px 10px; text-align: center; }
.pictogram-card__label { margin: 0; color: var(--ink-950); font-size: 1.12em; font-weight: 850; line-height: 1.25; overflow-wrap: anywhere; }
.pictogram-card__status { min-height: 24px; margin-top: 7px; color: var(--warning-800); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .78rem; font-weight: 750; }
.pictogram-card__actions { margin-top: auto; padding: 10px; border-top: 1px solid var(--surface-200); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.card-action { min-height: 48px; padding: 7px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-0); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-700); font-size: .7rem; font-weight: 800; cursor: pointer; }
.card-action svg { width: 20px; height: 20px; }
.card-action:hover { border-color: var(--brand-600); background: var(--brand-100); color: var(--brand-800); }
.card-reorder { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.card-reorder button { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-50); display: grid; place-items: center; cursor: pointer; }
.card-reorder button:hover { background: var(--surface-100); }
.exact-value { max-width: 100%; padding: 18px 12px; border: 2px solid var(--brand-600); border-radius: var(--radius-md); background: var(--brand-100); color: var(--brand-900); font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; line-height: 1.1; overflow-wrap: anywhere; }
.text-fallback { min-height: 120px; width: 100%; padding: 14px; border: 2px dashed var(--warning-800); border-radius: var(--radius-md); background: var(--warning-100); color: var(--warning-800); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.text-fallback svg { width: 34px; height: 34px; }
.text-fallback strong { color: inherit; overflow-wrap: anywhere; }

/* Dialogs and alternatives */
.app-dialog { width: min(calc(100% - 28px), 760px); max-height: min(88vh, 900px); padding: 0; border: 1px solid var(--border); border-radius: 24px; background: var(--surface-0); color: var(--ink-900); box-shadow: var(--shadow-md); }
.app-dialog::backdrop { background: rgb(5 23 31 / .62); backdrop-filter: blur(3px); }
.dialog-shell { max-height: inherit; display: flex; flex-direction: column; }
.dialog-header { min-height: 72px; padding: 12px 16px 12px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-header h2 { font-size: 1.35rem; }
.dialog-content { padding: 22px; overflow: auto; overscroll-behavior: contain; }
.alternative-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.alternative-card { min-height: 178px; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-0); display: grid; grid-template-rows: 1fr auto; gap: 8px; place-items: center; text-align: center; font-weight: 750; cursor: pointer; }
.alternative-card:hover { border-color: var(--brand-600); background: var(--brand-100); }
.alternative-card img { width: 100%; height: 116px; object-fit: contain; }
.library-list { display: grid; gap: 14px; }
.library-item { padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-0); display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; box-shadow: var(--shadow-sm); }
.library-item h2 { font-size: 1.18rem; margin-bottom: 4px; }
.library-item p { color: var(--ink-600); margin: 0; font-size: .82rem; }
.library-item__preview { min-height: 44px; display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.library-item__preview img { width: 44px; height: 44px; padding: 3px; border: 1px solid var(--surface-200); border-radius: 9px; background: var(--surface-50); object-fit: contain; }
.library-item__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* Composer */
.composer-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .72fr); gap: 22px; align-items: start; }
.composer-controls { min-width: 0; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box > svg { position: absolute; left: 14px; z-index: 1; color: var(--ink-500); }
.search-box .input { padding-left: 46px; }
.category-list { display: flex; gap: 8px; overflow-x: auto; padding: 3px 3px 8px; scrollbar-width: thin; }
.category-chip { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-0); color: var(--ink-700); font-weight: 750; white-space: nowrap; cursor: pointer; }
.category-chip:hover { border-color: var(--brand-600); }
.category-chip[aria-pressed="true"] { border-color: var(--brand-700); background: var(--brand-100); color: var(--brand-900); }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.catalog-item { min-height: 168px; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-0); display: grid; grid-template-rows: 1fr auto; gap: 8px; place-items: center; text-align: center; color: var(--ink-900); font-weight: 800; cursor: pointer; box-shadow: var(--shadow-sm); }
.catalog-item:hover { border-color: var(--brand-600); background: var(--brand-100); transform: translateY(-1px); }
.catalog-item img { width: 100%; height: 116px; object-fit: contain; }
.catalog-item span { max-width: 100%; overflow-wrap: anywhere; line-height: 1.2; font-size: .86rem; }
.sentence-panel { position: sticky; top: calc(var(--topbar-h) + 18px); }
.sentence-text { min-height: 60px; padding: 14px; border-radius: var(--radius-md); background: var(--brand-100); color: var(--brand-900); font-size: 1.08rem; font-weight: 800; line-height: 1.45; }
.sentence-items { display: grid; gap: 10px; margin: 14px 0; max-height: 44vh; overflow: auto; }
.sentence-item { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-50); display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.sentence-item img { width: 62px; height: 62px; padding: 3px; border-radius: 10px; background: var(--surface-0); object-fit: contain; }
.sentence-item strong { min-width: 0; overflow-wrap: anywhere; }
.sentence-item__buttons { display: grid; grid-template-columns: repeat(2, 44px); gap: 5px; }
.sentence-item__buttons button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-0); display: grid; place-items: center; cursor: pointer; }
.sentence-item__buttons button:last-child { width: 94px; grid-column: 1 / -1; }
.sentence-item__buttons button:hover { background: var(--surface-100); }
.skeleton { min-height: 168px; background: linear-gradient(90deg, var(--surface-100), var(--surface-50), var(--surface-100)); background-size: 220% 100%; animation: skeleton 1.2s linear infinite; }
@keyframes skeleton { to { background-position: -220% 0; } }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.setting-group > h2 { margin-bottom: 7px; }
.setting-group > p { color: var(--ink-600); font-size: .88rem; }
.profile-options, .theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 14px 0 16px; }
.choice-card { min-height: 62px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-50); display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-700); font-weight: 800; cursor: pointer; }
.choice-card:hover { border-color: var(--brand-600); background: var(--brand-100); }
.choice-card[aria-pressed="true"] { border: 2px solid var(--brand-700); background: var(--brand-100); color: var(--brand-900); }

/* Information and admin */
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.definition-list { margin: 0; display: grid; }
.definition-list > div { padding: 13px 0; border-top: 1px solid var(--surface-200); display: grid; grid-template-columns: minmax(120px, .34fr) 1fr; gap: 16px; }
.definition-list > div:first-child { border-top: 0; }
.definition-list dt { font-weight: 850; color: var(--ink-950); }
.dashboard-hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 142px; padding: 17px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-0); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 5px 12px; align-content: center; box-shadow: var(--shadow-sm); }
.metric-card__icon { width: 46px; height: 46px; grid-row: 1 / 3; border-radius: 14px; background: var(--brand-100); color: var(--brand-800); display: grid; place-items: center; align-self: center; }
.metric-card strong { font-size: 1.65rem; line-height: 1; }
.metric-card span { color: var(--ink-600); font-size: .78rem; font-weight: 700; }
.admin-tabs { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.admin-tabs button { min-height: 46px; padding: 8px 13px; border: 0; border-radius: 11px 11px 0 0; background: transparent; color: var(--ink-600); font-weight: 800; white-space: nowrap; cursor: pointer; }
.admin-tabs button:hover { background: var(--surface-100); }
.admin-tabs button[aria-selected="true"] { background: var(--brand-100); color: var(--brand-900); box-shadow: inset 0 -3px 0 var(--brand-700); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; background: var(--surface-0); font-size: .84rem; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--surface-200); text-align: left; vertical-align: top; }
th { background: var(--surface-100); color: var(--ink-950); font-size: .75rem; letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }

/* Empty states and feedback */
.empty-state { min-height: 280px; padding: 38px 20px; border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-0); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state__icon { width: 72px; height: 72px; margin-bottom: 14px; border-radius: 22px; background: var(--brand-100); color: var(--brand-800); display: grid; place-items: center; }
.empty-state__icon svg { width: 36px; height: 36px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 50ch; color: var(--ink-600); }
.toast-region { position: fixed; z-index: 200; right: 18px; bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom)); width: min(calc(100% - 36px), 420px); display: grid; gap: 9px; pointer-events: none; }
.toast { padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--ink-950); color: var(--surface-0); box-shadow: var(--shadow-md); display: flex; align-items: flex-start; gap: 10px; font-weight: 700; }
.toast--error { background: var(--danger-700); color: #fff; }
.noscript { margin: 20px; padding: 20px; border: 2px solid var(--danger-700); border-radius: var(--radius-md); background: var(--danger-100); color: var(--danger-700); font-weight: 800; }

@media (max-width: 980px) {
  .preview-layout, .composer-layout { grid-template-columns: 1fr; }
  .sentence-panel { position: static; }
  .ocr-summary, .dashboard-hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid, .info-grid { grid-template-columns: 1fr; }
  .pictogram-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  :root { --topbar-h: 68px; --nav-h: 72px; }
  .topbar__inner { padding: 7px 12px; gap: 8px; }
  .brand-button { min-height: 52px; gap: 9px; }
  .brand-mark { width: 46px; height: 46px; border-radius: 15px; }
  .brand-mark svg { width: 30px; height: 30px; }
  .brand-copy > span { display: none; }
  .brand-copy strong { font-size: 1.05rem; }
  .status-pill { width: 48px; padding: 0; justify-content: center; }
  .status-pill #mode-pill-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .main-content { padding: 24px 14px calc(var(--nav-h) + 42px + env(safe-area-inset-bottom)); }
  .page > * + * { margin-top: 18px; }
  .page-header { flex-direction: column; gap: 14px; margin-bottom: 22px; }
  .back-button { order: -1; }
  .hero { padding: 24px 19px; border-radius: 22px; }
  .hero__meta { gap: 7px; }
  .badge { font-size: .76rem; }
  .action-grid { grid-template-columns: 1fr; gap: 12px; }
  .action-tile { min-height: 128px; padding: 19px; gap: 16px; border-radius: 22px; }
  .action-tile__icon { width: 66px; height: 66px; border-radius: 19px; }
  .action-tile__icon svg { width: 36px; height: 36px; }
  .action-tile strong { font-size: 1.3rem; }
  .secondary-action { padding: 12px 14px; }
  .panel, .setting-group { padding: 18px; }
  .panel__header { flex-direction: column; gap: 12px; }
  .bottom-nav { bottom: max(7px, env(safe-area-inset-bottom)); width: calc(100% - 14px); min-height: 70px; padding: 5px; border-radius: 20px; }
  .bottom-nav__item { min-height: 58px; font-size: .67rem; border-radius: 15px; }
  .bottom-nav__item svg { width: 22px; height: 22px; }
  .camera-frame { aspect-ratio: 3 / 4; border-radius: 20px; }
  .camera-guide { inset: 6%; }
  .camera-toolbar { grid-template-columns: 52px 78px 52px; gap: 20px; }
  .camera-toolbar .icon-button { width: 52px; height: 52px; }
  .capture-button { width: 78px; height: 78px; }
  .capture-button svg { width: 34px; height: 34px; }
  .crop-stage { min-height: 250px; }
  .crop-presets { grid-template-columns: 1fr 1fr; }
  .ocr-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ocr-block { grid-template-columns: 36px 1fr; padding: 11px; }
  .result-toolbar { position: static; flex-direction: column; align-items: stretch; }
  .segmented { width: 100%; grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .result-toolbar__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pictogram-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .pictogram-card__visual { min-height: 145px; padding: 12px; }
  .pictogram-card__body { padding: 11px 8px 8px; }
  .pictogram-card__label { font-size: 1rem; }
  .pictogram-card__actions { grid-template-columns: 1fr; }
  .card-reorder { grid-column: 1; }
  .card-action { flex-direction: row; font-size: .72rem; }
  .library-item { grid-template-columns: 1fr; padding: 16px; }
  .library-item__actions { justify-content: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .library-item__actions .btn:last-child { grid-column: 1 / -1; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .catalog-item { min-height: 152px; }
  .catalog-item img { height: 100px; }
  .sentence-item { grid-template-columns: 58px minmax(0, 1fr); }
  .sentence-item__buttons { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(44px, 1fr)); }
  .sentence-item__buttons button, .sentence-item__buttons button:last-child { width: auto; grid-column: auto; }
  .profile-options, .theme-options { grid-template-columns: 1fr 1fr; }
  .dashboard-hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .definition-list > div { grid-template-columns: 1fr; gap: 4px; }
  .app-dialog { width: calc(100% - 18px); max-height: 92vh; border-radius: 20px; }
  .dialog-content { padding: 17px; }
}

@media (max-width: 420px) {
  .topbar__status .icon-button { display: none; }
  .main-content { padding-inline: 11px; }
  .pictogram-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pictogram-card__visual { min-height: 126px; }
  .pictogram-card__status { font-size: .68rem; }
  .result-toolbar__actions { grid-template-columns: 1fr; }
  .ocr-summary, .dashboard-hero-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card, .metric-card { min-height: 100px; padding: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
html[data-reduced-motion="true"] *, html[data-reduced-motion="true"] *::before, html[data-reduced-motion="true"] *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }

@media print {
  :root { --body-size: 13pt; }
  body { background: #fff; color: #000; }
  .topbar, .bottom-nav, .no-print, .toast-region { display: none !important; }
  .main-content { padding: 0; }
  .page { width: 100%; max-width: none; }
  .pictogram-grid { grid-template-columns: repeat(4, 1fr); gap: 10pt; }
  .pictogram-card { break-inside: avoid; box-shadow: none; border-color: #777; }
  .pictogram-card__actions { display: none; }
  .pictogram-card__visual { min-height: 110pt; }
  .panel, .text-versions { box-shadow: none; }
}

/* Mobile overflow hardening */
.choice-card { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .profile-options { grid-template-columns: 1fr; }
  .theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
