:root {
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --accent: #e6a93c;
  --radius-card: 15px;
  --radius-pill: 999px;
  --max-w: 480px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tg-vh: 100dvh; /* вне Telegram остаётся обычный 100dvh */
}

[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: #141418;
  --surface2: #1b1b20;
  --text: #f1f0ea;
  --muted: #94949c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --accent: #e6a93c;
  --accent-soft: rgba(230, 169, 60, 0.16);
  --good: #54c08a;
  --good-soft: rgba(84, 192, 138, 0.15);
  --topbar: rgba(11, 11, 13, 0.72);
  --tabbar: rgba(15, 15, 18, 0.86);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28), 0 3px 10px rgba(0, 0, 0, 0.22);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.32), 0 12px 30px rgba(0, 0, 0, 0.30);
  --shadow-3: 0 4px 12px rgba(0, 0, 0, 0.38), 0 20px 50px rgba(0, 0, 0, 0.36);
  --glow-sm: 0 0 12px rgba(230, 169, 60, 0.16);
  --glow-md: 0 0 22px rgba(230, 169, 60, 0.20), 0 0 60px rgba(230, 169, 60, 0.08);
  --hairline-gold: linear-gradient(135deg, rgba(230, 169, 60, 0.50), rgba(255, 255, 255, 0.10) 30%, rgba(230, 169, 60, 0.06) 62%, rgba(230, 169, 60, 0.38));
  --gold-text: linear-gradient(180deg, #ffd98a 8%, #e6a93c 55%, #c9871f 100%);
}

[data-theme="light"] {
  --bg: #f2f0e8;
  --surface: #ffffff;
  --surface2: #f7f5ee;
  --text: #191919;
  --muted: #6c6c72;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);
  --accent: #bd7a17;
  --accent-soft: rgba(189, 122, 23, 0.13);
  --good: #2f9d68;
  --good-soft: rgba(47, 157, 104, 0.13);
  --topbar: rgba(242, 240, 232, 0.78);
  --tabbar: rgba(248, 246, 239, 0.9);
  --shadow-1: 0 1px 2px rgba(40, 30, 10, 0.06), 0 3px 8px rgba(40, 30, 10, 0.05);
  --shadow-2: 0 2px 6px rgba(40, 30, 10, 0.07), 0 10px 26px rgba(40, 30, 10, 0.08);
  --shadow-3: 0 4px 10px rgba(40, 30, 10, 0.08), 0 18px 44px rgba(40, 30, 10, 0.10);
  --glow-sm: 0 0 10px rgba(189, 122, 23, 0.12);
  --glow-md: 0 0 18px rgba(189, 122, 23, 0.14), 0 0 48px rgba(189, 122, 23, 0.06);
  --hairline-gold: linear-gradient(135deg, rgba(189, 122, 23, 0.45), rgba(189, 122, 23, 0.10) 35%, rgba(189, 122, 23, 0.05) 62%, rgba(189, 122, 23, 0.32));
  --gold-text: linear-gradient(180deg, #d18f1e, #a96c0e 75%);
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: #f0c069;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-shell {
  min-height: var(--tg-vh);
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: var(--max-w);
  height: var(--tg-vh);
  min-height: var(--tg-vh);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--safe-top) + 10px) 10px 10px;
}

/* На home — «кристалл» в шапке */
.topbar.topbar-crystal,
.topbar:has(.brand-crystal) {
  border-bottom-color: rgba(230, 169, 60, 0.22);
  background:
    radial-gradient(140px 50px at 18% 50%, rgba(230, 169, 60, 0.16), transparent 70%),
    radial-gradient(100px 40px at 70% 20%, rgba(230, 169, 60, 0.06), transparent 65%),
    var(--topbar);
  box-shadow:
    0 1px 0 rgba(230, 169, 60, 0.12),
    0 8px 28px rgba(0, 0, 0, 0.25),
    inset 0 -1px 0 rgba(230, 169, 60, 0.06);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 26px;
  line-height: 1;
  padding: 0 0 3px;
  border-radius: 10px;
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.88);
}

.brand {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: row;
  align-items: center;
  padding-left: 6px;
  padding-right: 4px;
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Одна строка: facet orb + АБСОЛЮТ | lang | тема */
.brand-crystal {
  gap: 8px;
  max-width: min(46vw, 160px);
  padding: 4px 12px 4px 5px;
  border-radius: 12px;
  border: 1px solid rgba(230, 169, 60, 0.38);
  background:
    radial-gradient(60px 28px at 12% 50%, rgba(230, 169, 60, 0.28), transparent 70%),
    linear-gradient(135deg, rgba(230, 169, 60, 0.12), transparent 55%),
    rgba(12, 12, 16, 0.72);
  box-shadow:
    0 0 22px rgba(230, 169, 60, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 14px rgba(230, 169, 60, 0.08);
}

.brand-crystal .brand-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1.15;
  max-width: 100%;
  text-shadow:
    0 0 18px rgba(230, 169, 60, 0.5),
    0 1px 0 rgba(0, 0, 0, 0.45);
}

.topbar-orb.crystal-orb.mini {
  width: 24px;
  height: 24px;
  margin: 0;
  flex: none;
}

.topbar-orb.crystal-orb.mini span {
  border-color: rgba(230, 169, 60, 0.6);
}

.topbar-orb.crystal-orb.mini span:nth-child(2) {
  inset: 5px;
}

.topbar-orb.crystal-orb.mini span:nth-child(3) {
  inset: 9px;
}

.topbar-orb.crystal-orb.mini.facet b {
  width: 5px;
  height: 5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex: none;
  margin-left: auto;
}

.brand-sub {
  display: none;
}

[data-theme="light"] .topbar.topbar-crystal,
[data-theme="light"] .topbar:has(.brand-crystal) {
  background:
    radial-gradient(140px 50px at 18% 50%, rgba(189, 122, 23, 0.14), transparent 70%),
    var(--topbar);
}

[data-theme="light"] .brand-crystal {
  background:
    radial-gradient(80px 36px at 12% 50%, rgba(189, 122, 23, 0.18), transparent 70%),
    rgba(255, 255, 255, 0.82);
  border-color: rgba(189, 122, 23, 0.35);
  box-shadow:
    0 0 20px rgba(189, 122, 23, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 0 14px rgba(189, 122, 23, 0.06);
}

.top-title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  padding-left: 4px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-btn {
  margin-left: 2px;
  width: 40px;
  height: 40px;
  flex: none;
  overflow: visible;
}

.theme-btn:active {
  transform: scale(0.88) rotate(-18deg);
}

.theme-glyph {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: linear-gradient(105deg, var(--text) 0 48%, transparent 52% 100%);
  box-shadow:
    0 0 0 1px rgba(230, 169, 60, 0.25),
    0 0 12px rgba(230, 169, 60, 0.18);
  flex: none;
}

[data-theme="light"] .theme-glyph {
  border-color: rgba(189, 122, 23, 0.65);
  background: linear-gradient(105deg, #1a1a1c 0 48%, #f2f0e8 52% 100%);
}

/* Home */
.page {
  padding: 16px 16px 26px;
}

.page.tight {
  padding-top: 14px;
}

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 22px;
}

.progress-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}

.progress-nums {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
}

.progress-nums .big {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.progress-nums .of {
  font-size: 15px;
  color: var(--muted);
}

.progress-pct {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}

.bar {
  margin-top: 14px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 2px 12px;
}

.topic-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: inherit;
  font: inherit;
  margin-bottom: 9px;
  transition: transform 0.12s ease;
}

.topic-btn:active {
  transform: scale(0.985);
}

.topic-n {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  min-width: 30px;
}

.topic-n.hot {
  color: var(--accent);
}

.topic-n.cold {
  color: var(--muted);
}

.topic-mid {
  flex: 1;
  min-width: 0;
}

.topic-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topic-sub {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 62px;
}

.topic-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.mini-bar {
  width: 54px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.mini-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* Topic cards */
.topic-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.topic-head-n {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.topic-head-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-wrap: pretty;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
}

.card.learned {
  background: var(--surface2);
  border-left-color: var(--good);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-title {
  flex: 1;
  min-width: 0;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.card.learned .card-title {
  color: var(--muted);
}

.fav-btn {
  width: 40px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  margin: -4px -6px 0 0;
  font-size: 19px;
  line-height: 1;
  color: var(--muted);
  transition: transform 0.12s ease;
}

.fav-btn.on {
  color: var(--accent);
}

.fav-btn:active {
  transform: scale(0.85);
}

.card-p {
  margin: 9px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  opacity: 0.92;
  text-wrap: pretty;
}

.card-items {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-item {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  opacity: 0.92;
  padding-left: 17px;
  text-indent: -17px;
  text-wrap: pretty;
}

.card-item .bullet {
  color: var(--accent);
  font-weight: 700;
}

.card-meta {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-line {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-wrap: pretty;
}

.meta-line strong {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

.learn-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 36px;
  margin-top: 14px;
  transition: transform 0.12s ease;
}

.learn-btn:active {
  transform: scale(0.96);
}

.learn-btn.on {
  border-color: transparent;
  background: var(--good-soft);
  color: var(--good);
}

/* Search composer: text + clear × + mic + send (unicode/CSS icons — TG-safe) */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 4px 4px 4px 14px;
  min-height: 48px;
  margin-bottom: 16px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  height: 40px;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.search-box input::-webkit-search-decoration,
.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-results-button,
.search-box input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.search-icon-btn:active {
  transform: scale(0.92);
  color: var(--text);
}

.clear-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border-radius: 50%;
}

.clear-btn .ico-x {
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
}

.mic-btn {
  color: var(--muted);
}

.mic-btn .ico-mic {
  display: block;
  width: 14px;
  height: 20px;
  position: relative;
  border-radius: 7px 7px 6px 6px;
  border: 1.6px solid currentColor;
  box-sizing: border-box;
}

.mic-btn .ico-mic::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 5px;
  margin-left: -5px;
  border: 1.6px solid currentColor;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-sizing: border-box;
}

.mic-btn .ico-mic::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 1.6px;
  height: 4px;
  margin-left: -0.8px;
  background: currentColor;
}

.mic-btn:active {
  color: var(--accent);
}

.search-send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.search-send-btn .ico-send {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  transform: translateX(1px);
}

.search-send-btn:active {
  transform: scale(0.94);
  filter: brightness(1.08);
}

.empty-state {
  padding: 44px 16px;
  text-align: center;
}

.empty-state .kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 8px;
}

.empty-state .msg {
  font-size: 14.5px;
  color: var(--muted);
  text-wrap: pretty;
  line-height: 1.55;
}

.empty-state .count {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 12px;
  color: var(--muted);
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.result-card.learned {
  background: var(--surface2);
  border-left-color: var(--good);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.result-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.result-card.learned .result-title {
  color: var(--muted);
}

.result-snippet {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 5px;
  text-wrap: pretty;
}

/* Flashcards */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 36px;
  white-space: nowrap;
  transition: transform 0.12s ease;
}

.chip:active {
  transform: scale(0.95);
}

.chip.on {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.deck-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 10px;
}

.deck-counter {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.deck-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shuffle-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-transform: uppercase;
}

.shuffle-btn:active {
  transform: scale(0.95);
}

.flip-stage {
  perspective: 1600px;
  cursor: pointer;
  height: 360px;
}

.flip-stage:active {
  transform: scale(0.992);
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.34, 1.15, 0.4, 1); /* slight overshoot: the card settles */
  transform-style: preserve-3d;
}

.flip-inner.flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  padding: 26px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.flip-front {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.flip-back {
  transform: rotateY(180deg);
  background: var(--surface2);
  border-color: var(--border-strong);
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flip-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.flip-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.flip-hint {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.deck-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.nav-sq {
  flex: none;
  width: 54px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  padding-bottom: 3px;
}

.nav-sq:active {
  transform: scale(0.94);
}

.nav-learn {
  flex: 1;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}

.nav-learn.on {
  border-color: transparent;
  background: var(--good-soft);
  color: var(--good);
}

.nav-learn:active {
  transform: scale(0.98);
}

.deck-empty {
  padding: 48px 20px;
  text-align: center;
}

.deck-empty h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.deck-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-wrap: pretty;
  line-height: 1.55;
}

.fav-empty {
  padding: 56px 22px;
  text-align: center;
}

.fav-empty h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.fav-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-wrap: pretty;
  line-height: 1.55;
}

/* Tab bar */
.tabbar {
  flex: none;
  display: flex;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  gap: 2px;
  background: var(--tabbar);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 6px;
  background: transparent;
  border: none;
  border-radius: 12px;
  min-height: 52px;
  transition: transform 0.12s ease;
}

.tab:active {
  transform: scale(0.92);
}

.tab-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s ease;
}

.tab.on .tab-dot {
  background: var(--accent);
}

.tab-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s ease;
}

.tab.on .tab-label {
  color: var(--text);
}

/* Loading / error */
.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #0b0b0d;
  color: #94949c;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.boot.error {
  color: #ff8a80;
  padding: 24px;
  text-align: center;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Home entry chips (Profile / Today) */
.home-chips {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.home-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 14px 15px;
  min-height: 62px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  color: inherit;
  font: inherit;
  transition: transform 0.12s ease;
}

.home-chip:active {
  transform: scale(0.97);
}

.home-chip.primary {
  border-color: transparent;
  background: var(--accent-soft);
}

.home-chip .chip-k {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.home-chip.primary .chip-k {
  color: var(--accent);
}

.home-chip .chip-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Profile form */
.pf-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 14px;
}

.pf-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pf-legend {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.pf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pf-field > span {
  font-size: 12.5px;
  color: var(--muted);
}

.pf-input {
  width: 100%;
  min-height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}

.pf-input:focus {
  border-color: var(--accent);
}

.axis-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.axis-label {
  flex: none;
  width: 76px;
  font-size: 13.5px;
}

.axis-range {
  flex: 1;
  min-width: 0;
  height: 36px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.axis-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.axis-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.axis-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.axis-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
}

.axis-val {
  flex: none;
  width: 22px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

.pf-save {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #0b0b0d;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease;
}

.pf-save:active {
  transform: scale(0.98);
}

/* Today / Daily Matrix */
.today-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.today-date {
  font-size: 15px;
  font-weight: 600;
}

.today-formula {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.today-hello {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.matrix-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 4px 16px 12px;
  margin-bottom: 16px;
}

.matrix-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.matrix-block:last-child {
  border-bottom: none;
}

.block-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.focus-card {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  min-height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  color: inherit;
  font: inherit;
  margin-bottom: 8px;
  transition: transform 0.12s ease;
}

.focus-card:last-child {
  margin-bottom: 0;
}

.focus-card:active {
  transform: scale(0.985);
}

.focus-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.focus-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.matrix-line {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  opacity: 0.92;
  text-wrap: pretty;
}

.matrix-line .risk-axis {
  color: var(--accent);
  font-weight: 600;
}

.matrix-line.drill {
  padding: 11px 13px;
  background: var(--good-soft);
  border-radius: 12px;
  color: var(--good);
  opacity: 1;
}

/* 3-axis hologram strip */
.axes-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.strip-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.axes3 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.axis3-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.axis3-pole {
  flex: none;
  width: 68px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.axis3-pole.right {
  text-align: right;
}

.axis3-line {
  flex: 1;
  height: 2px;
  background: var(--border-strong);
  position: relative;
}

.axis3-line > i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.companions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.companion {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

/* 6-axis self-score strip */
.score-strip {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-label {
  flex: none;
  width: 76px;
  font-size: 13px;
  color: var(--muted);
}

.score-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.score-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.score-val {
  flex: none;
  width: 20px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.score-row.risk .score-label {
  color: var(--text);
  font-weight: 600;
}

.score-row.risk .score-bar > i {
  background: var(--good);
}

.score-row.risk .score-val {
  color: var(--good);
}

.today-foot {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.today-empty {
  padding: 40px 20px;
  text-align: center;
}

.today-empty h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.today-empty p {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  text-wrap: pretty;
}

.today-empty .pf-save {
  max-width: 240px;
  margin: 0 auto;
}

/* a11y focus */
.home-chip:focus-visible,
.pf-save:focus-visible,
.pf-input:focus-visible,
.focus-card:focus-visible,
.axis-range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === Crystal Absolute · axes quiz · memory · lang === */

.lang-wrap {
  position: relative;
  flex: none;
  z-index: 40;
}

.lang-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--accent);
  border-radius: 50%;
  border: 1px solid rgba(230, 169, 60, 0.35);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 230, 170, 0.18), transparent 60%),
    rgba(20, 20, 28, 0.55);
  box-shadow: 0 0 14px rgba(230, 169, 60, 0.12);
}

.lang-btn.open {
  border-color: rgba(230, 169, 60, 0.7);
  box-shadow: 0 0 18px rgba(230, 169, 60, 0.28);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 230, 170, 0.28), transparent 60%),
    rgba(230, 169, 60, 0.12);
}

.lang-fan {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 999px;
  border: 1px solid rgba(230, 169, 60, 0.32);
  background:
    linear-gradient(180deg, rgba(20, 20, 28, 0.96), rgba(11, 11, 13, 0.94));
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(230, 169, 60, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: langFanIn 0.18s ease-out;
  z-index: 50;
}

@keyframes langFanIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lang-orb {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(230, 169, 60, 0.28);
  background: rgba(20, 20, 28, 0.9);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.lang-orb:active {
  transform: scale(0.9);
}

.lang-orb.on {
  color: #0b0b0d;
  border-color: rgba(230, 169, 60, 0.85);
  background: linear-gradient(160deg, #ffd98a 0%, #e6a93c 55%, #c9871f 100%);
  box-shadow: 0 0 16px rgba(230, 169, 60, 0.4);
}

[data-theme="light"] .lang-btn {
  background:
    radial-gradient(circle at 35% 30%, rgba(189, 122, 23, 0.14), transparent 60%),
    rgba(255, 255, 255, 0.85);
  border-color: rgba(189, 122, 23, 0.35);
}

[data-theme="light"] .lang-fan {
  background: linear-gradient(180deg, #fff, #f7f5ee);
  border-color: rgba(189, 122, 23, 0.28);
}

[data-theme="light"] .lang-orb {
  background: #fff;
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .lang-fan {
    animation: none;
  }
}

.crystal-page {
  position: relative;
}

.crystal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(230, 169, 60, 0.28);
  background:
    radial-gradient(120px 60px at 20% 40%, rgba(230, 169, 60, 0.18), transparent 70%),
    linear-gradient(135deg, rgba(20, 20, 28, 0.95), rgba(11, 11, 13, 0.4));
  box-shadow: 0 0 40px rgba(230, 169, 60, 0.08), inset 0 0 24px rgba(230, 169, 60, 0.05);
}

.crystal-banner-t {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
}

.crystal-orb {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 8px auto 16px;
}

.crystal-orb.mini {
  width: 36px;
  height: 36px;
  margin: 0;
  flex: none;
}

/* Facet crystal: hard edges, gold lattice — not soft blob */
.crystal-orb span {
  position: absolute;
  inset: 0;
  border-radius: 18% 42% 22% 48% / 28% 20% 52% 42%;
  border: 1px solid rgba(230, 169, 60, 0.55);
  background:
    linear-gradient(135deg, rgba(255, 236, 180, 0.28) 0%, transparent 42%),
    linear-gradient(320deg, rgba(230, 169, 60, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 35% 28%, rgba(255, 230, 170, 0.4), rgba(230, 169, 60, 0.08) 48%, transparent 72%);
  box-shadow:
    0 0 28px rgba(230, 169, 60, 0.28),
    inset 0 0 12px rgba(255, 220, 140, 0.12);
  animation: crystalPulse 5.5s ease-in-out infinite;
  clip-path: polygon(50% 0%, 92% 28%, 78% 92%, 22% 92%, 8% 28%);
}

.crystal-orb span:nth-child(2) {
  inset: 10px;
  opacity: 0.78;
  animation-delay: -1.2s;
  clip-path: polygon(50% 6%, 86% 32%, 74% 88%, 26% 88%, 14% 32%);
  border-radius: 0;
}

.crystal-orb span:nth-child(3) {
  inset: 18px;
  opacity: 0.55;
  animation-delay: -2.4s;
  clip-path: polygon(50% 12%, 78% 38%, 68% 82%, 32% 82%, 22% 38%);
}

.crystal-orb.facet b {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 1px;
  background: radial-gradient(circle, rgba(255, 240, 200, 0.95), rgba(230, 169, 60, 0.4) 60%, transparent 75%);
  box-shadow: 0 0 14px rgba(230, 169, 60, 0.65);
  animation: crystalCore 2.8s ease-in-out infinite;
  z-index: 2;
}

.crystal-orb.mini span:nth-child(2) {
  inset: 6px;
}

.crystal-orb.mini span:nth-child(3) {
  inset: 11px;
}

@keyframes crystalPulse {
  0%, 100% { transform: rotate(0deg) scale(1); filter: brightness(1); }
  50% { transform: rotate(10deg) scale(1.05); filter: brightness(1.18); }
}

@keyframes crystalSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes crystalCore {
  0%, 100% { opacity: 0.7; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.crystal-orb.crystal-spin span {
  animation: crystalSpin 14s linear infinite, crystalPulse 5.5s ease-in-out infinite;
}

.crystal-orb.crystal-spin span:nth-child(2) {
  animation-duration: 18s, 5.5s;
  animation-direction: reverse, normal;
}

.crystal-orb.crystal-spin span:nth-child(3) {
  animation-duration: 22s, 5.5s;
}

.topbar-orb.crystal-spin span {
  animation: crystalSpin 10s linear infinite, crystalPulse 5s ease-in-out infinite;
}

/* Profile personal crystal slot (tg-card right) */
.tg-meta {
  flex: 1;
  min-width: 0;
}

.pf-crystal-slot {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 12px;
  border: 1px solid rgba(230, 169, 60, 0.5);
  background:
    radial-gradient(circle at 40% 35%, rgba(255, 230, 170, 0.28), transparent 55%),
    linear-gradient(160deg, rgba(40, 32, 18, 0.9), rgba(12, 12, 16, 0.95));
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  gap: 1px;
  padding: 4px 2px 3px;
  box-shadow:
    inset 0 0 14px rgba(230, 169, 60, 0.16),
    0 0 16px rgba(230, 169, 60, 0.12);
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.pf-crystal-slot.off {
  border-color: rgba(255, 255, 255, 0.12);
  opacity: 0.55;
  filter: grayscale(0.35);
}

.pf-crystal {
  position: relative;
  width: 28px;
  height: 28px;
  --cr-rot: 0deg;
  --cr-hue: 38;
}

.pf-crystal i {
  position: absolute;
  inset: 0;
  border-radius: 28% 72% 68% 32% / 35% 30% 70% 65%;
  border: 1px solid hsla(var(--cr-hue), 72%, 58%, 0.55);
  background: radial-gradient(
    circle at 35% 30%,
    hsla(var(--cr-hue), 80%, 78%, 0.4),
    hsla(var(--cr-hue), 70%, 45%, 0.12) 50%,
    transparent 72%
  );
  transform: rotate(var(--cr-rot));
  animation: crystalSpin 16s linear infinite;
}

.pf-crystal i:nth-child(2) {
  inset: 5px;
  opacity: 0.75;
  animation-direction: reverse;
  animation-duration: 11s;
}

.pf-crystal i:nth-child(3) {
  inset: 10px;
  opacity: 0.55;
  animation-duration: 20s;
}

.crystal-mode-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.4;
  font-style: italic;
}

.crystal-mode-hint.solo {
  color: #e07070;
  background: rgba(180, 40, 40, 0.12);
  border: 1px solid rgba(200, 60, 60, 0.28);
  border-radius: 10px;
  padding: 8px 12px;
  filter: blur(0);
}

.pf-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.4;
}

.axis-score-only {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.axis-score-only .axis-val {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 13px;
}

/* Library mother → child list */
.child-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.child-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 14px;
  border-radius: 13px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  min-height: 56px;
  box-shadow: var(--shadow-1);
}

.child-btn:active {
  transform: scale(0.985);
  border-color: rgba(230, 169, 60, 0.35);
}

.child-btn-l {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.child-btn-t {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.child-btn-s {
  font-size: 12px;
  color: var(--muted);
}

.child-btn-r {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

.child-crumb {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

/* Memory residual pipeline */
.mem-pipeline {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.mem-pipeline i {
  width: 14px;
  height: 1px;
  background: rgba(230, 169, 60, 0.45);
}

.mem-pipeline span {
  color: var(--accent);
  opacity: 0.9;
}

.mem-residual {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(230, 169, 60, 0.28);
  background: rgba(230, 169, 60, 0.08);
  text-align: left;
}

.mem-res-k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.mem-res-p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.mem-res-meta {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}

/* Crystal pure-pixel panel */
.crystal-panel {
  margin: 0 0 16px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(230, 169, 60, 0.35);
  background:
    radial-gradient(120px 60px at 90% 0%, rgba(230, 169, 60, 0.14), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-1);
}

.crystal-panel.apex {
  border-color: rgba(230, 169, 60, 0.65);
  box-shadow: var(--glow-sm), var(--shadow-2);
}

.crystal-panel.solo {
  border-color: rgba(200, 80, 80, 0.35);
}

.crystal-panel.muted {
  opacity: 0.9;
}

.cp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.cp-k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.cp-pixel {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text);
  font-weight: 600;
}

.cp-place,
.cp-codes {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.cp-stage {
  font-size: 13px;
  margin: 8px 0 10px;
  line-height: 1.4;
}

.cp-tri {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 12px;
}

.cp-comps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.cp-comp {
  display: grid;
  grid-template-columns: 22px 1fr 28px;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
}

.cp-comp-n {
  font-family: var(--font-mono);
  color: var(--accent);
}

.cp-comp-t {
  color: var(--text);
}

.cp-comp-s {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--muted);
}

.cp-flag {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(200, 70, 70, 0.35);
  background: rgba(160, 40, 40, 0.12);
}

.cp-flag-t {
  font-weight: 650;
  font-size: 13px;
  color: #e07070;
  font-style: italic;
}

.cp-flag-m {
  font-size: 12.5px;
  margin: 4px 0;
  line-height: 1.4;
}

.cp-flag-d {
  font-size: 12px;
  color: var(--muted);
}

.cp-ok {
  font-size: 12.5px;
  color: var(--good);
  margin-bottom: 10px;
}

.cp-quals-wrap {
  margin: 10px 0;
}

.cp-quals-k {
  font-size: 11px;
  color: #e07070;
  font-style: italic;
  margin-bottom: 6px;
}

.cp-quals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cp-qual {
  font-size: 11.5px;
  font-style: italic;
  color: #e8a0a0;
  background: rgba(160, 40, 40, 0.14);
  border: 1px solid rgba(200, 70, 70, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  filter: blur(0.15px);
}

.cp-apex-ref {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: 0.04em;
}

.cp-disc,
.cp-need {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.4;
}

.pf-crystal-slot {
  flex-direction: column;
  gap: 2px;
}

.pf-crystal-slot.apex {
  border-color: rgba(230, 169, 60, 0.75);
  box-shadow: 0 0 16px rgba(230, 169, 60, 0.35);
}

.pf-crystal-px {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--accent);
  line-height: 1;
}

.crystal-day .cd-pixel {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 4px;
}

.crystal-day .cd-stage {
  font-size: 13px;
  margin-bottom: 4px;
}

.crystal-day .cd-quals {
  font-size: 12px;
  color: #e07070;
  font-style: italic;
}

.matrix-line.risk-m {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.cp-bio,
.cp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.cp-bio-row,
.cp-field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  gap: 8px;
}

.cp-field-row.on {
  color: var(--good);
}

.cp-field-row.off {
  color: var(--muted);
}

.cp-field-row.risk {
  color: #e07070;
  font-style: italic;
}

.cp-nutrition {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.home-chips.triple {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.home-chips.triple .home-chip {
  min-height: 70px;
  padding: 12px 10px;
}

.home-chip.crystal-chip {
  border-color: rgba(230, 169, 60, 0.4);
  background:
    radial-gradient(80px 40px at 50% 0%, rgba(230, 169, 60, 0.2), transparent 70%),
    var(--surface);
}

.home-chip.crystal-chip .chip-k {
  color: var(--accent);
}

.axes-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.axis-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface2);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: inset 0 0 0 1px rgba(230, 169, 60, 0.04);
}

.axis-card.open {
  border-color: rgba(230, 169, 60, 0.35);
  box-shadow: 0 0 24px rgba(230, 169, 60, 0.1);
}

.axis-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  min-height: 40px;
}

.axis-name {
  display: block;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
}

.axis-holo {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.axis-score-pill {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  min-width: 48px;
  text-align: right;
}

.axis-score-pill small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.axis-essence {
  margin: 10px 0 6px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  text-wrap: pretty;
}

.axis-link {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  font-family: var(--font-mono);
}

.axis-row.mini {
  margin: 8px 0;
  grid-template-columns: 90px 1fr 28px;
}

.axis-diag-btn {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.axis-quiz {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.axis-q-t {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}

.axis-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.axis-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.axis-opt.on {
  border-color: rgba(230, 169, 60, 0.55);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(230, 169, 60, 0.15);
}

.opt-sc {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

.axis-interpret {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(230, 169, 60, 0.06);
  border: 1px solid rgba(230, 169, 60, 0.15);
}

.ax-line {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.ax-line.drill-line {
  color: var(--good);
}

.ax-src {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Memory crystal */
.mem-streak {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}

.mem-title {
  margin: 0 0 8px;
  text-align: center;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--text);
}

.mem-intro {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 12px;
  text-wrap: pretty;
  text-align: center;
}

.mem-steps {
  margin: 0 0 16px;
  padding: 12px 14px 12px 32px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.mem-steps li {
  margin: 0 0 8px;
}

.mem-steps li:last-child {
  margin-bottom: 0;
}

.mem-steps strong {
  color: var(--accent);
  font-weight: 600;
}

.mem-res-what {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  font-style: italic;
}

.mem-orb {
  margin-bottom: 10px;
}

.mem-prompt-card {
  padding: 18px 16px;
  border-radius: 18px;
  border: 1px solid rgba(230, 169, 60, 0.3);
  background:
    radial-gradient(180px 100px at 50% 0%, rgba(230, 169, 60, 0.16), transparent 70%),
    var(--surface);
  box-shadow: 0 0 48px rgba(230, 169, 60, 0.1);
  margin-bottom: 14px;
}

.mem-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.mem-prompt {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  text-wrap: pretty;
}

.mem-topic {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.mem-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mem-opt {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.mem-opt:active {
  transform: scale(0.99);
  border-color: var(--accent);
}

.mem-result {
  padding: 20px 16px;
  border-radius: 16px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--surface);
}

.mem-result.ok {
  border-color: rgba(84, 192, 138, 0.4);
  background: var(--good-soft);
}

.mem-result.bad {
  border-color: rgba(255, 138, 128, 0.35);
  background: rgba(255, 120, 100, 0.08);
}

.mem-result p {
  margin: 0 0 12px;
  line-height: 1.5;
}

.mem-right {
  font-size: 16px;
}

[data-theme="light"] .crystal-banner {
  background:
    radial-gradient(120px 60px at 20% 40%, rgba(189, 122, 23, 0.15), transparent 70%),
    linear-gradient(135deg, #fff, #f7f5ee);
}

.app::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 1;
  background:
    radial-gradient(ellipse 90% 42% at 50% -8%, rgba(230, 169, 60, 0.13), transparent 58%),
    radial-gradient(ellipse 55% 30% at 10% 30%, rgba(126, 148, 255, 0.045), transparent 70%),
    radial-gradient(ellipse 70% 38% at 92% 80%, rgba(230, 169, 60, 0.05), transparent 70%),
    radial-gradient(ellipse 130% 95% at 50% 42%, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
}

.app::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.05;
}

[data-theme="light"] .app::before {
  background:
    radial-gradient(ellipse 90% 42% at 50% -8%, rgba(189, 122, 23, 0.10), transparent 58%),
    radial-gradient(ellipse 55% 30% at 10% 30%, rgba(90, 110, 220, 0.035), transparent 70%),
    radial-gradient(ellipse 130% 95% at 50% 42%, transparent 60%, rgba(60, 45, 15, 0.08) 100%);
}

[data-theme="light"] .app::after {
  opacity: 0.035;
}

.app > * {
  position: relative;
  z-index: 1;
}

@media (max-width: 380px) {
  .home-chips.triple {
    grid-template-columns: 1fr;
  }
}

/* Telegram profile card */
.tg-card {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(42, 171, 238, 0.35);
  background:
    radial-gradient(120px 60px at 10% 0%, rgba(42, 171, 238, 0.14), transparent 70%),
    var(--surface);
}

.tg-card.muted {
  border-color: var(--border);
  background: var(--surface);
  opacity: 0.92;
}

.tg-card.linked {
  box-shadow: 0 0 28px rgba(42, 171, 238, 0.1);
}

.tg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tg-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 2px solid rgba(42, 171, 238, 0.45);
  background: var(--surface2);
}

.tg-avatar.ph {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #2aabee;
}

.tg-card-t {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2aabee;
  margin-bottom: 4px;
}

.tg-card-p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.tg-name {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
}

.tg-user {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.tg-prem {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.04em;
  background: rgba(230, 169, 60, 0.2);
  color: var(--accent);
  vertical-align: middle;
}

.tg-sync-btn {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(42, 171, 238, 0.4);
  background: rgba(42, 171, 238, 0.12);
  color: #7ec8f0;
  font-size: 13px;
  font-weight: 600;
}

.tg-sync-btn:active {
  transform: scale(0.98);
}

[data-theme="light"] .tg-sync-btn {
  color: #0b6e99;
  background: rgba(42, 171, 238, 0.1);
}

/* === CRYSTAL ABSOLUTE polish pass === */

/* Tier 1 — content cards: matte, subtle lift, top sheen */
.card,
.result-card,
.pf-section,
.axes-strip,
.matrix-card {
  box-shadow: var(--shadow-1);
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 46%), var(--surface);
}

[data-theme="light"] .card {
  background: var(--surface);
}

/* Tier 2 — hero surfaces: 1px gradient hairline rim (padding-box/border-box trick) */
.progress-card {
  border: 1px solid transparent;
  background:
    radial-gradient(140% 90% at 50% -20%, rgba(230, 169, 60, 0.10), transparent 55%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
  box-shadow: var(--shadow-2);
}

.mem-prompt-card {
  border: 1px solid transparent;
  background:
    radial-gradient(180px 100px at 50% 0%, rgba(230, 169, 60, 0.16), transparent 70%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
  box-shadow: var(--shadow-3), var(--glow-md);
}

.crystal-banner {
  border: 1px solid transparent;
  background:
    radial-gradient(120px 60px at 20% 40%, rgba(230, 169, 60, 0.18), transparent 70%) padding-box,
    linear-gradient(180deg, rgba(20, 20, 28, 0.95), rgba(11, 11, 13, 0.75)) padding-box,
    var(--hairline-gold) border-box;
  box-shadow: var(--shadow-2), var(--glow-sm);
}

[data-theme="light"] .progress-card {
  background:
    radial-gradient(140% 90% at 50% -20%, rgba(189, 122, 23, 0.07), transparent 55%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
}

[data-theme="light"] .mem-prompt-card {
  background:
    radial-gradient(180px 100px at 50% 0%, rgba(189, 122, 23, 0.10), transparent 70%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
}

[data-theme="light"] .crystal-banner {
  background:
    radial-gradient(120px 60px at 20% 40%, rgba(189, 122, 23, 0.12), transparent 70%) padding-box,
    linear-gradient(180deg, #ffffff, #f7f5ee) padding-box,
    var(--hairline-gold) border-box;
}

/* Molten progress bars */
@keyframes barSheen {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(340%); }
}

.bar {
  margin-top: 14px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.bar > i {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: linear-gradient(90deg, #b5791d, var(--accent) 55%, #ffd98a);
  box-shadow: 0 0 10px rgba(230, 169, 60, 0.45);
}

.bar > i::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: barSheen 3.4s ease-in-out infinite;
}

.mini-bar > i {
  background: linear-gradient(90deg, #c9871f, var(--accent) 70%, #f0c069);
  box-shadow: 0 0 6px rgba(230, 169, 60, 0.35);
}

[data-theme="light"] .bar {
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.10);
}

[data-theme="light"] .bar > i {
  background: linear-gradient(90deg, #96620f, var(--accent) 55%, #dfa63d);
  box-shadow: 0 0 8px rgba(189, 122, 23, 0.28);
}

[data-theme="light"] .bar > i::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
}

[data-theme="light"] .mini-bar > i {
  background: linear-gradient(90deg, #96620f, var(--accent));
  box-shadow: none;
}

/* Gold glow discipline (only selected/CTA glows; green learned state stays matte) */
.chip.on {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, rgba(230, 169, 60, 0.65), rgba(230, 169, 60, 0.15) 60%, rgba(230, 169, 60, 0.45)) border-box;
  color: var(--accent);
  box-shadow: var(--glow-sm);
}

.fav-btn.on {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(230, 169, 60, 0.55);
}

.pf-save {
  background: linear-gradient(180deg, #f2c15c, #d9982a 60%, #c8871c);
  color: #0b0b0d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.40), 0 6px 20px rgba(230, 169, 60, 0.24);
}

.pf-save:active {
  transform: scale(0.98);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 10px rgba(230, 169, 60, 0.18);
}

.home-chip.primary {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
  box-shadow: var(--glow-sm);
}

[data-theme="light"] .chip.on {
  background:
    linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, rgba(189, 122, 23, 0.55), rgba(189, 122, 23, 0.15) 60%, rgba(189, 122, 23, 0.40)) border-box;
}

[data-theme="light"] .fav-btn.on {
  text-shadow: 0 0 10px rgba(189, 122, 23, 0.30);
}

[data-theme="light"] .pf-save {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 18px rgba(189, 122, 23, 0.22);
}
/* NOTE: .learn-btn.on / .nav-learn.on (green) intentionally stay matte — gold keeps exclusivity. */

/* Crystal-facet flip faces */
.flip-face {
  border: 1px solid transparent;
  box-shadow: var(--shadow-2);
}

.flip-front {
  background:
    linear-gradient(218deg, rgba(255, 255, 255, 0.045) 0 26%, rgba(255, 255, 255, 0) 26.5%) padding-box,
    linear-gradient(152deg, rgba(230, 169, 60, 0.09) 0 18%, rgba(230, 169, 60, 0) 18.5%) padding-box,
    linear-gradient(24deg, rgba(230, 169, 60, 0.05) 0 14%, rgba(230, 169, 60, 0) 14.5%) padding-box,
    radial-gradient(130% 85% at 50% -12%, rgba(230, 169, 60, 0.13), transparent 55%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
}

.flip-back {
  border: 1px solid transparent;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(230, 169, 60, 0.08), transparent 55%) padding-box,
    linear-gradient(var(--surface2), var(--surface2)) padding-box,
    var(--hairline-gold) border-box;
}

.flip-tag {
  letter-spacing: 0.08em;
  text-shadow: 0 0 14px rgba(230, 169, 60, 0.40);
}

.flip-hint {
  letter-spacing: 0.14em;
  opacity: 0.75;
}

[data-theme="light"] .flip-front {
  background:
    linear-gradient(218deg, rgba(189, 122, 23, 0.05) 0 26%, rgba(189, 122, 23, 0) 26.5%) padding-box,
    linear-gradient(152deg, rgba(189, 122, 23, 0.04) 0 18%, rgba(189, 122, 23, 0) 18.5%) padding-box,
    radial-gradient(130% 85% at 50% -12%, rgba(189, 122, 23, 0.08), transparent 55%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--hairline-gold) border-box;
}

[data-theme="light"] .flip-back {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(189, 122, 23, 0.06), transparent 55%) padding-box,
    linear-gradient(var(--surface2), var(--surface2)) padding-box,
    var(--hairline-gold) border-box;
}

[data-theme="light"] .flip-tag {
  text-shadow: none;
}

/* Topic rows — this rule owns .topic-btn's full transition (excluded from springy release list) */
.topic-btn {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 50%), var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s ease, box-shadow 0.18s ease;
}

@media (hover: hover) {
  .topic-btn:hover {
    border-color: rgba(230, 169, 60, 0.35);
    box-shadow: var(--shadow-1), var(--glow-sm);
  }
}

.topic-btn:active {
  transform: scale(0.985);
  border-color: rgba(230, 169, 60, 0.5);
  box-shadow: var(--shadow-1), var(--glow-sm);
}

.topic-n.hot {
  background: var(--gold-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent); /* fallback */
}

[data-theme="light"] .topic-btn {
  background: var(--surface);
}

@media (hover: hover) {
  [data-theme="light"] .topic-btn:hover {
    border-color: rgba(189, 122, 23, 0.35);
  }
}

[data-theme="light"] .topic-btn:active {
  border-color: rgba(189, 122, 23, 0.45);
}

/* Typography polish */
.progress-pct,
.topic-head-n,
.axis-score-pill {
  background: var(--gold-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent); /* fallback */
  filter: drop-shadow(0 0 10px rgba(230, 169, 60, 0.28));
}

.axis-score-pill small {
  -webkit-text-fill-color: var(--muted);
}

.progress-nums .big {
  font-size: 32px;
  letter-spacing: -0.03em;
}

.progress-pct,
.deck-counter,
.topic-count,
.progress-nums .big {
  font-variant-numeric: tabular-nums;
}

.eyebrow,
.section-label {
  letter-spacing: 0.18em;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(230, 169, 60, 0.35), var(--border) 45%, transparent);
}

[data-theme="light"] .progress-pct,
[data-theme="light"] .topic-head-n,
[data-theme="light"] .axis-score-pill {
  filter: none;
}

[data-theme="light"] .section-label::after {
  background: linear-gradient(90deg, rgba(189, 122, 23, 0.35), var(--border) 45%, transparent);
}

/* Tab bar refinement */
.tabbar {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 45%),
    var(--tabbar);
}

.tabbar::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 4%, rgba(230, 169, 60, 0.30) 32%, rgba(230, 169, 60, 0.30) 68%, transparent 96%);
}

.tab.on .tab-dot {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(230, 169, 60, 0.9), 0 0 16px rgba(230, 169, 60, 0.45);
}

.tab.on .tab-label {
  color: var(--accent);
}

.topbar {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .tabbar {
  background: var(--tabbar);
}

[data-theme="light"] .tabbar::before {
  background: linear-gradient(90deg, transparent 4%, rgba(189, 122, 23, 0.30) 32%, rgba(189, 122, 23, 0.30) 68%, transparent 96%);
}

[data-theme="light"] .tab.on .tab-dot {
  box-shadow: 0 0 6px rgba(189, 122, 23, 0.5);
}

[data-theme="light"] .topbar {
  box-shadow: none;
}

/* Branded boot */
.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.boot-orb {
  width: 84px;
  height: 84px;
  margin: 0 0 18px;
}

.boot-word {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: #e6a93c;
  text-shadow: 0 0 24px rgba(230, 169, 60, 0.45);
  animation: fadeUp 0.5s ease both;
}

.boot-sub {
  margin-top: 7px;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: #94949c;
  animation: fadeUp 0.5s ease 0.1s both;
}

.boot-shimmer {
  position: relative;
  width: 132px;
  height: 3px;
  margin-top: 20px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.boot-shimmer i {
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(230, 169, 60, 0.8), transparent);
  transform: translateX(-100%);
  animation: bootSweep 1.1s ease-in-out infinite;
}

@keyframes bootSweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 86px);
  transform: translateX(-50%) translateY(8px);
  max-width: min(420px, calc(100vw - 48px));
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  border: 1px solid rgba(230, 169, 60, 0.35);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 0 20px rgba(230, 169, 60, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[data-theme="light"] .toast {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Home hero */
.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 14px;
}

.hero-hi {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-streak {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid rgba(230, 169, 60, 0.3);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
}

/* Search highlight + shared dim orb */
mark.hl {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}

.result-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2px 2px 10px;
}

.crystal-orb.dim {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.55;
}

/* focus-visible completeness */
.icon-btn:focus-visible,
.topic-btn:focus-visible,
.tab:focus-visible,
.chip:focus-visible,
.fav-btn:focus-visible,
.learn-btn:focus-visible,
.nav-sq:focus-visible,
.nav-learn:focus-visible,
.shuffle-btn:focus-visible,
.clear-btn:focus-visible,
.mem-opt:focus-visible,
.axis-opt:focus-visible,
.axis-head:focus-visible,
.axis-diag-btn:focus-visible,
.tg-sync-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tap targets (44px) */
.icon-btn {
  width: 44px;
  height: 44px;
}

.fav-btn {
  position: relative;
}

.fav-btn::after {
  content: "";
  position: absolute;
  inset: -5px -2px; /* 40x34 -> 44x44 hit area */
}

.clear-btn {
  position: relative;
}

.clear-btn::after {
  content: "";
  position: absolute;
  inset: -7px; /* 34px -> 48px hit area */
  border-radius: 50%;
}

/* Inside Telegram the native MainButton replaces the inline profile save */
html.in-tg [data-act="save-profile"] {
  display: none;
}

/* === Motion system === */

/* One-shot entry classes (replaces the deleted always-on animations) */
.app.app-mounted {
  animation: fadeUp 0.4s ease both; /* boot fade — plays exactly once */
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page.screen-enter {
  animation: screenIn 0.3s cubic-bezier(0.25, 0.8, 0.35, 1) both;
}

/* Staggered cascade on screen entry */
@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen-enter .home-chip,
.screen-enter .progress-card,
.screen-enter .topic-btn,
.screen-enter .focus-card {
  animation: itemIn 0.34s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.screen-enter .home-chip {
  animation-delay: calc(40ms * var(--i, 0));
}

.screen-enter .progress-card {
  animation-delay: 100ms;
}

.screen-enter .topic-btn {
  animation-delay: min(calc(45ms * var(--i, 0) + 140ms), 420ms);
}

.screen-enter .focus-card {
  animation-delay: calc(50ms * var(--i, 0) + 60ms);
}

/* Flip physics */
.flip-stage {
  position: relative;
  touch-action: pan-y; /* horizontal swipes go to JS, vertical scroll stays native */
}

.flip-stage::before {
  content: "";
  position: absolute;
  inset: 12px 6px -8px;
  border-radius: 20px;
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.5), 0 0 34px rgba(230, 169, 60, 0.12);
  opacity: 0; /* animated via opacity only */
  pointer-events: none;
  z-index: -1;
}

[data-theme="light"] .flip-stage::before {
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.18), 0 0 34px rgba(189, 122, 23, 0.1);
}

.flip-stage.flip-lift {
  animation: flipLift 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-stage.flip-lift::before {
  animation: flipShadow 0.6s ease;
}

@keyframes flipLift {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  45% {
    transform: scale(1.035) translateY(-4px);
  }
}

@keyframes flipShadow {
  0%, 100% {
    opacity: 0;
  }
  45% {
    opacity: 1;
  }
}

/* "Learned" success moment */
.result-card {
  position: relative; /* anchor for the glow pseudo (.card is already relative) */
}

.card.just-learned::after,
.result-card.just-learned::after,
.flip-stage.just-learned::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(84, 192, 138, 0.55);
  box-shadow: 0 0 26px rgba(84, 192, 138, 0.3), inset 0 0 18px rgba(84, 192, 138, 0.14);
  opacity: 0;
  animation: learnedGlow 0.7s ease-out;
}

.flip-stage.just-learned::after {
  border-radius: 20px;
}

@keyframes learnedGlow {
  0% {
    opacity: 0;
    transform: scale(0.985);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.015);
  }
}

.check-pop {
  display: inline-block;
  animation: checkPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkPop {
  0% {
    transform: scale(0) rotate(-20deg);
  }
  60% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

/* Star favorite pop */
.fav-btn.fav-pop {
  animation: favPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes favPop {
  0% {
    transform: scale(0.3) rotate(-35deg);
  }
  55% {
    transform: scale(1.3) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

/* Memory verdict */
.mem-result.res-ok-in {
  animation: memOkIn 0.5s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.mem-result.res-ok-in .mem-right {
  animation: checkPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.12s both;
}

@keyframes memOkIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.mem-result.res-bad-in {
  animation: memShake 0.5s ease;
}

@keyframes memShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  35% { transform: translateX(7px); }
  55% { transform: translateX(-5px); }
  75% { transform: translateX(3px); }
  90% { transform: translateX(-1px); }
}

/* Count-up pop */
.progress-nums .big.big-pop {
  display: inline-block;
  animation: bigPop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes bigPop {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Unified springy press states (.topic-btn owns its transition above) */
.icon-btn,
.home-chip,
.chip,
.learn-btn,
.fav-btn,
.tab,
.nav-sq,
.nav-learn,
.shuffle-btn,
.mem-opt,
.axis-opt,
.clear-btn,
.focus-card,
.pf-save,
.tg-sync-btn,
.axis-diag-btn,
.flip-stage {
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:active,
.topic-btn:active,
.home-chip:active,
.chip:active,
.learn-btn:active,
.fav-btn:active,
.tab:active,
.nav-sq:active,
.nav-learn:active,
.shuffle-btn:active,
.mem-opt:active,
.axis-opt:active,
.clear-btn:active,
.focus-card:active,
.pf-save:active,
.tg-sync-btn:active,
.axis-diag-btn:active,
.flip-stage:active {
  transition-duration: 0.08s;
  transition-timing-function: ease-out;
}

/* Reduced-motion kill-switch — MUST stay the last block in this file */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important; /* also stops infinite crystalPulse / barSheen / bootSweep */
    transition-duration: 0.01ms !important;
  }
}
