/* ── Header ──────────────────────────────────────────────── */

.topbar {
  border-bottom: 1px solid var(--silver-border);
  padding: 0 1.5rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  background: var(--surface-raised);
  box-shadow: 0 1px 8px var(--silver-glow);
}/* ── Sidebars ─────────────────────────────────────────────── */

/* ── Nav rail (left) ─────────────────────────────────────── */

.nav-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 56px;
  background: var(--surface-raised);
  border-right: 1px solid var(--gold-border);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease;
  overflow: hidden;
}

.nav-rail.expanded { width: 200px; }

.nav-rail.expanded .nav-rail-toggle { width: 100%; }

.nav-rail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.nav-rail-top {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-rail-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--gold-border);
  color: var(--gold);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-rail-toggle:hover { background: var(--gold-dim); }

.nav-rail-links {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  gap: 0.15rem;
}

.nav-rail-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 44px;
  padding: 0 0 0 0;
  text-decoration: none;
  color: var(--text-label);
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  overflow: hidden;
}

.nav-rail-link:hover {
  color: var(--text);
  background: var(--gold-dim);
  border-left-color: var(--gold);
}

.nav-rail-link.active {
  color: var(--gold);
  background: var(--gold-dim);
  border-left-color: var(--gold);
}

.nav-rail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 53px;
}

.nav-rail-label {
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-mono), ui-monospace, monospace;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.nav-rail.expanded .nav-rail-label { opacity: 1; }

/* Push main content right so rail doesn't overlap */
.page-wrap { padding-left: 56px; transition: padding-left 0.22s ease; }
body.nav-expanded .page-wrap { padding-left: 200px; }

/* Right sidebar — unchanged */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 260px;
  background: rgba(17, 19, 24, 0.72);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-style: solid;
  border-width: 0;
  border-color: var(--gold-border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform 0.22s ease;
  overflow: hidden;
  font-family: var(--font-mono), ui-monospace, monospace;
}

[data-theme="light"] .nav-rail { background: var(--surface); }
[data-theme="light"] .sidebar { background: rgba(248, 249, 251, 0.78); }
[data-theme="light"] .sidebar-header { background: rgba(255, 255, 255, 0.5); }

.sidebar-right { right: 0; border-left-width: 1px; transform: translateX(100%); }
.sidebar.open  { transform: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--gold-border);
  background: rgba(10, 12, 16, 0.5);
  flex-shrink: 0;
  min-height: 44px;
  gap: 0.4rem;
}

.sidebar-title {
  flex: 1;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.sidebar-header-btns {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sidebar-pin-btn { display: none; color: var(--text-label); border-color: var(--silver-border); }
.sidebar-close   { color: var(--text-label); border-color: var(--silver-border); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* Backdrop (right sidebar only) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 250;
}
.sidebar-backdrop.active { display: block; }

/* Right sidebar pull-tab on mobile */
.sidebar-tab {
  display: none;
  position: fixed;
  top: 65%;
  transform: translateY(-50%);
  z-index: 200;
  background: var(--surface-raised);
  border: 1px solid var(--silver-border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 1.25rem 0.45rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.sidebar-tab:hover { background: var(--surface-3); color: var(--text); }
.sidebar-tab-right { right: 0; border-radius: var(--r-md) 0 0 var(--r-md); border-right: none; }
.sidebar-right.open ~ .sidebar-tab-right { transform: translateY(-50%) scaleX(-1); }

/* Topbar sidebar buttons */
.sidebar-topbar-btn { flex-shrink: 0; }

/* Desktop: show pin button */
@media (min-width: 768px) {
  .sidebar-pin-btn { display: inline-flex; }
}

/* ── Mobile nav rail ─────────────────────────────────────── */

@media (max-width: 767px) {
  .nav-rail {
    top: auto;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.5rem;
    width: auto;
    height: 56px;
    flex-direction: row;
    border: 1px solid var(--gold-border);
    border-radius: 1.25rem;
    background: rgba(17, 19, 24, 0.88);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    box-shadow: 0 8px 28px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,220,100,0.07);
    z-index: 300;
    overflow: hidden;
  }
  [data-theme="light"] .nav-rail {
    background: rgba(255, 255, 255, 0.90);
    box-shadow: 0 8px 28px rgba(0,0,0,0.12), inset 0 1px 0 rgba(160,120,0,0.06);
  }

  .nav-rail-inner {
    flex-direction: row;
    width: 100%;
    height: 56px;
    align-items: stretch;
  }

  .nav-rail-top {
    flex-direction: row;
    flex: 1;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
  }

  .nav-rail-toggle { display: none; }

  .nav-rail-links {
    flex: 1;
    flex-direction: row;
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  .nav-rail-link {
    flex: 1;
    height: 56px;
    padding: 0;
    border-left: none;
    border-bottom: none;
    border-top: 2px solid transparent;
    justify-content: center;
    min-width: 0;
  }

  .nav-rail-link.active {
    border-top-color: var(--gold);
    border-left-color: transparent;
    border-bottom-color: transparent;
  }

  .nav-rail-icon { width: auto; flex: none; }

  .nav-rail-label { display: none; }

  /* Lift toolbar above the floating nav pill so prev/next buttons are always visible */
  .toolbar { bottom: calc(56px + 0.5rem); z-index: 320; }

  /* padding-bottom = floating nav (56px + 8px gap) + toolbar height (~7rem) */
  .page-wrap { padding-left: 0; padding-bottom: calc(56px + 7rem); transition: padding 0.22s ease; }
  body.nav-expanded .page-wrap { padding-left: 0; padding-bottom: calc(56px + 7rem); }

  .sidebar { width: min(85vw, 320px); }
  .sidebar-tab { display: block; }
}

/* ── Rich theme: powerline ribbon on the mobile bottom nav-rail ── */
@media (max-width: 767px) {
  /* Powerline ribbon needs full-width + overflow for the arrow chevrons */
  [data-theme="rich"] .nav-rail {
    left: 0; right: 0; bottom: 0; width: 100%;
    border-radius: 0;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none; border: none; background: transparent;
    overflow: visible;
  }
  [data-theme="rich"] .nav-rail-inner,
  [data-theme="rich"] .nav-rail-top,
  [data-theme="rich"] .nav-rail-links { overflow: visible; background: transparent; border: none; }

  /* Base segment reset */
  [data-theme="rich"] .nav-rail-link {
    position: relative;
    border: none;
    transition: filter 0.12s;
    overflow: visible;
  }

  /* Powerline arrow — 56px-tall right-pointing chevron */
  [data-theme="rich"] .nav-rail-link::after {
    content: '';
    position: absolute;
    right: -14px;
    top: 0;
    bottom: 0;
    width: 0;
    border-top: 28px solid transparent;
    border-bottom: 28px solid transparent;
    border-left: 14px solid #313640;
    z-index: 1;
  }

  /* Per-segment One Dark colors + descending z-index for seamless overlap */
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(1) { z-index: 9; background: #313640; color: #abb2bf; }
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(1)::after { border-left-color: #313640; }

  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(2) { z-index: 8; background: #1d3d6b; color: #61afef; }
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(2)::after { border-left-color: #1d3d6b; }

  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(3) { z-index: 7; background: #1c3823; color: #98c379; }
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(3)::after { border-left-color: #1c3823; }

  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(4) { z-index: 6; background: #3c1e52; color: #c678dd; }
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(4)::after { border-left-color: #3c1e52; }

  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(5) { z-index: 5; background: #3d2e12; color: #e5c07b; }
  /* Last segment: no arrow */
  [data-theme="rich"] .nav-rail-links > .nav-rail-link:nth-child(5)::after { display: none; }

  /* Hover / active */
  [data-theme="rich"] .nav-rail-link:hover { filter: brightness(1.28); }
  [data-theme="rich"] .nav-rail-link.active { filter: brightness(1.45); color: #fff !important; border-top-color: transparent !important; }

  /* Rich: toolbar above the flat nav bar (56px tall, bottom 0) */
  [data-theme="rich"] .toolbar { bottom: 56px; z-index: 320; }
  [data-theme="rich"] .page-wrap { padding-bottom: calc(56px + 6.5rem); }
  [data-theme="rich"] body.nav-expanded .page-wrap { padding-bottom: calc(56px + 6.5rem); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  border-radius: 4px;
  outline-offset: 3px;
}
.brand-link:hover .brand-name {
  -webkit-text-fill-color: var(--gold);
  animation-play-state: paused;
}
.brand-link:hover .brand-icon {
  filter: drop-shadow(0 0 6px var(--gold));
}

.brand-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: var(--gold);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  filter: drop-shadow(0 0 4px var(--gold-glow));
}

.brand-name {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* reset h1 browser defaults when used as a heading */
  margin: 0;
  padding: 0;
  line-height: inherit;
  /* shimmer: gold light sweeps left→right through each word */
  background: linear-gradient(
    90deg,
    var(--text) 0%,
    var(--text) 40%,
    var(--gold) 50%,
    var(--text) 60%,
    var(--text) 100%
  );
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: brand-shimmer 6s ease-in-out infinite;
}

/* ── Topbar controls ─────────────────────────────────────── */

.topbar-a11y {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.a11y-control { display: flex; }

/* ── Unified button foundation ────────────────────────────── */
/* Shape, font, border and transitions shared by every button type.
   Sizing, padding and semantic state colours are set per-class below. */

.btn,
.icon-btn,
.copy-btn,
.challenge-btn,
.puter-ask-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--silver-border);
  border-radius: var(--r-sm);
  color: var(--text-label);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active,
.icon-btn:active,
.copy-btn:active,
.challenge-btn:active,
.puter-ask-btn:active { transform: translateY(1px); }

.btn:disabled,
.icon-btn:disabled,
.copy-btn:disabled,
.challenge-btn:disabled,
.puter-ask-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Gold hover — default for all buttons; semantic overrides follow per-class */
.btn:not(:disabled):hover,
.icon-btn:not(:disabled):hover,
.copy-btn:not(:disabled):hover,
.challenge-btn:not(:disabled):hover,
.puter-ask-btn:not(:disabled):hover {
  color: var(--text);
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

/* ── Icon btn (topbar: A-, A+, theme) ──────────────────────── */
.icon-btn { padding: 0.2rem 0.45rem; }
.icon-btn[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-border); background: var(--gold-dim); }

/* ── Stats widget (footer) ────────────────────────────────── */

.stats-widget {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  background: var(--surface-raised);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-md);
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
}

.stat-item   { color: var(--text-muted); }
.stat-label  { color: var(--text-label); margin-right: 0.1rem; }
.stat-sep    { color: var(--text-label); }
.stat-streak { color: var(--gold); font-weight: 700; }
.stat-pipe   { color: var(--silver-border); padding: 0 0.1rem; }

.stat-reset-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  color: var(--text-label);
  line-height: 1;
}
.stat-reset-btn:hover { color: var(--text); text-decoration: underline; }

/* ── Revisit note ────────────────────────────────────────── */

.revisit-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--gold);
  background: var(--surface-2);
  border-top: 1px solid var(--gold-border);
  padding: 0.45rem 1.5rem;
}

.revisit-note::before {
  content: "↩";
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Layout ──────────────────────────────────────────────── */

.container {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Status bar ──────────────────────────────────────────── */

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--silver-border);
  border-radius: var(--r-md);
  padding: 0.4rem 0.75rem;
  overflow: hidden;
}

.nav-bar-plain {
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-label);
  text-decoration: none;
  transition: color 0.15s ease;
}
.nav-link:hover      { color: var(--gold); }
.nav-link-active     { color: var(--gold); }

.nav-sep {
  font-size: 0.7rem;
  color: var(--text-dim);
  user-select: none;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.3rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-bar.loading .status-dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status-bar.ready   .status-dot { background: var(--green); }
.status-bar.error   .status-dot { background: #ef4444; }
.status-bar.error #status-text  { color: #f87171; }

@keyframes brand-shimmer {
  0%   { background-position: -100% center; }
  55%  { background-position: 200% center; }
  100% { background-position: 200% center; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

