:root {
  --color-primary: #0f766e;
  --color-secondary: #6b214e;
  --color-accent: #115e59;
  --surface: #fffdf9;
  --surface-raised: #ffffff;
  --surface-muted: #f2f7f6;
  --ink: #14211f;
  --ink-muted: #43524f;
  --line: #c6d2cf;
  --link: #075f59;
  --secondary-text: #6b214e;
  --focus: #7c2d5b;
  --on-brand: #ffffff;
  --color-on-brand: var(--on-brand);
  --shadow: 0 0.75rem 2rem rgb(20 33 31 / 0.12);
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --page-width: 72rem;
  --maxw: var(--page-width);
  --radius: 0.875rem;
  --radius-lg: 1.375rem;
  --text-hi: var(--ink);
  --text-mid: var(--ink-muted);
  --text-low: var(--ink-muted);
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --surface: #10201d;
  --surface-raised: #162925;
  --surface-muted: #1c332e;
  --ink: #f3f5ef;
  --ink-muted: #d2ddd8;
  --line: #58716a;
  --link: #91e0d1;
  --secondary-text: #f1a9d2;
  --focus: #f1a9d2;
  --shadow: 0 0.75rem 2rem rgb(0 0 0 / 0.28);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #10201d;
    --surface-raised: #162925;
    --surface-muted: #1c332e;
    --ink: #f3f5ef;
    --ink-muted: #d2ddd8;
    --line: #58716a;
    --link: #91e0d1;
    --secondary-text: #f1a9d2;
    --focus: #f1a9d2;
    --shadow: 0 0.75rem 2rem rgb(0 0 0 / 0.28);
  }
}

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

body {
  min-block-size: 100vh;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.125rem;
  text-underline-offset: 0.16rem;
}

a:hover {
  color: var(--secondary-text);
}

:focus-visible {
  outline: 0.1875rem solid var(--focus);
  outline-offset: 0.1875rem;
}

.container {
  inline-size: min(var(--page-width), calc(100% - 2rem));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 100;
  min-block-size: 2.75rem;
  padding: 0.625rem 1rem;
  background: var(--surface-raised);
  color: var(--ink);
  border: 0.125rem solid var(--focus);
  border-radius: 0.5rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.marketing-header {
  border-block-end: 0.0625rem solid var(--line);
  background: var(--surface-raised);
}

.marketing-nav,
.marketing-links,
.auth-nav-cluster,
.marketing-actions,
.site-footer__row,
.site-footer__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.marketing-nav {
  min-block-size: 4.5rem;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-block: 0.5rem;
}

.marketing-links {
  flex: 1 1 27rem;
  flex-wrap: wrap;
}

.marketing-actions {
  flex-wrap: wrap;
}

.brand {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  text-decoration: none;
}

.brand[href],
.site-footer__row > a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding-inline: 0.625rem;
}

.marketing-links a,
.auth-nav-cluster a,
.marketing-actions a,
.site-footer__links a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding-inline: 0.625rem;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.marketing-links a:hover,
.auth-nav-cluster a:hover,
.marketing-actions a:hover,
.site-footer__links a:hover {
  background: var(--surface-muted);
  color: var(--secondary-text);
}

/* Backward-compatible launcher contracts. The shared tools launcher still
   consumes these generic selectors and token names from base.css. */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
}

.card {
  display: block;
  min-block-size: 2.75rem;
  padding: 1.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-raised), var(--surface-muted));
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.2s ease;
}

.card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--line));
  color: inherit;
  transform: translateY(-0.1875rem);
}

.card h3 {
  margin: 0 0 0.4rem;
  color: var(--text-hi);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 650;
}

.card p {
  margin: 0;
  color: var(--text-low);
  font-size: 0.92rem;
}

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text-hi);
  --btn-bd: var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  padding: 0.625rem 1rem;
  border: 0.0625rem solid var(--btn-bd);
  border-radius: 0.625rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.btn-ghost:hover {
  border-color: var(--color-accent);
  color: var(--text-hi);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  padding: 0.625rem 1rem;
  border: 0.125rem solid var(--color-primary);
  border-radius: 0.5rem;
  background: var(--color-primary);
  color: var(--on-brand);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

/* The marketing navigation selector has greater specificity than the generic
   button class. Keep the primary CTA's reviewed on-brand ink in every state. */
.marketing-actions a.button-link {
  color: var(--on-brand);
}

.button-link:hover {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--on-brand);
}

.button-link--secondary {
  background: transparent;
  color: var(--link);
}

.marketing-actions a.button-link--secondary {
  color: var(--link);
}

.button-link--secondary:hover {
  color: var(--on-brand);
}

.marketing-actions a.button-link:hover,
.marketing-actions a.button-link:focus-visible {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--on-brand);
}

.marketing-actions a.button-link:focus-visible {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.marketing-actions a.button-link--secondary:focus-visible {
  background: transparent;
  color: var(--link);
}

.auth-avatar {
  display: inline-grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: 50%;
  background: var(--color-secondary);
  color: var(--on-brand);
  font-size: 0.875rem;
  font-weight: 700;
}

/* The landing preserves the SharedAuth cookie-backed /auth/me contract.
   Keep these five visibility declarations byte-stable for its focused guard. */
[data-auth-show="authenticated"] { display: none !important; }
body.is-authenticated [data-auth-show="authenticated"] { display: block !important; }
body.is-authenticated [data-auth-show="guest"]         { display: none  !important; }
body.is-authenticated [data-auth-show="authenticated"][data-auth-display="flex"] { display: flex !important; }
body.is-authenticated [data-auth-show="authenticated"][data-auth-display="grid"] { display: grid !important; }

body.is-authenticated       #auth-guest-nav,
body:not(.is-authenticated) #auth-user-nav { display: none !important; }

.auth-return {
  margin-block-start: 1.5rem;
  padding: 1rem;
  border-inline-start: 0.25rem solid var(--color-primary);
  background: var(--surface-muted);
}

.site-footer {
  margin-block-start: 3rem;
  border-block-start: 0.0625rem solid var(--line);
  background: var(--surface-raised);
}

.site-footer__row {
  justify-content: space-between;
  flex-wrap: wrap;
  padding-block: 1rem;
}

.site-footer__links {
  flex-wrap: wrap;
}

@media (max-width: 47.9375rem) {
  .marketing-nav {
    align-items: flex-start;
  }

  .marketing-links {
    order: 3;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
  }
}
