:root {
  color-scheme: dark;

  --bg: light-dark(#f4f7fb, #0f1115);
  --panel: light-dark(#ffffff, #151923);
  --panel2: light-dark(#f7f9fc, #111522);
  --text: light-dark(#182132, #e8eaf0);
  --muted: light-dark(#5f697d, #aab0c0);
  --border: light-dark(rgba(17, 24, 39, 0.12), rgba(255, 255, 255, 0.12));
  --border2: light-dark(rgba(17, 24, 39, 0.2), rgba(255, 255, 255, 0.18));
  --border3: light-dark(rgba(17, 24, 39, 0.28), rgba(255, 255, 255, 0.24));
  --accent: #6aa0ff;
  --danger: light-dark(#cf3c3c, #ff6a6a);
  --ok: light-dark(#2f8f5b, #73d39c);
  --warn: light-dark(#2229ea, #ffd27a);

  --surface1: light-dark(rgba(17, 24, 39, 0.02), rgba(255, 255, 255, 0.02));
  --surface2: light-dark(rgba(17, 24, 39, 0.03), rgba(255, 255, 255, 0.03));
  --surface3: light-dark(rgba(17, 24, 39, 0.04), rgba(255, 255, 255, 0.04));
  --surface4: light-dark(rgba(17, 24, 39, 0.06), rgba(255, 255, 255, 0.06));

  --accent-subtle-bg: light-dark(rgba(106, 160, 255, 0.1),
      rgba(106, 160, 255, 0.16));
  --accent-subtle-border: light-dark(rgba(106, 160, 255, 0.34),
      rgba(106, 160, 255, 0.42));
  --accent-soft-ring: light-dark(rgba(106, 160, 255, 0.18),
      rgba(106, 160, 255, 0.24));
  --accent-focus-ring: light-dark(rgba(106, 160, 255, 0.28),
      rgba(106, 160, 255, 0.34));
  --text-soft: light-dark(rgba(24, 33, 50, 0.78), rgba(232, 234, 240, 0.78));

  --table-head-bg: light-dark(rgba(244, 247, 252, 0.96),
      rgba(17, 21, 34, 0.95));
  --table-head-bg-sticky: light-dark(rgba(248, 250, 253, 0.98),
      rgba(17, 21, 34, 0.98));
  --sticky-cell-bg: light-dark(rgba(248, 250, 253, 0.98),
      rgba(15, 17, 21, 0.98));
  --tooltip-bg: light-dark(rgba(17, 24, 39, 0.92), rgba(0, 0, 0, 0.72));
  --scrim-bg: light-dark(rgba(17, 24, 39, 0.18), rgba(0, 0, 0, 0.55));
  --dialog-shadow: light-dark(rgba(17, 24, 39, 0.22), rgba(0, 0, 0, 0.35));
  --debug-bg: light-dark(rgba(255, 255, 255, 0.94), rgba(0, 0, 0, 0.86));
  --menu-bg: light-dark(rgba(255, 255, 255, 0.98), rgba(0, 0, 0, 0.85));

  --sidebar-w: 380px;
  --sidebar-w-min: 300px;
  --sidebar-w-max: 560px;
  --sidebar-resize-w: 10px;
  --header-h-pad: 12px;
  --footer-h-pad: 0px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.4 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
}

/* Prevent page scrolling; only sidebar + main scroll. */
body {
  overflow: hidden;
}

/* Skip link for keyboard users */
.skipLink {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.skipLink:focus {
  left: 10px;
}

/* Holy-grail shell */
.appShell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--sidebar-resize-w) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header header"
    "sidebar divider main"
    "footer footer footer";
  overflow: hidden;
}

/* Header */
.appHeader {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--header-h-pad);
  border-bottom: 1px solid var(--border);
  background: var(--surface1);
  min-width: 0;
}

.appTitle {
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.01em;
}

.appHeaderRight {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.headerUtilityGroup {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.headerActionGroup {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Top view tabs */
.topTabs {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--surface2);
  box-shadow: inset 0 1px 0 var(--surface4);
}

.topTabs [role="tab"] {
  position: relative;
  appearance: none;
  border: 0;
  margin: 0;
  min-height: 42px;
  padding: 8px 22px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.topTabs [role="tab"]+[role="tab"]::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}

.topTabs [role="tab"]:hover {
  background: var(--surface3);
  color: var(--text);
}

.topTabs [role="tab"][aria-selected="true"] {
  background: color-mix(in srgb, var(--panel) 82%, var(--accent) 18%);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent-soft-ring),
    0 0 0 1px var(--accent-subtle-border);
}

.topTabs [role="tab"][aria-selected="true"]::before,
.topTabs [role="tab"][aria-selected="true"]+[role="tab"]::before {
  opacity: 0;
}

.topTabs [role="tab"][hidden] {
  display: none;
}

.pcPlaceholderViewBody {
  min-height: 0;
  overflow: auto;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.pcPlaceholderViewTitle {
  margin: 0;
  font-size: 20px;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.pcPlaceholderViewText {
  margin: 0;
  max-width: 48rem;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Light/dark theme controls */
.themeControl {
  width: 36px;
  display: grid;
  grid-template-rows: 14px 14px;
  gap: 2px;
  flex: 0 0 auto;
}

.themeMiniSwitch {
  position: relative;
  display: block;
  height: 14px;
  cursor: pointer;
}

.themeMiniSwitch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.themeMiniTrack {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  padding: 1px;
  border-radius: 999px;
  background: var(--surface2);
  overflow: hidden;
}

.themeMiniSelectBg {
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(50% - 1px);
  height: calc(100% - 2px);
  border-radius: 999px;
  background: var(--surface4);
  border: 1px solid var(--border);
  transition:
    transform 160ms ease,
    opacity 160ms ease;
  pointer-events: none;
}

.themeControl[data-resolved-theme="dark"] .themeMiniSelectBg {
  transform: translateX(100%);
}

.themeControl[data-theme-mode="auto"] .themeMiniSelectBg {
  opacity: 0.58;
}

.themeMiniOption {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.themeIcon {
  display: inline-grid;
  place-items: center;
  width: 10px;
  height: 10px;
  color: var(--muted);
}

.themeIcon svg {
  width: 10px;
  height: 10px;
  display: block;
  fill: currentColor;
}

.svgIcon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#pc_btnAccount {
  margin-left: 2em;
}

.themeControl[data-resolved-theme="light"] .themeMiniOptionLight .themeIcon,
.themeControl[data-resolved-theme="dark"] .themeMiniOptionDark .themeIcon {
  color: var(--text);
}

.themeControl[data-theme-mode="auto"] .themeIcon {
  color: var(--text-soft);
}

.themeMiniSwitch input:focus-visible+.themeMiniTrack,
.themeAutoBtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.themeAutoBtn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  width: 100%;
  min-width: 0;
  height: 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.themeAutoBtn:hover {
  color: var(--text);
}

.themeControl[data-theme-mode="auto"] .themeAutoBtn {
  background: var(--surface4);
  color: var(--text);
}

/* Session controls */
.headerUtilityGroup {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.headerActionGroup {
  display: flex;
  align-items: center;
  gap: 6px;
}

.iconBtn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}

.iconBtn:hover {
  border-color: var(--border2);
  background: var(--surface4);
}

.iconBtn img {
  width: 18px;
  height: 18px;
  display: block;
  opacity: 0.9;
}

.iconBtnSubtle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.iconBtnSubtle:hover {
  background: var(--surface4);
  border-color: var(--border2);
  color: var(--text);
}

.iconBtnSubtle img {
  width: 16px;
  height: 16px;
  opacity: 0.72;
}

.iconSvg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

.iconBtnSubtle .iconSvg {
  width: 16px;
  height: 16px;
}

button.controlBtn {
  border: none;
  outline: none;
  background: none;
}

button.controlBtn svg.iconSvg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* 
button.controlBtn[aria-pressed="false"] svg.iconSvg.onIcon {
  color: red;
  width: 0;
  height: 0;
}

button.controlBtn[aria-pressed="true"] svg.iconSvg.offIcon {
  width: 0;
  height: 0;
} 
*/

/* Sidebar */
.toolPanel {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.toolPanelBody {
  padding: 14px 14px 8px 14px;
  overflow: auto;
  min-height: 0;
  /* critical for overflow in flex/grid children */
}

/* Panel Resizer */
.sidebarResizeHandle {
  grid-area: divider;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  width: 100%;
  background: transparent;
  cursor: col-resize;
  position: relative;
  touch-action: none;
}

.sidebarResizeHandle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 1px);
  width: 2px;
  background: transparent;
  transition: background-color 120ms ease;
}

.sidebarResizeHandle:hover::before,
.sidebarResizeHandle:focus-visible::before,
body.isResizingSidebar .sidebarResizeHandle::before {
  background: var(--border2);
}

.sidebarResizeHandle:focus-visible {
  outline: none;
}

body.isResizingSidebar {
  cursor: col-resize;
  user-select: none;
}

/* Data panel: collapsible blocks */
.detailsBlock {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
  padding: 12px;
  /* margin-bottom: 12px; */
}

.detailsBlock>summary {
  cursor: pointer;
  /* color: var(--text); */
}

.detailsMeta {
  color: var(--muted);
  font-size: 12px;
}

.detailsBlock[open] .detailsMeta {
  opacity: 0.7;
}

/* Dataset summary */
.datasetSummary .summarySection,
.dataStatusBlock .summarySection {
  margin-top: 8px;
  color: var(--text);
  font-weight: 600;
}

.datasetSummary .summaryBullet,
.dataStatusBlock .summaryBullet {
  color: var(--muted);
  padding-left: 2px;
}

.datasetSummary,
.dataStatusBlock {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 1em;
}

.dataStatusBlock {
  padding-top: 0.5em;
}

.datasetSummary .kv,
.dataStatusBlock .kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.datasetSummary .kv .k,
.dataStatusBlock .kv .k {
  color: var(--muted);
}

.datasetSummary .kv .v,
.dataStatusBlock .kv .v {
  color: var(--text);
  text-align: right;
}

.datasetSuggestion {
  margin-top: 4px;
}

.linkButton {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.linkButton:hover {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
  border-radius: 6px;
}

.linkButton:focus-visible {
  outline: 3px solid rgba(106, 160, 255, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Main */
.viewsPanel {
  grid-area: main;
  min-width: 0;
  overflow: hidden;
  /* views manage internal scroll */
  display: block;
}

.pc_manifestView {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 12px;
  overflow: auto;
  white-space: pre;
  border-top: 1px solid var(--border-subtle);
}

/* Footer */
.appFooter {
  grid-area: footer;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: var(--footer-h-pad);
}

/* Bottom panel tabs */
.bottomTabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border-top: 1px solid var(--border);
}

.bottomTabs [role="tab"] {
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 12px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.bottomTabs [role="tab"]:last-child {
  border-right: 0;
}

.bottomTabs [role="tab"]:hover {
  background: var(--surface4);
  color: var(--text);
}

.bottomTabs [role="tab"][aria-selected="true"] {
  background: var(--accent-subtle-bg);
  color: var(--text);
  box-shadow: inset 0 2px 0 var(--accent);
}

/* Panels */
.toolPanelBody [role="tabpanel"][hidden] {
  display: none;
}

.toolPanelBody [role="tabpanel"]:not([hidden]) {
  display: block;
}

h1 {
  font-size: 18px;
  margin: 0 0 12px 0;
}

h2,
summary {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

h2,
h3,
summary {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

h2 {
  font-size: 13px;
}

h3,
summary {
  font-size: 12px;
  font-weight: bold;
}

.block {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
  margin-bottom: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.field>span {
  color: var(--muted);
  font-size: 12px;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
}

select,
button,
input[type="text"],
textarea {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  outline: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

select:not([multiple]):not(.pcRichSelect):not(.tourPhraseIndex) {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 10px;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 17px 17px;
}

select:not([multiple]):not(.pcRichSelect):not(.tourPhraseIndex)::-ms-expand {
  display: none;
}

.pcRichSelect,
.pcRichSelect::picker(select) {
  appearance: base-select;
}

.pcRichSelect {
  min-width: 0;
  padding-right: 0;
}

.pcRichSelect option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pcRichSelect::picker-icon {
  content: "";

  width: 18px;
  height: 18px;

  background-color: currentColor;

  mask:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1'/></svg>") center / 18px 18px no-repeat;

  -webkit-mask:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1'/></svg>") center / 18px 18px no-repeat;

  transform: translate(-5px, 2px);
}

.pcRichSelect optgroup legend {
  font-weight: normal;
  background-color: var(--panel2);
  color: var(--muted);
}

.pcRichSelect optgroup+optgroup {
  border-top: 1px solid var(--pc-border-subtle);
  padding-top: 0.25rem;
}


.pcSelectIcon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: currentColor;
}


/* Sources buttons */

.sourceActionRow {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-around;
}

.sourceTile {
  width: 84px;
  height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.sourceTile:hover {
  background: var(--surface4);
  border-color: var(--border2);
  box-shadow: 0 0 0 1px var(--accent-soft-ring);
}

.sourceTile .iconSvg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.sourceLabel {
  font-size: 12px;
  color: var(--muted);
}

.sourceTile:hover .sourceLabel {
  color: var(--text);
}

.visuallyHiddenFileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visibility (keyboard accessibility) */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-focus-ring);
}

select[multiple] {
  padding: 6px;
}

textarea.monoArea {
  width: 100%;
  font:
    12px/1.35 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

button:hover {
  background: var(--surface4);
  border-color: var(--border2);
}

.status {
  color: var(--muted);
  margin-top: 8px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.errors {
  color: var(--danger);
  font-size: 12px;
  margin: 8px 0 0 0;
}

.errors .fixRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.errors .fixBtn {
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}

.parseReport {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface1);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
}

.parseReport .line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.badgeOk {
  color: var(--ok);
}

.badgeWarn {
  color: var(--warn);
}

.badgeBad {
  color: var(--danger);
}

.facetsSummary {
  display: grid;
  gap: 8px;
}

/* 
.facetRow {
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) minmax(0, auto);
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  scroll-margin-top: 40px;
  scroll-margin-bottom: 40px;
  border-radius: 0;
}

.facetRow > :nth-child(2),
.facetRow > :nth-child(3) {
  min-width: 0;
  justify-self: end;
}

.facetRow > :first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facetRow .facetPill {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
} */

.facetNameInput {
  width: 100%;
}

.facetRow:last-child {
  border-bottom: none;
}

/* Keep pills visually secondary */
.facetRow> :nth-child(2),
.facetRow> :nth-child(3) {
  opacity: 0.85;
}

/* Slightly stronger on hover/focus */
.facetRow:hover> :nth-child(2),
.facetRow:hover> :nth-child(3),
.facetRow.pcFocused> :nth-child(2),
.facetRow.pcFocused> :nth-child(3) {
  opacity: 1;
}

/* View panels */
.viewsPanel [role="tabpanel"] {
  height: 100%;
  outline: none;
  overflow: hidden;
}

.viewsPanel [role="tabpanel"][hidden] {
  display: none;
}

.viewsPanel [role="tabpanel"]:not([hidden]) {
  display: grid;
  grid-template-rows: 1fr auto;
  /* scroll region + footer */
  min-height: 0;
}

/* Footer under each view */
.viewFooter {
  padding: 0 12px 12px 12px;
}

/* Table */
.tableWrap {
  overflow: auto;
  padding: 12px;
  min-height: 0;
  /* critical inside grid */
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--table-head-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  white-space: nowrap;
  z-index: 2;
}

thead th.stickyFirst {
  left: 0;
  position: sticky;
  z-index: 3;
  background: var(--table-head-bg-sticky);
}

.thBtn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.sortBadge {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

/* Meta icon button: small, inline, calm */
.facetMetaBtn {
  margin-left: 8px;
  padding: 0 6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--surface2);
  color: var(--muted);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: help;
}

/* Only "wake up" on hover/focus */
thead th:hover .facetMetaBtn,
thead th:focus-within .facetMetaBtn {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
  background: var(--surface4);
}

.facetMetaIcons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.facetMetaIcon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  display: block;
  fill: currentColor;
}

/* Make facet type/kind read like badges */
.facetRow .facetPill {
  justify-self: end;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: var(--surface3);
  color: var(--muted);
  text-align: right;
}

/* Persistent highlight */
.facetRow.pcFocused {
  background: rgba(106, 160, 255, 0.12);
  box-shadow: inset 3px 0 0 rgba(106, 160, 255, 0.65);
  padding-left: 7px;
  /* compensate for border */
  margin-left: -7px;
  /* compensate for border */
}

/* Arrival pulse */
.facetRow.pcFocused.pcFocusPulse {
  animation: pcFocusPulse 600ms ease-out;
}

@keyframes pcFocusPulse {
  0% {
    background: rgba(106, 160, 255, 0.35);
  }

  60% {
    background: rgba(106, 160, 255, 0.2);
  }

  100% {
    background: rgba(106, 160, 255, 0.12);
  }
}

/* Make sure the sort glyph stays visually separate */
.sortBadge {
  margin-left: 8px;
}

tbody td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 10px;
  color: var(--text);
  white-space: nowrap;
}

tbody td.stickyFirst {
  left: 0;
  position: sticky;
  z-index: 1;
  background: var(--sticky-cell-bg);
  border-right: 1px solid var(--border);
  color: var(--muted);
}

tbody tr:hover td {
  background: var(--surface2);
}

tbody tr:hover td.stickyFirst {
  background: var(--sticky-cell-bg);
}

td.bad {
  outline: 1px solid rgba(255, 106, 106, 0.35);
  background: rgba(255, 106, 106, 0.05);
}

td.selected {
  outline: 2px solid rgba(106, 160, 255, 0.55);
  background: rgba(106, 160, 255, 0.08);
}

.cellInput {
  width: 100%;
  border-radius: 8px;
  padding: 6px 8px;
}

/* Chart */
.chartWrap {
  overflow: auto;
  padding: 12px;
  min-height: 0;
}

.chartHost {
  height: 100%;
  min-height: 320px;
  /* keeps it usable if the viewport is short */
}

.pcTooltip {
  position: absolute;
  pointer-events: none;
  background: var(--tooltip-bg);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  max-width: 320px;
  display: none;
  transform: translate(10px, 10px);
}

.pcLegend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 0 12px 12px 12px;
}

.pcLegend button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}

.pcLegend button.off {
  opacity: 0.45;
  text-decoration: line-through;
}

/* Tours log styling moved from inline style */
.toursLog {
  height: 160px;
  overflow: auto;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface1);
}

/* Dialogs */
/* My data dialog */
.pcDialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(720px, 92vw);
}

.pcDialog::backdrop {
  background: var(--scrim-bg);
}

.pcDialogInner {
  margin: 0;
  padding: 0;
}

.pcDialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pcDialogHeader h2 {
  margin: 0;
  font-size: 16px;
}

.pcDialogClose {
  border-radius: 10px;
  padding: 6px 10px;
}

.pcDialogBody {
  padding: 14px;
}

.pcDialogFooter {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 1em;
}

.pcMyDataList {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.pcMyDataItem {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface1);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  align-items: center;
}

.pcMyDataTitle {
  font-weight: 600;
}

.pcMyDataMeta {
  color: var(--muted);
  font-size: 12px;
}

.pcMyDataUseBtn {
  grid-row: 1 / span 2;
  grid-column: 2;
  border-radius: 999px;
  padding: 8px 12px;
}

/* Chart SVG classes (colors controlled by CSS, not JS) */
.chartSvg {
  width: 100%;
  height: 100%;
}

.axisLine {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

.axisTick {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

.gridLine {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.tickLabel {
  fill: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}

.chartTitle {
  fill: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 600;
}

.seriesLine {
  stroke: rgba(106, 160, 255, 0.9);
}

.seriesPoint {
  fill: rgba(106, 160, 255, 0.9);
}

.barRect {
  fill: rgba(106, 160, 255, 0.65);
}

/* Future mobile room (intentionally minimal; not “mobile UI” yet) */
@media (max-width: 860px) {
  :root {
    --sidebar-w: 320px;
  }
}

/* Debugging */

/* Debug panel */

#pc_debugPanel {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 300px;
  max-height: 40vh;
  background: var(--menu-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  font:
    12px/1.3 ui-monospace,
    monospace;
  color: #e8eaf0;
  display: flex;
  flex-direction: column;
  z-index: 9999;
}

#pc_debugPanel.hidden {
  display: none;
}

.pcDebugHeader {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pcDebugHeader button {
  font-size: 11px;
  padding: 2px 6px;
}

.pcDebugLog {
  overflow: auto;
  padding: 6px;
}

.pcDebugRow {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* State inspector */

#pc_stateInspector {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 520px;
  height: 70vh;
  display: flex;
  flex-direction: column;
  z-index: 9998;
  background: var(--debug-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #e8eaf0;
}

#pc_stateInspector.hidden {
  display: none;
}

.pcStateHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.pcStateTitle {
  font:
    12px/1.2 ui-monospace,
    monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pcStateActions {
  display: flex;
  gap: 8px;
}

#pc_stateInspector button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--surface4);
  color: #e8eaf0;
  cursor: pointer;
}

#pc_stateInspector button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pcStateBody {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pcStateMeta {
  padding: 8px 10px;
  font:
    11px/1.3 ui-monospace,
    monospace;
  color: rgba(232, 234, 240, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pcStatePre {
  margin: 0;
  padding: 10px;
  overflow: auto;
  min-height: 0;
  font:
    12px/1.35 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  white-space: pre;
}

.filelist {
  display: flex;
  justify-content: space-between;
}

.filelist div p {
  padding: 0 0 0.25em 0;
  margin: 0;
}

/* Publish */

#pc_publishToursText {
  height: 20em;
}

.share_output {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  gap: 0.5em;
}

#pc_publishStatus a {
  font-size: 1.1em;
  color: var(--text);
}

#pc_qrCanvas {
  height: 150px;
  width: 150px;
}


/* profiles */

.headerMenuWrap {
  position: relative;
  flex: 0 0 auto;
  anchor-name: --pc-profile-anchor;
  display: inline-block;
}

.headerMenu {
  position: absolute;
  position-anchor: --pc-profile-anchor;
  top: anchor(bottom);
  right: anchor(right);
  left: auto;
  bottom: auto;
  margin: 8px 0 0 0;
  padding: 8px;
  min-width: 220px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--menu-bg);
  color: var(--text);
  box-shadow: 0 12px 28px var(--dialog-shadow);
  overflow: visible;
}

.headerMenu:popover-open {
  display: block;
}

.headerMenuSection {
  display: grid;
  gap: 4px;
}

.headerMenuLabel {
  padding: 6px 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.headerMenuItem {
  appearance: none;
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.headerMenuItem:hover {
  background: var(--surface4);
  border-color: var(--border2);
}

.headerMenuItem[aria-checked="true"] {
  background: var(--accent-subtle-bg);
  border-color: var(--accent-subtle-border);
  box-shadow: inset 0 0 0 1px var(--accent-soft-ring);
}

.headerMenuItemTitle {
  font-size: 13px;
  font-weight: 600;
}

.headerMenuItemMeta {
  color: var(--muted);
  font-size: 12px;
}