:root {
  --st-shell-navy: #0c2340;
  --st-shell-green: #0d5c3a;
  --st-shell-canvas: #faf5eb;
  --st-shell-surface: #ffffff;
  --st-shell-surface-quiet: #f5efeb;
  --st-shell-text: #0f172a;
  --st-shell-muted: #475569;
  --st-shell-border: rgba(12, 35, 64, 0.14);
  --st-shell-focus: #a84d08;
  --st-shell-shadow: 0 12px 30px -20px rgba(12, 35, 64, 0.38);
}

html { overflow-x: clip; }

.st-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

:root[data-theme="dark"] {
  --st-shell-navy: #19476e;
  --st-shell-green: #0f7047;
  --st-shell-canvas: #071421;
  --st-shell-surface: #0c2340;
  --st-shell-surface-quiet: #102a43;
  --st-shell-text: #f8fafc;
  --st-shell-muted: #cbd5e1;
  --st-shell-border: rgba(203, 213, 225, 0.28);
  --st-shell-focus: #f0b26b;
  --st-shell-shadow: 0 16px 34px -22px rgba(0, 0, 0, 0.8);

  /* Shared tokens used by the older in-domain tools. */
  --color-bg: #071421;
  --color-bg-2: #0a1d30;
  --color-surface: rgba(12, 35, 64, 0.9);
  --color-surface-2: #102a43;
  --color-border: rgba(203, 213, 225, 0.2);
  --color-border-hover: rgba(126, 226, 184, 0.4);
  --color-primary: #9ed0ff;
  --color-primary-glow: rgba(158, 208, 255, 0.22);
  --color-primary-dim: rgba(158, 208, 255, 0.1);
  --color-secondary: #7ee2b8;
  --color-secondary-glow: rgba(126, 226, 184, 0.18);
  --color-accent: #f0b26b;
  --color-amber: #f0b26b;
  --color-text: #f8fafc;
  --color-text-muted: #cbd5e1;
  --color-text-subtle: #9eadbc;
  --shadow-card: 0 18px 42px -28px rgba(0, 0, 0, 0.8);
  --shadow-card-hover: 0 24px 50px -28px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(126, 226, 184, 0.22);

  --color-planet: #19476e;
  --color-planet-glow: rgba(158, 208, 255, 0.22);
  --color-sign: #0f7047;
  --color-sign-glow: rgba(126, 226, 184, 0.2);
  --color-house: #8a4b0f;
  --color-house-glow: rgba(240, 178, 107, 0.2);
  --color-gold: #f0b26b;
  --color-gold-glow: rgba(240, 178, 107, 0.2);

  --cream: #071421;
  --paper: #0c2340;
  --surface: #0c2340;
  --surface-soft: #102a43;
  --ink: #f8fafc;
  --navy: #9ed0ff;
  --navy-soft: #cbd5e1;
  --emerald: #7ee2b8;
  --emerald-bright: #0f7047;
  --amber: #f0b26b;
  --muted: #cbd5e1;
  --border: rgba(203, 213, 225, 0.22);
  --border-strong: rgba(203, 213, 225, 0.42);
  --ring-track: #29435e;
  --shadow: 0 22px 56px -34px rgba(0, 0, 0, 0.85);
}

/* The shared ScreenText header used by every same-domain tool. */
.app-header.st-tool-header {
  position: relative;
  z-index: 120;
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--st-shell-border);
  background: transparent;
  color: var(--st-shell-text);
  font-family: "Inter", "Segoe UI", sans-serif;
}

.st-tool-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--st-shell-text);
  text-decoration: none;
}

.st-tool-brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--st-shell-navy), var(--st-shell-green));
  box-shadow: 0 4px 12px rgba(12, 35, 64, 0.2);
  color: #fff;
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
}

.st-tool-brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.st-tool-brand-copy strong {
  color: var(--st-shell-text);
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.st-tool-brand-copy small {
  margin-top: 0.12rem;
  color: var(--st-shell-green);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:root[data-theme="dark"] .st-tool-brand-copy small { color: #7ee2b8; }

.st-tool-links {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-tool-links a,
.st-tool-back,
.st-tool-cta {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.st-tool-links a {
  padding: 0.5rem 0.8rem;
  color: var(--st-shell-muted);
}

.st-tool-links a:hover { background: var(--st-shell-surface-quiet); color: var(--st-shell-text); }

.st-tool-actions { display: flex; align-items: center; gap: 0.55rem; }

.st-tool-cta {
  padding: 0.5rem 1.15rem;
  background: linear-gradient(135deg, var(--st-shell-navy), var(--st-shell-green));
  box-shadow: var(--st-shell-shadow);
  color: #fff;
}

.st-tool-back {
  display: none;
  padding: 0.45rem 0.65rem;
  color: var(--st-shell-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.st-tool-mobile-toggle {
  display: none;
  min-width: 64px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--st-shell-border);
  border-radius: 12px;
  background: transparent;
  color: var(--st-shell-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.st-tool-mobile-toggle:hover { background: var(--st-shell-surface-quiet); }

.st-tool-mobile-menu {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  z-index: 140;
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  border: 1px solid var(--st-shell-border);
  border-radius: 0 0 16px 16px;
  background: var(--st-shell-surface);
  box-shadow: 0 22px 46px -28px rgba(0, 0, 0, 0.65);
}
.st-tool-mobile-menu[hidden] { display: none !important; }
.st-tool-mobile-menu a {
  min-height: 46px;
  display: flex;
  align-items: center;
  border-radius: 11px;
  padding: 0.6rem 0.8rem;
  color: var(--st-shell-text);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}
.st-tool-mobile-menu a:hover,
.st-tool-mobile-menu a:focus-visible { background: var(--st-shell-surface-quiet); }
.st-tool-mobile-menu .st-tool-mobile-cta {
  justify-content: center;
  background: linear-gradient(135deg, var(--st-shell-navy), var(--st-shell-green));
  color: #fff;
}

.st-theme-picker { position: relative; flex: 0 0 auto; }
.st-theme-trigger {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--st-shell-border);
  border-radius: 12px;
  background: var(--st-shell-surface);
  box-shadow: var(--st-shell-shadow);
  color: var(--st-shell-text);
  cursor: pointer;
}
.st-theme-trigger:hover { background: var(--st-shell-surface-quiet); }
.st-theme-trigger svg,
.st-theme-menu svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon-light,
.theme-icon-dark { display: none; }
:root[data-theme-choice="light"] .theme-icon-system { display: none; }
:root[data-theme-choice="light"] .theme-icon-light { display: block; }
:root[data-theme-choice="dark"] .theme-icon-system { display: none; }
:root[data-theme-choice="dark"] .theme-icon-dark { display: block; }

.st-theme-menu {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 150;
  width: 220px;
  padding: 0.45rem;
  border: 1px solid var(--st-shell-border);
  border-radius: 16px;
  background: var(--st-shell-surface);
  box-shadow: 0 18px 48px -22px rgba(0, 0, 0, 0.55);
}
.st-theme-menu[hidden] { display: none !important; }
.st-theme-menu button {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 24px 1fr 20px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--st-shell-muted);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.st-theme-menu button:hover,
.st-theme-menu button:focus-visible,
.st-theme-menu button[aria-checked="true"] { background: var(--st-shell-surface-quiet); color: var(--st-shell-text); }
.st-theme-menu button > span:nth-child(2) { display: grid; gap: 0.08rem; }
.st-theme-menu strong { color: var(--st-shell-text); font-size: 0.9rem; }
.st-theme-menu small { color: var(--st-shell-muted); font-size: 0.74rem; }
.st-theme-check { color: var(--st-shell-green); font-weight: 900; opacity: 0; text-align: center; }
.st-theme-menu button[aria-checked="true"] .st-theme-check { opacity: 1; }

.app-header.st-tool-header :focus-visible {
  outline: 3px solid var(--st-shell-focus);
  outline-offset: 3px;
}

/* Dark surfaces for tools that originally shipped only in light mode. */
:root[data-theme="dark"] body {
  background-color: var(--st-shell-canvas);
  color: var(--st-shell-text);
}

:root[data-theme="dark"] .glass-card,
:root[data-theme="dark"] .list-panel,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .names-panel,
:root[data-theme="dark"] .results-panel,
:root[data-theme="dark"] .deck-panel,
:root[data-theme="dark"] .timer-card,
:root[data-theme="dark"] .mode-option,
:root[data-theme="dark"] .group-card,
:root[data-theme="dark"] .name-chip,
:root[data-theme="dark"] .deck-item,
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  background-color: var(--st-shell-surface);
  color: var(--st-shell-text);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #9eadbc; opacity: 1; }

:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .pick-button,
:root[data-theme="dark"] .make-button,
:root[data-theme="dark"] .primary-button {
  background: linear-gradient(135deg, #19476e, #0f7047);
  color: #fff;
}

:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .add-button,
:root[data-theme="dark"] .set-button {
  background: #19476e;
  color: #fff;
}

:root[data-theme="dark"] .result-stage,
:root[data-theme="dark"] .flashcard {
  background: linear-gradient(145deg, #132b4b, #1d3d66);
  border-color: rgba(203, 213, 225, 0.24);
}

:root[data-theme="dark"] .group-card h3 { background: #19476e; color: #fff; }
:root[data-theme="dark"] .group-card:nth-child(3n+2) h3 { background: #0f7047; }
:root[data-theme="dark"] .group-card:nth-child(3n) h3 { background: #8a4b0f; }
:root[data-theme="dark"] .text-button.danger,
:root[data-theme="dark"] .form-message.error,
:root[data-theme="dark"] .field-message.error { color: #ffb195; }

@media (max-width: 900px) {
  .st-tool-links,
  .st-tool-cta { display: none; }
  .st-tool-mobile-toggle { display: inline-flex; }
}

@media (max-width: 560px) {
  .app-header.st-tool-header { min-height: 68px; gap: 0.5rem; }
  .st-tool-brand-mark { width: 32px; height: 32px; }
  .st-tool-brand-copy strong { font-size: 1.05rem; }
  .st-tool-brand-copy small { font-size: 0.48rem; }
  .st-tool-actions { gap: 0.2rem; }
}

@media (max-width: 380px) {
  .st-tool-brand-copy small { display: none; }
  .st-tool-mobile-toggle { min-width: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-header.st-tool-header *,
  .app-header.st-tool-header *::before,
  .app-header.st-tool-header *::after { transition-duration: 0.01ms !important; }
}
