/* ==========================================================================
   InstaScan AI · Bento Grid theme
   One grid of rounded tiles, each doing one job. Neutral canvas, white
   tiles, a few tinted feature tiles, brand gradient on the hero.
   ========================================================================== */

:root {
  /* Brand (each palette below sets the --p-* inputs) */
  --brand-1: var(--p-brand-1, #6366f1);
  --brand-2: var(--p-brand-2, #8b5cf6);
  --brand-3: #06b6d4;
  --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
  --hero-grad: var(--p-hero, var(--brand-grad));
  --stats-bg: var(--p-stats, #111322);
  --mix: var(--p-mix, 16%);

  /* Canvas + tiles */
  --bg: var(--p-bg, #efeee9);
  --tile: #ffffff;
  --tile-2: #f6f5f1;
  --tile-3: #ecebe5;
  --border: #e3e1da;
  --border-strong: #d2cfc6;
  --ink-tile-text: #f5f5ff;

  /* Text */
  --text: #14151f;
  --text-2: #4b4d5c;
  --text-3: #7a7c8a;

  /* Accent */
  --accent: color-mix(in srgb, var(--brand-1) 88%, black);
  --accent-soft: color-mix(in srgb, var(--brand-1) 13%, transparent);
  --ring: color-mix(in srgb, var(--brand-1) 45%, transparent);

  /* Status */
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;

  /* Workspace */
  --stage-bg: #f3f2ed;
  --stage-dot: rgba(20, 21, 31, .10);

  --shadow-sm: 0 1px 2px rgba(20, 21, 31, .05);
  --shadow: 0 1px 2px rgba(20, 21, 31, .04), 0 6px 18px -8px rgba(20, 21, 31, .12);
  --shadow-lg: 0 24px 48px -16px rgba(20, 21, 31, .28);
  --glow: 0 8px 22px -6px color-mix(in srgb, var(--brand-1) 60%, transparent);

  --radius: 26px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --gap: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: color-mix(in srgb, var(--brand-1) 7%, #0b0b10);
    --tile: #16161e;
    --tile-2: #1d1d27;
    --tile-3: #262633;
    --border: #262633;
    --border-strong: #363646;
    --stats-bg: var(--p-stats-dark, #1f1d3a);
    --mix: var(--p-mix-dark, 22%);
    --ink-tile-text: #f5f5ff;
    --text: #ededf5;
    --text-2: #b4b5c6;
    --text-3: #85879a;
    --accent: color-mix(in srgb, var(--brand-1) 55%, white);
    --accent-soft: color-mix(in srgb, var(--brand-1) 20%, transparent);
    --ring: color-mix(in srgb, var(--brand-1) 60%, transparent);
    --good: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --stage-bg: #101017;
    --stage-dot: rgba(255, 255, 255, .07);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: color-mix(in srgb, var(--brand-1) 7%, #0b0b10);
  --tile: #16161e;
  --tile-2: #1d1d27;
  --tile-3: #262633;
  --border: #262633;
  --border-strong: #363646;
  --stats-bg: var(--p-stats-dark, #1f1d3a);
  --mix: var(--p-mix-dark, 22%);
  --ink-tile-text: #f5f5ff;
  --text: #ededf5;
  --text-2: #b4b5c6;
  --text-3: #85879a;
  --accent: color-mix(in srgb, var(--brand-1) 55%, white);
  --accent-soft: color-mix(in srgb, var(--brand-1) 20%, transparent);
  --ring: color-mix(in srgb, var(--brand-1) 60%, transparent);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --stage-bg: #101017;
  --stage-dot: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .7);
  --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.pad { padding: 14px 4px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: rgba(99, 102, 241, .28); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- The bento grid ---------- */
.bento {
  display: grid;
  gap: var(--gap);
  max-width: 1560px;
  margin: 0 auto;
  padding: var(--gap) 20px 24px;
  grid-template-columns: 300px minmax(0, 1fr) minmax(0, 1fr) 380px;
  grid-template-areas:
    "hero    hero    search  stats"
    "upload  viewer  viewer  results"
    "files   viewer  viewer  results"
    "lang    viewer  viewer  results"
    "pre     adv     translate export";
}
.tile-hero    { grid-area: hero; }
.tile-stats   { grid-area: stats; }
.tile-search  { grid-area: search; }
.tile-upload  { grid-area: upload; }
.tile-viewer  { grid-area: viewer; }
.tile-results { grid-area: results; }
.tile-files   { grid-area: files; }
.tile-lang    { grid-area: lang; }
.tile-pre     { grid-area: pre; }
.tile-adv     { grid-area: adv; }
.tile-translate { grid-area: translate; }
.tile-export  { grid-area: export; }

.tile {
  position: relative;
  min-width: 0;
  --hue: var(--tile);
  padding: 20px;
  background: color-mix(in srgb, var(--hue) var(--mix), var(--tile));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: tile-in .45s cubic-bezier(.2, .7, .2, 1) both;
}
.bento > .tile:nth-child(1) { animation-delay: 0s; }
.bento > .tile:nth-child(2) { animation-delay: .04s; }
.bento > .tile:nth-child(3) { animation-delay: .08s; }
.bento > .tile:nth-child(4) { animation-delay: .1s; }
.bento > .tile:nth-child(5) { animation-delay: .12s; }
.bento > .tile:nth-child(n+6) { animation-delay: .16s; }
@keyframes tile-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.tile-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--label, var(--text-3));
}
.label-icon {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 6px;
  border-radius: 10px;
  stroke-width: 2.1;
  color: inherit;
  background: color-mix(in srgb, currentColor 15%, transparent);
}

/* ---------- Hero tile ---------- */
.tile-hero {
  overflow: hidden;
  padding: 24px 28px 26px;
  color: #fff;
  border: 0;
  background:
    radial-gradient(420px 260px at 92% 10%, rgba(6, 182, 212, .45), transparent 70%),
    radial-gradient(520px 320px at 70% 120%, rgba(236, 72, 153, .35), transparent 70%),
    var(--hero-grad);
  box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--brand-1) 70%, transparent);
}
.tile-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 46px solid rgba(255, 255, 255, .08);
  pointer-events: none;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35), 0 8px 22px -6px rgba(14, 22, 66, .6);
  transition: transform .25s;
}
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.04); }
.brand-mark { font: 700 18px var(--display); letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 7px; }
.ai-badge {
  font: 700 10.5px var(--font);
  letter-spacing: .08em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-1);
}
.hero-actions { display: flex; align-items: center; gap: 8px; }
.tile-hero h1 {
  position: relative;
  z-index: 1;
  font: 700 clamp(26px, 3.1vw, 40px)/1.08 var(--display);
  letter-spacing: -.03em;
  max-width: 640px;
}
.tile-hero h1 .h1-dot { display: inline-block; margin: 0 .12em; color: rgba(255, 255, 255, .55); font-weight: 400; transform: translateY(-.04em); }
.tile-hero h1 .h1-keep { white-space: nowrap; }
.tagline { position: relative; z-index: 1; margin-top: 10px; font-size: 14.5px; color: rgba(255, 255, 255, .85); }
.tagline a { color: #fff; font-weight: 600; text-underline-offset: 3px; }
/* One line of pills: the text scales with the banner's width (container units); where it would
   drop below 10px (phones) the row stays at 10px and scrolls sideways instead of wrapping. */
.hero-pills {
  position: relative;
  z-index: 1;
  container-type: inline-size;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.hero-pills::-webkit-scrollbar { display: none; }
.hero-pills.fade-end { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.hero-pills.fade-start { -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%); mask-image: linear-gradient(90deg, transparent, #000 15%); }
.hero-pills.fade-start.fade-end { -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); }
.hero-pills li {
  flex: none;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: clamp(10px, calc((100cqi - 130px) / 44), 12.5px);
  font-weight: 600;
  letter-spacing: -.005em;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
}

.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
}
.engine-status .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .7); }
.engine-status[data-state="loading"] .dot { background: #fcd34d; animation: pulse 1s infinite; }
.engine-status[data-state="busy"] .dot { background: #a5f3fc; animation: pulse 1s infinite; }
.engine-status[data-state="ready"] .dot { background: #6ee7b7; box-shadow: 0 0 0 4px rgba(110, 231, 183, .25); }
.engine-status[data-state="error"] .dot { background: #fca5a5; }
@keyframes pulse { 50% { opacity: .35; } }
.tile-hero .icon-btn { color: #fff; background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .25); }
.tile-hero .icon-btn:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, .28); border-color: rgba(255, 255, 255, .5); }

/* ---------- Stats tile ---------- */
.tile-stats { background: var(--stats-bg); color: var(--ink-tile-text); border-color: transparent; display: flex; flex-direction: column; }
.tile-stats .tile-label { color: rgba(245, 245, 255, .6); }
.stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 10px; }
.stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}
.stat b { font: 700 26px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { margin-top: 6px; font-size: 12px; color: rgba(245, 245, 255, .6); }
.stat-main { grid-column: 1 / -1; background: var(--brand-grad); border: 0; box-shadow: var(--glow); }
.stat-main b { font-size: 46px; }
.stat-main span { color: rgba(255, 255, 255, .8); }
.stats.is-empty b { opacity: .45; }

/* ---------- Search tile ---------- */
.tile-search { display: flex; flex-direction: column; min-height: 0; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--tile);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.search-box input { flex: 1; min-width: 0; padding: 11px 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 14.5px; outline: none; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-box kbd {
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--tile-2);
  color: var(--text-3);
  font: 600 11px var(--mono);
}
.search-summary { margin: 10px 2px 6px; font-size: 12.5px; color: var(--ink, var(--text-2)); }
.search-summary b { font-weight: 700; }
.search-summary .link-btn { padding: 0 2px; font-size: 12.5px; }
.search-results { list-style: none; margin: 0; padding: 0; max-height: 168px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.search-file {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--tile);
  border: 1px solid var(--border);
}
.search-file-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 12.5px; font-weight: 700; }
.search-file-head span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-file-head .count { flex: none; }
.search-hit {
  display: block;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.search-hit:hover, .search-hit:focus-visible { background: var(--accent-soft); color: var(--text); }
.search-hit .where { margin-right: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.search-hit mark { padding: 0 2px; border-radius: 4px; background: #fde047; color: #14151f; }
.search-more { padding: 2px 6px; font-size: 11.5px; color: var(--text-3); }
.auto-check { margin: 12px 2px 0; font-size: 12.5px; }

/* Search modes: Text / Image / Describe */
.search-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.search-head .tile-label { margin-bottom: 0; }
.seg-sm { padding: 3px; border-radius: 12px; }
.seg-sm .seg-btn { padding: 4px 10px; font-size: 12px; border-radius: 9px; }
.query-row { display: flex; align-items: center; gap: 12px; }
.query-thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 68px;
  height: 68px;
  overflow: hidden;
  border-radius: 14px;
  border: 1.5px dashed var(--border-strong);
  background: var(--tile);
  color: var(--text-3);
}
.query-thumb.has-image { border-style: solid; border-color: var(--accent); }
.query-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.query-thumb svg { width: 26px; height: 26px; stroke-width: 1.6; }
.query-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.query-actions .btn { width: 100%; }
#describeForm { padding-right: 5px; }
#describeForm .btn { padding: 6px 12px; }
.match-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 10px; }
.match-row img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #fff; }
.match-name { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-detail { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 11.5px; color: var(--text-3); }
.match-badge { padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; background: var(--accent-soft); color: var(--accent); }
.match-badge.dup { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.match-bar { flex: 1; height: 5px; border-radius: 999px; background: var(--tile-3); overflow: hidden; }
.match-bar i { display: block; height: 100%; border-radius: 999px; background: var(--brand-grad); }
.search-summary .btn { margin-top: 8px; }

/* ---------- Upload tile ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text-2);
  border-radius: var(--radius-md);
  border: 1.5px dashed rgba(99, 102, 241, .45);
  background: var(--tile);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.dropzone svg {
  width: 64px;
  height: 64px;
  padding: 15px;
  margin-bottom: 10px;
  color: #fff;
  stroke-width: 2.2;
  border-radius: 18px;
  background: var(--brand-grad);
  box-shadow: var(--glow);
  transition: transform .2s;
}
.dropzone strong { color: var(--text); font-size: 14.5px; font-weight: 700; }
.dropzone span { font-size: 12.5px; }
.dropzone .formats { margin-top: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; color: var(--text-3); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { outline: none; border-color: var(--brand-1); box-shadow: 0 0 0 4px var(--accent-soft); }
.dropzone:hover svg, .dropzone.drag svg { transform: translateY(-2px) rotate(-4deg); }
.dropzone.drag { transform: scale(1.015); }
.input-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.input-actions > * { flex: 1; }
.input-actions > .drive-btn { flex-basis: 100%; }
.btn-icon { width: 18px; height: 18px; flex: none; stroke: none; }
.btn-icon * { stroke: none; }

/* ---------- Files tile ---------- */
.tile-files { display: flex; flex-direction: column; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.section-head .tile-label { margin-bottom: 10px; }
.count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
}
.file-list { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--tile-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-item:hover { border-color: var(--border-strong); }
.file-item.active { background: var(--accent-soft); border-color: var(--accent); }
.file-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; background: var(--stage-bg); }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status { font-size: 11.5px; color: var(--text-3); }
.file-status.done { color: var(--good); }
.file-status.error { color: var(--bad); }
.file-status.running { color: var(--accent); }
.remove-btn { width: 26px; height: 26px; border: 0; border-radius: 8px; background: none; color: var(--text-3); font-size: 17px; line-height: 1; cursor: pointer; }
.remove-btn:hover { background: rgba(239, 68, 68, .12); color: var(--bad); }
.empty-note { padding: 18px 0; text-align: center; border: 1px dashed var(--border-strong); border-radius: 14px; }
.run-all { width: 100%; margin-top: 12px; padding: 11px 14px; font-size: 14px; }

/* ---------- Settings tiles ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > label { font-weight: 600; font-size: 13px; }
select, input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--tile-2);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select:hover, input[type="text"]:hover { border-color: var(--border-strong); }
select:focus, input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--tile); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="range"] { width: 100%; accent-color: var(--brand-1); }
.check { display: flex; align-items: center; gap: 9px; margin: 9px 0; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--brand-1); width: 16px; height: 16px; margin: 0; }
.check.inline { margin: 0; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 5px 5px 12px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
}
.chip button { width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgba(127, 127, 127, .3); color: inherit; line-height: 1; cursor: pointer; }
.chip button:hover { background: rgba(127, 127, 127, .5); }

/* ---------- Translate tile ---------- */
.tile-translate { display: flex; flex-direction: column; }
.translate-langs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 8px; }
.translate-langs .field { margin-bottom: 0; }
.swap-btn { margin-bottom: 4px; }
.translate-btn { width: 100%; margin-top: 14px; }
.tr-engine { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--ink, var(--text-2)); }
.tr-engine b { font-weight: 700; }
.tr-engine.is-online { padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); }
.translation-meta { margin-bottom: 8px; font-size: 12px; color: var(--text-3); }

/* ---------- Export tile ---------- */
.tile-export { display: flex; flex-direction: column; }
.export-note { font-size: 13px; color: var(--ink, var(--text-2)); opacity: .9; margin-bottom: 14px; }
.export-bar { display: flex; gap: 8px; margin-top: auto; }
.export-bar > * { flex: 1; }
.export-bar .btn { width: 100%; }
.dropdown { position: relative; }
.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 10;
  min-width: 240px;
  padding: 6px;
  border-radius: 16px;
  background: var(--tile);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.menu button { display: block; width: 100%; padding: 8px 11px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.menu button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.menu button:disabled { color: var(--text-3); cursor: not-allowed; }
.menu hr { margin: 5px 0; border: 0; border-top: 1px solid var(--border); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--tile);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { border: 0; color: #fff; background: var(--brand-grad); box-shadow: var(--glow); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 26px -8px rgba(99, 102, 241, .75); }
.btn-primary:disabled { box-shadow: none; }
.btn-dark { border: 0; color: var(--bg); background: var(--text); }
.btn-dark:hover:not(:disabled) { border: 0; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.link-btn { padding: 2px 4px; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: var(--text-3); cursor: default; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--tile);
  color: var(--text-2);
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s, background .15s;
}
.icon-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

/* ---------- Viewer tile ---------- */
.tile-viewer { display: flex; flex-direction: column; min-height: 640px; padding: 14px; }
.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 2px 4px 12px; }
.toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.seg, .tabs { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--tile-2); border: 1px solid var(--border); }
.seg-btn, .tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.seg-btn:hover, .tab:hover { color: var(--text); }
.seg-btn.active, .tab.active { color: var(--text); background: var(--tile); box-shadow: var(--shadow); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 22px;
  border-radius: 18px;
  background-color: var(--stage-bg);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1px);
  background-size: 18px 18px;
}
.stage-empty { text-align: center; color: var(--text-2); max-width: 280px; }
.stage-empty svg { width: 68px; height: 68px; padding: 17px; margin-bottom: 8px; color: var(--accent); stroke-width: 1.6; border-radius: 22px; background: var(--tile); box-shadow: var(--shadow); }
.stage-empty p { margin-top: 6px; }
.stage-empty p:first-of-type { font: 600 16px var(--display); color: var(--text); }
.canvas-wrap { position: relative; line-height: 0; border-radius: 8px; box-shadow: var(--shadow-lg); }
.canvas-wrap canvas { display: block; max-width: 100%; height: auto; border-radius: 8px; }
#imageCanvas { background: #fff; }
#overlayCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.word-tip { position: absolute; z-index: 3; padding: 5px 10px; border-radius: 9px; background: #14151f; color: #fff; font-size: 12px; line-height: 1.4; white-space: nowrap; pointer-events: none; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow); }
.word-tip b { font-family: var(--mono); font-weight: 500; }
.progress-box { position: absolute; left: 50%; bottom: 20px; width: min(380px, calc(100% - 32px)); padding: 12px 14px; transform: translateX(-50%); background: var(--tile); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.progress { height: 8px; border-radius: 999px; background: var(--tile-3); overflow: hidden; }
.progress-fill { width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-1), var(--brand-2), var(--brand-3), var(--brand-1)); background-size: 300% 100%; animation: flow 2s linear infinite; transition: width .25s; }
@keyframes flow { to { background-position: -300% 0; } }
.image-meta { padding: 10px 6px 0; min-height: 28px; }

/* ---------- Results tile ---------- */
.tile-results { display: flex; flex-direction: column; min-height: 0; padding: 18px; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.results-head .tile-label { margin-bottom: 0; }
.tab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.result-text {
  flex: 1;
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  resize: none;
  background: var(--tile-2);
  color: var(--text);
  font: 13.5px/1.7 var(--mono);
  white-space: pre-wrap;
}
.result-text::placeholder { color: var(--text-3); }
.words-wrap { flex: 1; min-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 18px; background: var(--tile-2); }
.words-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.words-table th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; text-align: left; background: var(--tile-2); border-bottom: 1px solid var(--border); color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.words-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.words-table td:nth-child(2) { font-family: var(--mono); word-break: break-all; }
.words-table td:first-child, .words-table td:last-child { color: var(--text-3); }
.words-table tr { cursor: pointer; }
.words-table tbody tr:hover td { background: var(--accent-soft); }
.words-table tr.low td:nth-child(2) { color: var(--bad); }
.conf { display: inline-flex; align-items: center; gap: 8px; }
.conf-bar { width: 52px; height: 6px; border-radius: 999px; background: var(--tile-3); overflow: hidden; }
.conf-bar i { display: block; height: 100%; border-radius: 999px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: calc(100% - 32px); padding: 11px 18px; transform: translateX(-50%); border-radius: 14px; background: #14151f; color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; }

/* ==========================================================================
   Colour palettes  ·  <html data-palette="ocean|sunset"> (Ocean is the default)
   Each palette sets the brand, hero, stats and canvas inputs, plus a hue per
   tile. A tinted tile mixes its hue into the tile colour (--mix), and its
   label and ink are darkened (light mode) or lightened (dark mode) versions
   of the same hue.
   ========================================================================== */
.tinted { border-color: transparent; }
:root[data-palette] .tinted {
  --label: color-mix(in srgb, var(--hue) 62%, var(--text));
  --ink: color-mix(in srgb, var(--hue) 55%, var(--text));
}

/* Sunset: warm oranges, pinks and amber */
:root[data-palette="sunset"] {
  --p-brand-1: #f97316; --p-brand-2: #db2777;
  --p-hero: linear-gradient(120deg, #fbbf24 0%, #f97316 40%, #db2777 100%);
  --p-stats: #4a044e; --p-stats-dark: #4a044e;
  --p-search: linear-gradient(105deg, #db2777 0%, #a21c5f 45%, #6b0f56 75%, #4a044e 100%);
  --p-bg: #fdf3ea; --p-mix: 22%; --p-mix-dark: 24%;
}
:root[data-palette="sunset"] .tile-upload  { --hue: #fb923c; }
:root[data-palette="sunset"] .tile-search  { --hue: #f472b6; }
:root[data-palette="sunset"] .tile-files   { --hue: #f43f5e; }
:root[data-palette="sunset"] .tile-lang    { --hue: #f59e0b; }
:root[data-palette="sunset"] .tile-pre     { --hue: #e879f9; }
:root[data-palette="sunset"] .tile-adv     { --hue: #fbbf24; }
:root[data-palette="sunset"] .tile-translate { --hue: #fb7185; }
:root[data-palette="sunset"] .tile-export  { --hue: #f97316; }
:root[data-palette="sunset"] .tile-results { --hue: #fdba74; }

/* Ocean: cool teal, sky and periwinkle */
:root[data-palette="ocean"] {
  --p-brand-1: #0891b2; --p-brand-2: #4f46e5;
  --p-hero: linear-gradient(120deg, #06b6d4 0%, #3b82f6 55%, #6366f1 100%);
  --p-stats: #0c1e3e; --p-stats-dark: #0c1e3e;
  --p-search: linear-gradient(105deg, #6366f1 0%, #4347c9 40%, #23308a 72%, #0c1e3e 100%);
  --p-bg: #edf5f7; --p-mix: 20%; --p-mix-dark: 24%;
}
:root[data-palette="ocean"] .tile-upload  { --hue: #22d3ee; }
:root[data-palette="ocean"] .tile-search  { --hue: #a78bfa; }
:root[data-palette="ocean"] .tile-files   { --hue: #3b82f6; }
:root[data-palette="ocean"] .tile-lang    { --hue: #14b8a6; }
:root[data-palette="ocean"] .tile-pre     { --hue: #818cf8; }
:root[data-palette="ocean"] .tile-adv     { --hue: #0ea5e9; }
:root[data-palette="ocean"] .tile-translate { --hue: #10b981; }
:root[data-palette="ocean"] .tile-export  { --hue: #6366f1; }
:root[data-palette="ocean"] .tile-results { --hue: #67e8f9; }

/* Palette picker (hero tile) */
.palette-picker { display: inline-flex; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); }
.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .7);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); transform: scale(1.12); }

/* ---------- Search tile: gradient bridge between the hero and Last result ---------- */
:root[data-palette] .bento .tile-search {
  --label: rgba(255, 255, 255, .78);
  --ink: rgba(255, 255, 255, .88);
  color: #f5f5ff;
  border-color: transparent;
  background:
    radial-gradient(360px 220px at 12% 0%, rgba(255, 255, 255, .16), transparent 70%),
    radial-gradient(320px 240px at 100% 100%, rgba(6, 182, 212, .18), transparent 70%),
    var(--p-search, var(--brand-grad));
  box-shadow: 0 18px 40px -20px color-mix(in srgb, var(--stats-bg) 80%, transparent);
}
.bento .tile-search .search-summary b { color: #fff; }
.bento .tile-search .search-summary .link-btn { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.bento .tile-search .seg { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); }
.bento .tile-search .seg-btn { color: rgba(255, 255, 255, .78); }
.bento .tile-search .seg-btn:hover { color: #fff; }
.bento .tile-search .seg-btn.active { color: #14151f; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.bento .tile-search .search-box { background: #fff; border-color: transparent; box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .35); }
.bento .tile-search .search-box input { color: #14151f; }
.bento .tile-search .search-box input::placeholder { color: #6b7080; }
.bento .tile-search .search-box svg { color: #6b7080; }
.bento .tile-search .search-box kbd { background: #f1f2f6; border-color: #d7d9e0; color: #6b7080; }
.bento .tile-search .search-box:focus-within { box-shadow: 0 0 0 3px rgba(255, 255, 255, .45); }
.bento .tile-search .query-thumb { border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85); }
.bento .tile-search .query-thumb.has-image { border-color: #fff; }
.bento .tile-search .query-actions .btn { background: #fff; color: #14151f; border-color: transparent; }
.bento .tile-search .query-actions .btn:disabled { background: rgba(255, 255, 255, .55); color: rgba(20, 21, 31, .6); opacity: 1; }
.bento .tile-search .search-file { background: #fff; border-color: transparent; color: #14151f; }
.bento .tile-search .search-hit { color: #3b3f50; }
.bento .tile-search .search-hit:hover, .bento .tile-search .search-hit:focus-visible { background: #eef0ff; color: #14151f; }
.bento .tile-search .match-name, .bento .tile-search .search-file-head { color: #14151f; }
.bento .tile-search .match-detail, .bento .tile-search .search-more, .bento .tile-search .search-hit .where { color: #6b7080; }
.bento .tile-search .match-bar { background: #e6e8f0; }
.bento .tile-search .count { background: #eef0ff; color: #3730a3; }
.bento .tile-search .search-results { scrollbar-color: rgba(255, 255, 255, .45) transparent; }

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

/* ---------- Responsive bento ---------- */
@media (max-width: 1240px) {
  .bento {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "hero    hero"
      "search  search"
      "upload  stats"
      "viewer  viewer"
      "files   results"
      "lang    results"
      "pre     adv"
      "translate export";
  }
  .tile-viewer { min-height: 560px; }
}
@media (max-width: 720px) {
  .bento {
    --gap: 12px;
    padding: 12px 16px 20px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hero" "upload" "files" "search" "viewer" "stats" "results" "translate" "export" "lang" "pre" "adv";
  }
  .tile { padding: 16px; border-radius: 22px; }
  .tile-hero { padding: 20px; }
  .hero-top { flex-wrap: wrap; row-gap: 10px; margin-bottom: 16px; }
  .brand { gap: 8px; }
  .brand-logo { width: 44px; height: 44px; border-radius: 11px; }
  .brand-mark { font-size: 16px; }
  .hero-actions { gap: 6px; }
  .tile-hero .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
  .palette-picker { padding: 4px; gap: 5px; }
  .swatch { width: 20px; height: 20px; }
  .engine-status { padding: 6px 8px; }
  .engine-status .label { display: none; }
  .tile-viewer { min-height: 460px; padding: 12px; }
  .stat-main b { font-size: 40px; }
}

/* ---------- Add files + Files: fade from the banner down towards the image viewer ----------
   Both tiles sit below the banner at every width, so they carry its last colour down to light. */
:root[data-palette="ocean"] {
  --m-upload: linear-gradient(180deg, #6366f1 0%, #8592f6 45%, #c7cefd 100%);
  --m-files: linear-gradient(180deg, #d5dbfe 0%, #eef0ff 60%, #fbfbff 100%);
  --m-check: #1e1b4b;
}
:root[data-palette="sunset"] {
  --m-upload: linear-gradient(180deg, #db2777 0%, #ec6b9b 45%, #fbc8d8 100%);
  --m-files: linear-gradient(180deg, #fde0e9 0%, #fff1f5 60%, #fffbfc 100%);
  --m-check: #4a0d27;
}
@media (prefers-color-scheme: dark) {
  :root[data-palette="ocean"]:not([data-theme="light"]) {
    --m-upload: linear-gradient(180deg, #6366f1 0%, #3f3fb8 45%, #23215e 100%);
    --m-files: linear-gradient(180deg, #201e4f 0%, #1a1a33 60%, #16161e 100%);
    --m-check: #e0e7ff;
  }
  :root[data-palette="sunset"]:not([data-theme="light"]) {
    --m-upload: linear-gradient(180deg, #db2777 0%, #9d1d5c 45%, #4e0f3a 100%);
    --m-files: linear-gradient(180deg, #431232 0%, #2a1424 60%, #16161e 100%);
    --m-check: #fde2ea;
  }
}
:root[data-theme="dark"][data-palette="ocean"] {
  --m-upload: linear-gradient(180deg, #6366f1 0%, #3f3fb8 45%, #23215e 100%);
  --m-files: linear-gradient(180deg, #201e4f 0%, #1a1a33 60%, #16161e 100%);
  --m-check: #e0e7ff;
}
:root[data-theme="dark"][data-palette="sunset"] {
  --m-upload: linear-gradient(180deg, #db2777 0%, #9d1d5c 45%, #4e0f3a 100%);
  --m-files: linear-gradient(180deg, #431232 0%, #2a1424 60%, #16161e 100%);
  --m-check: #fde2ea;
}

:root[data-palette] .bento .tile-upload {
  --label: rgba(255, 255, 255, .92);
  background: var(--m-upload);
  border-color: transparent;
  box-shadow: 0 14px 30px -18px rgba(30, 27, 75, .55);
}
:root[data-palette] .bento .tile-upload .auto-check { color: var(--m-check); font-weight: 500; }
:root[data-palette] .bento .tile-upload .auto-check input { accent-color: var(--m-check); }
:root[data-palette] .bento .tile-files {
  background: var(--m-files);
  border-color: transparent;
}

/* ---------- Image viewer: gradient frame bridging Search (above) and Stats (below), cool stage ---------- */
:root[data-palette="ocean"] {
  --v-frame: linear-gradient(180deg, #c7cefd 0%, #e2e6ff 28%, #eef1fb 68%, #c6cfe9 100%);
  --v-stage: #f7f8ff; --v-dot: rgba(67, 71, 201, .16); --v-shadow: rgba(12, 30, 62, .35);
}
:root[data-palette="sunset"] {
  --v-frame: linear-gradient(180deg, #fbc8d8 0%, #ffe2eb 28%, #fff2f6 68%, #e9cddf 100%);
  --v-stage: #fff8fa; --v-dot: rgba(219, 39, 119, .16); --v-shadow: rgba(74, 4, 78, .35);
}
@media (prefers-color-scheme: dark) {
  :root[data-palette="ocean"]:not([data-theme="light"]) {
    --v-frame: linear-gradient(180deg, #2d2f80 0%, #1e2050 30%, #151a33 70%, #0f1d3d 100%);
    --v-stage: #0f1226; --v-dot: rgba(165, 180, 252, .12); --v-shadow: rgba(0, 0, 0, .55);
  }
  :root[data-palette="sunset"]:not([data-theme="light"]) {
    --v-frame: linear-gradient(180deg, #5c1442 0%, #371331 30%, #231425 70%, #2c0a30 100%);
    --v-stage: #170f17; --v-dot: rgba(251, 200, 216, .10); --v-shadow: rgba(0, 0, 0, .55);
  }
}
:root[data-palette="ocean"][data-theme="dark"] {
  --v-frame: linear-gradient(180deg, #2d2f80 0%, #1e2050 30%, #151a33 70%, #0f1d3d 100%);
  --v-stage: #0f1226; --v-dot: rgba(165, 180, 252, .12); --v-shadow: rgba(0, 0, 0, .55);
}
:root[data-palette="sunset"][data-theme="dark"] {
  --v-frame: linear-gradient(180deg, #5c1442 0%, #371331 30%, #231425 70%, #2c0a30 100%);
  --v-stage: #170f17; --v-dot: rgba(251, 200, 216, .10); --v-shadow: rgba(0, 0, 0, .55);
}
:root[data-palette] .bento .tile-viewer {
  --stage-bg: var(--v-stage);
  --stage-dot: var(--v-dot);
  background: var(--v-frame);
  border-color: transparent;
  box-shadow: 0 18px 40px -22px var(--v-shadow);
}
:root[data-palette] .bento .tile-viewer .seg { background: color-mix(in srgb, var(--tile) 55%, transparent); border-color: transparent; }
:root[data-palette] .bento .tile-viewer .stage { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--v-dot) 80%, transparent); }
:root[data-palette] .bento .tile-viewer .icon-btn { background: color-mix(in srgb, var(--tile) 70%, transparent); }

/* ---------- About (below the grid): app description, Google data use, privacy ---------- */
.about { max-width: 1560px; margin: 0 auto; padding: 0 20px 28px; }
.about-card {
  padding: 26px 28px;
  border-radius: var(--radius);
  background: var(--tile);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.about h2 { font: 700 22px/1.2 var(--display); letter-spacing: -.02em; color: var(--text); }
.about-lead { margin-top: 6px; color: var(--text-2); font-size: 14.5px; max-width: 760px; }
.about-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; margin-top: 20px; }
.about h3 { font: 600 15px var(--display); color: var(--text); margin-bottom: 8px; }
.about ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.about li { color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.about li b { color: var(--text); font-weight: 600; }
.about a { color: var(--accent); text-underline-offset: 2px; }
.about code { font-size: 12.5px; padding: 1px 5px; border-radius: 6px; background: var(--tile-2); color: var(--text); }
.about-links { margin-top: 14px; font-size: 13.5px; font-weight: 600; }
.about-foot { margin-top: 14px; text-align: center; font-size: 12.5px; color: var(--text-3); }
@media (max-width: 1100px) { .about-grid { grid-template-columns: 1fr; gap: 18px; } }
@media (max-width: 720px) { .about { padding: 0 16px 22px; } .about-card { padding: 20px 18px; border-radius: 22px; } }

/* ---------- Banner logo button + About us / disclaimer dialog ---------- */
.brand-btn { flex: none; padding: 0; border: 0; background: none; border-radius: 14px; cursor: pointer; line-height: 0; }
.brand-btn:focus-visible { outline: 3px solid rgba(255, 255, 255, .85); outline-offset: 3px; }
.brand-btn:hover .brand-logo { transform: rotate(-6deg) scale(1.04); }

.about-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--tile);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(8, 12, 40, .55);
  overflow: hidden;
}
.about-dialog[open] { display: flex; flex-direction: column; animation: ad-in .22s cubic-bezier(.2, .7, .2, 1); }
.about-dialog::backdrop { background: rgba(10, 14, 40, .55); backdrop-filter: blur(3px); }
@keyframes ad-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.ad-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  color: #fff;
  background: var(--p-hero, var(--brand-grad));
}
.ad-head img { flex: none; width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.ad-head h2 { font: 700 19px/1.2 var(--display); letter-spacing: -.01em; }
.ad-nowrap { white-space: nowrap; }
.ad-head p { font-size: 12.5px; color: rgba(255, 255, 255, .8); margin-top: 2px; }
.ad-head .ad-close { margin-left: auto; color: #fff; background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .3); }
.ad-body { padding: 18px 22px 6px; overflow-y: auto; display: grid; gap: 16px; }
.ad-body h3 { font: 600 15px var(--display); margin-bottom: 6px; }
.ad-body p, .ad-body li { font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.ad-body p + p { margin-top: 6px; }
.ad-body ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.ad-body b { color: var(--text); font-weight: 600; }
.ad-body a, .ad-foot a { color: var(--accent); text-underline-offset: 2px; }
.ad-body .ad-credits { font-size: 12.5px; }
.ad-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
@media (max-width: 720px) {
  .about-dialog { border-radius: 20px; max-height: 88vh; }
  .ad-head img { width: 72px; height: 72px; border-radius: 17px; }
  .ad-body { padding: 16px 16px 6px; }
  .ad-foot { padding: 12px 16px 16px; }
  .ad-foot .btn { width: 100%; }
}
