/* ============================================================================
   Global Application Styles
   Using Pico.css variables for consistency
   ============================================================================ */

/* ============================================================================
   Self-hosted typography
   - Instrument Serif: display / headings (static 400 + italic, OFL)
   - Hanken Grotesk:   UI / body (variable wght 100-900 + italic axis, OFL)
   - JetBrains Mono:   code / technical output (variable wght 100-800, OFL)
   Subsets split into latin + latin-ext via unicode-range so the browser
   only fetches the file it needs for the active glyphs. font-display: swap
   renders system fallback during the ~50ms woff2 fetch, then upgrades.
   ============================================================================ */

/* Hanken Grotesk — body / UI */
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/HankenGrotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/HankenGrotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/HankenGrotesk-Italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/HankenGrotesk-Italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Instrument Serif — display / headings */
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-Italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-Italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Fraunces — logo wordmark only. Variable axes: opsz (9-144), wght (400-700),
   SOFT (30-100). Has the weight and presence Instrument Serif lacks at
   small wordmark sizes. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* JetBrains Mono — code blocks, technical output */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/JetBrainsMono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/JetBrainsMono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Override Pico's font stacks. Pico's --pico-font-family resolves
     to --pico-font-family-sans-serif by default, so html/body/forms
     all inherit Hanken Grotesk via the cascade. */
  --pico-font-family-sans-serif:
    "Hanken Grotesk",
    system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --pico-font-family-monospace:
    "JetBrains Mono",
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --pico-font-family: var(--pico-font-family-sans-serif);

  /* Display family — applied to h1-h3. Editorial serif at large sizes. */
  --font-family-display:
    "Instrument Serif",
    Georgia, "Times New Roman", "Liberation Serif", serif;

  /* Logo family — Instrument Serif is too thin for a wordmark at 28px;
     Fraunces carries weight and warmth at small sizes via its
     optical-size axis. */
  --font-family-logo:
    "Fraunces",
    Georgia, "Times New Roman", "Liberation Serif", serif;

  /* Subtle weight bump for body text. Variable font handles this for
     free; 420 lands between regular and medium and reads cleaner on
     light backgrounds than the default 400. */
  --pico-font-weight: 420;

  /* Semantic status palette for soft badges (filled tint + readable text).
     Light values are AA on their own tint; the [data-theme="dark"] block
     below overrides them with dark-surface-appropriate tints. */
  --status-success-bg: #d4edda;
  --status-success-text: #155724;
  --status-warning-bg: #fff3cd;
  --status-warning-text: #856404;
  --status-danger-bg: #f8d7da;
  --status-danger-text: #721c24;
  --status-info-bg: #d1ecf1;
  --status-info-text: #0c5460;
  --status-neutral-bg: #e2e3e5;
  --status-neutral-text: #383d41;
}

/* Display font for top-three heading levels. h4-h6 stay sans to keep
   hierarchy clear and avoid serif noise at small sizes — Instrument
   Serif is a display face, not a text face. */
h1, h2, h3 {
  font-family: var(--font-family-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.5rem); }

/* Opt-in editorial serif for display text that isn't an h1-h3 — section
   eyebrows, stat figures, pull quotes. A named hook so "set this with the
   display face" is intentional rather than a one-off font-family override.
   ``.display-serif-italic`` adds the italic for an editorial accent. */
.display-serif,
.display-serif-italic {
  font-family: var(--font-family-display);
  letter-spacing: -0.01em;
}

.display-serif-italic {
  font-style: italic;
}

/* Bind mono explicitly so user-agent defaults don't override Pico's
   variable on bare <code>/<pre>/<kbd>/<samp>. */
code, kbd, samp, pre, .mono {
  font-family: var(--pico-font-family-monospace);
}

/* ============================================================================
   Warm dark mode
   ----------------------------------------------------------------------------
   Override Pico's cool blue-charcoal dark palette with deep oxblood-brown
   surfaces and warm-cream text. Reads as "leather chair at night" rather
   than "monitor in a meeting room". Primary accent still comes from the
   selected Pico variant (default / jade / pumpkin) so admin colour
   overrides still apply.

   The high-contrast theme uses [data-theme="high-contrast"] which never
   matches these rules, so accessibility mode stays pure black-on-white.
   ============================================================================ */

[data-theme="dark"] {
  --pico-background-color: #1F1A15;
  --pico-card-background-color: #2B2520;
  --pico-card-sectioning-background-color: #25201B;
  --pico-color: #F2EBE0;
  --pico-h1-color: #FBF6EE;
  --pico-h2-color: #F5EFE4;
  --pico-h3-color: #F0EADE;
  --pico-h4-color: #E8E1D3;
  --pico-h5-color: #DFD7C8;
  --pico-h6-color: #D6CDBD;
  --pico-heading-color: #F5EFE4;
  --pico-muted-color: #A39A8A;
  --pico-muted-border-color: #3A332C;
  --pico-card-border-color: #3A332C;
  --pico-code-background-color: #15110D;
  --pico-code-color: #E8C896;
  --pico-form-element-background-color: #25201B;
  --pico-form-element-border-color: #3A332C;
  --pico-form-element-color: #F2EBE0;
  --pico-form-element-placeholder-color: #8A8170;
  --pico-form-element-active-background-color: #2B2520;
  --pico-form-element-disabled-background-color: #1F1A15;
  --pico-secondary-background: #3A332C;
  --pico-secondary-inverse: #F2EBE0;
  --pico-table-row-stripped-background-color: #25201B;
  --pico-table-border-color: #3A332C;
  --pico-dropdown-background-color: #2B2520;
  --pico-dropdown-border-color: #3A332C;
  --pico-blockquote-color: #C8BFAD;
  --pico-blockquote-border-color: #3A332C;

  /* Status palette — dark tints harmonised with the warm surfaces above,
     bright foreground text keeps AA contrast on the tinted background. */
  --status-success-bg: #1D3326;
  --status-success-text: #7EE0A6;
  --status-warning-bg: #3A3014;
  --status-warning-text: #F0C674;
  --status-danger-bg: #3A1D1F;
  --status-danger-text: #F2A3A8;
  --status-info-bg: #14323A;
  --status-info-text: #82D4E6;
  --status-neutral-bg: #2E2A24;
  --status-neutral-text: #BCB4A6;
  color-scheme: dark;
}

/* Switch (role="switch") sizing. Padding gives the thumb visible inset
   from the border (the thumb is height:100% of the content box, so
   padding shrinks it). Keep width - height = 1em so Pico's hardcoded
   `margin-inline-start: calc(2.25em - 1.25em)` on the checked thumb still
   lands flush with the right edge of the content box. */
[type="checkbox"][role="switch"] {
  width: 2.75em;
  height: 1.75em;
  padding: 0.1875em;
}

/* ============================================================================
   Accessibility Components
   ============================================================================ */

/* Skip Navigation Link — hidden off-screen until focused.
   Keep the element in the accessibility tree (no ``visibility: hidden``)
   so screen-reader reading mode can announce it; only the visual
   position moves out of view. */
.skip-link {
  position: absolute;
  top: -200px;
  left: 6px;
  z-index: 1000;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  border: 2px solid var(--pico-primary);
  border-radius: var(--pico-border-radius);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 6px;
  outline: 2px solid var(--pico-background-color);
  outline-offset: 2px;
}

/* Screen Reader Only Text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   Header & Navigation
   ============================================================================ */

/* Header Logo — Fraunces 600 with optical sizing + a touch of SOFT
   for warm terminals. opsz=28 matches the rendered size in px so the
   glyph proportions are tuned for this exact wordmark size. */
.header-logo-text {
  font-family: var(--font-family-logo);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 28, "SOFT" 50;
  text-decoration: none;
}

.header-logo-image {
  display: block;
  height: 2.25rem;
  width: auto;
  max-width: 16rem;
  object-fit: contain;
}

.branding-preview {
  display: block;
  max-height: 4rem;
  max-width: 16rem;
  width: auto;
  object-fit: contain;
  margin-bottom: 0.5rem;
  border-radius: var(--pico-border-radius);
}

.branding-preview-favicon {
  max-height: 2.5rem;
  max-width: 2.5rem;
}

.header-logo-subtitle {
  display: block;
  font-family: var(--pico-font-family-sans-serif);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Theme Toggle */
#theme-toggle-icon {
  text-decoration: none;
}

/* Footer controls (theme switch + language picker) */
.footer-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-controls .language-picker {
  margin: 0;
  display: inline-flex;
  align-items: stretch;
}

/* Pin both controls to the same box so the row aligns exactly. */
.footer-controls #theme-toggle-icon,
.footer-controls .language-picker-select {
  box-sizing: border-box;
  height: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  line-height: 1;
  width: auto;
}

.footer-controls .language-picker-select {
  padding-right: 2rem;
}

/* Responsive Navigation Container */
.responsive-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.responsive-nav .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.responsive-nav .nav-item {
  white-space: nowrap;
}

/* Navigation Button Styling */
.responsive-nav a[role="button"] {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  text-decoration: none;
}

/* Compact action buttons inside table rows / lists (e.g. prompt library). */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row-actions form {
  margin: 0;
}

.row-actions a[role="button"],
.row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Prompt library: responsive card grid + cards. */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.prompt-card {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.prompt-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.prompt-badge {
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0.8;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.25rem 0;
}

.prompt-chips code {
  font-size: 0.75rem;
}

.prompt-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: auto;
}

.prompt-card-actions form.inline-form {
  margin: 0;
}

.prompt-card-actions a[role="button"],
.prompt-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: auto;
  margin: 0;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Prompt editor: split pane (form left, live preview right). */
.prompt-editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .prompt-editor-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.prompt-preview-pane {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.prompt-preview-body {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22rem;
  overflow-y: auto;
}

.prompt-preview-body mark {
  border-radius: 0.2rem;
  padding: 0 0.15rem;
}

/* Breathing room between the preview and the Test button / output. */
#pe-test {
  margin-top: 1.5rem;
}

#pe-test-output {
  margin-top: 1rem;
}

.prompt-editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  opacity: 0.85;
}

.prompt-diff {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  overflow-x: auto;
}

.prompt-diff ins {
  background: rgba(46, 160, 67, 0.18);
  text-decoration: none;
}

.prompt-diff del {
  background: rgba(248, 81, 73, 0.18);
  text-decoration: none;
}

/* Form action row (e.g. submit + cancel). Keeps an <a role="button"> and a
   <button> the same height and side-by-side instead of full-width stacked. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.form-actions a[role="button"],
.form-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0;
}

/* No underline on nav-link hover; use a subtle opacity shift instead
   (font-weight changes would reflow buttons/dropdowns). */
.responsive-nav a:hover,
.responsive-nav a:focus,
.mobile-nav-menu a:hover,
.mobile-nav-menu a:focus {
  text-decoration: none;
  opacity: 0.8;
}

/* Active page indicator — visual cue mirrors aria-current="page". */
.responsive-nav a[aria-current="page"],
.mobile-nav-menu a[aria-current="page"] {
  font-weight: var(--weight-medium, 500);
}

/* Menu separator: list items with role="separator" render as a horizontal
   rule without nesting an invalid <hr> inside <li>. Keeps the screen-reader
   announcement to "separator" rather than "list item, horizontal rule". */
.nav-separator {
  border-top: 1px solid var(--pico-muted-border-color);
  margin: 0.4rem 0;
  list-style: none;
  height: 0;
}

/* Inline form wrapper for the logout button in the user menu. */
.nav-logout-form {
  margin: 0;
}

.desktop-nav-dropdown .nav-logout-form button,
.mobile-dropdown-menu .nav-logout-form button {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  display: block;
  width: 100%;
  margin: 0.125rem 0;
  padding: 0.75rem 2rem;
  color: var(--pico-dropdown-color, var(--pico-contrast));
  font-size: 0.95rem;
  font-weight: var(--weight-normal, 400);
  text-align: left;
  text-decoration: none;
  border: 0;
  border-radius: 0;
}

.desktop-nav-dropdown .nav-logout-form button {
  width: auto;
  margin: calc(var(--pico-form-element-spacing-vertical) * -0.5)
    calc(var(--pico-form-element-spacing-horizontal) * -1);
  padding: calc(var(--pico-form-element-spacing-vertical) * 0.5)
    var(--pico-form-element-spacing-horizontal);
}

.desktop-nav-dropdown .nav-logout-form button:hover,
.desktop-nav-dropdown .nav-logout-form button:focus-visible,
.mobile-dropdown-menu .nav-logout-form button:hover,
.mobile-dropdown-menu .nav-logout-form button:focus-visible {
  color: var(--pico-primary);
  background-color: var(--pico-dropdown-hover-background-color);
  box-shadow: none;
}

/* Unread message badge — semantically a status counter rather than a
   highlighted text fragment. Visually matches Pico's <mark> styling so
   the change is invisible to sighted users. */
.nav-unread-badge {
  background: var(--pico-mark-background-color);
  color: var(--pico-mark-color);
  padding: 0.1em 0.4em;
  border-radius: var(--pico-border-radius);
  font-size: 0.85em;
}

/* Nib mascot icon in nav — size to match emoji/text height, no layout bump. */
.nib-nav-mascot {
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.25em;
  object-fit: contain;
}

/* Desktop/Mobile Visibility Controls */
.desktop {
  display: flex;
}

.mobile-only {
  display: none;
}

/* ============================================================================
   Mobile Navigation (Hamburger Menu)
   ============================================================================ */

.hamburger-menu {
  position: relative;
}

.hamburger-toggle {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  --pico-color: var(--pico-contrast);
  position: relative;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s linear;
}

.hamburger-toggle:hover,
.hamburger-toggle:active,
.hamburger-toggle:focus {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  --pico-color: var(--pico-contrast);
}

.hamburger-toggle:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
}

.hamburger-toggle:focus-visible .hamburger-line {
  background: var(--pico-primary);
}

.hamburger-line {
  position: relative;
  width: 1.5rem;
  height: 0.125rem;
  background: var(--pico-color);
  border-radius: 0.125rem;
  transform-origin: 1px;
  transition: all 0.3s linear;
}

/* Mobile Navigation Menu */
.mobile-nav-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  min-width: 16rem;
  margin: 0;
  padding: var(--pico-spacing) 0;
  list-style: none;
  background: var(--pico-card-background-color);
  border: var(--pico-border-width) solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  box-shadow: var(--pico-box-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.mobile-nav-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mobile-nav-menu li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

.mobile-nav-menu > li > a,
.mobile-dropdown-toggle {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  --pico-color: var(--pico-contrast);
  display: block;
  width: 100%;
  margin: 0.125rem 0;
  padding: var(--pico-spacing) 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-nav-menu > li > a:hover,
.mobile-dropdown-toggle:hover {
  color: var(--pico-primary);
  background-color: var(--pico-dropdown-hover-background-color);
  transform: translateX(4px);
}

/* Mobile Dropdown Menus */
.mobile-dropdown {
  position: relative;
}

.mobile-dropdown-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Pico's `nav li [type=button]` rule (specificity 0,1,2) outranks the shared
   `.mobile-dropdown-toggle` rule (0,1,0) and would force the toggle's
   horizontal padding down to the nav-link spacing, indenting it less than the
   plain `<a>` items (which win via `.mobile-nav-menu > li > a`). Match the
   anchor inset with an equally scoped, higher-specificity selector. */
.mobile-nav-menu > li > .mobile-dropdown-toggle {
  padding: var(--pico-spacing) 1.5rem;
}

.mobile-dropdown-toggle .dropdown-arrow {
  flex-shrink: 0;
  margin-left: 1rem;
}

.dropdown-arrow {
  font-size: 0.8rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.mobile-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.mobile-dropdown-menu {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 0;
  margin: 0;
  margin-top: 0.5rem;
  padding: 0.5rem 0;
  list-style: none;
  background-color: var(--pico-card-sectioning-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.mobile-dropdown.active .mobile-dropdown-menu {
  max-height: 80dvh;
  overflow-y: auto;
}

.mobile-dropdown-menu li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

.mobile-dropdown-menu a {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0.125rem 0;
  padding: 0.75rem 2rem;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: none;
  color: var(--pico-color);
  transition: all 0.2s ease;
}

.mobile-dropdown-menu a:hover {
  color: var(--pico-primary);
  background-color: var(--pico-dropdown-hover-background-color);
  transform: translateX(4px);
}

.mobile-dropdown:last-child .mobile-dropdown-toggle {
  border-bottom: none;
}

/* ============================================================================
   Feedback Sections
   ============================================================================ */

.feedback-section {
  margin-top: 3rem;
  padding: 2rem;
  text-align: center;
  background-color: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
}

.feedback-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Specific Feedback Variants */
.chatbot-feedback-section,
.tool-feedback-section {
  margin-top: 2rem;
  padding: 1rem;
  background-color: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
}

/* ============================================================================
   About Section
   ============================================================================ */

.about-section {
  margin-top: 0;
}

.about-info-block {
  margin: var(--pico-spacing) 0;
  padding-top: var(--pico-spacing);
  border-top: 1px solid var(--pico-muted-border-color);
}

.about-info-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.about-info-block > header h3,
.about-info-block > h3 {
  margin-bottom: calc(var(--pico-spacing) * 0.5);
}

/* ============================================================================
   Message System
   ============================================================================ */

.messages .message,
.notification {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: var(--pico-spacing) 0;
  padding: var(--pico-spacing);
  font-size: 0.95rem;
  line-height: 1.4;
  border: var(--pico-border-width) solid;
  border-radius: var(--pico-border-radius);
  overflow-wrap: break-word;
  word-break: break-word;
}

.messages .message .message-text {
  flex: 1 1 auto;
  min-width: 0;
}

.messages .message .message-icon {
  display: inline;
  margin-right: 0.25rem;
}

/* Reset Pico's primary-button styling for the unobtrusive × dismiss control,
   while keeping a 44 px touch target (WCAG 2.5.5). The visible glyph stays
   compact via padding; the hit area extends to the project minimum. */
.messages .message button.message-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.messages .message button.message-close:hover {
  opacity: 1;
  background: rgba(127, 127, 127, 0.18);
  transform: scale(1.05);
}

.messages .message button.message-close:focus-visible {
  opacity: 1;
  background: rgba(127, 127, 127, 0.18);
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
  box-shadow: none;
}

.messages .message button.message-close:active {
  transform: scale(0.95);
}

/* Success Messages */
.message-success,
.notification.success {
  color: var(--pico-color);
  background-color: var(--pico-form-element-valid-background-color);
  border-color: var(--pico-form-element-valid-border-color);
}

/* Error Messages */
.message-error,
.error-message,
.notification.error,
.login-error,
.text-danger {
  color: var(--pico-color);
  background-color: var(--pico-form-element-invalid-background-color);
  border-color: var(--pico-form-element-invalid-border-color);
}

/* Warning Messages */
.message-warning,
.notification.warning {
  color: var(--pico-color);
  background-color: var(--pico-mark-background-color);
  border-color: var(--pico-mark-color);
}

/* Info Messages */
.message-info,
.notification.info {
  color: var(--pico-color);
  background-color: var(--pico-primary-focus);
  border-color: var(--pico-primary);
}

/* Legacy Support */
.login-error {
  margin: var(--pico-spacing) 0;
  padding: var(--pico-spacing);
  border: var(--pico-border-width) solid var(--pico-form-element-invalid-border-color);
  border-radius: var(--pico-border-radius);
}

/* Field-specific Errors */
small.text-danger {
  display: block;
  margin-top: 0.25rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  background: none;
  border: none;
}

.field-error {
  display: block;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--pico-form-element-invalid-color);
  background-color: var(--pico-form-element-invalid-background-color);
  border: 1px solid var(--pico-form-element-invalid-border-color);
  border-radius: var(--pico-border-radius);
}

.maintenance-banner {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  color: var(--pico-color-amber-900, #5a4500);
  background: var(--pico-color-amber-50, #fff8e1);
  border: 2px solid var(--pico-color-amber-500, #f0ad4e);
  border-radius: var(--pico-border-radius);
}

[data-theme="dark"] .maintenance-banner {
  color: var(--pico-color-amber-100, #fff3cd);
  background: color-mix(in srgb, var(--pico-color-amber-500, #f0ad4e) 18%, transparent);
}

/* Site-wide information banner rendered above the header (always visible
   while enabled). The bar spans the full width; its content aligns to the
   page container. Three emphasis levels: info / warning / critical. */
.information-banner {
  width: 100%;
  border-bottom: 2px solid currentColor;
}

.information-banner__inner {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding-block: 0.6rem;
}

.information-banner__icon {
  flex: 0 0 auto;
  line-height: 1;
}

.information-banner__text {
  flex: 1 1 auto;
  white-space: pre-line;
}

.information-banner--info {
  color: var(--pico-color-azure-900, #0b3d63);
  background: var(--pico-color-azure-50, #e7f3fb);
  border-color: var(--pico-color-azure-400, #2a7ab9);
}

.information-banner--warning {
  color: var(--pico-color-amber-900, #5a4500);
  background: var(--pico-color-amber-50, #fff8e1);
  border-color: var(--pico-color-amber-500, #f0ad4e);
}

.information-banner--critical {
  color: var(--pico-color-red-900, #7a1c1c);
  background: var(--pico-color-red-50, #fdecea);
  border-color: var(--pico-color-red-500, #d9534f);
}

[data-theme="dark"] .information-banner--info {
  color: var(--pico-color-azure-100, #d6e9fb);
  background: color-mix(in srgb, var(--pico-color-azure-500, #2a7ab9) 18%, transparent);
}

[data-theme="dark"] .information-banner--warning {
  color: var(--pico-color-amber-100, #fff3cd);
  background: color-mix(in srgb, var(--pico-color-amber-500, #f0ad4e) 18%, transparent);
}

[data-theme="dark"] .information-banner--critical {
  color: var(--pico-color-red-100, #f9d6d2);
  background: color-mix(in srgb, var(--pico-color-red-500, #d9534f) 22%, transparent);
}

.error-page-section {
  margin-top: var(--pico-spacing);
}

.error-page-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
}

.gpu-game-shell {
  position: relative;
}

.maintenance-page {
  padding-top: 3rem;
  text-align: center;
}

.maintenance-page-message {
  max-width: 60ch;
  margin: 1rem auto;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
}

.empty-state-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.empty-state-title {
  margin: 0.75rem 0 0.25rem;
}

.empty-state-message {
  max-width: 48ch;
  margin: 0.25rem auto 1rem;
  opacity: 0.8;
}

/* Centered column layout for empty states that include a Nib mascot.
   The mascot sits on top; title and message stack below, narrow column
   so long German strings wrap cleanly. */
.empty-state-with-mascot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state-with-mascot .nib-mascot {
  margin-bottom: 0.5rem;
}

.legal-document {
  max-width: 56rem;
  margin: 0 auto;
}

.legal-document .markdown-content table {
  width: 100%;
}

.legal-document .markdown-content pre {
  padding: 1rem;
  overflow-x: auto;
  border-radius: var(--pico-border-radius);
}

.legal-document .markdown-content code {
  font-size: 0.875em;
}

.legal-document .markdown-content h1,
.legal-document .markdown-content h2,
.legal-document .markdown-content h3 {
  margin-top: 1.5rem;
}

.overflow-x-auto {
  max-width: 100%;
  overflow-x: auto;
}

.overflow-x-auto table {
  margin-bottom: 0;
}

main.container td > form {
  margin: 0;
}

main.container td > form button {
  margin: 0;
}

/* ============================================================================
   Footer
   ============================================================================ */

.responsive-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

/* ============================================================================
   Loading States
   ============================================================================ */

.loading-indicator {
  display: none;
}

.loading-indicator.active {
  display: block;
}

/* ============================================================================
   Media Queries
   ============================================================================ */

/* Mobile */
@media (max-width: 768px) {
  .desktop {
    display: none !important;
  }

  .mobile-only {
    display: block;
  }

  .responsive-nav {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .responsive-nav .nav-links {
    display: none !important;
  }

  .responsive-footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: center;
  }

  .responsive-footer .footer-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .responsive-footer .footer-admin {
    font-weight: bold;
  }

  /* Prevent floating bug-report button from covering bottom content */
  main.container {
    padding-bottom: 4rem;
  }

  main.container article > table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .header-logo-text {
    font-size: 1.25rem;
  }

  .mobile-nav-menu {
    right: -0.5rem;
    min-width: calc(100vw - 2rem);
  }

  .mobile-nav-menu > li > a,
  .mobile-dropdown-toggle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .responsive-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .responsive-footer .footer-links {
    gap: 0.25rem;
  }

  .responsive-footer .footer-links li {
    font-size: 0.9rem;
  }
}

/* ============================================================================
   User Dropdown Username Truncation
   ============================================================================ */

/* Desktop user dropdown - truncate long usernames */
.nav-item details.dropdown summary {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile user dropdown - truncate long usernames */
.mobile-dropdown-toggle {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-dropdown-toggle .dropdown-arrow {
  flex-shrink: 0;
}

/* ============================================================================
   Service Worker Update Toast
   ============================================================================ */

.sw-update-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100vw - 2rem);
  padding: 0.75rem 1rem;
  background: var(--pico-card-background-color);
  color: var(--pico-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: sw-toast-slide-in 0.25s ease-out;
}

.sw-update-toast button {
  margin: 0;
}

@keyframes sw-toast-slide-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .sw-update-toast {
    animation: none;
  }
}

/* ============================================================================
   Global Top Progress Bar (loading indicator)
   ============================================================================ */

.global-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 10000;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
}

.global-progress-bar::before {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--pico-primary);
  animation: global-progress-slide 1.1s ease-in-out infinite;
}

@keyframes global-progress-slide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(160%); }
  100% { transform: translateX(160%); }
}

@media (prefers-reduced-motion: reduce) {
  .global-progress-bar::before {
    animation: none;
    width: 100%;
    opacity: 0.6;
  }
}

/* ============================================================================
   Header Logo Hover
   ============================================================================ */

.header-logo-text {
  transition: color 0.15s ease;
}

.header-logo-text:hover,
.header-logo-text:focus-visible {
  color: var(--pico-primary);
}

.header-logo-subtitle {
  transition: opacity 0.15s ease;
}

.header-logo-text:hover .header-logo-subtitle {
  opacity: 1;
}

/* ============================================================================
   Nav Mascot Hover Micro-Interaction
   ============================================================================ */

.nib-nav-mascot {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nib-nav-link:hover .nib-nav-mascot,
.nib-nav-link:focus-visible .nib-nav-mascot {
  transform: scale(1.18) rotate(-6deg);
}

@media (prefers-reduced-motion: reduce) {
  .nib-nav-mascot,
  .nib-nav-link:hover .nib-nav-mascot,
  .nib-nav-link:focus-visible .nib-nav-mascot {
    transition: none;
    transform: none;
  }
}

/* ============================================================================
   Hamburger Morph (cleaner X)
   ============================================================================ */

.hamburger-toggle.active .hamburger-line:first-child {
  transform: translate(2px, 5px) rotate(45deg);
}

.hamburger-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-toggle.active .hamburger-line:nth-child(3) {
  transform: translate(2px, -5px) rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
  .hamburger-line {
    transition: none;
  }
}

/* ============================================================================
   Desktop Dropdown Chevron Rotation
   Pico renders a ▾ on <summary>; rotate it on open.
   ============================================================================ */

.desktop-nav-dropdown[open] > summary::after {
  transform: rotate(180deg);
}

.desktop-nav-dropdown > summary::after {
  transition: transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .desktop-nav-dropdown > summary::after {
    transition: none;
  }
}

/* ============================================================================
   Favorite Pill Toggle Pulse
   ============================================================================ */

@keyframes favorite-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.pill-favorite[data-just-toggled="true"] .favorite-icon {
  display: inline-block;
  animation: favorite-pulse 0.35s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .pill-favorite[data-just-toggled="true"] .favorite-icon {
    animation: none;
  }
}

/* ============================================================================
   Result Heading Highlight (post-load attention flash)
   ============================================================================ */

@keyframes result-heading-highlight {
  0%   { box-shadow: 0 0 0 0 rgba(var(--pico-primary-rgb, 99, 99, 99), 0.0); }
  20%  { box-shadow: 0 0 0 6px rgba(var(--pico-primary-rgb, 99, 99, 99), 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(var(--pico-primary-rgb, 99, 99, 99), 0.0); }
}

#result-heading.result-heading-flash {
  border-radius: var(--pico-border-radius);
  animation: result-heading-highlight 1s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  #result-heading.result-heading-flash {
    animation: none;
  }
}

/* ============================================================================
   Code-Block Inline Copy Button (added by tool-loading-states/markdown render)
   ============================================================================ */

.result-output-content pre {
  position: relative;
}

.code-copy-button {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--pico-color);
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

@media (max-width: 768px) {
  .code-copy-button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
  }
}

.result-output-content pre:hover .code-copy-button,
.result-output-content pre:focus-within .code-copy-button,
.code-copy-button:focus-visible,
.code-copy-button:hover {
  opacity: 1;
}

.code-copy-button:hover {
  background: var(--pico-dropdown-hover-background-color);
}

.code-copy-button.copied {
  color: var(--status-success-text);
  background: var(--status-success-bg);
  border-color: var(--status-success-text);
  opacity: 1;
}

/* ============================================================================
   Utility Page Icon — unified alignment for emoji + PNG variants
   ============================================================================ */

.utility-page-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  position: static;
  top: auto;
}

/* ============================================================================
   Welcome Wizard — theme picker tiles
   ============================================================================ */

/* The theme tiles are Pico buttons, so their <small> caption otherwise falls
   back to --pico-muted-color, which is unreadable on the saturated button
   fill (secondary slate, or primary green when active — barely 1:1 contrast).
   Bind the caption to the button's own inverse text colour so it keeps the
   same contrast as the tile title; the smaller font size still marks the
   hierarchy. */
.welcome-theme-tile small {
  color: inherit;
}
