:root {
  /* Design tokens. A tool's own theme.css loads after this file and can
     override any of these to give that tool its own accent palette while
     keeping the same structure/spacing everywhere. */
  --bg-flat: #eceafb;
  --panel: #ffffff;
  --panel-border: rgba(31, 35, 51, 0.08);
  --display-grad: linear-gradient(135deg, #7c5cff 0%, #4f8cff 100%);

  --accent-primary: #7c5cff;
  --accent-primary-dim: rgba(124, 92, 255, 0.14);
  --accent-teal: #0d9488;
  --accent-teal-dim: rgba(13, 148, 136, 0.12);
  --accent-rose: #e11d74;
  --accent-rose-dim: rgba(225, 29, 116, 0.1);
  --accent-amber: #d97706;
  --accent-amber-dim: rgba(217, 119, 6, 0.12);
  --accent-blue: #2563eb;
  --accent-blue-dim: rgba(37, 99, 235, 0.12);
  --accent-error: #e11d48;

  --text-primary: #1f2333;
  --text-muted: #585c7b;
  --text-on-accent: #ffffff;

  --key-bg: #f5f4fb;
  --key-bg-hover: #ebe9f7;
  --radius: 20px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* The widest a tool's own content gets (see e.g. compound-interest and
     mortgage's theme.css, which override their .xx-app content element to
     this same width for their multi-panel layouts). The header/footer use
     it directly below so they're consistently wide on every page, matching
     whichever tool currently needs the most room - not just the page
     currently being viewed. */
  --content-wide: 900px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg-flat);
  color: var(--text-primary);
  font-family: var(--sans);
  display: flex;
  justify-content: center;
  padding: 24px;
}

.page {
  width: 100%;
  min-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* A tool's default content (.card/.info/.hint) is centered independently
   of .page, which has no max-width of its own - that way switching
   between tools never shifts the header/footer, even when one specific
   tool's content needs to be wider: that tool overrides the width of just
   its own content element (see e.g. compound-interest's theme.css). */
.card, .info, .hint {
  width: 100%;
  max-width: 640px;
}

/* The header and footer are always --content-wide (currently 900px, the
   widest any tool's own content gets) regardless of which tool is showing,
   so they read as one consistent site-wide chrome band rather than
   resizing with each page's own content width. */
.site-header, .site-footer {
  width: 100%;
  max-width: var(--content-wide);
}

/* ---------- Site header / banner: a distinct colored band, not just
   text sitting on the page background ---------- */
.site-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  text-align: center;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  padding: 26px 20px;
  border-radius: var(--radius);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.site-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-decoration: none;
}

/* ---------- Submenu: cross-tool navigation ---------- */
.submenu {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* A category with no live tools is a single disabled pill (.submenu-cat-
   disabled); a category with live tools is a button (.submenu-cat-btn)
   that reveals its own tools in .submenu-dropdown - both top-level pills
   share the same base look. */
.submenu-category { position: relative; }

.submenu-cat-btn, .submenu-cat-disabled {
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.submenu-cat-btn { font: inherit; cursor: pointer; }
.submenu-cat-btn:hover { background: rgba(255, 255, 255, 0.28); }

.submenu-cat-btn.active {
  color: var(--accent-primary);
  background: #ffffff;
  font-weight: 600;
}
.submenu-cat-btn.active:hover { background: #ffffff; }

.submenu-cat-btn::after {
  content: '';
  width: 0;
  height: 0;
  margin-left: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.submenu-category.open .submenu-cat-btn::after { transform: rotate(180deg); }

.submenu-cat-disabled { cursor: not-allowed; opacity: 0.75; }

/* A floating card, not a second pill row - opacity/transform/visibility
   (not display) so open/close can transition smoothly; position:absolute
   already takes it out of flow while hidden, so display can stay "flex"
   throughout. --cat-accent (set inline per category in build.js from
   categories.json) tints the top bar and the active/hover accent so each
   category's menu reads as visually distinct, not just a generic list. */
.submenu-dropdown {
  --accent: var(--cat-accent, var(--accent-primary));
  display: flex;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  min-width: 200px;
  transform: translateX(-50%) translateY(-6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  background: color-mix(in srgb, var(--accent) 12%, white);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 22px 45px rgba(31, 20, 80, 0.28), 0 6px 16px rgba(31, 20, 80, 0.16);
  border-top: 3px solid var(--accent);
  z-index: 20;
}
.submenu-category.open .submenu-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Small diamond "pointer" connecting the card back to its button. */
.submenu-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  width: 11px;
  height: 11px;
  background: color-mix(in srgb, var(--accent) 12%, white);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

.submenu-dropdown-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 6px 10px 4px;
}

.submenu-dropdown a, .submenu-dropdown span[data-soon] {
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 9px;
  border-left: 3px solid transparent;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.12s ease, transform 0.12s ease, border-color 0.12s ease;
}
.submenu-dropdown a:hover {
  background: #ffffff;
  border-left-color: var(--accent);
  transform: translateX(2px);
  box-shadow: 0 1px 4px rgba(31, 35, 51, 0.1);
}
.submenu-dropdown a.active {
  background: #ffffff;
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(31, 35, 51, 0.1);
}
.submenu-dropdown span[data-soon] { color: var(--text-muted); cursor: not-allowed; }

.soon {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 999px;
}
.submenu-dropdown .soon { background: rgba(255, 255, 255, 0.7); color: var(--text-muted); }

/* ---------- Generic card panel: a tool's (or page's) main container ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 20px 45px rgba(76, 60, 140, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.card h1 {
  margin: 0 0 12px;
  font-size: 22px;
}

.card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Shared "how to use" info section ---------- */
.info {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 20px 45px rgba(76, 60, 140, 0.1);
}

.info h2 { margin: 0 0 8px; font-size: 19px; color: var(--text-primary); }
.info > p { margin: 0 0 20px; font-size: 14px; line-height: 1.55; color: var(--text-primary); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 24px;
}

.info-block h3, .info-example h3 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
}

.key-guide { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.key-guide > div { display: flex; gap: 12px; align-items: baseline; }
.key-guide dt { flex: 0 0 auto; min-width: 58px; font-family: var(--mono); font-weight: 700; color: var(--text-primary); }
.key-guide dd { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-muted); }

.info-example { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--panel-border); }
.info-example p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-primary); }
.info-example strong { color: var(--accent-primary); }

code {
  font-family: var(--mono);
  background: var(--key-bg);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ---------- Site footer: matches the header band, anchored to the
   bottom of the viewport when page content doesn't fill it ---------- */
.site-footer {
  background: var(--accent-primary);
  color: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  white-space: nowrap;
}
.footer-links a:hover { color: #ffffff; text-decoration: underline; }

.footer-copyright {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 400px) {
  .site-title { font-size: 22px; }
}
