*,
*::before,
*::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------- */
/* Calm — warm paper, system light/dark                                      */
/* -------------------------------------------------------------------------- */
html[data-theme="calm"] {
  color-scheme: light dark;
  --bg: #fafaf8;
  --fg: #141413;
  --muted: #5c5b57;
  --border: #e3e2dc;
  --accent: #1a4d3e;
  --accent-hover: #0f3329;
  --focus: #2563eb;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Liberation Sans", sans-serif;
  --font-display: var(--font);
  --radius: 0.5rem;
  --link-transform: none;
  --link-weight: 500;
  --link-bg: transparent;
  --link-bg-hover: transparent;
  --name-weight: 600;
  --name-tracking: -0.02em;
  --name-transform: none;
  --body-gradients: none;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="calm"] {
    --bg: #101110;
    --fg: #f2f1ed;
    --muted: #9c9a93;
    --border: #2a2b29;
    --accent: #7dd3c0;
    --accent-hover: #a8e6d9;
    --focus: #93c5fd;
  }
}

/* -------------------------------------------------------------------------- */
/* Ink — editorial dark                                                       */
/* -------------------------------------------------------------------------- */
html[data-theme="ink"] {
  color-scheme: dark;
  --bg: #090a0c;
  --fg: #ebe6de;
  --muted: #8a8580;
  --border: #2c2a26;
  --accent: #d4a574;
  --accent-hover: #e4bc90;
  --focus: #e4bc90;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --radius: 0.375rem;
  --link-transform: none;
  --link-weight: 500;
  --link-bg: rgba(255, 255, 255, 0.03);
  --link-bg-hover: rgba(212, 165, 116, 0.08);
  --name-weight: 500;
  --name-tracking: 0.01em;
  --name-transform: none;
  --body-gradients: radial-gradient(ellipse 70% 50% at 50% -10%, rgba(212, 165, 116, 0.07) 0%, transparent 55%);
}

/* -------------------------------------------------------------------------- */
/* Swiss — neo-brutalist                                                      */
/* -------------------------------------------------------------------------- */
html[data-theme="swiss"] {
  color-scheme: light;
  --bg: #ecece8;
  --fg: #0a0a0a;
  --muted: #3d3d3d;
  --border: #0a0a0a;
  --accent: #0a0a0a;
  --accent-hover: #2d2d2d;
  --focus: #005fcc;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --radius: 0;
  --link-transform: uppercase;
  --link-weight: 700;
  --link-bg: #ffffff;
  --link-bg-hover: #0a0a0a;
  --name-weight: 800;
  --name-tracking: -0.045em;
  --name-transform: uppercase;
  --body-gradients: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(10, 10, 10, 0.04) 2px,
    rgba(10, 10, 10, 0.04) 3px
  );
}

/* -------------------------------------------------------------------------- */
/* Signal — cyan / space                                                      */
/* -------------------------------------------------------------------------- */
html[data-theme="signal"] {
  color-scheme: dark;
  --bg: #05040a;
  --fg: #e8f1ff;
  --muted: #7d92a8;
  --border: rgba(34, 211, 238, 0.28);
  --accent: #22d3ee;
  --accent-hover: #a5f3fc;
  --focus: #c4b5fd;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --radius: 0.75rem;
  --link-transform: none;
  --link-weight: 600;
  --link-bg: rgba(15, 23, 42, 0.5);
  --link-bg-hover: rgba(34, 211, 238, 0.1);
  --name-weight: 700;
  --name-tracking: -0.03em;
  --name-transform: none;
  --body-gradients: radial-gradient(ellipse 90% 70% at 50% -30%, rgba(88, 28, 135, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 20%, rgba(14, 116, 144, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 0% 80%, rgba(59, 130, 246, 0.12) 0%, transparent 45%);
}

html[data-theme="signal"] .link:hover {
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(34, 211, 238, 0.2);
}

/* -------------------------------------------------------------------------- */
/* Dawn — soft sunrise, always light                                          */
/* -------------------------------------------------------------------------- */
html[data-theme="dawn"] {
  color-scheme: light;
  --bg: #fff8f5;
  --fg: #3d2a32;
  --muted: #8a6f78;
  --border: #f0d0dc;
  --accent: #c94f6d;
  --accent-hover: #a63d56;
  --focus: #7c3aed;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --radius: 0.75rem;
  --link-transform: none;
  --link-weight: 500;
  --link-bg: rgba(255, 255, 255, 0.65);
  --link-bg-hover: rgba(201, 79, 109, 0.08);
  --name-weight: 600;
  --name-tracking: -0.02em;
  --name-transform: none;
  --body-gradients: linear-gradient(165deg, rgba(255, 220, 235, 0.55) 0%, transparent 42%),
    linear-gradient(210deg, rgba(215, 235, 255, 0.45) 0%, transparent 38%);
}

/* -------------------------------------------------------------------------- */
/* Mono — terminal catalog, monospace                                         */
/* -------------------------------------------------------------------------- */
html[data-theme="mono"] {
  color-scheme: light;
  --bg: #e8e8e8;
  --fg: #0a0a0a;
  --muted: #4a4a4a;
  --border: #b8b8b8;
  --accent: #0a0a0a;
  --accent-hover: #333;
  --focus: #0066cc;
  --font: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --font-display: var(--font);
  --radius: 2px;
  --link-transform: none;
  --link-weight: 600;
  --link-bg: #f4f4f4;
  --link-bg-hover: #dcdcdc;
  --name-weight: 700;
  --name-tracking: -0.04em;
  --name-transform: none;
  --body-gradients: none;
}

/* -------------------------------------------------------------------------- */
/* Lagoon — teal coast                                                        */
/* -------------------------------------------------------------------------- */
html[data-theme="lagoon"] {
  color-scheme: light;
  --bg: #e5f2ef;
  --fg: #0c2c27;
  --muted: #3d6b62;
  --border: #a8d4c8;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --focus: #0ea5e9;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --radius: 1rem;
  --link-transform: none;
  --link-weight: 600;
  --link-bg: rgba(255, 255, 255, 0.55);
  --link-bg-hover: rgba(13, 148, 136, 0.12);
  --name-weight: 700;
  --name-tracking: -0.025em;
  --name-transform: none;
  --body-gradients: radial-gradient(ellipse 100% 60% at 50% -15%, rgba(45, 212, 191, 0.2) 0%, transparent 50%);
}

/* -------------------------------------------------------------------------- */
/* Parchment — sepia page                                                     */
/* -------------------------------------------------------------------------- */
html[data-theme="parchment"] {
  color-scheme: light;
  --bg: #f0e6d8;
  --fg: #3a2e22;
  --muted: #6b5a48;
  --border: #d2c4b0;
  --accent: #8b4513;
  --accent-hover: #6b3410;
  --focus: #b45309;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Palatino, "Palatino Linotype", Georgia, serif;
  --radius: 0.25rem;
  --link-transform: none;
  --link-weight: 500;
  --link-bg: rgba(255, 252, 248, 0.5);
  --link-bg-hover: rgba(139, 69, 19, 0.08);
  --name-weight: 600;
  --name-tracking: 0;
  --name-transform: none;
  --body-gradients: none;
}

/* -------------------------------------------------------------------------- */
/* Neon — electric pink + lime                                                */
/* -------------------------------------------------------------------------- */
html[data-theme="neon"] {
  color-scheme: dark;
  --bg: #0a0310;
  --fg: #fff5fb;
  --muted: #c4a8c8;
  --border: rgba(255, 45, 146, 0.35);
  --accent: #ff2d92;
  --accent-hover: #ff7eb8;
  --focus: #b7ff00;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font);
  --radius: 0.5rem;
  --link-transform: none;
  --link-weight: 600;
  --link-bg: rgba(30, 10, 40, 0.6);
  --link-bg-hover: rgba(255, 45, 146, 0.12);
  --name-weight: 800;
  --name-tracking: -0.03em;
  --name-transform: none;
  --body-gradients: radial-gradient(circle at 15% 85%, rgba(183, 255, 0, 0.14) 0%, transparent 42%),
    radial-gradient(circle at 90% 10%, rgba(255, 45, 146, 0.2) 0%, transparent 35%),
    linear-gradient(180deg, #12051a 0%, #060308 100%);
}

html[data-theme="neon"] .link:hover {
  box-shadow: 0 0 0 1px var(--accent), 0 0 22px rgba(255, 45, 146, 0.35);
}

/* -------------------------------------------------------------------------- */
/* Clay — terracotta + cream                                                  */
/* -------------------------------------------------------------------------- */
html[data-theme="clay"] {
  color-scheme: light;
  --bg: #f7f1ec;
  --fg: #2c211c;
  --muted: #6e574e;
  --border: #e0cfc4;
  --accent: #b85c38;
  --accent-hover: #943a1f;
  --focus: #2563eb;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font);
  --radius: 0.5rem;
  --link-transform: none;
  --link-weight: 600;
  --link-bg: rgba(255, 255, 255, 0.45);
  --link-bg-hover: rgba(184, 92, 56, 0.1);
  --name-weight: 700;
  --name-tracking: -0.02em;
  --name-transform: none;
  --body-gradients: radial-gradient(ellipse 80% 50% at 80% 0%, rgba(184, 92, 56, 0.12) 0%, transparent 45%);
}

/* -------------------------------------------------------------------------- */
/* Base layout                                                                */
/* -------------------------------------------------------------------------- */
html {
  font-family: var(--font);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
  color: var(--fg);
  background-color: var(--bg);
  background-image: var(--body-gradients);
  background-size: auto, auto, auto;
}

.wrap {
  width: 100%;
  max-width: 26rem;
}

.header {
  margin-bottom: 2rem;
  text-align: center;
}

.name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: var(--name-weight);
  letter-spacing: var(--name-tracking);
  text-transform: var(--name-transform);
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.links--icons {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.link {
  display: block;
  padding: 0.65rem 1rem;
  text-align: center;
  text-decoration: none;
  font-weight: var(--link-weight);
  text-transform: var(--link-transform);
  color: var(--fg);
  background: var(--link-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.link--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.55rem;
}

.link-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-icon-svg {
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
  fill: currentColor;
  stroke: none;
}

html[data-theme="swiss"] .link {
  letter-spacing: 0.07em;
  font-size: 0.8125rem;
}

html[data-theme="swiss"] .link--icon {
  font-size: 1rem;
}

.link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--link-bg-hover);
}

html[data-theme="swiss"] .link:hover {
  color: #fff;
  border-color: #0a0a0a;
  background: #0a0a0a;
}

.link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.samples-back-link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color 0.18s ease;
}

.samples-back-link:hover {
  color: var(--accent);
}

.samples-back-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.samples-back {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
}

.samples-back + .demo {
  margin-top: 1.25rem;
}

/* -------------------------------------------------------------------------- */
/* Demo / sample UI                                                           */
/* -------------------------------------------------------------------------- */
.demo {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.demo-h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: var(--name-tracking);
}

.demo-lead {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.demo-hr {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.demo-h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.demo-h3:first-of-type {
  margin-top: 0.75rem;
}

.demo-p {
  margin: 0 0 0.65rem;
  font-size: 0.9375rem;
}

.demo-p--accent {
  margin-bottom: 0.85rem;
}

.demo-mid {
  color: var(--muted);
}

.demo-blockquote {
  margin: 0 0 1rem;
  padding: 0.65rem 0 0.65rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.demo-blockquote p {
  margin: 0;
}

.demo-list {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}

.demo-caption {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
}

.demo-row--stack {
  flex-direction: column;
  align-items: stretch;
}

.demo-badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
}

.demo-inline-link {
  font-weight: 500;
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.demo-inline-link:hover {
  color: var(--accent-hover);
}

.demo-card {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--fg) 5%, var(--bg));
}

.demo-card-title {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.demo-card-text {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.demo-label {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 8rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.demo-btn {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: default;
}

.demo-btn:hover {
  background: var(--accent-hover);
}

.demo-input {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--fg) 4%, var(--bg));
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
}

.demo-input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.demo-note {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
}

.demo-code {
  padding: 0.12em 0.35em;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.5);
  background: color-mix(in srgb, var(--fg) 10%, var(--bg));
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.84em;
}

.demo-pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--fg) 8%, var(--bg));
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

.demo-pre code {
  font-family: inherit;
}

html[data-theme="swiss"] .demo-hr,
html[data-theme="swiss"] .demo-blockquote {
  border-width: 2px;
}

html[data-theme="swiss"] .demo-badge {
  border-radius: 0;
  border-width: 2px;
}

html[data-theme="swiss"] .demo-card,
html[data-theme="swiss"] .demo-pre,
html[data-theme="swiss"] .demo-input,
html[data-theme="swiss"] .demo-code {
  border-width: 2px;
  border-radius: 0;
}

html[data-theme="swiss"] .demo-btn {
  border: 2px solid #0a0a0a;
  border-radius: 0;
  background: #fff;
  color: #0a0a0a;
}

html[data-theme="swiss"] .demo-btn:hover {
  background: #0a0a0a;
  color: #fff;
}

html[data-theme="neon"] .demo-btn:hover {
  box-shadow: 0 0 18px rgba(255, 45, 146, 0.45);
}

html[data-theme="neon"] .demo-badge {
  box-shadow: 0 0 12px rgba(255, 45, 146, 0.25);
}

/* -------------------------------------------------------------------------- */
/* Top-right chrome — theme & language                                        */
/* -------------------------------------------------------------------------- */
.chrome {
  position: fixed;
  z-index: 100;
  top: max(0.65rem, env(safe-area-inset-top, 0px));
  right: max(0.65rem, env(safe-area-inset-right, 0px));
  max-width: calc(100vw - 1.3rem);
}

.chrome-inner {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chrome-menu {
  position: relative;
  display: inline-flex;
}

.chrome-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.85);
  background: color-mix(in srgb, var(--bg) 92%, var(--fg));
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.chrome-menu-trigger:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.chrome-menu-trigger:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chrome-menu-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 6%, var(--bg));
}

.chrome-menu-trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.chrome-svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
}

.chrome-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 150;
  min-width: 10.5rem;
  max-width: min(14rem, calc(100vw - 2rem));
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 96%, var(--fg));
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  overflow: visible;
}

html[data-theme="ink"] .chrome-menu-panel,
html[data-theme="signal"] .chrome-menu-panel,
html[data-theme="neon"] .chrome-menu-panel {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}

.chrome-menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: calc(var(--radius) * 0.65);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}

.chrome-menu-item:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--fg);
}

.chrome-menu-item[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  color: var(--accent);
  font-weight: 600;
}

.chrome-menu-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

html[data-theme="swiss"] .chrome-menu-trigger,
html[data-theme="swiss"] .chrome-menu-panel {
  border-width: 2px;
  border-radius: 0;
}

html[data-theme="swiss"] .chrome-menu-item {
  border-radius: 0;
}
