/* ============================================================
   Panel — single design system for all tabs.
   Casino palette: deep violet felt, gold, cream.
   Technical comments in English, UI text in Russian only.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --bg: #160a2e;
  --card: rgba(255, 255, 255, 0.05);
  --card-2: rgba(255, 255, 255, 0.08);
  --line: rgba(240, 196, 90, 0.22);
  --text: #f7f0dd;
  --muted: #c0b4d8;
  --gold: #f0c45a;
  --gold-2: #ffe9a8;
  --gold-deep: #d4a017;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --red: #d33a4e;
  --radius: 20px;
  --display: "Cinzel", Georgia, "Times New Roman", serif;
  --body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(139, 92, 246, 0.38), transparent 62%),
    radial-gradient(1000px 760px at 92% 112%, rgba(236, 72, 153, 0.26), transparent 58%),
    radial-gradient(760px 560px at 60% 50%, rgba(240, 196, 91, 0.10), transparent 65%),
    linear-gradient(160deg, #1c0f3a 0%, #160a2e 48%, #0f0721 100%);
  background-attachment: fixed;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(22, 10, 46, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-in {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-deep));
  box-shadow: 0 0 26px rgba(240, 196, 91, 0.45);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px solid rgba(22, 10, 46, 0.6);
  border-radius: 6px;
  transform: rotate(45deg);
}
.brand-name {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(120deg, #fff3c4, var(--gold) 45%, var(--gold-deep) 75%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 6px;
  margin: -6px;
  scroll-padding-inline: 6px;
}
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 860px) {
  .tabs {
    --fade-l: 18px;
    --fade-r: 18px;
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  }
  .tabs.at-start { --fade-l: 0px; }
  .tabs.at-end { --fade-r: 0px; }
  .tabs.at-start.at-end { mask-image: none; -webkit-mask-image: none; }
}
.tab {
  flex: 0 0 auto;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}
.tab:hover { color: var(--text); background: rgba(240, 196, 91, 0.10); }
.tab.is-active {
  color: #241654;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 6px 22px rgba(240, 196, 91, 0.35);
}

/* ---------- Focus and skip link ---------- */
:where(a, button, input, textarea, select, [tabindex]):focus { outline: none; }
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 3px;
}
.key:focus-visible { outline-offset: 2px; }
.page:focus { outline: none; }
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--gold);
  color: #241654;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 90px;
}
.panel { display: none; animation: fade 0.35s ease; }
.panel.is-active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }

/* ---------- Clock tab ---------- */
.hero {
  text-align: center;
  padding: 44px 24px;
  margin-bottom: 16px;
  background:
    linear-gradient(180deg, rgba(240, 196, 91, 0.12), transparent 72%),
    var(--card);
}
.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
}
.hero-screen {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 8px;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 55%, rgba(8, 4, 20, 0.55), rgba(8, 4, 20, 0) 72%);
}
.hero-screen .seg-wrap {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.hero-screen .seg-wrap.is-on { display: flex; }
.hero-screen .seg-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 4px rgba(240, 196, 90, 0.30));
}
.hero-time.is-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.hero-time {
  font-family: var(--display);
  font-size: clamp(52px, 9vw, 96px);
  font-weight: 700;
  line-height: 1.05;
  margin: 14px 0 8px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, #fff3c4, var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-date { color: var(--muted); font-size: 17px; }

.clocks { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.clock { display: flex; flex-direction: column; }
.clock-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}
.clock-city {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clock-meta { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.clock-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(240, 196, 91, 0.6);
  flex: 0 0 auto;
}
.clock-icon.is-night {
  background: #b9a6ff;
  box-shadow: 0 0 10px rgba(185, 166, 255, 0.5);
}
.clock-gmt { font-size: 12px; color: var(--muted); }
.clock-time {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 700;
  margin: 8px 0 2px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.clock-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.clock-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Calculator tab ---------- */
.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  max-width: 1000px;
  margin: 0 auto;
}
.calc { width: 100%; padding: 28px; }
.calc-display {
  background: rgba(10, 5, 24, 0.55);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px 10px;
  margin-bottom: 16px;
}
.calc-expr {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.4;
  text-align: right;
  min-height: 24px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.calc-expr::-webkit-scrollbar { display: none; }
.calc-expr:focus { outline: none; }
.calc-screen {
  position: relative;
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 4px;
}
.seg-wrap {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: flex-end;
}
.seg-wrap.is-on { display: flex; }
.seg-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 3px rgba(240, 196, 90, 0.30));
}
.calc-result {
  font-family: var(--display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calc-result.is-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.key {
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 23px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 0;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.key:hover { border-color: rgba(240, 196, 90, 0.7); transform: translateY(-1px); }
.key:active { transform: translateY(0); }
.key-op { color: var(--gold); }
.key-fn { color: var(--muted); }
.key-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.key-eq {
  grid-column: span 3;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-deep));
  color: #241654;
  border: none;
  font-size: 26px;
  box-shadow: 0 5px 16px rgba(212, 160, 23, 0.35);
}
.hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 16px 0 0;
}

/* ---------- Calculator history ---------- */
.history {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.history-head h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin: 0;
}
.history-clear {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.history-clear:hover { color: var(--text); border-color: rgba(240, 196, 90, 0.6); }
.history-clear:disabled { opacity: 0.35; cursor: default; }
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 196, 91, 0.35) transparent;
}
.history-entry {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  width: 100%;
  font: inherit;
  text-align: right;
  color: var(--text);
  background: rgba(10, 5, 24, 0.35);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.history-entry:hover {
  border-color: rgba(240, 196, 90, 0.6);
  background: rgba(240, 196, 91, 0.07);
}
.history-expr {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-result {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--gold);
}
.history-empty {
  margin: auto;
  padding: 40px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.history-note {
  margin: 14px 0 0;
  padding-top: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Generators tab ---------- */
.gens {
  grid-template-columns: minmax(0, 1fr);
}
.gen { display: flex; flex-direction: column; }
.gen h3 { margin: 0 0 6px; font-family: var(--display); font-size: 22px; color: var(--gold); }
.gen .muted { font-size: 14px; margin: 0 0 14px; }
.gen .btn { margin-top: auto; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
input[type="number"] {
  width: 78px;
  flex: 0 0 auto;
  font: inherit;
  color: var(--text);
  background: rgba(10, 5, 24, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
input[type="number"]:focus { border-color: var(--gold); }
input[type="number"]:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 1px; }

.gen-out {
  background: rgba(10, 5, 24, 0.45);
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  font-family: var(--display);
  font-size: 52px;
  font-weight: 700;
  color: var(--gold);
  padding: 18px;
  margin-bottom: 14px;
  min-height: 96px;
}
.gen-out.pop span { display: inline-block; animation: pop 0.3s ease; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0.2; }
  100% { transform: scale(1); opacity: 1; }
}

.btn {
  font: inherit;
  font-weight: 700;
  color: #241654;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-deep));
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 5px 16px rgba(212, 160, 23, 0.30);
  transition: filter 0.2s, transform 0.1s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.98); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip.is-on {
  color: #241654;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  border-color: transparent;
  font-weight: 700;
}
.chips-out {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 44px;
  margin-bottom: 14px;
}
.chips-out:empty {
  min-height: 96px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
}
.chips-out:empty::before {
  content: "Числа появятся здесь";
  color: var(--muted);
  font-size: 14px;
}
.chip-num {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  animation: pop 0.3s ease;
}

.coin {
  width: 130px;
  height: 130px;
  margin: 6px auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  color: #241654;
  background: conic-gradient(from 210deg, #ffe9a8, #f0c45a 30%, #8a6d2b 55%, #ffe9a8 80%, #f0c45a);
  box-shadow: 0 12px 30px rgba(240, 196, 91, 0.35);
}
.coin.flip { animation: flip 0.6s ease; }
@keyframes flip {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(720deg); }
}

.color-out {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  padding: 8px;
  transition: background 0.25s;
}
.color-out.red { background: #d33a4e; }
.color-out.white { background: #f7f0dd; color: #241654; }
.color-out.black { background: #1b1a24; border-color: #3a3850; }

/* ---------- Games catalog ---------- */
.catalog-head, .reading-head { text-align:center; margin-bottom: 26px; }
.catalog-title, .reading-title {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #fff3c4, var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.catalog-head .muted, .reading-head .muted { max-width: 520px; margin: 0 auto; }

.catalog {
  grid-template-columns: repeat(auto-fit, minmax(260px, 310px));
  justify-content: center;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.tile:hover {
  transform: translateY(-6px);
  border-color: rgba(240, 196, 90, 0.65);
  box-shadow: 0 18px 40px rgba(139, 92, 246, 0.28), 0 0 0 1px rgba(240, 196, 90, 0.35);
}
.tile-img {
  display: block;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  background: #1b0f38;
}
.tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 300;
  color: rgba(240, 196, 90, 0.55);
}
.tile-empty .tile-img {
  border-style: dashed;
  background: rgba(240, 196, 90, 0.04);
}
.tile-body { display: flex; flex-direction: column; gap: 4px; }
.tile-name { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--gold); }
.tile-tag { color: var(--muted); font-size: 13px; }
.tile-go { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--gold-2); letter-spacing: 0.04em; }
.tile-empty { cursor: default; }
.tile-empty:hover { transform: none; border-color: var(--line); box-shadow: none; }
.tile-empty .tile-name { color: var(--muted); }

/* ---------- Reading shelf ---------- */
.shelf {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  max-width: 1040px;
  margin: 0 auto;
}
.story {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: 16px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.story:hover {
  transform: translateY(-5px);
  border-color: rgba(240, 196, 90, 0.6);
  box-shadow: 0 18px 40px rgba(139, 92, 246, 0.22), 0 0 0 1px rgba(240, 196, 90, 0.3);
}
.story-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.story-cover::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(240, 196, 90, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 0 12px rgba(240, 196, 90, 0.04);
}
.story-violet {
  background:
    radial-gradient(circle at 30% 22%, rgba(139, 92, 246, 0.55), transparent 62%),
    linear-gradient(150deg, #2b1957, #160a2e);
}
.story-rose {
  background:
    radial-gradient(circle at 70% 20%, rgba(236, 72, 153, 0.42), transparent 62%),
    linear-gradient(150deg, #39153b, #160a2e);
}
.story-gold {
  background:
    radial-gradient(circle at 50% 16%, rgba(240, 196, 90, 0.34), transparent 62%),
    linear-gradient(150deg, #2c2150, #160a2e);
}
.story-suit {
  position: relative;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 64px;
  line-height: 1;
  color: #ffe9a8;
  text-shadow: 0 0 28px rgba(240, 196, 91, 0.45);
}
.story-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.story-title {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gold);
}
.story-tag { font-size: 13px; color: var(--muted); }
.story-state {
  margin-top: auto;
  padding-top: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-2);
}
.story-bar {
  display: block;
  height: 3px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(240, 196, 90, 0.12);
  overflow: hidden;
}
.story-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-2));
  transition: width 0.3s ease;
}

/* ---------- Reading overlay ---------- */
body.reader-open { overflow: hidden; }
.reader {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 4, 18, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.reader.is-open { display: flex; animation: fade 0.2s ease; }
.reader-panel {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  height: min(880px, 92dvh);
  background: linear-gradient(160deg, #241654, #120b29);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.reader-head { flex: 0 0 auto; padding: 14px 20px 0; }
.reader-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.reader-percent {
  margin-right: auto;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.reader-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.reader-tool:hover {
  color: var(--text);
  background: rgba(240, 196, 90, 0.1);
  border-color: rgba(240, 196, 90, 0.6);
}
.reader-close { font-size: 22px; line-height: 1; color: var(--text); }
.reader-tool:disabled { opacity: 0.35; cursor: default; }
.reader-tool:disabled:hover {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}
.reader-track {
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.reader-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-2));
  box-shadow: 0 0 12px rgba(240, 196, 90, 0.6);
  transition: width 0.15s linear;
}
.reader-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 34px 32px 64px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 196, 91, 0.35) transparent;
}
.reader-scroll:focus-visible { outline: 2px solid var(--gold-2); outline-offset: -2px; }
.reader-body { max-width: 620px; margin: 0 auto; }
.reader-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.reader-title {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.15;
  color: var(--gold);
  margin: 0 0 22px;
}
.reader-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--reader-size, 18px);
  line-height: 1.75;
  color: #f3ead2;
}
.reader-text p { margin: 0 0 1em; }
.reader-text p:first-of-type::first-letter {
  float: left;
  padding: 0.06em 0.1em 0 0;
  font-family: var(--display);
  font-size: 3.4em;
  line-height: 0.8;
  color: var(--gold);
}
.reader-end {
  margin: 40px 0 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.reader-end::before {
  content: "";
  display: block;
  width: 48px;
  height: 1px;
  margin: 0 auto 14px;
  background: var(--line);
}

/* ---------- Reading (empty) ---------- */
.empty { text-align: center; padding: 70px 24px; }
.empty-icon {
  font-size: 64px;
  color: var(--gold);
  margin-bottom: 14px;
  animation: float 3.5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.empty h3 { font-family: var(--display); font-size: 26px; margin: 0 0 8px; color: var(--gold); }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto; }

/* ---------- Footer ---------- */
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.footer-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--gold-2); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

/* ---------- Responsive ---------- */
@media (min-width: 720px) {
  .gens { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .header-in {
    padding: 10px 16px;
    gap: 12px;
    justify-content: flex-start;
  }
  .brand-name { display: none; }
  .tabs { flex: 1; }
}

@media (max-width: 940px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 540px;
  }
  .history { min-height: 200px; }
  .history-list { max-height: 320px; }
}

@media (max-width: 640px) {
  .page { padding: 28px 16px 72px; }
  .hero { padding: 34px 18px; }
  .hero-time { font-size: 56px; }
  .calc { padding: 20px; }
  .calc-screen { height: 96px; }
  .calc-result { font-size: 34px; }
  .key { padding: 13px 0; font-size: 21px; }
  .history { padding: 16px; }
  .history-list { max-height: 260px; }
  .catalog { grid-template-columns: minmax(0, 1fr); }
  .reader { padding: 0; }
  .reader-panel { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .reader-head { padding: 12px 16px 0; }
  .reader-scroll { padding: 26px 20px 50px; }
  .reader-tool { width: 34px; height: 34px; }
}

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