:root {
  color-scheme: light;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-muted: rgba(255, 255, 255, 0.55);
  --text: #122033;
  --muted: #5f6e80;
  --accent: #295eff;
  --border: rgba(18, 32, 51, 0.1);
  --danger: #f85757;
  --win: #26bd6c;
  --miss: #8e98a8;
  --shadow: 0 24px 70px rgba(15, 24, 44, 0.12);
  --page-bg: radial-gradient(circle at top left, rgba(87, 146, 255, 0.28), transparent 28%), radial-gradient(circle at top right, rgba(255, 126, 126, 0.18), transparent 22%), linear-gradient(160deg, #eef4ff 0%, #fcfcff 42%, #eef3f4 100%);
  --panel-radius: 28px;
  --font-main: "Avenir Next", "Segoe UI Variable", "Helvetica Neue", sans-serif;
  --font-display: "Avenir Next", "Helvetica Neue", sans-serif;
}

body[data-variant="signal"] {
  --surface: rgba(7, 18, 17, 0.76);
  --surface-strong: rgba(5, 17, 15, 0.93);
  --surface-muted: rgba(5, 17, 15, 0.62);
  --text: #dff5ed;
  --muted: #8ab6a7;
  --accent: #74f0b9;
  --border: rgba(116, 240, 185, 0.14);
  --shadow: 0 32px 90px rgba(0, 0, 0, 0.35);
  --page-bg: radial-gradient(circle at 20% 20%, rgba(40, 140, 110, 0.32), transparent 24%), radial-gradient(circle at 80% 10%, rgba(245, 88, 87, 0.12), transparent 18%), linear-gradient(140deg, #061311 0%, #071c18 40%, #0b1614 100%);
  --font-main: "IBM Plex Mono", "SFMono-Regular", "Menlo", monospace;
  --font-display: "Avenir Next Condensed", "Arial Narrow", sans-serif;
}

body[data-variant="ledger"] {
  --surface: rgba(247, 241, 229, 0.85);
  --surface-strong: rgba(252, 247, 236, 0.96);
  --surface-muted: rgba(245, 237, 216, 0.72);
  --text: #2d2417;
  --muted: #74664d;
  --accent: #8d6035;
  --border: rgba(78, 56, 24, 0.12);
  --shadow: 0 22px 64px rgba(87, 65, 36, 0.14);
  --page-bg: radial-gradient(circle at 0% 0%, rgba(188, 151, 79, 0.16), transparent 22%), radial-gradient(circle at 100% 0%, rgba(132, 99, 61, 0.12), transparent 18%), linear-gradient(180deg, #f4ead7 0%, #f8f2e7 48%, #efe4cf 100%);
  --font-main: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-display: "Baskerville", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--page-bg);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 48%, transparent 100%);
  opacity: 0.24;
}

#app {
  position: relative;
  z-index: 1;
}

body[data-embed="true"] {
  overflow-x: hidden;
}

body[data-embed="true"]::before {
  opacity: 0.18;
}

.header-shell,
.header-collapsible,
.collapsible-body {
  display: grid;
  gap: 14px;
}

.header-shell-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

body[data-embed="true"] .header-shell-bar {
  display: none;
}

.header-mini-title {
  margin: 0;
  color: var(--muted);
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

body[data-embed="true"] .shell {
  width: min(100% - 12px, 100%);
  padding: 10px 0 22px;
}

.aurora-grid,
.ledger-columns,
.signal-shell {
  display: grid;
  gap: 18px;
}

.aurora-grid {
  grid-template-columns: 1.1fr 1.4fr;
  grid-template-areas:
    "hero chart"
    "stats chart"
    "events events";
}

.hero-panel { grid-area: hero; }
.chart-panel { grid-area: chart; }
.stats-panel { grid-area: stats; }
.events-panel { grid-area: events; }

.signal-shell {
  grid-template-columns: 320px minmax(0, 1fr) 420px;
  align-items: start;
}

.signal-center {
  display: grid;
  gap: 18px;
}

.ledger-columns {
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow: hidden;
}

.highlight-panel {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
}

.glow-panel {
  position: relative;
}

.glow-panel::after {
  content: "";
  position: absolute;
  inset: -120px auto auto -90px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(41, 94, 255, 0.22), transparent 72%);
  pointer-events: none;
}

.dense-panel {
  padding-top: 18px;
}

.header-block {
  display: grid;
  gap: 18px;
}

.collapsible-body.is-collapsed,
.header-collapsible.is-collapsed {
  display: none;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.04;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 4rem);
  max-width: 12ch;
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.75rem);
}

.subtitle {
  margin: 12px 0 0;
  max-width: 72ch;
  color: var(--muted);
}

.header-actions {
  display: grid;
  gap: 14px;
}

.variant-switch,
.control-strip,
.status-row,
.utility-row,
.refresh-strip,
.legend-toggle,
.filter-row,
.events-footer,
.summary-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.refresh-strip {
  align-items: center;
}

.strip-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.ghost-button,
.segmented-button,
.primary-button,
.secondary-button,
.danger-button,
.collapse-toggle,
.legend-chip,
.filter-chip,
.game-pill,
.duration-chip,
.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-muted);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  font: inherit;
}

.ghost-button:hover,
.segmented-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.collapse-toggle:hover,
.legend-chip:hover,
.filter-chip:hover {
  transform: translateY(-1px);
}

.ghost-button small {
  display: block;
  opacity: 0.68;
}

.primary-button,
.segmented-button.is-active,
.legend-chip.is-active,
.filter-chip.is-active,
.ghost-button.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-button {
  background: rgba(248, 87, 87, 0.12);
  color: var(--danger);
  border-color: rgba(248, 87, 87, 0.3);
}

.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.game-pill:disabled,
.duration-chip:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.game-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 14px;
}

.game-pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface-strong);
  border-radius: 14px;
}

.game-pill svg {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: var(--surface-strong);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.collapse-toggle {
  background: var(--surface-strong);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.92rem;
}

.tone-win { color: var(--win); }
.tone-danger { color: var(--danger); }
.tone-miss { color: var(--miss); }

.status-pill.tone-win,
.metric-card.tone-win,
.insight-card.tone-win,
.flag-badge.tone-win,
.filter-chip.tone-win,
.legend-chip.tone-win {
  border-color: rgba(38, 189, 108, 0.28);
}

.status-pill.tone-danger,
.metric-card.tone-danger,
.insight-card.tone-danger,
.flag-badge.tone-danger,
.filter-chip.tone-danger,
.legend-chip.tone-danger {
  border-color: rgba(248, 87, 87, 0.28);
}

.status-pill.tone-miss,
.metric-card.tone-miss,
.insight-card.tone-miss,
.flag-badge.tone-miss,
.filter-chip.tone-miss,
.legend-chip.tone-miss {
  border-color: rgba(142, 152, 168, 0.28);
}

.notice-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.notice-stack.is-empty {
  display: none;
}

.notice {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.notice-info {
  background: rgba(41, 94, 255, 0.1);
}

.notice-error {
  background: rgba(248, 87, 87, 0.14);
}

.hero-card-set,
.insight-grid {
  display: grid;
  gap: 12px;
}

.hero-card-set {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.insight-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card,
.window-card,
.insight-card {
  min-height: 132px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.metric-card p,
.window-card p,
.insight-card p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.metric-card strong,
.window-card strong,
.insight-card strong {
  display: block;
  font-size: clamp(1.25rem, 2vw, 2.1rem);
  margin-bottom: 10px;
}

.metric-card span,
.window-card span,
.insight-card span,
.table-frame td span {
  color: var(--muted);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.chart-heading-copy {
  display: grid;
  gap: 12px;
}

.chart-period-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 520px);
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.chart-period-switch .segmented-button {
  width: 100%;
  justify-content: center;
  background: transparent;
}

.chart-period-switch .segmented-button.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(41, 94, 255, 0.2);
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chart-metric-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.chart-metric-toggle:hover {
  transform: translateY(-1px);
}

.chart-metric-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chart-metric-check {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  background: transparent;
}

.chart-metric-toggle span {
  pointer-events: none;
}

.chart-metric-toggle.is-active {
  background: var(--surface-strong);
}

.chart-metric-toggle.is-active .chart-metric-check {
  color: #ffffff;
}

.chart-metric-toggle.tone-win.is-active .chart-metric-check {
  background: var(--win);
  border-color: var(--win);
  box-shadow: inset 0 0 0 12px var(--win);
}

.chart-metric-toggle.tone-danger.is-active .chart-metric-check {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: inset 0 0 0 12px var(--danger);
}

.chart-metric-toggle.tone-miss.is-active .chart-metric-check {
  background: var(--miss);
  border-color: var(--miss);
  box-shadow: inset 0 0 0 12px var(--miss);
}

.chart-metric-toggle.tone-win {
  color: var(--win);
}

.chart-metric-toggle.tone-danger {
  color: var(--danger);
}

.chart-metric-toggle.tone-miss {
  color: var(--miss);
}

.chart-wrap,
.table-frame {
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  max-height: 480px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.table-frame .stats-table {
  min-width: 420px;
}

.table-frame thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
}

.chart-wrap {
  padding: 10px;
}

.chart-wrap.is-compact {
  padding: 6px;
}

.trend-chart,
.chart-empty {
  width: 100%;
  display: block;
}

.trend-chart {
  border-radius: 18px;
}

.trend-chart.is-compact {
  min-height: 180px;
}

.chart-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.trend-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.chart-note {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.events-frame {
  max-height: 480px;
  overflow: auto;
}

.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.events-footer {
  justify-content: space-between;
  margin-top: 14px;
}

.events-controls,
.events-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.compact-wrap {
  gap: 8px;
}

.checkbox-col {
  width: 72px;
  text-align: center;
}

.table-check-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
}

.event-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.events-table tbody tr.is-selected {
  background: rgba(41, 94, 255, 0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(10, 16, 28, 0.55);
  padding: 20px;
}

.modal-card {
  width: min(520px, 100%);
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.dice-backdrop {
  background: rgba(10, 16, 28, 0.65);
}

.dice-modal {
  width: min(760px, 100%);
}

.dice-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
}

.dice-duration-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.duration-chip {
  border-radius: 999px;
  padding: 7px 8px;
  background: var(--surface-muted);
}

.duration-chip.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.dice-stage {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(160deg, var(--surface-strong), var(--surface));
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  cursor: pointer;
}

.dice-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.dice-box small {
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

/* 3-D cube using CSS perspective */
.dice-cube-wrap {
  perspective: 320px;
}

.dice-cube {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-22deg) rotateY(30deg);
  /* top face */
  background: var(--surface-strong);
  /* front face shine */
  box-shadow:
    /* front left edge shadow */
    -3px 3px 0 0 rgba(0,0,0,0.18),
    /* bottom depth */
    0 8px 0 0 rgba(0,0,0,0.22),
    /* outer glow */
    0 14px 28px rgba(0,0,0,0.18),
    /* inner top-left highlight */
    inset 0 1px 0 rgba(255,255,255,0.22),
    inset -1px 0 0 rgba(0,0,0,0.12);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  /* pseudo top-face via ::before, right-face via ::after */
}

.dice-cube::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, transparent 60%);
  pointer-events: none;
}

/* right face */
.dice-cube::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 3px;
  width: 8px;
  bottom: -5px;
  background: rgba(0,0,0,0.22);
  border-radius: 0 6px 6px 0;
  transform: skewY(-45deg);
  pointer-events: none;
}

/* bottom face */
.dice-cube-bottom {
  position: absolute;
  left: 3px;
  bottom: -8px;
  right: -5px;
  height: 8px;
  background: rgba(0,0,0,0.28);
  border-radius: 0 0 6px 6px;
  transform: skewX(-45deg);
  pointer-events: none;
}

.dice-stage.is-rolling .dice-cube {
  animation: dice-throw var(--dice-roll-duration, 1s) cubic-bezier(0.22, 0.82, 0.24, 1) both;
}

.dice-stage.is-rolling .dice-box:last-child .dice-cube {
  animation-delay: 0.06s;
}

.dice-result {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dice-result span {
  color: var(--muted);
}

.dice-result strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.dice-result.tone-win {
  animation: result-pulse-win 0.75s ease;
}

.dice-result.tone-danger {
  animation: result-pulse-danger 0.75s ease;
}

@keyframes result-pulse-win {
  0% { transform: scale(1); }
  35% { transform: scale(1.03); box-shadow: 0 0 28px rgba(38, 189, 108, 0.45); }
  100% { transform: scale(1); box-shadow: none; }
}

@keyframes result-pulse-danger {
  0% { transform: scale(1); }
  35% { transform: scale(1.03); box-shadow: 0 0 28px rgba(248, 87, 87, 0.45); }
  100% { transform: scale(1); box-shadow: none; }
}

.streak-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.streak-bar svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

@keyframes dice-throw {
  0% {
    transform: translateY(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
  18% {
    transform: translateY(-30px) rotateX(220deg) rotateY(160deg) rotateZ(50deg);
  }
  56% {
    transform: translateY(-12px) rotateX(480deg) rotateY(290deg) rotateZ(160deg);
  }
  82% {
    transform: translateY(2px) rotateX(640deg) rotateY(360deg) rotateZ(230deg);
  }
  100% {
    transform: translateY(0) rotateX(720deg) rotateY(420deg) rotateZ(250deg);
  }
}

.modal-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.modal-message {
  margin: 0;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

select {
  appearance: none;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 18px;
  font: inherit;
}

.signal-sidebar,
.signal-feed {
  position: sticky;
  top: 18px;
}

.signal-stats-panel .table-frame,
.signal-feed .table-frame {
  max-height: 540px;
}

.ledger-masthead {
  margin-bottom: 18px;
}

.ledger-shell .header-block {
  grid-template-columns: 1.2fr 1fr;
  align-items: start;
}

body[data-density="compact"] {
  font-size: 12px;
}

body[data-density="compact"] .shell {
  width: min(100% - 12px, 100%);
  padding: 8px 0 14px;
}

body[data-density="compact"] .aurora-grid,
body[data-density="compact"] .ledger-columns,
body[data-density="compact"] .signal-shell,
body[data-density="compact"] .signal-center,
body[data-density="compact"] .header-block,
body[data-density="compact"] .header-actions,
body[data-density="compact"] .hero-card-set,
body[data-density="compact"] .insight-grid,
body[data-density="compact"] .header-shell,
body[data-density="compact"] .header-collapsible,
body[data-density="compact"] .collapsible-body {
  gap: 6px;
}

body[data-density="compact"] .panel,
body[data-density="compact"] .metric-card,
body[data-density="compact"] .window-card,
body[data-density="compact"] .insight-card,
body[data-density="compact"] .modal-card {
  padding: 8px;
  border-radius: 14px;
}

body[data-density="compact"] .dense-panel {
  padding-top: 8px;
}

body[data-density="compact"] .eyebrow,
body[data-density="compact"] .section-kicker {
  margin: 0 0 2px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
}

body[data-density="compact"] h1 {
  font-size: clamp(1.05rem, 4vw, 1.4rem);
  max-width: none;
}

body[data-density="compact"] h2,
body[data-density="compact"] .modal-card h3 {
  font-size: 1rem;
}

body[data-density="compact"] .subtitle,
body[data-density="compact"] .header-mini-title,
body[data-density="compact"] .strip-label,
body[data-density="compact"] .chart-note,
body[data-density="compact"] .modal-message {
  font-size: 0.78rem;
}

body[data-density="compact"] .ghost-button small {
  display: none;
}

body[data-density="compact"] .ghost-button,
body[data-density="compact"] .segmented-button,
body[data-density="compact"] .primary-button,
body[data-density="compact"] .secondary-button,
body[data-density="compact"] .danger-button,
body[data-density="compact"] .collapse-toggle,
body[data-density="compact"] .legend-chip,
body[data-density="compact"] .filter-chip,
body[data-density="compact"] .game-pill,
body[data-density="compact"] .duration-chip,
body[data-density="compact"] .icon-button,
body[data-density="compact"] .table-check-toggle,
body[data-density="compact"] select,
body[data-density="compact"] .status-pill {
  padding: 5px 8px;
  font-size: 0.76rem;
}

body[data-density="compact"] .icon-button {
  width: 30px;
  height: 30px;
}

body[data-density="compact"] .icon-button svg {
  width: 15px;
  height: 15px;
}

body[data-density="compact"] .game-strip {
  margin-bottom: 8px;
  gap: 6px;
}

body[data-density="compact"] .game-pill {
  border-radius: 10px;
}

body[data-density="compact"] .dice-stage {
  border-radius: 14px;
  padding: 8px;
  gap: 20px;
}

body[data-density="compact"] .dice-cube {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  font-size: 1.1rem;
}

body[data-density="compact"] .dice-result {
  margin-top: 8px;
  padding: 8px;
}

body[data-density="compact"] .dice-result strong {
  font-size: 1rem;
}

body[data-density="compact"] .status-pill {
  gap: 4px;
}

body[data-density="compact"] .metric-card,
body[data-density="compact"] .window-card,
body[data-density="compact"] .insight-card {
  min-height: 0;
}

body[data-density="compact"] .metric-card p,
body[data-density="compact"] .window-card p,
body[data-density="compact"] .insight-card p {
  margin-bottom: 6px;
  font-size: 0.72rem;
}

body[data-density="compact"] .metric-card strong,
body[data-density="compact"] .window-card strong,
body[data-density="compact"] .insight-card strong {
  margin-bottom: 4px;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
}

body[data-density="compact"] .section-heading {
  gap: 8px;
  margin-bottom: 6px;
}

body[data-density="compact"] .chart-heading-copy {
  gap: 6px;
}

body[data-density="compact"] .chart-period-switch {
  width: 100%;
  padding: 4px;
  gap: 4px;
}

body[data-density="compact"] .chart-toolbar {
  gap: 6px;
}

body[data-density="compact"] .chart-metric-toggle {
  gap: 6px;
  padding: 5px 8px;
  font-size: 0.76rem;
}

body[data-density="compact"] .chart-metric-check {
  width: 16px;
  height: 16px;
  font-size: 0.65rem;
}

body[data-density="compact"] .chart-wrap,
body[data-density="compact"] .table-frame {
  border-radius: 14px;
}

body[data-density="compact"] .chart-wrap {
  padding: 4px;
}

body[data-density="compact"] th,
body[data-density="compact"] td {
  padding: 6px 7px;
  font-size: 0.74rem;
}

body[data-density="compact"] .events-frame {
  max-height: 300px;
}

body[data-density="compact"] .checkbox-col {
  width: 46px;
}

body[data-density="compact"] .event-checkbox {
  width: 15px;
  height: 15px;
}

body[data-density="compact"] .modal-backdrop {
  padding: 10px;
}

body[data-density="compact"] .modal-actions {
  gap: 6px;
  margin-top: 10px;
}

@media (max-width: 1180px) {
  .aurora-grid,
  .ledger-columns,
  .signal-shell,
  .ledger-shell .header-block {
    grid-template-columns: 1fr;
  }

  .aurora-grid {
    grid-template-areas:
      "hero"
      "chart"
      "stats"
      "events";
  }

  .signal-sidebar,
  .signal-feed {
    position: static;
  }

  body[data-density="compact"] .shell {
    width: min(100% - 8px, 100%);
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 100%);
    padding-top: 14px;
  }

  body[data-embed="true"] .shell {
    width: min(100% - 8px, 100%);
    padding-top: 8px;
  }

  .panel {
    padding: 16px;
    border-radius: 22px;
  }

  .chart-period-switch {
    width: 100%;
  }

  .chart-metric-toggle {
    width: 100%;
    justify-content: flex-start;
  }

  .hero-card-set,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px;
    font-size: 0.94rem;
  }

  .events-footer,
  .section-heading,
  .modal-actions {
    flex-direction: column;
  }

  .game-strip,
  .dice-result,
  .dice-modal-head {
    flex-direction: column;
    align-items: stretch;
  }

  .dice-stage {
    gap: 24px;
  }

  h1 {
    max-width: none;
  }

  body[data-density="compact"] .shell {
    width: min(100% - 6px, 100%);
    padding-top: 4px;
  }

  body[data-density="compact"] .panel {
    padding: 6px;
  }

  body[data-density="compact"] .events-footer,
  body[data-density="compact"] .section-heading,
  body[data-density="compact"] .modal-actions,
  body[data-density="compact"] .header-shell-bar {
    flex-direction: column;
    align-items: stretch;
  }

  body[data-density="compact"] .hero-card-set,
  body[data-density="compact"] .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-density="compact"] h1 {
    font-size: 0.95rem;
  }

  body[data-density="compact"] h2,
  body[data-density="compact"] .modal-card h3 {
    font-size: 0.88rem;
  }

  body[data-density="compact"] th,
  body[data-density="compact"] td {
    padding: 5px 6px;
    font-size: 0.68rem;
  }
}

/* Предпочтения и инсайты */
.preferences-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
}

.preferences-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.preferences-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shortcut-link {
  text-decoration: none;
}

.preferences-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.preferences-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preferences-body.is-collapsed {
  display: none;
}

.pref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
}

.pref-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.pref-field-check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
}

.pref-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.pref-input {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
}

.pref-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.insight-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.insight-box {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.insight-box.is-human {
  padding: 14px;
}

.insight-box.is-locked {
  border-color: rgba(248, 87, 87, 0.4);
  background: rgba(248, 87, 87, 0.06);
}

.insight-title {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.insight-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.marker-sections {
  display: grid;
  gap: 10px;
}

.marker-section {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.marker-section p {
  margin: 7px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text);
}

.marker-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.marker-head strong {
  font-size: 0.82rem;
  color: var(--text);
}

.marker-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #111827;
}

.marker-green {
  border-color: rgba(39, 196, 111, 0.42);
  background: rgba(39, 196, 111, 0.08);
}

.marker-green .marker-pill {
  background: #83f2ad;
}

.marker-yellow {
  border-color: rgba(245, 191, 66, 0.48);
  background: rgba(245, 191, 66, 0.1);
}

.marker-yellow .marker-pill {
  background: #ffe083;
}

.marker-red {
  border-color: rgba(248, 87, 87, 0.5);
  background: rgba(248, 87, 87, 0.09);
}

.marker-red .marker-pill {
  background: #ff9a9a;
}

.marker-detail {
  color: var(--muted) !important;
}

/* Прогресс дневной нормы */
.quota-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quota-progress.is-empty {
  font-size: 0.78rem;
  color: var(--muted);
}

.quota-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.quota-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #5a8bff);
  transition: width 0.4s ease;
}

.quota-progress.is-done .quota-bar-fill {
  background: linear-gradient(90deg, var(--win), #3bd884);
}

/* Три голоса */
.voices-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
}

.voices-body.is-collapsed {
  display: none;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.voice-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.voice-coach {
  border-color: rgba(38, 189, 108, 0.35);
}

.voice-psychic {
  border-color: rgba(123, 97, 255, 0.4);
}

.voice-master {
  border-color: rgba(245, 158, 66, 0.4);
}

.voice-name {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.voice-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.voice-empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
