:root {
  --header-height: 74px;
  --sidebar-width: clamp(310px, 24vw, 410px);
  --bg: #f4f0ff;
  --panel: #ffffff;
  --panel-2: #f1ebff;
  --text: #22183f;
  --muted: #5e5487;
  --accent: #6d3af2;
  --accent-2: #8f68ff;
  --border: #dbd1f4;
  --shadow: 0 10px 24px rgba(57, 35, 116, 0.1);
  --radius: 14px;
  --pill-bg: rgba(109, 58, 242, 0.12);
  --pill-text: #4f4a8f;
  --quote-bg: color-mix(in srgb, var(--accent) 7%, white 93%);
  --quote-border: color-mix(in srgb, var(--accent) 34%, var(--border) 66%);
  --quote-text: color-mix(in srgb, var(--text) 88%, var(--accent) 12%);
  --text-on-accent: #ffffff;
  --overlay-backdrop: rgba(0, 0, 0, 0.45);
  --on-accent-border: rgba(255, 255, 255, 0.65);
  --on-accent-surface: rgba(255, 255, 255, 0.15);
  --mode-wizard-bg: linear-gradient(135deg, #6d3af2 0%, #8f68ff 100%);
  --mode-wizard-border: #6d3af2;
  --mode-wizard-text: var(--text-on-accent);
}

html[data-theme="dark"] {
  --bg: #171127;
  --panel: #211738;
  --panel-2: #2a1f45;
  --text: #f3eefe;
  --muted: #c3b6ec;
  --accent: #9c7dff;
  --accent-2: #b49dff;
  --border: #3a2d5b;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  --pill-bg: rgba(180, 157, 255, 0.16);
  --pill-text: #efe9ff;
  --quote-bg: color-mix(in srgb, var(--accent) 12%, var(--panel) 88%);
  --quote-border: color-mix(in srgb, var(--accent) 42%, var(--border) 58%);
  --quote-text: color-mix(in srgb, var(--text) 92%, var(--accent) 8%);
  --mode-wizard-bg: linear-gradient(135deg, #9c7dff 0%, #b49dff 100%);
  --mode-wizard-border: #b49dff;
  --mode-wizard-text: #140d25;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.65;
  overflow: hidden;
}

code, pre { font-family: "IBM Plex Mono", "Cascadia Code", monospace; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: 0 0 auto;
  border: 0;
  box-shadow: none;
}

.topbar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-title {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.1;
}

.topbar-subtitle {
  margin-top: 0.08rem;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.15;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--panel-2) 82%, var(--accent) 18%);
  transform: translateY(-1px);
}

#nav-toggle { display: none; }
#theme-toggle { margin-left: auto; }

.topbar-wizard-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  width: 92px;
  height: 38px;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.84rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s;
}

.topbar-wizard-btn svg { flex: 0 0 auto; }
.wizard-label { line-height: 1; }

.topbar-wizard-btn--wizard {
  background: var(--mode-wizard-bg);
  border-color: var(--mode-wizard-border);
  color: var(--mode-wizard-text);
  box-shadow: 0 10px 24px rgba(57, 35, 116, 0.12);
}

.topbar-wizard-btn--guide {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

.topbar-wizard-btn:hover { transform: translateY(-1px); }

.topbar-wizard-btn:hover,
.topbar-wizard-btn:focus-visible {
  text-decoration: none;
}

.topbar-wizard-btn--wizard:hover {
  color: var(--mode-wizard-text);
  box-shadow: 0 14px 28px rgba(57, 35, 116, 0.18);
}

.topbar-wizard-btn--wizard:focus-visible {
  color: var(--mode-wizard-text);
}

.topbar-wizard-btn--guide:hover {
  background: color-mix(in srgb, var(--panel-2) 78%, var(--accent) 22%);
  color: var(--accent);
  box-shadow: none;
}

.topbar-wizard-btn--guide:focus-visible {
  color: var(--accent);
}

.topbar-wizard-btn:active { transform: scale(0.97); }

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow: auto;
  z-index: 30;
}

.sidebar__inner {
  padding: 1rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

#sidebar-nav {
  flex: 1 1 auto;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.35rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

.sidebar-support-links {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0 0.9rem;
}

.sidebar-support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  box-shadow: none;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-support-link:hover,
.sidebar-support-link:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--panel-2) 80%, var(--accent) 20%);
  color: var(--accent);
  transform: translateY(-1px);
}

.sidebar-support-link--github {
  width: 44px;
  height: 44px;
}

.sidebar-support-link--github svg,
.sidebar-support-link--kofi svg {
  width: 22px;
  height: 22px;
}

.sidebar-support-link--kofi svg {
  width: 25px;
  height: 25px;
}

.sidebar-support-link--kofi {
  flex: 0 0 auto;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0 1rem;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.sidebar-stat-card {
  position: relative;
  z-index: 2;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--panel-2), color-mix(in srgb, var(--panel) 78%, var(--accent) 22%));
  box-shadow: none;
  text-align: center;
  overflow: visible;
}

.sidebar-stat-toggle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  z-index: 4;
}

.sidebar-stat-toggle:hover,
.sidebar-stat-toggle:focus-visible {
  color: var(--accent);
  background: color-mix(in srgb, var(--panel) 30%, transparent 70%);
  box-shadow: 0 6px 14px rgba(57, 35, 116, 0.16);
}

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

.sidebar-stat-toggle__icon {
  display: block;
  width: 28px;
  height: 18px;
  filter: drop-shadow(0 2px 4px rgba(57, 35, 116, 0.22));
  transition: transform 0.18s ease, filter 0.18s ease;
}

.sidebar-stat-toggle__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sidebar-stat-toggle__icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-stat-card[data-sidebar-stats-open="true"] .sidebar-stat-toggle__icon {
  transform: rotate(180deg);
}

.sidebar-stat-card[data-sidebar-stats-open="true"] {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top-color: transparent;
}

.sidebar-stats-panel {
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: calc(100% - 1px);
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding: 0.42rem 0.5rem 0.5rem;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(145deg, var(--panel-2), color-mix(in srgb, var(--panel) 78%, var(--accent) 22%));
  backdrop-filter: none;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transform-origin: bottom center;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  max-height: var(--sidebar-stats-max-height, calc(100vh - var(--header-height) - 18px));
  overflow: hidden;
  z-index: 3;
}

.sidebar-stat-card[data-sidebar-stats-open="true"] .sidebar-stats-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.sidebar-stats-panel__header {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  align-items: center;
  text-align: center;
}

.sidebar-stats-panel__header strong {
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
}

.sidebar-stats-panel__header span {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.3;
}

.sidebar-stats-panel__content {
  display: grid;
  gap: 0.24rem;
  overflow: hidden;
}

.sidebar-stats-accounts {
  display: grid;
  gap: 0.24rem;
}

.sidebar-stats-total-card,
.sidebar-stats-platform-card,
.sidebar-stats-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.sidebar-stats-total-card {
  display: grid;
  gap: 0.12rem;
  padding: 0.32rem 0.55rem 0.36rem;
  text-align: center;
}

.sidebar-stats-total-card__label,
.sidebar-stats-row__label {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.05;
}

.sidebar-stats-total-card__value,
.sidebar-stats-platform-card__value,
.sidebar-stats-icon-item__count,
.sidebar-stats-platform-card__mode strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sidebar-stats-total-card__value {
  font-size: 1.04rem;
  line-height: 1;
}

.sidebar-stats-platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.24rem;
}

.sidebar-stats-platform-card {
  display: grid;
  gap: 0.16rem;
  padding: 0.32rem 0.38rem;
  text-align: center;
}

.sidebar-stats-platform-card__head {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
}

.sidebar-stats-platform-card__logo {
  max-width: 34px;
  height: 13px;
  object-fit: contain;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.sidebar-stats-platform-card__value {
  font-size: 0.88rem;
  line-height: 1;
}

.sidebar-stats-platform-card__modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--border);
}

.sidebar-stats-platform-card__mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.04rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.sidebar-stats-mode-icon {
  width: 15px;
  height: 15px;
  min-height: 15px;
  color: var(--muted);
  flex: 0 0 auto;
  display: block;
}

.sidebar-stats-platform-card__mode strong {
  display: block;
  line-height: 1;
  margin-top: -0.02rem;
}

.sidebar-stats-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 0.22rem;
  padding: 0.26rem 0.4rem 0.3rem;
}

.sidebar-stats-row__label {
  text-align: left;
}

.sidebar-stats-icon-row {
  display: grid;
  justify-items: center;
  align-items: start;
  gap: 0.16rem;
}

.sidebar-stats-icon-row--logos,
.sidebar-stats-icon-row--emoji {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.sidebar-stats-icon-row--discover {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sidebar-stats-icon-row--categories {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sidebar-stats-icon-row--formatter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sidebar-stats-icon-row--addons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sidebar-stats-icon-item {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.08rem;
  min-width: 0;
  padding: 0.08rem 0.08rem;
}

.sidebar-stats-icon-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  margin: 0 auto;
}

.sidebar-stats-icon-item__logo {
  max-width: 20px;
  max-height: 14px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.sidebar-stats-icon-item__emoji {
  font-size: 1.08rem;
  line-height: 1;
}

.sidebar-stats-icon-item__text {
  color: var(--muted);
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
}

.sidebar-stats-icon-item__count {
  font-size: 0.68rem;
  line-height: 1.05;
  white-space: nowrap;
}

.sidebar-stat-card__eyebrow,
.sidebar-stat-card__suffix {
  display: block;
  color: var(--muted);
  line-height: 1.2;
}

.sidebar-stat-card__eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-stat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: stretch;
  margin-top: 0;
  padding: 1.2rem 0.95rem 1rem;
}

.sidebar-stat-divider {
  width: 1px;
  background: color-mix(in srgb, var(--border) 75%, transparent 25%);
  border-radius: 999px;
}

.sidebar-stat-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
}

.sidebar-stat-item__label,
.sidebar-stat-item__suffix {
  display: block;
  line-height: 1.2;
}

.sidebar-stat-item__label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-stat-item__value {
  display: block;
  color: var(--accent);
  font-size: clamp(1.35rem, 0.95rem + 1vw, 1.95rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sidebar-stat-item__suffix {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
}

.sidebar-credit {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.sidebar-credit__link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.sidebar-credit__link:hover,
.sidebar-credit__link:focus-visible {
  color: var(--accent-2);
  text-decoration: underline;
}

.layout {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  left: var(--sidebar-width);
  overflow-y: auto;
}

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.1rem 1rem 2rem;
}

.doc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem clamp(1rem, 2vw, 2rem) 1.2rem;
  overflow-wrap: anywhere;
}

.fade-in { animation: fadeIn 320ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-backdrop);
  border: 0;
  z-index: 25;
}

@media (max-width: 1040px) {
  #nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-title { font-size: 1.05rem; }
  .topbar-subtitle { font-size: 0.76rem; }

  .layout { left: 0; }

  .sidebar {
    width: min(96vw, 560px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 66px;
    padding: 0 0.7rem;
    gap: 0.5rem;
  }

  .topbar-logo { width: 28px; height: 28px; }
  .topbar-title { font-size: 0.95rem; }
  .topbar-subtitle { display: none; }

  .topbar-wizard-btn {
    width: 78px;
    height: 34px;
    padding: 0 0.55rem;
    font-size: 0.8rem;
    border-radius: 9px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 0.95rem;
  }

  .topbar-wizard-btn svg {
    width: 14px;
    height: 14px;
  }

  .doc-card {
    padding: 1rem 0.85rem;
    border-radius: 12px;
  }

  .sidebar-stat-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-stat-divider {
    width: auto;
    height: 1px;
  }

  .sidebar-stats-panel {
    max-height: calc(100vh - var(--header-height) - 12px);
  }

  .sidebar-stats-row {
    grid-template-columns: 68px minmax(0, 1fr);
    padding-left: 0.28rem;
    padding-right: 0.28rem;
  }

  .sidebar-stats-platform-card__logo {
    max-width: 40px;
    height: 15px;
  }

  .sidebar-stats-icon-row--logos,
  .sidebar-stats-icon-row--emoji {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
