@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Oxanium:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --surface: #fff;
  --text: #14161c;
  --muted: #5a6172;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #d8dce6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --font: "Oxanium", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  --header-h: 3.25rem;
  /* Primary page titles (shell pages + auth card headings) */
  --page-h1-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  /* Gutter inside .wrap (all shell pages); keep symmetric — avoid inline padding on <main> */
  --page-main-pad: clamp(1rem, 4vw, 1.75rem);
  /* Space between paragraphs (slightly roomier prose) */
  --prose-p-after: 1em;
  --prose-p-after-last: 1.35em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181c27;
    --text: #e8eaef;
    --muted: #9aa3b5;
    --border: #2a3142;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: clamp(0.95rem, 0.88rem + 0.35vw, 1.05rem);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

.wrap {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--page-main-pad);
}

/* Long prose pages: a bit more breathing room below the fold */
main.wrap.home-page,
main.wrap.doc-page,
main.wrap.about-page,
main.wrap.pricing-page,
main.wrap.demo-page,
main.wrap.app-settings-page {
  padding-bottom: clamp(1.75rem, 5vw, 2.75rem);
}

/* ─── Pricing ───────────────────────────────────────────────────────────── */

.pricing-lead {
  font-size: clamp(1.12rem, 1rem + 0.65vw, 1.38rem);
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 var(--prose-p-after);
  color: var(--text);
}

.pricing-section {
  margin-top: 2rem;
}

.pricing-section:first-of-type {
  margin-top: 0.25rem;
}

.page-hero > .pricing-section:first-of-type {
  margin-top: 0;
}

.page-hero .pricing-section > h2.visually-hidden {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.pricing-section h2 {
  font-size: clamp(1.15rem, 1rem + 0.65vw, 1.35rem);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.pricing-facts {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.65rem;
}

.pricing-facts > div {
  display: grid;
  grid-template-columns: minmax(5rem, 7rem) 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
}

.pricing-facts dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92em;
}

.pricing-facts dd {
  margin: 0;
}

.pricing-table-wrap {
  overflow-x: auto;
  margin: 1rem 0 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.pricing-table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
  font-size: 0.92em;
}

.pricing-table caption {
  padding: 0.65rem 0.75rem 0;
  text-align: left;
}

.pricing-table th,
.pricing-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.pricing-table thead th {
  font-weight: 600;
  text-align: left;
  background: var(--bg);
}

.pricing-table tbody tr:last-child th,
.pricing-table tbody tr:last-child td {
  border-bottom: none;
}

.pricing-table tbody th[scope="row"] {
  font-weight: 500;
  text-align: left;
}

.pricing-table tbody td:not(:first-child),
.pricing-table thead th:not(:first-child) {
  text-align: center;
}

.pricing-footer-links {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.pricing-footer-links li {
  margin: 0.35rem 0;
}

.pricing-section--contact .muted {
  font-size: 0.9em;
}

/* ─── Header ────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Top strip: brand on the left, toggle button on the right */
.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* ─── Brand ─────────────────────────────────────────────────────────────── */

.site-brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}

.site-brand__logo {
  display: block;
  height: 2.25rem;
  width: auto;
  object-fit: contain;
}

@media (hover: hover) {
  .site-brand:hover { opacity: 0.8; }
}

/* ─── Hamburger button ──────────────────────────────────────────────────── */

.nav-toggle {
  display: none; /* shown only on mobile */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s, border-color 0.15s;
}

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

@media (hover: hover) {
  .nav-toggle:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-color: var(--accent);
    color: var(--accent);
  }
}

.nav-toggle__bar {
  display: block;
  width: 1.25rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.25s ease, opacity 0.2s ease, translate 0.25s ease;
}

.site-header.is-open .nav-toggle__bar:nth-child(1) { translate: 0 7px;  transform: rotate(45deg);  }
.site-header.is-open .nav-toggle__bar:nth-child(2) { opacity: 0;         transform: scaleX(0);      }
.site-header.is-open .nav-toggle__bar:nth-child(3) { translate: 0 -7px; transform: rotate(-45deg); }

/* ─── Navigation ────────────────────────────────────────────────────────── */

/* Base link styles shared between mobile and desktop */
.site-nav a {
  display: block;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.18s ease, background 0.18s ease;
}

/* ── Desktop ≥ 768 px ─────────────────────────────────────────────────── */
@media (min-width: 768px) {
  /*
   * Nav is outside .wrap in the DOM, but we mirror the .wrap constraints
   * (max-width + margin: auto + same padding) so the links align with the
   * right edge of the page content, directly above the body text.
   *
   * left:0 + right:0 + max-width:40rem + margin:auto → browser centres the
   * absolutely-positioned box exactly like .wrap centres its block.
   */
  .site-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    max-width: 40rem;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    pointer-events: none;
    padding-right: clamp(1rem, 4vw, 1.75rem);
    padding-left: clamp(1rem, 4vw, 1.75rem);
    gap: 0.25rem;
    box-sizing: border-box;
  }

  .site-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.125rem 0.35rem;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    /*
     * Skip the brand in .site-header__bar: horizontal inset matches .site-nav padding;
     * this extra offset clears the logo mark only.
     */
    padding-left: 3rem;
  }

  .site-nav__list > #auth-nav {
    margin-left: auto;
    flex-shrink: 0;
  }

  .site-nav a {
    padding: 0.35rem 0.75rem;
    font-size: 0.95rem;
    color: var(--muted);
    pointer-events: auto;
  }

  @media (hover: hover) {
    .site-nav a:hover {
      color: var(--text);
      background: color-mix(in srgb, var(--border) 60%, transparent);
    }
  }

  .site-nav .auth-menu {
    flex-shrink: 0;
  }

  .site-nav .auth-menu__summary {
    color: var(--muted);
    font-size: 0.95rem;
  }

  @media (hover: hover) {
    .site-nav .auth-menu__summary:hover {
      color: var(--text);
      background: color-mix(in srgb, var(--border) 60%, transparent);
    }
  }

  /*
   * .site-nav uses pointer-events: none so the brand in .site-header__bar stays
   * clickable under this overlay; only interactive descendants opt in with
   * pointer-events: auto (see .site-nav a, .auth-menu, .auth-nav__logout).
   */
  .site-nav .auth-menu,
  .site-nav .auth-menu__panel,
  .site-nav .auth-nav__logout {
    pointer-events: auto;
  }

  /* Settings, /doc, /about: same single-row overlay as home — not pointer-events: auto on nav (would swallow logo clicks). */
  .site-nav.site-nav--app {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    max-width: 40rem;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    pointer-events: none;
    padding-right: clamp(1rem, 4vw, 1.75rem);
    padding-left: clamp(1rem, 4vw, 1.75rem);
    gap: 0.25rem;
    border-top: none;
    background: transparent;
    max-height: none;
    box-sizing: border-box;
  }

  .site-nav.site-nav--app .site-nav__list--app {
    padding: 0;
    padding-left: 3rem;
    max-width: none;
    margin: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    /* Match .site-nav__list (home) so nav density does not jump between pages */
    gap: 0.125rem 0.35rem;
    box-sizing: border-box;
  }

  .site-nav.site-nav--app .site-nav__list--app > #auth-nav {
    margin-left: auto;
  }
}

/* Google auth — nav slot (HTMX replaces #auth-nav) */
.auth-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  max-width: 100%;
}

@media (min-width: 768px) {
  .auth-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-end;
    max-width: none;
  }
}

.auth-nav__link {
  display: inline-block;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  pointer-events: auto;
}

@media (hover: hover) {
  .auth-nav__link:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--border) 60%, transparent);
  }
}

.auth-nav__user {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: auto;
}

.auth-nav__logout {
  margin: 0;
}

button.btn-logout {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  pointer-events: auto;
}

@media (hover: hover) {
  button.btn-logout:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--border) 50%, transparent);
    border-color: var(--accent);
  }
}

/* Avatar dropdown (signed-in) */
.auth-menu {
  position: relative;
  list-style: none;
}

.auth-menu__summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  pointer-events: auto;
  box-sizing: border-box;
}

.auth-menu__summary::-webkit-details-marker {
  display: none;
}

/* Desktop: flyout submenu indicator (Settings + Logout inside panel) */
@media (min-width: 768px) {
  .auth-menu__summary {
    position: relative;
    padding-right: 1.2rem;
  }

  .auth-menu__summary::after {
    content: "";
    position: absolute;
    right: 0.15rem;
    top: 50%;
    width: 0.35em;
    height: 0.35em;
    margin-top: -0.2em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.45;
    pointer-events: none;
  }

  details.auth-menu[open] > .auth-menu__summary::after {
    margin-top: 0.05em;
    transform: rotate(-135deg);
  }
}

.auth-menu__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-menu__avatar--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  color: var(--accent);
}

.auth-menu__avatar--placeholder .auth-menu__avatar-icon {
  display: block;
  flex-shrink: 0;
}

.auth-menu__label {
  max-width: 10rem;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.auth-menu__panel {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 12rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
}

.auth-menu__item {
  display: block;
  padding: 0.5rem 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.auth-menu__item:hover,
.auth-menu__item--button:hover {
  background: color-mix(in srgb, var(--border) 40%, transparent);
}

/* Match link row styling (panel); primary action styling for Logout */
.auth-menu__item--button {
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

/* Login / onboarding cards */
.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.auth-card {
  max-width: 26rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card__brand {
  margin: 0 0 1rem;
}

.auth-card__brand-link {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.auth-card__logo {
  display: block;
  height: 2.5rem;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.auth-card__brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

@media (hover: hover) {
  .auth-card__brand-link:hover .auth-card__brand-name {
    color: var(--accent);
  }

  .auth-card__brand-link:hover .auth-card__logo {
    opacity: 0.88;
  }
}

.auth-card__back {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.auth-card__back a {
  color: var(--muted);
  font-weight: 600;
}

.auth-card__title {
  margin: 0 0 0.5rem;
  font-size: var(--page-h1-size);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.auth-card__lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

a.btn-google {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: #4285f4;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #4285f4 80%, #000);
}

a.btn-google:hover {
  filter: brightness(1.05);
}

.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.onboarding-form__check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.95rem;
  line-height: 1.45;
  cursor: pointer;
}

.onboarding-form__check input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.onboarding-form__submit {
  align-self: flex-start;
}

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

/* App shell: simplified top nav (no hamburger) */
.site-nav--app {
  position: static;
  max-height: none;
  background: var(--surface);
  border-top: 1px solid var(--border);
  pointer-events: auto;
  padding: 0;
}

.site-nav__list--app {
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem clamp(1rem, 4vw, 1.75rem);
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.site-nav--app a {
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
}

.site-nav--app a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--border) 50%, transparent);
}

/* ── Mobile < 768 px ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .nav-toggle {
    display: flex;
  }

  /*
   * .site-nav is a DIRECT child of .site-header, NOT inside .wrap.
   * As a normal block element it inherits the full width of .site-header.
   * max-height collapses it when closed; expands it when .is-open.
   */
  .site-nav {
    overflow: hidden;
    max-height: 0;
    background: var(--surface);
    transition: max-height 0.28s ease, box-shadow 0.28s ease;
  }

  .site-header.is-open .site-nav {
    /* Room for open avatar menu (Settings + Sign out); 12rem clipped the panel */
    max-height: min(32rem, 85dvh);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  }

  .site-nav__list {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0.75rem 0.65rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .site-nav__list > li {
    width: 100%;
  }

  .site-nav__list > #auth-nav {
    margin-left: 0;
  }

  /* .site-nav--app already has a top border on the strip */
  .site-nav--app > .site-nav__list {
    border-top: none;
  }

  /* Override desktop “chip row” defaults on narrow screens */
  .site-nav__list--app {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0.35rem 0.75rem 0.65rem;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .site-nav--app a {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
  }

  /* <li> is a block — automatically full width, no flex needed */
  .site-nav a {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    color: var(--text);
    border-radius: calc(var(--radius) - 4px);
    text-align: left;
  }

  .auth-nav__link {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    color: var(--text);
    width: 100%;
    text-align: left;
    box-sizing: border-box;
  }

  .auth-nav__user {
    max-width: 100%;
    text-align: left;
    padding: 0.35rem 1.25rem 0;
  }

  /*
   * Signed-in: full-width column; avatar row + in-flow Settings / Sign out.
   */
  .site-nav__list .auth-nav--signed-in {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }

  .auth-nav--signed-in .auth-menu {
    width: 100%;
    min-width: 0;
  }

  .auth-nav--signed-in .auth-menu__summary {
    /* Same horizontal inset as .site-nav a */
    padding: 0.85rem 1.25rem;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    list-style: none;
  }

  .auth-nav--signed-in .auth-menu__label {
    text-align: left;
  }

  .auth-nav--signed-in .auth-menu__panel {
    position: static;
    right: auto;
    top: auto;
    z-index: auto;
    width: 100%;
    min-width: 0;
    margin: 0.4rem 0 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .auth-nav--signed-in .auth-menu__item,
  .auth-nav--signed-in .auth-menu__item--button {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    border-radius: calc(var(--radius) - 4px);
    text-align: left;
    box-sizing: border-box;
  }

  .auth-nav--signed-in .auth-nav__logout {
    margin: 0;
    width: 100%;
    max-width: 100%;
  }

  /*
   * App shell (/doc, Settings): same collapsible drawer as home when <768px
   * (requires .nav-toggle + #site-nav in the template).
   */
}

/* API tokens — Settings (015) */
.form-error {
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.95rem;
}

@media (prefers-color-scheme: dark) {
  .form-error {
    color: #f87171;
  }
}

.api-keys-section {
  margin-top: 1.5rem;
}

.page-secondary-panel .api-keys-section {
  margin-top: 0;
}

.api-keys-create {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 1rem 0 1.25rem;
}

.api-keys-limit-info {
  margin: 1rem 0 1.25rem;
  max-width: 40rem;
}

.api-keys-create__label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--text);
  min-width: 12rem;
}

.api-keys-create__label input {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.api-keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.api-keys-table th,
.api-keys-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.api-keys-table th {
  background: color-mix(in srgb, var(--border) 30%, var(--surface));
  font-weight: 600;
}

.api-keys-table code {
  word-break: break-all;
}

button.btn-revoke {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  color: #b91c1c;
  background: transparent;
  border: 1px solid color-mix(in srgb, #b91c1c 45%, var(--border));
  border-radius: 6px;
  cursor: pointer;
}

button.btn-revoke:hover {
  background: color-mix(in srgb, #b91c1c 12%, transparent);
}

button.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  margin-top: 0.5rem;
}

button.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.btn-danger {
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  color: #fff;
  background: #b91c1c;
  border: 1px solid #991b1b;
  border-radius: 6px;
  cursor: pointer;
}

button.btn-danger:hover {
  background: #991b1b;
}

.api-key-reveal {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.api-key-reveal__code {
  display: block;
  margin: 0.65rem 0 0.75rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  word-break: break-all;
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
}

.api-key-dialog {
  max-width: 28rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.api-key-dialog__form p {
  margin: 0 0 1rem;
  line-height: 1.5;
  color: var(--muted);
}

.api-key-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#top,
#weather,
#guide {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle__bar,
  .site-nav {
    transition-duration: 0.01ms !important;
  }
}

/* ─── Content ────────────────────────────────────────────────────────────── */

h1 {
  margin: 0 0 0.35em;
  font-size: var(--page-h1-size);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin: 0 0 0.65em;
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.2rem);
  font-weight: 600;
}

section {
  margin-top: clamp(1.25rem, 3vw, 2rem);
  padding: clamp(1rem, 3vw, 1.35rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

section:first-of-type {
  margin-top: clamp(1rem, 2.5vw, 1.5rem);
}

p {
  margin: 0 0 var(--prose-p-after);
  color: var(--muted);
  word-break: break-word;
}

p:last-of-type {
  margin-bottom: var(--prose-p-after-last);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 0.12em 0.35em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--border) 45%, transparent);
}

button.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  max-width: 20rem;
  transition: background 0.15s ease, transform 0.08s ease;
}

@media (hover: hover) {
  button.btn-primary:hover {
    background: var(--accent-hover);
  }
}

button.btn-primary:active {
  transform: scale(0.98);
}

.tech-status {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #22a05a;
  vertical-align: middle;
}

.tech-status--error {
  color: var(--accent);
}

.htmx-target {
  margin-top: 0.85rem;
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px dashed var(--border);
  background: color-mix(in srgb, var(--bg) 80%, var(--surface));
}

.htmx-target:empty::before {
  content: "…";
  color: var(--muted);
  opacity: 0.5;
}

.htmx-target code {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: none;
  padding: 0;
}

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

/* ─── Home: value proposition + WMO showcase grid ───────────────────────── */

.home-page h1,
.page-hero h1 {
  font-size: var(--page-h1-size);
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

/* Intro panel: matches homepage hero + secondary panels (surface card) */
.home-hero,
.page-hero,
.page-secondary-panel {
  margin-bottom: clamp(1.25rem, 4vw, 2rem);
  padding: clamp(1.1rem, 3vw, 1.65rem) clamp(1rem, 3vw, 1.35rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-secondary-panel {
  margin-bottom: 0;
}

.page-hero strong {
  color: var(--text);
  font-weight: 600;
}

.page-hero a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

@media (hover: hover) {
  .page-hero a:hover {
    color: var(--accent-hover);
  }
}

.home-hero__usp {
  font-size: clamp(1.12rem, 1rem + 0.65vw, 1.38rem);
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 var(--prose-p-after);
  color: var(--text);
}

.home-hero__detail {
  max-width: 38rem;
}

.home-hero__detail strong {
  color: var(--text);
  font-weight: 600;
}

.site-footer {
  margin-top: 3rem;
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  display: flex;
  justify-content: center;
}

.site-footer__nav {
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
}

.site-footer__nav a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

@media (hover: hover) {
  .site-footer__nav a:hover {
    color: var(--accent-hover);
  }
}

.site-footer__sep {
  opacity: 0.65;
  user-select: none;
}

.auth-page .site-footer {
  align-self: stretch;
  width: 100%;
  margin-top: 2rem;
  padding-bottom: 1.5rem;
}

.demo-page__intro,
.demo-page__intro-detail {
  max-width: 38rem;
}

.page-hero .demo-page__intro,
.page-hero .demo-page__intro-detail {
  margin-top: 0;
}

.home-hero__detail a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

@media (hover: hover) {
  .home-hero__detail a:hover {
    color: var(--accent-hover);
  }
}

/* ─── Home: 2×2 WMO showcase (p5 hosts) ───────────────────────────────────── */

.home-visual-grid {
  margin-top: clamp(1.5rem, 4vw, 2.25rem);
  padding-top: clamp(1.25rem, 3vw, 1.75rem);
  border-top: 1px solid var(--border);
}

.home-visual-grid__title {
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.2rem);
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.home-visual-grid__hint {
  margin: 0 0 1rem;
  font-size: 0.92rem;
}

.home-visual-grid__cells {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.75rem, 2.5vw, 1.15rem);
}

@media (max-width: 520px) {
  .home-visual-grid__cells {
    grid-template-columns: 1fr;
  }
}

.home-visual-cell {
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-visual-cell__cap {
  display: block;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
}

.home-visual-cell__frame {
  padding: 0.5rem;
}

.home-visual-cell__frame .weather-visual-frame {
  margin: 0 auto;
  max-width: none;
  width: 100%;
}

#weather {
  scroll-margin-top: calc(var(--header-h) + 0.75rem);
}

/* Demo forecast body: visual lines up with card edges */
.weather-demo-details {
  padding: 0;
  margin-top: 0.35rem;
  min-height: 2rem;
  border: none;
  background: transparent;
}

.weather-demo-shell {
  position: relative;
  max-width: 24rem;
}

.weather-demo-shell .weather-spinner {
  display: block;
  margin-top: 0.5rem;
}

.weather-card--demo {
  margin-bottom: 0;
}

.weather-city--demo-select {
  margin-bottom: 0;
}

/* Select replaces static city line: typographic match to `.weather-city` */
.weather-demo-select--inline {
  width: 100%;
  max-width: none;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding-left: 0.35rem;
  padding-right: 2.2rem;
  line-height: 1.3;
  min-height: 2.25rem;
}

.weather-demo-select--inline:hover {
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}

.weather-demo-select--inline:focus {
  border-color: var(--accent);
  background: var(--bg);
}

/* ─── Weather form ───────────────────────────────────────────────────────── */

.fp-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 20rem;
}

.fp-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.fp-input:focus {
  border-color: var(--accent);
}

.fp-select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  /* custom dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%239aa3b5' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
}

.fp-select:focus {
  border-color: var(--accent);
}

/* ─── Weather section ────────────────────────────────────────────────────── */

.weather-card {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
}

.weather-city {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.weather-desc {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.weather-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.25rem;
  margin: 0;
  font-size: 0.9rem;
}

.weather-dl dt {
  color: var(--muted);
  font-weight: 500;
}

.weather-dl dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
}

.weather-error {
  color: var(--accent);
  font-size: 0.9rem;
}

.weather-warning {
  font-size: 0.82rem;
  color: #c8a43a;
  background: rgba(200, 164, 58, 0.10);
  border: 1px solid rgba(200, 164, 58, 0.28);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  margin-bottom: 0.5rem;
}

/* p5.js weather canvas host (replaces former iframe) */
.weather-visual-frame {
  display: block;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.5rem auto 0;
  overflow: hidden;
  background: #0a0c14;
}

.weather-spinner {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

/* ─── Developer guide section ─────────────────────────────────────────────── */

.guide-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.guide-block:first-child {
  margin-top: 0.5rem;
  padding-top: 0;
  border-top: none;
}

.guide-block h3 {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Definition list used for workspace layout, endpoints, skills */
.guide-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 0;
}

.guide-dl dt {
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  padding-top: 0.1em;
}

.guide-dl dd {
  margin: 0;
  color: var(--muted);
}

/* Endpoints variant: slightly tighter */
.guide-dl--endpoints dt {
  font-size: 0.88rem;
}

/* Code blocks for shell commands */
.code-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.code-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: -0.25rem;
}

pre {
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: calc(var(--radius) - 4px);
  background: color-mix(in srgb, var(--bg) 70%, var(--border));
  border: 1px solid var(--border);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.88rem;
  color: var(--text);
}

.doc-page .doc-toc {
  margin: 1.25rem 0 1.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, var(--border));
}

.doc-page .doc-toc ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.doc-page section {
  margin-top: 1.75rem;
}

/* In-page TOC: keep section headings visible below sticky .site-header */
.doc-page section[id] {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.guide-note {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Bullet list for key rules */
.guide-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--muted);
}

.guide-list li strong {
  color: var(--text);
}

/* Responsive: stack dl to single column on very narrow screens */
@media (max-width: 480px) {
  .guide-dl {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .guide-dl dt {
    margin-top: 0.5rem;
  }
}
