/* NumGener 2.0 — site.css
   Дизайн-система без фреймворків. ДНК 1.0: червоний NUM + чорний GENER,
   білий фон, кубики й розіграші. Сигнатура: результат-«лотерейний квиток». */

:root {
  --ink: #1c1c1e;
  --muted: #66666e;
  --crimson: #d6293a;        /* фірмовий червоний 1.0, відкалiбрований */
  --crimson-dark: #b01e2e;
  --paper: #ffffff;
  --bg: #f7f6f4;
  --line: #e7e5e1;
  --ticket-bg: #fffdf8;      /* теплий папір квитка */
  --ok: #0e7c4a;
  /* gen-runtime.js бере var(--green) (✓ після копіювання, галочка платформи),
     але токена не було — колір мовчки падав у currentColor. */
  --green: var(--ok);
  /* Так само: runtime і .seg-item брали var(--text-dim), якого не було, —
     нумерація рядків виглядала частиною результату (колір і розмір як у нього). */
  --text-dim: var(--muted);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,28,30,.06), 0 8px 24px rgba(28,28,30,.07);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}

:root { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body, html[data-theme="dark"] {
  --ink: #ececee;
  --muted: #9b9ba3;
  --crimson: #e2495b;
  --crimson-dark: #ef6a7a;
  --paper: #1b1b1e;
  --bg: #131316;
  --line: #2c2c31;
  --ticket-bg: #211f24;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  /* Запобіжник: ніщо (підказка, реклама) не має прокручувати сторінку вбік на телефоні */
  overflow-x: clip;
  /* Sticky footer: на коротких сторінках футер притиснутий до низу екрана */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; }
a { color: var(--crimson); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--crimson-dark); }
:focus-visible { outline: 3px solid var(--crimson); outline-offset: 2px; border-radius: 4px; }

.container { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
/* inset-inline-start, не left: на RTL-сторінках (ar, fa, ur) left: -9999px
   розтягував документ на ~11000px і давав горизонтальну прокрутку; за
   початковий край (ліворуч у LTR, праворуч у RTL) браузер не прокручує. */
.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: 8px 16px; z-index: 100; border-end-end-radius: 8px;
}
.skip-link:focus { inset-inline-start: 0; }

/* ---------- Шапка ---------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px;
}
.logo {
  font-weight: 800; font-size: 1.45rem; letter-spacing: -0.02em;
  text-decoration: none; color: var(--ink); display: inline-flex; align-items: baseline; gap: 2px;
}
.logo b { color: var(--crimson); font-weight: 800; }
.logo-die-extra-pip { transition: opacity 0.2s ease; }
.logo:hover .logo-die-extra-pip { opacity: 1; }
.logo .die {
  width: 20px; height: 20px; margin-inline-start: 8px; align-self: center;
  background: var(--crimson); border-radius: 5px; position: relative; flex: none;
}
.logo .die::before {  /* грань «3» — три білі цятки по діагоналі */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle 2px at 25% 25%, #fff 98%, transparent),
    radial-gradient(circle 2px at 50% 50%, #fff 98%, transparent),
    radial-gradient(circle 2px at 75% 75%, #fff 98%, transparent);
}
.site-nav { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: .95rem;
  padding: 6px 2px; border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--crimson); border-bottom-color: var(--crimson); }

main { flex: 1 0 auto; width: 100%; }
main.container { padding-top: 32px; padding-bottom: 80px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 22px 0 30px; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 10px; }
.hero p { color: var(--muted); font-size: 1.06rem; max-width: 46ch; margin: 0 auto; }

/* ---------- Генератор ---------- */
.tool-shell {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(20px, 4vw, 40px); text-align: center;
  max-width: 720px; margin: 0 auto;
}
/* Телефон: короткий опис — у самий низ картки (після Generate і розширених
   налаштувань), щоб генератор був одразу під заголовком. Лише візуально (order):
   у HTML опис лишається під H1 — для пошуковиків і читачів екрана нічого не міняється. */
@media (max-width: 640px) {
  .tool-shell { display: flex; flex-direction: column; }
  /* у flex-колонці margin:auto стискав квиток до ширини числа — як у блоці: повна ширина до max-width */
  .tool-shell > * { width: 100%; }
  .tool-shell > .tool-lede { order: 1; margin: 22px auto 0; font-size: .95rem; }
}
.tool-shell h1 { font-size: clamp(1.45rem, 3.6vw, 2rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.tool-lede { color: var(--muted); margin: 0 auto 26px; max-width: 52ch; }

/* Сигнатура: результат-«квиток» з перфорованим краєм */
.ticket {
  position: relative; margin: 0 auto 26px; padding: 20px 34px;
  background: var(--ticket-bg); border: 1.5px dashed var(--line); border-radius: 12px;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: clamp(1.9rem, 6vw, 3rem); font-weight: 700; line-height: 1.25;
  overflow-wrap: anywhere; max-width: 560px;
  /* Стабільна висота: порожній стан і результат займають однаковий бокс,
     форма не стрибає при першій генерації */
  min-height: clamp(92px, 15vw, 118px);
  display: flex; align-items: center; justify-content: center;
}
.ticket::before, .ticket::after {  /* напівкруглі вирізи, як на відривному квитку */
  content: ""; position: absolute; top: 50%; width: 22px; height: 22px;
  background: var(--paper); border: 1.5px dashed var(--line); border-radius: 50%;
  transform: translateY(-50%);
}
.ticket::before { left: -12px; clip-path: inset(0 0 0 50%); }
.ticket::after  { right: -12px; clip-path: inset(0 50% 0 0); }
.ticket.is-empty { color: var(--muted); font-family: var(--font-body); font-size: 1rem; font-weight: 500; }
.ticket.is-error { color: var(--crimson-dark); font-family: var(--font-body); font-size: 1rem; font-weight: 600; border-color: var(--crimson); }

/* Параметри */
.controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 20px; text-align: start;
}
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: var(--font-num);
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
  height: 44px;  /* одна висота: Safari на iOS малює select нижчим за input */
}
/* Системна стрілка iOS не слухається висоти — своя, нейтрально-сіра для обох тем */
/* !important: форми slug і picker мають інлайн style="background:…; padding:10px 12px",
   який стирав стрілку (background-image) і відступ під неї — текст ліз під її місце */
.field select {
  -webkit-appearance: none; appearance: none; padding-inline-end: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238a8a93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 12px center !important;
  background-size: 12px 8px !important;
}
[dir="rtl"] .field select { background-position: left 12px center !important; }
.field input:focus, .field select:focus { border-color: var(--crimson); outline: none; box-shadow: 0 0 0 3px rgba(214,41,58,.15); }
/* Сегментований перемикач. flex-wrap і max-width обов'язкові: паддинги
   пунктів фіксовані в px, тож при 7 варіантах (uuid: v1/v3/v4/v5/v7/nil/max)
   контрол не звужується разом з екраном і на телефоні 360px вилазив за краї
   картки — половина варіантів ставала недосяжною. */
.seg { display:flex; flex-wrap:wrap; justify-content:center; max-width:100%;
       background:var(--bg-secondary); border:1px solid var(--line); border-radius:8px; padding:2px; }
/* .seg .seg-item, а не .seg-item: перемикач стоїть у .field, і `.field label`
   (0,1,1) давав пунктам margin-bottom:4px — активна кнопка прилипала до
   верхньої рамки (Nickname, UUID). */
.seg .seg-item { margin:0; cursor:pointer; position:relative; }
/* НЕ display:none — інпут має лишатися фокусованим і видимим для a11y */
.seg-item input { position:absolute; opacity:0; width:100%; height:100%; margin:0; cursor:pointer; }
.seg-item span { display:block; padding:4px 16px; font-weight:600; border-radius:6px; transition:all .2s; background:transparent; box-shadow:none; color:var(--text-dim); }
/* Активна позиція — фірмовий червоний, як Generate: колишній --paper у темній
   темі (#1b1b1e) майже зливався з фоном перемикача. */
.seg-item input:checked + span { background:var(--crimson); color:#fff; box-shadow:0 1px 3px rgba(0,0,0,.25); }
.seg-item:hover input:not(:checked) + span { color:var(--ink); background:var(--line); }
.seg-item input:focus-visible + span { outline:2px solid var(--crimson); outline-offset:2px; }
/* UUID v3/v5 на телефоні: поля namespace — у загальному ряду опцій, щоб
   Without hyphens і Namespace стали поруч, а Name — окремим рядком.
   Група ховається інлайном display:none (JS) — лише тоді не чіпаємо. */
@media (max-width: 560px) {
  .uuid-controls > .uuid-ns-group:not([style*="display: none"]) { display: contents !important; }
  .uuid-controls .uuid-ns-group > .field:first-child { min-width: 110px !important; }
}
/* UUID: перемикач версій заввишки як поле Count (44px) */
.uuid-controls .seg { height: 44px; align-items: stretch; }
.uuid-controls .seg .seg-item span { height: 100%; display: flex; align-items: center; justify-content: center; }
/* Телефон: пункти, що перенеслися на другий рядок, розтягуються на всю рамку
   (інакше вузькі кнопки стояли посеред широкої рамки — Nickname) */
@media (max-width: 520px) {
  .seg-item span { padding:4px 9px; }
  .seg .seg-item { flex: 1 1 auto; }
  .seg-item span { text-align: center; }
}

/* UUID на вузькому екрані. 36 моноширинних символів мусять лягти в один
   рядок: розбитий надвоє UUID виглядає як зіпсований і його не порівняти
   очима. Замість того щоб дотискати шрифт до нечитабельного, відвойовуємо
   ширину — прибираємо зайві поля картки й рядка. !important тут через те,
   що падінги рядків ставить інлайном gen-runtime.js. */
@media (max-width: 520px) {
    /* 20px, не 8: за 8px кнопка копіювання рядка лягала на виріз краю квитка і
       разом із ним виглядала як «]». Шрифт UUID і так стискається (2.6vw).
       Справа +16px: обгортка рядків (gen-runtime.js) заходить на 16px у правий
       відступ під смугу прокрутки — так рядок стоїть на 20px від обох країв. */
    .ticket.has-uuid-rows { padding-left: 20px; padding-right: 36px; }
    .has-uuid-rows .uuid-row { padding-left: 2px !important; padding-right: 2px !important; }
    .has-uuid-rows .uuid-num { margin-right: 4px !important; }
}
.switch { display: flex; align-items: center; gap: 10px; padding-top: 22px; }
.switch input { width: 20px; height: 20px; accent-color: var(--crimson); flex: none; }
/* Лейбл перемикача — другорядний контрол, а не значення: той самий стиль,
   що вже мали Coin Flip, Random Color, Picker, Random Number і Slug (кожен
   своєю копією); тепер глобально — Password, UUID, Dice і Nickname теж. */
.switch label { font-size: .88rem; font-weight: 500; color: var(--muted); cursor: pointer; transition: color .15s ease; }
.switch:hover label { color: var(--ink); }
/* Coin Flip: усі опції в Advanced Options (engine_forms/coin.html).
   Ряди по дві частини: Coins | Animated 3D Coin, потім поля «… означає»,
   і окремим третім рядом Random coin — утрьох у першому ряду довгі підписи
   (be, uk…) на телефоні налазили один на одного. */
.coin-options .coin-row { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; }
.coin-options .coin-row-random { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.coin-options .coin-row-random .switch { padding-top: 0; }
/* Nickname: поля режиму ховаються атрибутом hidden, а .controls і .switch
   мають власний display (grid / flex), який його перебиває. */
[data-nick-modes][hidden] { display: none !important; }
/* Nickname: підказка біля Platform — «?» без пресета, «!» з пресетом; лише на наведення чи фокус. */
/* Nickname: обране ☆ — короткий список поверх кількох партій (gen-runtime.js). */
.nick-favs { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 18px; text-align: start; }
.nick-favs-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.nick-favs-title { font-weight: 600; font-size: .88rem; margin-inline-end: auto; }
/* Копіювати / очистити — іконки з підписом у title, як іконки поля Slug Generator. */
.nick-favs-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  padding: 0; border-radius: 6px; border: none; background: transparent; color: var(--ink); opacity: .55;
  cursor: pointer; font: inherit; font-weight: 700; }
.nick-favs-btn:hover { opacity: .9; background: var(--line); }
/* Перемикач письма: рамка по ширині двох кнопок, а не всієї клітинки сітки. */
.nick-script .seg { display: inline-flex; flex-wrap: nowrap; white-space: nowrap; }
/* Назва абетки («Українська абетка») довша за колонку 170–205px: поле
   притискається праворуч і заходить у порожній хвіст сусідньої колонки,
   а не переносить другу кнопку під першу. */
.nick-script { justify-self: end; min-width: max-content; }
.nick-favs-list { display: flex; flex-wrap: wrap; gap: 6px; }
.nick-fav-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--line); font-family: monospace; font-size: .9rem; }
.nick-fav-chip button { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: .9rem; line-height: 1; padding: 2px 6px; }
.nick-fav-chip button:hover { color: var(--crimson); }
/* Nickname: слово й «Word position» в одному ряду; на телефоні — одне під одним. */
.nick-word-row { grid-template-columns: minmax(0, 1fr) minmax(130px, 180px); }
@media (max-width: 520px) { .nick-word-row { grid-template-columns: 1fr; } }
.coin-options .coin-row-means { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Перемикачі як у Random Color Generator: по центру прямокутника поля Coins
   (зсув на половину висоти його підпису), дрібніший приглушений підпис. */
.coin-options .coin-row .switch { padding-top: 0; transform: translateY(12px); }
.coin-options .switch label {
  font-size: .88rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s ease;
}
.coin-options .switch:hover label { color: var(--ink); }
/* Підказка «?» як у Slug Generator (Remove stop words): наведення чи фокус
   на лейблі показує бульбашку над іконкою. Скоуп — форми монети й ніків
   (Leet); інші генератори мають власні копії цих стилів у шаблонах. */
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .switch.has-help { position: relative; }
/* Іконка «?» / «!» впритул до тексту лейбла (flex прибирає пробіл між тегами,
   разом із margin було 7px) і вгорі, як верхній індекс, а не на рівні тексту. */
:is(.coin-options, .nick-options) .switch.has-help label { display: inline-flex; align-items: flex-start; }
:is(.nick-word-row, .nick-main-row) .field.has-help label { display: flex; align-items: flex-start; }
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .has-help label .help-icon { margin-top: -3px; }
.nick-preset-icon > span:not(.tooltip-bubble) { display: inline-flex; }
.nick-preset-icon > span[hidden] { display: none; }
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .help-icon {
  position: relative;
  display: inline-flex;
  vertical-align: 1px;
  margin-inline-start: 1px;
  color: var(--muted);
  opacity: .65;
  cursor: help;
}
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .help-icon:focus-visible { opacity: 1; outline: none; }
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .help-icon .tooltip-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  right: -10px;
  width: max-content;
  max-width: min(240px, 70vw);
  background: var(--ink);
  color: var(--paper);
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  padding: 6px 10px;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
  z-index: 20;
}
/* msgid підказки — фрагмент у нижньому регістрі, як у Slug; велика літера — лише на показі. */
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .help-icon .tooltip-bubble::first-letter { text-transform: uppercase; }
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .help-icon .tooltip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 12px;
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .switch.has-help label:hover .help-icon,
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .switch.has-help label:focus-within .help-icon { opacity: 1; }
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .switch.has-help label:hover .tooltip-bubble,
:is(.coin-options, .nick-options, .nick-word-row, .nick-main-row) .switch.has-help label:focus-within .tooltip-bubble {
  opacity: .95;
  visibility: visible;
  transform: translateY(0);
}

/* Nickname «Your word or name»: підказка на полі (не на перемикачі) — той
   самий показ на наведення чи фокус; бульбашка відкривається вправо, бо
   іконка біля лівого краю картки. */
:is(.nick-word-row, .nick-main-row) .field.has-help label:hover .help-icon,
:is(.nick-word-row, .nick-main-row) .field.has-help label:focus-within .help-icon { opacity: 1; }
:is(.nick-word-row, .nick-main-row) .field.has-help label:hover .tooltip-bubble,
:is(.nick-word-row, .nick-main-row) .field.has-help label:focus-within .tooltip-bubble {
  opacity: .95;
  visibility: visible;
  transform: translateY(0);
}
/* 70vw, не 80: прихована бульбашка «Platform» на телефоні 375px виступала за край
   на 7px — сторінка прокручувалась убік */
:is(.nick-word-row, .nick-main-row) .help-icon .tooltip-bubble { right: auto; left: -10px; max-width: min(300px, 70vw); }
:is(.nick-word-row, .nick-main-row) .help-icon .tooltip-bubble::after { right: auto; left: 12px; }

/* Кнопки */
.actions { display: flex; gap: 10px; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 700; border-radius: 10px; cursor: pointer;
  padding: 13px 30px; border: 1px solid transparent; transition: background .12s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--crimson); color: #fff; font-size: 1.05rem; }
.btn-primary:hover { background: var(--crimson-dark); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); min-width: 54px; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 6px; min-width: auto; }
.btn-lg { padding: 16px 40px; font-size: 1.25rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.meta-line { color: var(--muted); font-size: .85rem; margin-top: 14px; min-height: 1.2em; }
/* До першої генерації рядок часу порожній — у slug і Random Picker (не генерують
   самі) порожні 38px стояли між Generate і розширеними опціями. Ховаємо, поки порожній. */
#tool-root > #meta-box:empty { display: none; }

/* ---------- Картки інструментів ---------- */
.section-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; margin: 38px 0 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 40px; }
.usecase-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 40px; }
/* Входи в категорії на головній: вужча сітка, ніж у карток інструментів —
   це навігаційний рівень, а не каталог (каталог живе на /tools/). */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 12px; }
.cat-all { margin: 0 0 40px; font-size: .9rem; font-weight: 600; }
/* Стрілка живе тут, а не в тексті посилання: у dir="rtl" вона мусить
   дивитися вліво, а символ у шаблоні цього не вміє. */
.cat-all a::after { content: " \2192"; }
[dir="rtl"] .cat-all a::after { content: " \2190"; }
.card-tool, .card-usecase, .card-cat {
  display: block; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink);
  transition: all .2s; height: 100%; box-sizing: border-box;
}
.card-tool:hover, .card-usecase:hover, .card-cat:hover { border-color: var(--crimson); box-shadow: var(--shadow); color: var(--ink); }
.card-icon-wrapper {
  color: var(--crimson);
  transition: color 0.2s ease;
}
.card-tool:hover .card-icon-wrapper,
.card-usecase:hover .card-icon-wrapper,
.card-cat:hover .card-icon-wrapper {
  color: var(--hover-color, var(--crimson));
}
.card-tool h3, .card-usecase h3, .card-cat h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 700; color: var(--crimson); }
.card-tool p, .card-usecase p, .card-cat p { margin: 0; font-size: .88rem; color: var(--muted); }
.card-tool .card-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.chip {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.chip:hover { border-color: var(--crimson); color: var(--crimson); }

.why-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0 0 32px 0;
}
.why-list li {
  position: relative;
  padding-left: 24px;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.5;
}
.why-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--crimson);
  font-weight: bold;
}

/* ---------- Контент ---------- */
.prose { max-width: 72ch; margin: 40px auto 0; }
.prose h2 { font-size: 1.3rem; font-weight: 800; margin: 32px 0 10px; letter-spacing: -0.01em; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-inline-start: 24px; }
.prose li { margin-bottom: 6px; }

.faq { max-width: 72ch; margin: 40px auto 0; }
.faq h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 14px; }
.faq details {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 10px;
}
.faq summary { font-weight: 700; cursor: pointer; list-style-position: inside; }
.faq details[open] summary { color: var(--crimson); margin-bottom: 8px; }
.faq details p { margin: 0 0 8px; color: var(--ink); }

/* Перелінковка під FAQ сторінки інструмента (tools/related.py) */
.related-block { max-width: 72ch; margin: 40px auto 0; }
.related-block h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 14px; }
/* Flex з переносом, а не grid: самотня картка в останньому ряду стає по центру
   (у grid вона липла ліворуч). Ширина картки — частка ширини блоку, як колонки
   grid було: guides 1/2 від 532px, tools 1/2 від 412px і 1/3 від 624px. */
.related-block { container-type: inline-size; }
.related-guides { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.related-guides > * { flex: 0 0 100%; min-width: 0; }
@container (min-width: 532px) { .related-guides > * { flex-basis: calc((100% - 12px) / 2); } }
.related-guides .card-tool { height: auto; }
.related-guides h3 { font-size: 1.02rem; margin: 0 0 6px; }

.grid-cards.related-tools { display: flex; flex-wrap: wrap; justify-content: center; margin-bottom: 0; }
.related-tools > * { flex: 0 0 100%; min-width: 0; }
@container (min-width: 412px) { .related-tools > * { flex-basis: calc((100% - 16px) / 2); } }
@container (min-width: 624px) { .related-tools > * { flex-basis: calc((100% - 32px) / 3); } }
.ticket.is-reroll { cursor: pointer; }  /* RNG: одне число — ще раз кліком (gen-runtime.js) */

/* Сторінки помилок (404, 500) */
.error-page { max-width: 72ch; margin: 48px auto 0; text-align: center; }
.error-page .error-code { font-size: 4rem; font-weight: 800; color: var(--crimson); line-height: 1; margin: 0 0 8px; }
.error-page h1 { margin: 0 0 12px; }
.error-page p { color: var(--ink); margin: 0 0 24px; }
.error-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 40px; }
.error-actions a {
  display: inline-block; padding: 10px 18px; border-radius: 10px; font-weight: 700;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none;
}
.error-actions a.primary { background: var(--crimson); border-color: var(--crimson); color: #fff; }
.error-tools { max-width: 1100px; margin: 0 auto; }

.crumbs { 
    font-size: .95rem; 
    color: var(--muted); 
    margin-top: 16px;
    margin-bottom: 24px; 
    font-weight: 500;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.crumbs a { 
    color: var(--muted); 
    text-decoration: none;
    transition: color 0.2s ease;
}
.crumbs a:hover { color: var(--crimson); }

.page-title { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 20px; }
.article-meta { margin: -10px 0 22px; font-size: .88rem; color: var(--muted); }
.article-meta a { color: inherit; }

/* ---------- Футер ---------- */
.site-footer {
  background: var(--paper); border-top: 1px solid var(--line);
  margin-top: auto; padding: 36px 0 26px; font-size: .92rem;
  /* Anchor-реклама AdSense додає сторінці відступ знизу на свою висоту — тінь
     фарбує його кольором футера, інакше футер «відривається» від низу екрана */
  box-shadow: 0 100vh 0 100vh var(--paper);
}
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.footer-cols h2 {
  margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li { margin-bottom: 7px; }
.footer-cols a { color: var(--ink); text-decoration: none; }
.footer-cols a:hover { color: var(--crimson); }
.footer-cols h2 a { color: inherit; }
.footer-base {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--muted); font-size: .85rem;
}

/* ---------- Адаптив і доступність ---------- */
@media (max-width: 560px) {
  .site-header .container { justify-content: center; }
  .actions .btn-primary { flex: 1; }
  .ticket { padding: 20px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Компактна шапка (.nav-compact ставить скрипт у base.html, коли пункти меню
   не вміщуються в один рядок): іконки замість «All tools» і «Guides» */
.site-nav .nav-ico { display: none; }
.nav-compact .site-nav .nav-ico { display: block; }
.nav-compact .site-nav .nav-text { display: none; }
.nav-compact .tools-switch summary { display: inline-flex; align-items: center; padding: 8px 12px; }
.nav-compact .site-nav > a.nav-guides {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
}
.nav-compact .site-nav > a.nav-guides:hover { border-color: var(--crimson); }

/* Панелі «Усі інструменти» й мов відкриваються від краю шапки, а не від своєї
   кнопки: прив'язані до кнопки (вона не в куті), на телефоні й у вузькому вікні
   вони вилазили за лівий край екрана — частину пунктів не було видно. */
.site-header .container { position: relative; }

/* ---------- Перемикач мов ---------- */
.lang-switch { position: static; }
.lang-switch summary {
  list-style: none; cursor: pointer; font-weight: 600; font-size: .9rem;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; user-select: none;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary:hover { border-color: var(--crimson); color: var(--crimson); }
.lang-switch[open] summary { border-color: var(--crimson); }

.lang-panel {
  position: absolute; inset-inline-end: 20px; top: calc(100% + 8px); z-index: 50;
  width: min(760px, calc(100% - 40px)); max-height: 85vh; overflow-y: auto;
  padding: 12px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
}
/* Колонки — в окремій обгортці: прокручується панель (max-height), а колонки
   мають природну висоту. Багатоколонкова верстка прямо в панелі з межею висоти
   виносила зайві колонки праворуч за край — на телефоні частини мов не було. */
.lang-cols { display: flex; gap: 0 8px; }
.lang-column { flex: 1 1 0; min-width: 0; }
.lang-group { min-width: 0; margin-bottom: 4px; }
.lang-group-label {
  margin: 0 0 2px; padding: 0 7px; font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
.lang-group ul { margin: 0; padding: 0; list-style: none; }
a.lang-item {
  display: flex; align-items: center; gap: 5px; padding: 3px 7px;
  border-radius: 6px; text-decoration: none; color: var(--ink); font-size: .7rem;
  border-bottom: none; min-width: 0;
}
a.lang-item:hover { background: var(--bg); color: var(--crimson); }
.lang-item.is-active { font-weight: 700; color: var(--crimson); background: var(--bg); }
.lang-item.is-disabled { color: var(--muted); cursor: not-allowed; opacity: .65; }
.lang-flag {
  width: 15px; height: 11px; object-fit: cover; border-radius: 2px;
  box-shadow: 0 0 0 1px var(--line); flex: none; background: var(--bg);
}
.lang-item.is-disabled .lang-flag { filter: grayscale(1); }
.lang-native { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lang-badge {
  margin-inline-start: auto; padding: 1px 5px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  flex: none;
}
/* Телефон: групи мов у дві колонки (одна колонка займала ліву половину панелі) */
@media (max-width: 560px) {
  .lang-panel { inset-inline-end: 12px; width: calc(100% - 24px); }
  .lang-cols { display: block; columns: 2; column-gap: 8px; }
  .lang-column { display: contents; }
  .lang-group { break-inside: avoid; }
}


/* ---------- Перемикач інструментів ---------- */
.tools-switch { position: static; }
.tools-switch summary {
  list-style: none; cursor: pointer; font-weight: 600; font-size: .9rem;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; user-select: none;
}
.tools-switch summary::-webkit-details-marker { display: none; }
.tools-switch summary:hover { border-color: var(--crimson); color: var(--crimson); }
.tools-switch[open] summary { border-color: var(--crimson); }

.tools-panel {
  position: absolute; inset-inline-end: 20px; top: calc(100% + 8px); z-index: 50;
  width: min(760px, calc(100% - 40px)); max-height: 85vh; overflow-y: auto;
  padding: 12px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px 0;
}
.tools-column { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tools-group { min-width: 0; }
.tools-group-label {
  margin: 0 0 6px; padding: 0 7px; font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
.tools-group ul { margin: 0; padding: 0; list-style: none; }
a.tool-item {
  display: flex; align-items: center; padding: 4px 7px;
  border-radius: 6px; text-decoration: none; color: var(--ink); font-size: .85rem; font-weight: 500;
  border-bottom: none;
}
a.tool-item .tool-ico {
  color: var(--crimson);
  transition: color 0.2s ease;
}
a.tool-item:hover { background: var(--bg); color: var(--crimson); }
a.tool-item:hover .tool-ico {
  color: var(--hover-color, var(--crimson));
}
@media (max-width: 560px) {
  .tools-panel { inset-inline-end: 12px; width: calc(100% - 24px); }
}

/* ---------- Перемикач теми ---------- */
.theme-toggle {
  font: inherit; cursor: pointer; line-height: 1;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { border-color: var(--crimson); color: var(--crimson); }
.theme-toggle .ico-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
html[data-theme="dark"] .theme-toggle .ico-moon { display: none; }

/* ---------- SVG-логотип і прапор ---------- */
.logo svg { display: block; height: 26px; width: auto; }
.logo .wm-num { fill: var(--crimson); }
.logo .wm-gener { fill: var(--ink); }
.flag-ua { display: inline-block; width: 18px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-inline-start: 6px; }


/* Паролі та довгі рядки у квитку */
.ticket.is-text { font-size: clamp(1.05rem, 3vw, 1.5rem); letter-spacing: .02em; }
.controls-checks { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.controls-checks .switch { padding-top: 0; }


/* Кольорові свотчі та textarea списків */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.swatches.is-single { justify-content: center; padding: 4px 0; }
.swatch {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-num); font-size: 1rem; font-weight: 600;
  padding: 6px 14px 6px 8px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); box-shadow: var(--shadow);
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.swatch i {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); flex-shrink: 0;
  cursor: pointer; position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.swatch i:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--accent);
}
.swatches.is-single .swatch {
  font-size: 1.35rem; padding: 10px 20px 10px 12px; gap: 12px;
}
.swatches.is-single .swatch i {
  width: 36px; height: 36px;
}
.swatches.is-single .swatch.is-all-formats {
  font-size: clamp(0.75rem, 2.1vw, 0.95rem);
  padding: 6px 14px 6px 8px;
  gap: 8px;
  white-space: nowrap;
  flex-wrap: nowrap;
}
.swatches.is-single .swatch.is-all-formats i {
  width: 28px;
  height: 28px;
}
.swatches-list {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; align-items: center;
}
.color-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 2px 0;
}
.color-row-num {
  color: var(--muted); font-family: var(--font-num); font-size: 0.85rem;
  font-weight: 500; white-space: nowrap; flex-shrink: 0;
  width: 28px; text-align: right;
}
.color-row .swatch {
  font-size: 0.95rem;
  padding: 5px 14px 5px 8px;
  gap: 10px;
  box-sizing: border-box;
  flex-shrink: 0;
}
.color-row .swatch i {
  width: 24px;
  height: 24px;
}
.color-row .swatch.is-all-formats {
  font-size: clamp(0.72rem, 1.8vw, 0.84rem);
  padding: 4px 10px 4px 6px;
  gap: 6px;
  white-space: nowrap;
  flex-wrap: nowrap;
}
.color-row .swatch.is-all-formats i {
  width: 20px;
  height: 20px;
}
.color-row-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: none; border-radius: 6px;
  color: var(--ink); opacity: 0.45; cursor: pointer;
  font-size: 1.05rem; flex-shrink: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.color-row-btn:hover {
  opacity: 0.9;
  background: var(--paper);
}
/* Бейдж контрасту: «Aa 7.2:1» кольором кращого тексту на фоні цього кольору. */
.swatch-contrast {
  display: inline-flex; align-items: center;
  font-family: var(--font-num); font-size: .72em; font-weight: 700;
  line-height: 1; padding: 3px 7px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap; cursor: help;
  flex-shrink: 0;
}
.swatch-val {
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}
/* Телефон: з двома-трьома кодами «пілюля» кольору — один рядок без переносів
   (nowrap, частково інлайном з gen-runtime.js) — була ширшою за квиток: 402px на
   293, коди вилазили за поля. Тут вона переноситься: коди по рядках, пілюля стає
   заокругленим прямокутником; окремий код («rgb(225, 114, 70)») не розривається. */
@media (max-width: 560px) {
  .swatches .swatch, .color-row .swatch {
    flex-wrap: wrap !important; white-space: normal !important;
    justify-content: center; row-gap: 4px; max-width: 100%; min-width: 0;
    border-radius: 18px;
  }
  .color-row .swatch { flex-shrink: 1; }
  .swatches .swatch > span, .color-row .swatch > span { white-space: nowrap; }
}
.swatch-val:hover {
  color: var(--accent);
}
.field textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); resize: vertical;
}
.field textarea:focus { border-color: var(--crimson); outline: none; box-shadow: 0 0 0 3px rgba(214,41,58,.15); }
.field-wide { grid-column: 1 / -1; }

@keyframes result-flash {
  0% { transform: scale(0.98); background-color: rgba(214, 41, 58, 0.2); }
  50% { transform: scale(1.01); background-color: rgba(214, 41, 58, 0.1); }
  100% { transform: scale(1); background-color: var(--ticket-bg); }
}
.flash-animation {
  animation: result-flash 0.4s ease-out;
}

.tool-ico { vertical-align: -3px; margin-right: 6px; flex: 0 0 auto; }

/* Guide Hubs Styles */
.guides-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.guide-card {
    display: flex;
    flex-direction: column;
}

.guide-card-meta {
    margin-top: auto;
    font-size: 0.9em;
    color: var(--muted);
    font-weight: 500;
    padding-top: 12px;
}

.guide-card-draft {
    opacity: 0.6;
    cursor: default;
}
.guide-card-draft:hover {
    border-color: var(--border);
    box-shadow: none;
    color: inherit;
}
.guide-card-draft h3 {
    color: inherit;
}

.guide-article-prose {
    margin-top: 0;
    margin-bottom: 32px;
}

/* Хаб гайдів: навігація одразу під вступом — статті ліворуч, інструмент і
   сусідні інструменти праворуч; довгий текст іде вже після неї. */
.hub-lead { margin-bottom: 24px; }
.hub-lead p { max-width: 72ch; margin: 0; font-size: 1.05rem; }
/* Текст хабу тримає лівий край навігації над ним, а не центр сторінки. */
.hub-body { margin-inline: 0; margin-top: 0; }
.hub-body > h2:first-child { margin-top: 0; }
.hub-nav {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 36px;
}
.hub-nav--solo { grid-template-columns: 1fr; }
.hub-nav-title {
    margin: 0 0 12px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.hub-articles { display: grid; gap: 12px; }
.hub-article { height: auto; }
.hub-article h3 { font-size: 1.05rem; }
.hub-nav-side { display: grid; gap: 20px; }
.hub-tool { height: auto; display: flex; flex-direction: column; gap: 10px; }
.hub-tool h3 { margin: 0; }
.hub-tool-btn {
    align-self: flex-start;
    padding: 9px 18px;
    background: var(--crimson);
    color: #fff;
    font-weight: 600;
    font-size: .92rem;
    border-radius: 8px;
    transition: background .2s;
}
.hub-tool:hover .hub-tool-btn { background: var(--crimson-dark); }
.hub-related .chip-row { margin-bottom: 0; }
.hub-nav--solo .hub-nav-side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) {
    .hub-nav, .hub-nav--solo .hub-nav-side { grid-template-columns: 1fr; }
}

.guide-cta-section {
    margin-top: 32px;
}
.guide-cta-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--crimson);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
}


/* Scroll to top */
.scroll-to-top {
  position: fixed;
  bottom: calc(24px + var(--ad-anchor, 0px)); /* над anchor-рекламою, base.html */
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, color 0.2s ease, border-color 0.2s ease;
  z-index: 100;
  padding: 0;
}
.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-to-top:hover {
  color: var(--crimson);
  border-color: var(--crimson);
}
@media (max-width: 768px) {
  .scroll-to-top {
    bottom: calc(16px + var(--ad-anchor, 0px));
    right: 16px;
    width: 44px;
    height: 44px;
  }
}

/* 3D Coin Flip styles */
.coin-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  /* Малий відступ, щоб кнопка Generate лишалася на екрані. У польоті монета
     ненадовго виходить за верхній край тікета — у межах відступу над ним. */
  padding: 10px 0 6px;
  width: 100%;
}
/* Не більше трьох у ряд: 12 монет = 4 ряди по 3 (MAX_COINS у coin_engine.py). */
.coin-list {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
  align-items: center;
  max-width: calc(3 * 120px + 2 * 24px);
}
.coin-list.is-clickable { cursor: pointer; }
/* Кілька монет: під кожною — слово її сторони (gen-runtime.js, .coin-side).
   Підпис сам відділяє ряди, тож проміжок між рядами менший. */
.coin-list.has-sides { row-gap: 10px; }
.coin-cell { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.coin-side {
  max-width: 100%;
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}
.coin-list--many { gap: 20px; max-width: calc(3 * 96px + 2 * 20px); }
.coin-list--many .coin-wrapper { width: 96px; height: 96px; }
.coin-list--many .coin-label { font-size: .9rem; }
.coin-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  perspective: 1000px;
}
.coin-shadow {
  position: absolute;
  bottom: -12px;
  left: 10%;
  width: 80%;
  height: 14px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 75%);
  border-radius: 50%;
  filter: blur(2.5px);
  pointer-events: none;
}
.coin-toss {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}
.coin-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  border-radius: 50%;
  will-change: transform;
}
/* Ребро: 8 шарів по 1px між сторонами (COIN_EDGE_PX у gen-runtime.js).
   Колір для фото береться з краю зображення, для простої монети — золото. */
.coin-edge {
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: var(--coin-edge, #b45309);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
  border: 3px solid #d97706;
  background: radial-gradient(circle at 35% 35%, #fff1a8 0%, #f59e0b 55%, #b45309 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -2px 6px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(180, 83, 9, 0.3);
  color: #78350f;
  user-select: none;
  padding: 4px;
}
.coin-face-inner {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 2px dashed rgba(120, 53, 15, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.coin-face.front {
  transform: translateZ(4px);
}
/* rotateX, не rotateY: монета перекидається через горизонтальну вісь,
   і зворотна сторона після перевороту стоїть догори правильно. */
.coin-face.back {
  transform: rotateX(180deg) translateZ(4px);
}
.coin-face.coin-photo {
  border: none;
  background: #e2e8f0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  padding: 0;
}
[data-theme="dark"] .coin-face.coin-photo {
  background: #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}
.coin-face.coin-photo .coin-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  pointer-events: none;
  object-fit: contain;
}
.coin-label {
  max-width: 100%;
  font-size: 1.05rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #78350f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.coin-summary {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-num);
  padding: 8px 22px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.coin-caption {
  margin-top: -6px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.coin-tally {
  max-width: 46ch;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .85rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

@keyframes coin-summary-reveal {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 3D Dice Roller: геометрію й політ задає gen-runtime.js (makeDie, rollDie).
   --s — ребро кубика, --die — його колір, --pip — колір очок і цифр. */
.dice-stage {
  width: 100%;
  padding: 4px 0;
  display: flex;
  justify-content: center;
  /* Кубик влітає збоку — ховаємо його за краєм тікета, а не за краєм екрана
     (інакше на телефоні з'являється горизонтальна прокрутка). Угору — видно. */
  overflow-x: clip;
}
.dice-list { display: flex; flex-wrap: wrap; justify-content: center; }
/* WebGL: одне полотно на весь кидок поверх порожніх комірок (dice-3d.js,
   renderDice). Виступає вгору й униз — там політ і тіні; збоку його
   обрізає overflow-x у .dice-stage. */
.dice-stage.is-gl { position: relative; }
.dice-gl {
  position: absolute;
  left: 0;
  top: calc(-1 * var(--gl-top));
  width: 100%;
  height: calc(100% + var(--gl-top) + var(--gl-bottom));
  pointer-events: none;
}
.dice-list.is-clickable { cursor: pointer; }
.die-cell {
  position: relative;
  width: calc(var(--s) * 1.6);
  height: calc(var(--s) * 1.6);
  perspective: calc(var(--s) * 10);
}
.die-scene {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
}
.die {
  position: absolute;
  left: calc(var(--s) / -2);
  top: calc(var(--s) / -2);
  width: var(--s);
  height: var(--s);
  transform-style: preserve-3d;
  will-change: transform;
}
/* Грані й внутрішній куб розставляє makeDie(). */
.die-face, .die-inner, .die-vertex {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}
/* Заокруглення — DIE_RADIUS у gen-runtime.js: під нього рахується внутрішній куб. */
.die-face {
  border-radius: 18%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 60%),
    var(--die);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.1),
    inset 0 calc(var(--s) * -0.04) calc(var(--s) * 0.12) rgba(0, 0, 0, 0.2),
    inset 0 calc(var(--s) * 0.03) calc(var(--s) * 0.06) rgba(255, 255, 255, 0.25);
}
/* Латки вершин: трохи темніші — стик трьох граней, що звертає від світла. */
.die-inner { background: var(--die); }
.die-vertex { inset: auto; background: color-mix(in srgb, var(--die) 90%, #000); }
.die-shade {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
.die-pips {
  position: absolute;
  inset: 13%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}
.die-pip {
  width: 74%;
  height: 74%;
  margin: auto;
  border-radius: 50%;
  background: var(--pip);
  box-shadow: inset 0 calc(var(--s) * 0.025) calc(var(--s) * 0.035) rgba(0, 0, 0, 0.45);
}
.die-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-weight: 800;
  line-height: 1;
  color: var(--pip);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  user-select: none;
}
.die-num.is-flippable {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.1em;
}
.die-shadow {
  position: absolute;
  left: calc(var(--s) * -0.6);
  top: calc(var(--s) * -0.6);
  width: calc(var(--s) * 1.2);
  height: calc(var(--s) * 1.2);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.28) 55%, rgba(0, 0, 0, 0));
  pointer-events: none;
}

/* Підказка на дотик для позначок із поясненням лише в title (base.html, data-tap-tip) */
.tap-tip {
  position: absolute; z-index: 60; pointer-events: none;
  max-width: min(280px, calc(100vw - 16px));
  background: var(--ink); color: var(--paper); font-size: .75rem; line-height: 1.35;
  padding: 6px 10px; border-radius: 6px; box-shadow: var(--shadow);
}

/* Бульбашку підказки, зсунуту в межі екрана (base.html, fitTip), стрілка не
   наслідує — лишається над «?» */
.tooltip-bubble::after { translate: calc(-1 * var(--tip-shift, 0px)) 0; }
/* Телефон: у формах slug, random, picker підказка в один рядок (nowrap) — довгий
   текст робив бульбашку ширшою за екран (460px на 375), і браузер розширював під
   неї сторінку. Тут переноситься й не ширша за екран; на ПК — як було. */
@media (max-width: 560px) {
  .tooltip-bubble {
    white-space: normal !important; width: max-content;
    max-width: min(280px, calc(100vw - 24px)) !important;
  }
}

/* --- Власні рекламні блоки (SiteSettings.manual_ads; partials/ad_slot.html) --- */
/* min-height тримає місце, поки оголошення вантажиться, — сторінка не стрибає (CLS) */
.ad-slot { max-width: 72ch; min-height: 280px; margin: 40px auto 0; }
.prose .ad-slot { margin: 28px auto; }
/* Google не знайшов оголошення — порожньої діри не лишаємо */
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
@media (max-width: 480px) { .ad-slot { min-height: 250px; } }

/* --- Банер згоди на cookies (partials/consent_banner.html) --- */
/* Правий нижній кут — фізично, і в RTL теж (так вирішено). Кнопку «вгору»
   в тому ж куті банер на час показу просто перекриває. */
.consent {
  position: fixed; right: 24px; bottom: calc(24px + var(--ad-anchor, 0px)); z-index: 1000;
  width: min(400px, calc(100vw - 48px));
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.consent[hidden] { display: none; }
.consent-inner { padding: 18px 20px; }
.consent-title { margin: 0 0 6px; font-size: 1.05rem; }
.consent-text { margin: 0 0 12px; font-size: .92rem; color: var(--muted); line-height: 1.5; }
.consent-text a { color: var(--crimson); }
.consent-options { display: grid; gap: 10px; margin: 0 0 14px; }
.consent-options[hidden] { display: none; }
.consent-option { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; line-height: 1.45; }
.consent-option input { margin-top: 3px; accent-color: var(--crimson); flex: none; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-actions .btn { flex: 1 1 auto; }
.consent-actions .btn[hidden] { display: none; }
/* Accept виділяється, бо Reject/Customise трохи приглушені — але лише
   трохи: сильно слабша «відмова» — це вже nudging, за який CNIL штрафує.
   .62 — межа: нижче (.55) текст у світлій темі падає під WCAG AA 4.5:1. */
.consent-actions [data-consent-action="reject"],
.consent-actions [data-consent-action="customise"] { opacity: .62; }
.consent-actions [data-consent-action="reject"]:hover,
.consent-actions [data-consent-action="customise"]:hover,
.consent-actions [data-consent-action="reject"]:focus-visible,
.consent-actions [data-consent-action="customise"]:focus-visible { opacity: 1; }
@media (max-width: 480px) {
  .consent { right: 8px; bottom: calc(8px + var(--ad-anchor, 0px)); width: calc(100vw - 16px); }
  .consent-inner { padding: 14px 16px; }
}
.footer-linkbtn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--ink);
  cursor: pointer; text-align: start;
}
.footer-linkbtn:hover { color: var(--crimson); }
