/*
 * styles.css: the look of the ask page (amendment 49 in docs/decisions.md).
 *
 * Layout: a sticky topbar, a standalone login card and a framed two-column
 * panel. Change the look through the tokens on :root and the light theme
 * block under [data-theme="light"]. The page defaults to dark; shell.js flips
 * data-theme on <html>. Every font is a file under /static/fonts (see OFL.txt
 * there); no request goes to a font host. No importance flag and no colour
 * mixing function: mixed colours are literal values per theme. No animation
 * is gated behind the reduced-motion media query.
 */

/* ---- fonts ---- */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-v24-latin_latin-ext-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-v24-latin_latin-ext-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-v24-latin_latin-ext-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inconsolata";
  src: url("fonts/inconsolata-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DSEG7 Classic";
  src: url("fonts/dseg7classic-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---- tokens ---- */

:root {
  color-scheme: dark;

  --font-heading: "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --font-panel: "Inconsolata", "Noto Mono", Menlo, Monaco, Consolas, monospace;
  --font-digits: "DSEG7 Classic", "Inconsolata", "Noto Mono", Menlo, Monaco, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.125rem;
  --fs-4xl: 2.25rem;

  --r-sm: 0.375rem;
  --r-md: 0.625rem;
  --r-lg: 0.875rem;
  --r-xl: 1.375rem;
  --r-pill: 62.4375rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --header-h: 4.25rem;
  --frame-w: 58rem;
  --gutter: 1rem;

  --bg-primary: #0a0a0a;
  --bg-surface: #141414;
  --bg-card: #1a1a1a;
  --bg-elevated: #222222;
  --text-primary: #f0e6d3;
  --text-secondary: #8a8278;
  --text-muted: #5a5650;
  --border-color: #2a2a2a;
  --border-hover: #3a3a3a;
  --color-orange: #e8752a;
  --color-amber: #dfa05d;
  --color-coral: #ac5045;
  --color-teal: #3aafa9;
  --color-green: #658761;

  /* accent text that keeps 4.5:1 on the dark surfaces; the light theme sets
     these to the text colour and keeps the tone on a dot, border or fill */
  --text-accent: #e8752a;
  --text-ok: #3aafa9;
  --text-warn: #dfa05d;
  --text-danger: #d8615a;
  /* the orange that draws focus rings and the title's accent word: orange
     here, a darker orange in the light theme, so it keeps 3:1 there too */
  --accent-strong: #e8752a;
  --on-orange: #0a0a0a;

  /* the mixed colours as literal values, one set per theme */
  --topbar-bg: rgba(10, 10, 10, 0.85);
  --focus-ring: rgba(232, 117, 42, 0.18);
  --danger-bg: rgba(172, 80, 69, 0.08);
  --danger-border: rgba(172, 80, 69, 0.38);
  --avatar-glow-inner: rgba(232, 117, 42, 0.7);
  --avatar-glow-outer: rgba(232, 117, 42, 0.55);
  --details-glow: rgba(232, 117, 42, 0.28);
  --details-glow-hover: rgba(232, 117, 42, 0.52);
  --details-hover-border: #7b4c33;
  --orange-hover: #ed874c;
  --frame-ring: rgba(232, 117, 42, 0.1);
  --frame-shadow: 0 2.5rem 5rem -1rem rgba(0, 0, 0, 0.7);
  --menu-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.5);
  --page-glow: rgba(232, 117, 42, 0.06);
  /* the empty part of a meter, the tone at 26 percent over the card colour */
  --track-teal: #22413f;
  --track-amber: #4d3d2b;
  --track-coral: #402825;
  --grain-opacity: 0.09;
  /* figures are drawn for white paper, transparent PNGs among them */
  --figure-bg: #ffffff;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #f5f0e8;
  --bg-surface: #ebe5db;
  --bg-card: #e0d9cd;
  --bg-elevated: #d6cfc2;
  --text-primary: #1a1714;
  --text-secondary: #5a5650;
  --text-muted: #8a8278;
  --border-color: #cdc5b8;
  --border-hover: #b5ad9f;
  --text-accent: #1a1714;
  --text-ok: #1a1714;
  --text-warn: #1a1714;
  --text-danger: #1a1714;
  --accent-strong: #b8551a;
  --topbar-bg: rgba(245, 240, 232, 0.85);
  --details-hover-border: #dda380;
  --frame-shadow: 0 2.5rem 5rem -1rem rgba(20, 20, 16, 0.14);
  --menu-shadow: 0 1.5rem 3rem rgba(20, 20, 16, 0.14);
  --track-teal: #b5cec4;
  --track-amber: #e0cab0;
  --track-coral: #d2b5aa;
  --grain-opacity: 0.05;
}

/* ---- reset and base ---- */

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

html {
  font-size: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

::-webkit-scrollbar {
  width: 0.5rem;
  height: 0.5rem;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* the page background stays on body (never on html), so it keeps propagating
   to the canvas under the grain */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* film grain, under the content */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg width='240' height='240' viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}

.main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

em {
  font-style: normal;
  color: var(--accent-strong);
}

code,
pre {
  font-family: var(--font-mono);
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 0.125rem solid var(--accent-strong);
  outline-offset: 0.125rem;
}

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

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 60;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--text-accent);
  font-size: var(--fs-base);
}

.skip-link:focus {
  top: 0.5rem;
}

.hint {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-size: var(--fs-base);
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
}

.icon-large {
  width: 24px;
  height: 24px;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-0.375rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes frame-spring {
  0% {
    opacity: 0;
    transform: translateY(1.25rem) scale(0.985);
  }

  60% {
    opacity: 1;
    transform: translateY(-0.125rem) scale(1.003);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- the theme button (logged-out views) ---- */

.theme-fab {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 0.0625rem solid var(--border-color);
  border-radius: 50%;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.theme-fab:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* the sun shows in the dark theme (press for light), the moon in the light theme */
.theme-fab__icon {
  display: none;
}

[data-theme="dark"] .theme-fab__icon--sun {
  display: inline-block;
}

[data-theme="light"] .theme-fab__icon--moon {
  display: inline-block;
}

/* ---- the topbar (app view) ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(0.875rem);
  -webkit-backdrop-filter: saturate(160%) blur(0.875rem);
  border-bottom: 0.0625rem solid var(--border-color);
  overflow-x: clip;
}

.topbar__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.75rem;
  height: 100%;
  max-width: 100rem;
  margin: 0 auto;
  padding: 0 1.75rem;
}

.topbar__inner > * {
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  justify-self: start;
  border-radius: var(--r-sm);
}

.brand__mark {
  display: block;
  height: 1.375rem;
  width: auto;
  flex: none;
}

.brand__name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar__middle {
  min-height: 1px;
}

.member {
  position: relative;
  display: flex;
  align-items: center;
  justify-self: end;
  height: 100%;
}

.member__btn {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0;
  border-radius: var(--r-pill);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}

.member__btn:hover,
.member__btn[aria-expanded="true"] {
  transform: scale(1.04);
  box-shadow: 0 0 0 0.125rem var(--avatar-glow-inner), 0 0 1.25rem 0.125rem var(--avatar-glow-outer);
}

/* the "Account menu" tooltip: shown after a pause on hover, gone at once when
   the menu opens; anchored to the avatar's right edge so it stays on screen */
.member__btn::after {
  content: "Account menu";
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  transform: translateY(-0.25rem);
  padding: 0.375rem 0.625rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
  transition-delay: 0ms;
  z-index: 10;
}

.member__btn:hover::after {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 350ms;
}

.member__btn[aria-expanded="true"]::after {
  opacity: 0;
  transition-delay: 0ms;
}

.member__avatar {
  position: relative;
  display: block;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    var(--color-teal) 0deg 72deg,
    var(--color-green) 72deg 144deg,
    var(--color-amber) 144deg 216deg,
    var(--color-orange) 216deg 288deg,
    var(--color-coral) 288deg 360deg
  );
}

.member__avatar-inner {
  position: absolute;
  inset: 0.1875rem;
  display: grid;
  place-items: center;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  border-radius: 50%;
}

.member__avatar-text {
  display: block;
  transform: translateY(0.05em);
}

.member__avatar--lg {
  width: 3.125rem;
  height: 3.125rem;
}

.member__avatar--lg .member__avatar-inner {
  inset: 0.25rem;
  font-size: var(--fs-md);
}

.member__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.875rem);
  min-width: min(18.75rem, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-lg);
  padding: 0.625rem;
  box-shadow: var(--menu-shadow);
  z-index: 50;
  animation: drop-in 0.18s var(--ease);
}

.member__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.625rem 0.875rem;
}

.member__meta {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
  line-height: 1.2;
}

.member__name {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.member__email {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.member__role {
  margin-top: 0.1875rem;
  font-family: var(--font-mono);
  font-size: 0.65625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-accent);
}

.member__sep {
  height: 0.0625rem;
  margin: 0.25rem 0.125rem;
  background: var(--border-color);
}

.member__item,
.member__toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.84375rem;
  line-height: 1;
  color: var(--text-primary);
  border-radius: 0.4375rem;
  cursor: pointer;
  text-align: left;
}

.member__item:hover,
.member__toggle:hover {
  background: var(--bg-surface);
}

.member__ico {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--text-secondary);
}

.member__item--danger {
  color: var(--text-danger);
}

.member__state {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.member__state.is-on {
  color: var(--text-ok);
}

/* ---- the two-step login card: the QR on white, so a phone camera reads it ---- */

.qr-box {
  display: flex;
  width: 12.5rem;
  height: 12.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: #ffffff;
  border-radius: var(--r-sm);
}

.qr-box:empty {
  display: none;
}

.qr-image {
  width: 100%;
  height: 100%;
}

.two-step-key {
  display: block;
  margin: 0.5rem 0 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  color: var(--text-primary);
}

.switch {
  position: relative;
  flex: none;
  margin-left: auto;
  width: 2.125rem;
  height: 1.25rem;
  background: var(--bg-elevated);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-pill);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  left: 0.125rem;
  top: 50%;
  width: 0.875rem;
  height: 0.875rem;
  background: var(--text-secondary);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.member__toggle input:checked ~ .switch {
  background: var(--color-orange);
  border-color: var(--color-orange);
}

.member__toggle input:checked ~ .switch::after {
  transform: translate(0.875rem, -50%);
  background: var(--bg-primary);
}

.member__toggle input:focus-visible ~ .switch {
  outline: 0.125rem solid var(--accent-strong);
  outline-offset: 0.125rem;
}

/* ---- the logged-out views ---- */

.standalone {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login__card {
  width: 100%;
  max-width: 34rem;
  padding: 2.75rem 2.5rem 2.25rem;
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-lg);
  text-align: center;
}

.login__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1.75rem;
}

.login__mark {
  display: block;
  height: 1.5rem;
  width: auto;
  flex: none;
}

.login__brand-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  transform: translateY(0.0625rem);
}

.login__title {
  margin: 0 0 1.125rem;
  font-family: var(--font-heading);
  font-size: clamp(1.875rem, 3.6vw, 2.625rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.login__lede {
  max-width: 36ch;
  margin: 0 auto 1.75rem;
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text-secondary);
}

.loading-line {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

#login-form,
.password-card {
  text-align: left;
}

/* the slide reveal: two white overlays over an orange
   fill with a shine; on hover and keyboard focus they shrink to nothing, the
   shine sweeps, and the label turns dark once the orange dominates */
.login__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.75rem 1rem;
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 400;
  color: #1f1f1f;
  background-color: var(--color-orange);
  background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.32) 50%, transparent 70%);
  background-size: 200% 100%;
  background-position: -100% 0;
  background-repeat: no-repeat;
  border: 0.0625rem solid transparent;
  border-radius: 0.5rem;
  transition: background-position 900ms ease, transform 120ms ease;
}

.login__btn:hover,
.login__btn:focus-visible {
  background-position: 200% 0;
}

.login__btn:active {
  transform: translateY(0.0625rem);
}

.login__btn::before,
.login__btn::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #ffffff;
  transition: width 650ms ease-in-out;
  pointer-events: none;
}

.login__btn::before {
  left: 0;
}

.login__btn::after {
  right: 0;
}

.login__btn:hover::before,
.login__btn:hover::after,
.login__btn:focus-visible::before,
.login__btn:focus-visible::after {
  width: 0;
}

.login__btn > span {
  position: relative;
  z-index: 1;
  color: #1f1f1f;
  transition: color 200ms ease;
  transition-delay: 480ms;
}

.login__btn:hover > span,
.login__btn:focus-visible > span {
  color: var(--on-orange);
}

.login__btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.login__signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
  transition: color 120ms ease, border-color 120ms ease;
}

.login__signout:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.other-ways {
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 0.0625rem solid var(--border-color);
}

.other-ways-summary {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.other-ways-summary::marker {
  color: var(--color-orange);
}

/* ---- forms ---- */

/* form labels in the eyebrow recipe; the photo label is a button and the
   theme row a menu item, so both stay out */
label:not(.button):not(.member__toggle) {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

input,
textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-pill);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

textarea {
  min-height: 6rem;
  resize: vertical;
  border-radius: var(--r-md);
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
}

input:read-only {
  background: var(--bg-card);
  color: var(--text-secondary);
}

input:focus-visible,
textarea:focus-visible {
  outline: 0.125rem solid transparent;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.actions-small {
  margin-top: 0.5rem;
}

.actions-tight {
  margin-top: 0.5rem;
}

.actions-column {
  flex-direction: column;
  align-items: stretch;
}

/* ---- buttons ---- */

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.75rem 1.125rem;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--on-orange);
  background: var(--color-orange);
  border: 0.0625rem solid var(--color-orange);
  border-radius: var(--r-sm);
  transition: background 150ms var(--ease), transform 100ms var(--ease);
}

.button:hover {
  background: var(--orange-hover);
}

.button:active {
  transform: translateY(0.0625rem);
}

/* the shine belongs to the primary button only */
.button:not(.button-ghost):not(.button-secondary):not(.button-danger)::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-20deg);
  transition: left 450ms ease-in-out;
  pointer-events: none;
}

.button:not(.button-ghost):not(.button-secondary):not(.button-danger):hover::before {
  left: 100%;
}

.button .icon {
  width: 1rem;
  height: 1rem;
}

.button-secondary {
  min-height: 2.25rem;
  padding: 0.4375rem 0.6875rem;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--border-color);
  box-shadow: 0 0 0.5rem -0.125rem var(--details-glow);
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease), box-shadow 150ms var(--ease);
}

.button-secondary:hover {
  color: var(--text-accent);
  border-color: var(--details-hover-border);
  background: var(--bg-surface);
  box-shadow: 0 0 0.875rem -0.0625rem var(--details-glow-hover);
}

.button-ghost {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--border-color);
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}

.button-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-surface);
}

.button-danger {
  color: #ffffff;
  background: var(--color-coral);
  border-color: var(--color-coral);
}

.button-danger:hover {
  background: var(--color-coral);
  filter: brightness(1.12);
}

.button-small {
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  font-size: var(--fs-base);
}

/* the magic-link button keeps the small outline recipe of the retry button */
.button-secondary.button-small {
  padding: 0.4375rem 0.6875rem;
  font-size: 0.6875rem;
}

.button:disabled,
.button-secondary:disabled,
.button-ghost:disabled,
.button-danger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  filter: none;
}

/* a disabled button keeps its resting colour under the pointer; the primary
   rule carries the same :not chain as the shine, so it outranks the hover */
.button:not(.button-ghost):not(.button-secondary):not(.button-danger):disabled:hover {
  background: var(--color-orange);
}

.button-danger:disabled:hover {
  background: var(--color-coral);
  filter: none;
}

.button-ghost:disabled:hover,
.button-secondary:disabled:hover {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

/* no shine and no sweep on a disabled primary: same chain as the shine rules,
   later in the sheet, so it wins the tie */
.button:not(.button-ghost):not(.button-secondary):not(.button-danger):disabled::before,
.button:not(.button-ghost):not(.button-secondary):not(.button-danger):disabled:hover::before {
  content: none;
}

/* ---- messages ---- */

.message {
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-align: left;
  white-space: pre-line;
  overflow-wrap: break-word;
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: 0.5rem;
}

.message-error {
  color: var(--text-primary);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.message-ok {
  color: var(--text-ok);
  border-color: var(--color-teal);
}

.message-info {
  color: var(--text-secondary);
}

/* ---- the app view ---- */

.app-wrap {
  position: relative;
  /* 4.5rem above and 3rem below, as the design gives the detail panel; the
     side gutter sits on the same box */
  padding: 4.5rem 1.25rem 3rem;
  overflow-x: clip;
}

/* a faint orange glow behind the frame's top */
.app-wrap::before {
  content: "";
  position: absolute;
  inset: -2rem -2.5rem;
  pointer-events: none;
  background: radial-gradient(55rem 36rem at 50% -8%, var(--page-glow), transparent 60%);
  opacity: 0.6;
}

.app-frame {
  position: relative;
  max-width: var(--frame-w);
  margin: 0 auto;
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-hover);
  border-radius: 1.875rem;
  box-shadow: var(--frame-shadow), 0 0 0 0.0625rem var(--frame-ring);
  animation: frame-spring 0.42s var(--ease) both;
}

.app-body {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.375rem 1.625rem;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- the pill row under the main window, and the panels it opens ---- */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.375rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}

.pill:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.pill[aria-expanded="true"] {
  color: var(--text-accent);
  border-color: var(--details-hover-border);
  background: var(--bg-surface);
}

.pill-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.pill.tone-teal .pill-dot {
  background: var(--color-teal);
}

.pill.tone-amber .pill-dot {
  background: var(--color-amber);
}

.pill.tone-coral .pill-dot {
  background: var(--color-coral);
}

.pill-value {
  color: var(--text-primary);
}

.pill-value:empty {
  display: none;
}

/* The documentation panel: one chip per manual, a link to the maker's copy. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.375rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: 999px;
  text-decoration: none;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}

a.chip:hover,
a.chip:focus-visible {
  color: var(--text-accent);
  border-color: var(--details-hover-border);
  background: var(--bg-surface);
}

.chip-pages {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.panel {
  margin-top: 0.75rem;
}

.panel-text {
  margin: 0 0 0.5rem;
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-secondary);
}

.panel-text:last-child {
  margin-bottom: 0;
}

.page-title {
  margin-bottom: 1.0625rem;
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* The accent word keeps its colour and drops the slant: the page serves no
   italic face, and a browser-made slant is not a typeface. */
.page-title em {
  font-style: normal;
  color: var(--accent-strong);
}

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  font-size: var(--fs-base);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-md);
}


.card {
  padding: 1.25rem 1.375rem 1.375rem;
  background: var(--bg-card);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-xl);
}

.password-card {
  margin: 0.75rem 0;
}

.card-title {
  margin-bottom: 0.5rem;
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.2;
}

.card-lede {
  color: var(--text-secondary);
}

.conversation-bar {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border: 0.0625rem dashed var(--border-color);
  border-radius: var(--r-md);
}

.conversation-text {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.confirm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: var(--fs-base);
  font-weight: 700;
}

.thread {
  display: grid;
  gap: 1.5rem;
  margin: 1rem 0 0;
  list-style: none;
}

.turn {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.45s var(--ease) forwards;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.turn-question {
  justify-self: end;
  max-width: min(100%, 600px);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-radius: var(--r-lg) var(--r-lg) 0.25rem var(--r-lg);
}

.turn-question-text {
  white-space: pre-line;
}

.turn-photo {
  display: block;
  max-height: 160px;
  margin-top: 0.5rem;
  border-radius: var(--r-sm);
}

.turn-answer {
  min-width: 0;
}

/* ---- the ask card ---- */

.ask-card {
  margin-top: 1.25rem;
}

/* two classes, so it outranks the label recipe's :not() chain */
.ask-card .ask-label.ask-label {
  margin-top: 0;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.photo-thumb {
  display: inline-flex;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
}

.photo-image {
  width: 64px;
  height: 64px;
  object-fit: cover;
}

.photo-name {
  min-width: 0;
  color: var(--text-secondary);
  font-size: var(--fs-base);
  overflow-wrap: anywhere;
}

.ask-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.photo-pick:focus-within .button {
  outline: 0.125rem solid var(--accent-strong);
  outline-offset: 0.125rem;
}

.ask-button {
  min-width: 7.5rem;
}

/* ---- the answer card ---- */

.answer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: 999px;
}

.badge-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.badge-ok .badge-dot {
  background: var(--color-teal);
}

.answer-meta,
.refuse-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.answer-text {
  margin: 0.75rem 0 1rem;
  font-size: 1.0625rem;
  line-height: 1.55;
  white-space: pre-line;
}

.ref {
  color: var(--text-accent);
  font-weight: 700;
}

.ref:hover {
  text-decoration: underline;
}

[data-theme="light"] .ref {
  text-decoration: underline;
}

/* the support score as a board meter: teal at or above the threshold */
.support {
  margin: 0.5rem 0 1rem;
}

.support-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.3125rem;
}

.support-name {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.support-value {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-ok);
}

.support.is-low .support-value {
  color: var(--text-warn);
}

.support-bar {
  position: relative;
  height: 0.5rem;
  background: var(--track-teal);
  border-radius: 999px;
  overflow: visible;
}

.support-bar.is-low {
  background: var(--track-amber);
}

.support-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-teal);
  border-radius: 999px;
  transition: width 0.8s var(--ease), background 0.4s;
}

.support-bar.is-low .support-fill {
  background: var(--color-amber);
}

/* the 25, 50 and 75 percent separators, painted in the card colour */
.support-bar::after,
.meter-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), var(--bg-card) calc(25% - 1px), var(--bg-card) 25%);
  pointer-events: none;
}

.support-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--text-primary);
}

.support-note {
  margin-top: 0.375rem;
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.claims {
  margin: 0.5rem 0 0;
}

.claims-summary {
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
}

.claims-list {
  display: grid;
  gap: 0.375rem;
  margin: 0.5rem 0 0;
  list-style: none;
}

.claim {
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border-radius: var(--r-sm);
}

.claim-tag {
  justify-self: start;
  padding: 0.25rem 0.5625rem;
  font-family: var(--font-mono);
  font-size: 0.59375rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 0.0625rem solid currentColor;
  border-radius: 0.25rem;
}

.is-backed .claim-tag {
  color: var(--text-ok);
  border-color: var(--color-teal);
}

.is-unbacked .claim-tag {
  color: var(--text-warn);
  border-color: var(--color-amber);
}

.claim-quote,
.claim-note {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.claim-quote::before,
.claim-quote::after {
  content: "";
}

.disagreements {
  margin: 0.75rem 0;
  padding: 0.5625rem 0.75rem;
  background: var(--bg-surface);
  border: 0.0625rem solid var(--color-amber);
  border-radius: var(--r-md);
}

.disagreements .section-title {
  margin-top: 0;
  color: var(--text-warn);
}

.disagreement-list {
  display: grid;
  gap: 0.375rem;
  margin: 0.375rem 0 0;
  padding-left: 1.25rem;
  font-size: var(--fs-base);
}

.disagreement-claim {
  display: block;
}

.disagreement-pages {
  display: block;
  color: var(--text-secondary);
}

.section-title {
  margin: 1rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.citations {
  display: grid;
  gap: 0.75rem;
  list-style: none;
}

.citation {
  min-width: 0;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-md);
  scroll-margin-top: calc(var(--header-h) + 1rem);
  color: var(--text-secondary);
}

.citation:target {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

.citation-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.citation-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.375rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--on-orange);
  background: var(--color-orange);
  border-radius: 999px;
}

.citation-title {
  font-weight: 700;
}

.citation-page {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.citation-kind {
  padding: 0.25rem 0.5625rem;
  font-family: var(--font-mono);
  font-size: 0.59375rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border: 0.0625rem solid var(--border-color);
  border-radius: 0.25rem;
}

.citation-figure {
  margin-top: 0.5rem;
}

.citation-image {
  display: block;
  max-height: 220px;
  padding: 0.25rem;
  object-fit: contain;
  background: var(--figure-bg);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
}

.figure-note {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.citation-quote {
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--color-orange);
  font-size: var(--fs-base);
  color: var(--text-primary);
}

.citation-source,
.answer-id {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.stored-note {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: var(--fs-base);
  color: var(--text-warn);
  border: 0.0625rem solid var(--color-amber);
  border-radius: var(--r-sm);
}

/* ---- the refusal card ---- */

.refuse-card {
  border-color: var(--color-amber);
}

.refuse-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

/* the accent stays on the icon in both themes; the title keeps the text colour */
.refuse-head .icon {
  color: var(--color-amber);
}

.refuse-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.refuse-lead {
  margin-top: 0.5rem;
  color: var(--text-secondary);
}

.closest-list {
  display: grid;
  gap: 0.5rem;
  list-style: none;
}

.closest-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-md);
  color: var(--text-secondary);
}

.closest-title {
  font-weight: 700;
  color: var(--text-primary);
}

.closest-page,
.closest-score {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.refuse-reasons {
  display: grid;
  gap: 0.25rem;
  padding-left: 1.25rem;
}

.refuse-reasons .empty-line,
.search-kept .empty-line {
  list-style: none;
  color: var(--text-secondary);
}

.refuse-review {
  margin-top: 0.75rem;
  font-size: var(--fs-base);
  font-weight: 700;
}

.refuse-meta {
  margin-top: 0.5rem;
}

/* ---- the trace ---- */

.trace {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 0.0625rem solid var(--border-color);
}

.trace > summary {
  font-weight: 700;
  cursor: pointer;
}

.trace-count {
  font-weight: 400;
  color: var(--text-secondary);
}

.trace-steps {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  list-style: none;
}

.trace-step {
  min-width: 0;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border-radius: var(--r-sm);
}

.trace-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5625rem;
}

.trace-no {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.trace-tool {
  font-weight: 700;
  font-size: var(--fs-base);
  overflow-wrap: anywhere;
}

.trace-ms {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.trace-output {
  margin-top: 0.25rem;
  font-size: var(--fs-base);
  overflow-wrap: anywhere;
}

.trace-input-box summary {
  margin-top: 0.25rem;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

pre {
  margin-top: 0.5rem;
  padding: 0.5rem;
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-primary);
  border-radius: var(--r-sm);
}

.retrieval-list {
  display: grid;
  gap: 0.75rem;
}

.search {
  padding: 0.5rem 0.75rem;
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
}

.search-title {
  margin-bottom: 0.5rem;
  font-size: var(--fs-base);
}

/* the retrieval facts and the usage rows as a two-column spec table */
.spec {
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.spec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5625rem 0.8125rem;
  border-bottom: 0.0625rem solid var(--border-color);
}

.spec-row:last-child {
  border-bottom: 0;
}

.spec-row:nth-child(odd) {
  background: var(--bg-surface);
}

.spec-row dt {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.spec-row dd {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  line-height: 1.4;
  text-align: right;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.search-sub {
  margin: 0.75rem 0 0.25rem;
  font-size: var(--fs-base);
  font-weight: 700;
}

.search-dropped-summary {
  margin-top: 0.5rem;
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
}

.chunk-list {
  display: grid;
  gap: 0.25rem;
  padding-left: 1.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.chunk-id {
  display: block;
  overflow-wrap: anywhere;
}

.chunk-facts {
  color: var(--text-secondary);
}

/* ---- the usage panel ---- */

.usage {
  display: grid;
  /* the ring column is wide enough for the label's longest line,
     QUESTIONS · RESETS IN: 23H 59M, at the mono size */
  grid-template-columns: 15rem minmax(0, 1fr);
  column-gap: 1.5rem;
  align-items: center;
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.45s var(--ease) forwards;
}

.usage__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  height: 1.875rem;
  margin-bottom: 0.25rem;
}

.usage__ring,
.usage__meters {
  min-width: 0;
}

.usage-answers {
  grid-column: 1 / -1;
}

.usage-title {
  font-family: var(--font-panel);
  font-size: clamp(19px, 2.6vh, 24px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
}

.usage.is-open .badge-dot {
  background: var(--color-teal);
}

.usage.is-full .badge-dot,
.usage.is-paused .badge-dot,
.usage.is-error .badge-dot {
  background: var(--color-coral);
}

.ringbox {
  flex: none;
  display: flex;
  justify-content: center;
  height: clamp(92px, 17vh, 170px);
  margin: 0.125rem 0;
}

.ring {
  position: relative;
  width: clamp(92px, 17vh, 170px);
  height: clamp(92px, 17vh, 170px);
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 14;
}

/* dashed until the first numbers are drawn, in the Error state as well */
.usage.is-empty .ring-track {
  stroke-dasharray: 4 6;
}

.ring-arc {
  fill: none;
  stroke: var(--color-teal);
  stroke-width: 14;
  stroke-linecap: butt;
  transition: stroke-dashoffset 0.8s var(--ease), stroke 0.4s;
}

.ring-arc.tone-amber {
  stroke: var(--color-amber);
}

.ring-arc.tone-coral {
  stroke: var(--color-coral);
}

.ring-tick {
  stroke: var(--bg-card);
  stroke-width: 4;
}

.ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-digits);
  font-size: clamp(29px, 5.1vh, 55px);
  font-weight: 400;
  color: var(--text-primary);
}

.ring-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 1.375rem;
  margin: 0.25rem 0;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-secondary);
}

.ring-label b {
  font-weight: 500;
  color: var(--text-primary);
}

.rows {
  flex: none;
  padding-bottom: 0.375rem;
}

.meter {
  margin: 0.375rem 0;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.3125rem;
}

.meter-name {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.meter-value-wrap {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.meter-value {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.meter.tone-teal .meter-value {
  color: var(--text-ok);
}

.meter.tone-amber .meter-value {
  color: var(--text-warn);
}

.meter.tone-coral .meter-value {
  color: var(--text-danger);
}

.meter-percent {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.meter-bar {
  position: relative;
  height: 0.5rem;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.meter.tone-teal .meter-bar {
  background: var(--track-teal);
}

.meter.tone-amber .meter-bar {
  background: var(--track-amber);
}

.meter.tone-coral .meter-bar {
  background: var(--track-coral);
}

.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-teal);
  border-radius: 999px;
  transition: width 0.8s var(--ease), background 0.4s;
}

.meter.tone-amber .meter-fill {
  background: var(--color-amber);
}

.meter.tone-coral .meter-fill {
  background: var(--color-coral);
}

.warnbox {
  margin-top: 0.625rem;
  padding: 0.5625rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--text-warn);
  background: var(--bg-surface);
  border: 0.0625rem solid var(--color-amber);
  border-radius: var(--r-md);
  overflow-wrap: break-word;
}

.errbox {
  margin-top: 0.875rem;
  padding: 0.75rem 0.875rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-danger);
  background: var(--bg-surface);
  border: 0.0625rem solid var(--color-coral);
  border-radius: var(--r-md);
  overflow-wrap: break-word;
}

.usage-answers {
  margin-top: 0.75rem;
}

.usage-answers .section-title {
  margin-top: 0;
}

#usage-answers {
  max-height: 12rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---- the footer ---- */

.footer {
  width: 100%;
  max-width: calc(var(--frame-w) + 2.5rem);
  margin: 0 auto;
  padding: 1.25rem;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.footer a {
  color: var(--text-accent);
  border-bottom: 0.0625rem solid transparent;
  transition: border-color 120ms ease;
}

.footer a:hover {
  border-bottom-color: currentColor;
}

[data-theme="light"] .footer a {
  border-bottom-color: currentColor;
}

/* ---- narrow screens ---- */

@media (max-width: 38rem) {
  .topbar__inner {
    padding: 0 var(--gutter);
    gap: 1rem;
  }

  .app-wrap {
    padding: 0.5rem 0 2rem;
  }

  .app-frame {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .app-body {
    padding: 1rem var(--gutter);
  }

  .card,
  .login__card {
    padding: 1rem;
  }

  .login__card {
    padding: 1.75rem 1.25rem;
  }

  .usage {
    grid-template-columns: minmax(0, 1fr);
  }

  .ask-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .ask-button {
    width: 100%;
  }

  .spec-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
  }

  .spec-row dd {
    text-align: left;
  }

  .footer {
    padding: 1rem var(--gutter);
  }
}

/*
 * The hidden attribute always hides. Three attribute selectors outrank every
 * display rule above, so no importance flag is needed.
 */
[hidden][hidden][hidden] {
  display: none;
}
