:root {
  --bg: #000;
  --surface: #151719;
  --surface-2: #1b1d20;
  --surface-3: #25282a;
  --border: #292c2f;
  --text: #f2f2f2;
  --muted: #8f9397;
  --accent: #36cfda;
  --accent-2: #28bbc6;
  --accent-soft: rgba(54, 207, 218, .12);
  --fold: #25282a;
  --shadow: none;
  --radius: 2px;
}

html[data-theme="light"] {
  --bg: #eef2f3;
  --surface: #fff;
  --surface-2: #e7ecee;
  --surface-3: #dce4e7;
  --border: #c5cfd3;
  --text: #121719;
  --muted: #68757a;
  --accent: #10b9ca;
  --accent-2: #0895a4;
  --fold: #dce4e7;
}

html,
body {
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: Inter, Arial, Helvetica, system-ui, sans-serif;
  font-size: 12px;
}

[hidden] { display: none !important; }
button, select, input, textarea { border-color: var(--border); }

/* ZeroPoker reference: a shallow chrome strip and immediate access to Study. */
.topbar {
  height: 32px;
  padding: 0;
  border: 0;
  background: #18191b;
  overflow: hidden;
}
.brand,
.dataset-context,
.product-nav,
.top-actions { display: none !important; }
.topbar { display: flex; height: 32px; padding: 0 8px; align-items: center; }
.product-nav.view-switch { display: flex !important; margin: 0 0 0 auto; padding: 2px; }
.product-nav.view-switch a { min-width: 80px; min-height: 24px; padding-inline: 11px; }
.brand { flex: 0 0 auto; gap: 8px; }
.brand-mark {
  width: 27px;
  height: 27px;
  border: 2px solid #31d6e3;
  border-radius: 0;
  color: #31d6e3;
  background: transparent;
  box-shadow: inset 0 0 0 1px #18191b;
  font-size: 21px;
  font-weight: 400;
  line-height: 24px;
}
.brand h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -.7px; }
.brand .eyebrow { display: none; }
.dataset-context { margin-left: 43px; color: #e5e5e5; font-size: 13px; font-weight: 400; white-space: nowrap; }

.app-shell { display: block; min-height: calc(100vh - 32px); }
.workspace {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 29px 0 60px 15px;
}

/* Search remains available with / and overlays the faithful workspace. */
.sidebar {
  position: fixed;
  z-index: 90;
  top: 0;
  left: 0;
  width: min(390px, 92vw);
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #0c0e10;
  box-shadow: 18px 0 60px rgba(0, 0, 0, .55);
  transform: translateX(-105%);
  transition: transform 180ms ease;
}
body.library-open .sidebar { transform: translateX(0); }
.library-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(0, 0, 0, .7); }
.library-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.library-heading h2 { font-size: 18px; }
#library-close { width: 34px; padding: 0; font-size: 20px; }
.filter-section { padding-top: 10px; }
.filter-section > .section-heading h2 { font-size: 11px; text-transform: uppercase; }
#advanced-filters > summary { font-size: 10px; }
.results-section { min-height: 0; }

.table-header { display: none; }

/* Source image geometry: x15 sequence, x244 decision/range, x746 HU. */
.poker-study-layout {
  display: grid;
  grid-template-columns: 180px 565px;
  grid-template-rows: 292px 114px auto auto;
  column-gap: 50px;
  align-items: start;
  width: 794px;
}
.study-navigation { display: contents; }
.sequence-group { grid-column: 1; grid-row: 1; }
.decision-controls { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; width: 565px; }
.stack-group { grid-column: 1; grid-row: 2; margin-top: 38px; }
.sizing-group { grid-column: 1; grid-row: 3; margin-top: 46px; }
.hierarchy-debug { grid-column: 1; grid-row: 4; }
.range-stage {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 4;
  width: 565px;
  min-width: 565px;
  max-width: 565px;
  /* This transparent stage shares its grid cell with the decision controls.
     It must not intercept physical pointer input in its empty upper area. */
  pointer-events: none;
}
.range-hu-row,
.matrix-legend,
.range-panel,
.range-footer { pointer-events: auto; }

.nav-group,
.context-facet,
.continuation-facet { min-width: 0; }
.nav-group h3,
.context-facet h3,
.continuation-facet h3 {
  margin: 0 0 16px;
  color: #e1e1e1;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sequence-buttons { display: grid; grid-template-columns: 180px; gap: 1px; width: 180px; }
.sequence-buttons button,
.option-buttons button {
  height: 41px;
  min-height: 41px;
  padding: 0 9px;
  border: 1px solid #2a2c2f;
  border-radius: 4px;
  color: #f0f0f0;
  background: #1a1c1f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .25px;
  text-align: left;
  text-transform: uppercase;
}
.sequence-buttons button:hover,
.option-buttons button:hover { border-color: #414548; background: #202225; }
.sequence-buttons button.active,
.option-buttons button.active { border-color: var(--accent); color: #061013; background: var(--accent); }
.sequence-buttons button small,
.option-buttons button small { display: none; }
.option-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
button { cursor: pointer; }
button:focus-visible,
select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Human decision order: Hero, contextual position, then extra action. */
.position-group { order: 1; margin-top: 0; }
.context-groups { order: 2; display: flex; gap: 20px; margin-top: 19px; }
.extra-group { order: 3; margin-top: 19px; }
.context-facet h3 { margin-bottom: 14px; }
.context-facet { width: 125px; }
.facet-select {
  width: 125px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: #061013;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
.position-group h3 { margin-bottom: 21px; }
.position-buttons { gap: 20px; }
.position-buttons button { width: 53px; min-width: 53px; height: 36px; min-height: 36px; padding: 0; text-align: center; }
.extra-group h3 { margin-bottom: 20px; }
.extra-buttons { gap: 20px; }
.extra-buttons button { width: auto; min-width: 125px; height: 36px; min-height: 36px; padding-inline: 12px; text-align: center; }
.continuation-groups { order: 4; display: flex; gap: 20px; margin-top: 19px; }
.continuation-facet { width: 125px; }
.base-action-link { display: none !important; }

.nav-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stack-group h3 { margin-bottom: 17px; font-size: 13px; }
.exact-stack-select {
  display: block;
  width: 180px;
  height: 37px;
  min-height: 37px;
  padding: 0 9px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: #061013;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.exact-stack-slider-control { width: 180px; margin-top: 11px; }
.exact-stack-slider {
  display: block;
  width: 180px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
  appearance: none;
}
.exact-stack-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--stack-progress), #292d30 var(--stack-progress) 100%);
}
.exact-stack-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid #071214;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px #344247;
  appearance: none;
}
.exact-stack-slider::-moz-range-track { height: 4px; border-radius: 999px; background: #292d30; }
.exact-stack-slider::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.exact-stack-slider::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #071214; border-radius: 50%; background: var(--accent); }
.exact-stack-slider:hover::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.exact-stack-slider:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.exact-stack-slider:disabled { cursor: default; opacity: .5; }
.exact-stack-slider-labels { display: flex; justify-content: space-between; margin-top: 1px; color: #8f9397; font-size: 9px; font-weight: 700; }
.sizing-buttons { gap: 16px; padding-top: 2px; }
.sizing-buttons button {
  width: auto;
  min-width: 64px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 5px;
  text-align: center;
}

.hierarchy-debug { display: none; }
.hierarchy-debug summary { cursor: pointer; font-size: 8px; font-weight: 600; text-transform: uppercase; }
#hierarchy-debug-content { display: grid; gap: 4px; margin-top: 8px; font-size: 8px; }
#hierarchy-debug-content code { color: #a8b1b7; white-space: normal; }

.range-hu-row { position: absolute; top: -1px; right: 0; z-index: 2; display: flex; gap: 20px; height: 24px; align-items: center; justify-content: flex-end; }
.hu-control { display: flex; align-items: center; gap: 7px; color: #f2f2f2; cursor: pointer; font-size: 14px; font-weight: 400; }
.hu-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { display: flex; width: 35px; height: 22px; padding: 2px; border: 1px solid #71767a; border-radius: 999px; background: #141618; }
.toggle-track span { width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 120ms ease; }
.hu-control input:checked + .toggle-track { border-color: var(--accent); background: var(--accent); }
.hu-control input:checked + .toggle-track span { background: #061013; transform: translateX(13px); }
.hu-control.disabled { opacity: .4; pointer-events: none; }
.matrix-legend { height: 14px; min-height: 14px; margin: var(--legend-offset, 334px) 0 8px; }
.matrix-legend .legend { display: flex; flex-wrap: nowrap; gap: 21px; align-items: center; }
.matrix-legend .legend-item { display: flex; gap: 7px; align-items: center; padding: 0; border: 0; background: transparent; }
.matrix-legend .legend-swatch { width: 13px; height: 13px; border: 0; border-radius: 1px; }
.matrix-legend .legend-item strong { font-size: 10px; font-weight: 800; white-space: nowrap; text-transform: uppercase; }
.matrix-legend .legend-item small { display: none; }
.matrix-legend .legend-percentage { color: #a4a7aa; font-size: 9px; font-weight: 700; }
.matrix-legend .legend:has(.legend-item:nth-child(4)) { gap: 8px; }
.matrix-legend .legend:has(.legend-item:nth-child(4)) .legend-item { gap: 4px; }
.matrix-legend .legend:has(.legend-item:nth-child(4)) .legend-swatch { width: 10px; height: 10px; }
.matrix-legend .legend:has(.legend-item:nth-child(4)) .legend-item strong,
.matrix-legend .legend:has(.legend-item:nth-child(4)) .legend-percentage { font-size: 7px; }

.range-panel { position: static; width: 565px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.range-panel .panel-heading { display: none; }
.matrix-scroll { width: 565px; padding: 0; overflow: visible; }
.range-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  grid-template-rows: repeat(13, minmax(0, 1fr));
  gap: 0;
  width: 565px;
  min-width: 565px;
  height: 447px;
}
.range-cell {
  width: 100%;
  height: 100%;
  min-width: 0;
  aspect-ratio: auto;
  padding: 0;
  border: 1px solid #1b1d1f;
  border-radius: 0;
  color: #17191a;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  text-shadow: none;
  transform: none;
  transition: border-color 70ms ease;
}
.range-cell.empty { border-color: #1b1d1f; color: #74787b; background: var(--fold) !important; }
.range-cell:hover { z-index: 2; border-color: #f1f1f1; filter: brightness(1.05); transform: none; }
.range-cell.selected { border-color: #1b1d1f; filter: none; transform: none; }
.range-cell::after { display: none; }
.matrix-help { display: none; }

.range-footer {
  display: flex;
  width: 565px;
  height: 70px;
  align-items: flex-start;
  justify-content: flex-end;
}
.copy-range-button {
  margin-top: 20px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #1e2022;
  border-radius: 4px;
  color: #f1f1f1;
  background: #191b1e;
  font-size: 12px;
}
.copy-range-button span { position: relative; display: inline-block; width: 16px; height: 16px; margin-right: 5px; vertical-align: -4px; }
.copy-range-button span::before,
.copy-range-button span::after { position: absolute; width: 9px; height: 11px; border: 1px solid #e4e6e7; border-radius: 1px; content: ""; }
.copy-range-button span::before { top: 1px; left: 2px; }
.copy-range-button span::after { top: 4px; left: 5px; background: #191b1e; }

.details-column { display: none; }
.loading-overlay {
  z-index: 70;
  inset: 32px 0 0;
  background: rgba(0, 0, 0, .72);
  /* Navigation remains responsive while a newly selected table chunk loads. */
  pointer-events: none;
}
.loading-overlay > div { text-align: center; }

@media (max-width: 760px) {
  .workspace { padding-left: 15px; overflow-x: auto; }
}

html { scrollbar-width: none; }
html::-webkit-scrollbar { width: 0; height: 0; }

@media (max-width: 820px) {
  .poker-study-layout { display: block; width: 565px; }
  .study-navigation { display: block; width: 565px; }
  .decision-controls { width: 565px; margin-top: 24px; }
  .context-groups { flex-wrap: wrap; }
  .stack-group,
  .sizing-group,
  .hierarchy-debug { margin-top: 28px; }
  .range-stage { width: 565px; min-width: 565px; margin-top: 24px; }
  .range-hu-row { top: -28px; }
  .matrix-legend { margin-top: 0; }
}

@media print {
  .topbar, .study-navigation, .range-footer, .details-column { display: none !important; }
  .poker-study-layout { display: block; }
}
