/**
 * AirgapAI Feedback Portal — public form styles.
 *
 * Design lane: "Engineered Navy" (application-dashboard) + the two-layer
 * token model (raw hex -> intent tokens) per
 * documentation/design/phase-2-ui-and-form.md §1-2. Azure #007EC7 is the
 * active accent palette. Rounded fields/cards (9px/12px), squared 2-3px
 * status-style accents where noted. Light-first; dark is a token override
 * behind prefers-color-scheme + [data-theme] (see bottom of file), per §16.
 */

/* ---------------------------------------------------------------------- */
/* 1. Tokens                                                              */
/* ---------------------------------------------------------------------- */

:root {
  /* Navy ink / chrome */
  --navy-950: #060f1d;
  --navy-900: #0a1628;
  --navy-mid: #132040;
  --navy-heading: #08204a;

  /* AirgapAI Azure — the brand anchor */
  --azure: #007ec7;
  --azure-hover: #0069a8;
  --azure-strong: #08527f;
  --azure-bright: #009ef9;
  --azure-cyan: #00c2ff;
  --logo-cyan: #90e4fc;

  /* Architect-white surfaces */
  --paper-page: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f6f8fb;
  --tint-azure: #f0f7ff;
  --hairline: #e0e3e8;
  --hairline-strong: #d4d9e0;
  --border-brand: rgba(0, 126, 199, 0.55);

  /* Text ramp */
  --text-heading: #08204a;
  --text-body: #333b4a;
  --text-strong: #0b0f1a;
  --text-muted: #5b6675;
  --text-faint: #8892a7;
  --text-invert: #f5f4ef;

  /* Semantic */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --violet: #8b5cf6;
  --error-tint: #fee2e2;
  --error-deep: #991b1b;
  --success-tint: #dcfce7;

  /* Priority escalation */
  --pri-low: #5b6675;
  --pri-medium: #3b82f6;
  --pri-high: #f59e0b;
  --pri-critical: #ef4444;

  --ring: 0 0 0 3px rgba(0, 126, 199, 0.3);

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Courier New', monospace;

  --r-field: 9px;
  --r-card: 12px;
  --r-pill: 9999px;
  --r-badge: 3px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  --reading-max: 720px;
  --elev-card: 0 1px 2px rgba(10, 22, 40, 0.04), 0 8px 24px -8px rgba(10, 22, 40, 0.1);
  --elev-pop: 0 10px 30px -8px rgba(10, 22, 40, 0.28);
  --transition-fast: 140ms ease;
  --transition-med: 220ms ease;

  color-scheme: light;
}

/* Optional dark mode: pure intent-token override (documented but off by
   default per family convention) — honors OS preference, and lets a future
   toggle stamp data-theme to win explicitly in either direction. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper-page: #0a1628;
    --surface: #0f1d32;
    --surface-alt: #101f38;
    --tint-azure: rgba(0, 126, 199, 0.16);
    --hairline: rgba(255, 255, 255, 0.1);
    --hairline-strong: rgba(255, 255, 255, 0.16);
    --border-brand: rgba(0, 158, 249, 0.55);
    --text-heading: #f1f5f9;
    --text-body: #cbd5e1;
    --text-strong: #f8fafc;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --azure: #009ef9;
    --azure-hover: #33b1ff;
    --error-tint: rgba(239, 68, 68, 0.16);
    --success-tint: rgba(16, 185, 129, 0.16);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper-page: #0a1628;
  --surface: #0f1d32;
  --surface-alt: #101f38;
  --tint-azure: rgba(0, 126, 199, 0.16);
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --border-brand: rgba(0, 158, 249, 0.55);
  --text-heading: #f1f5f9;
  --text-body: #cbd5e1;
  --text-strong: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --azure: #009ef9;
  --azure-hover: #33b1ff;
  --error-tint: rgba(239, 68, 68, 0.16);
  --success-tint: rgba(16, 185, 129, 0.16);
  color-scheme: dark;
}
:root[data-theme='light'] {
  --paper-page: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f6f8fb;
  --tint-azure: #f0f7ff;
  --hairline: #e0e3e8;
  --hairline-strong: #d4d9e0;
  --border-brand: rgba(0, 126, 199, 0.55);
  --text-heading: #08204a;
  --text-body: #333b4a;
  --text-strong: #0b0f1a;
  --text-muted: #5b6675;
  --text-faint: #8892a7;
  --azure: #007ec7;
  --azure-hover: #0069a8;
  color-scheme: light;
}

/* ---------------------------------------------------------------------- */
/* 2. Reset + base                                                        */
/* ---------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  color: var(--text-heading);
  margin: 0 0 var(--s-2);
  line-height: 1.2;
}

p {
  margin: 0 0 var(--s-3);
}

button {
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

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

:focus-visible {
  outline: 2px solid var(--azure);
  outline-offset: 2px;
  border-radius: var(--r-field);
}

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

/* ---------------------------------------------------------------------- */
/* 3. Page layout                                                         */
/* ---------------------------------------------------------------------- */

.fb-page {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: var(--s-7) var(--s-4) var(--s-8);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

.fb-head {
  text-align: center;
  padding-top: var(--s-3);
}

.fb-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  color: var(--text-heading);
}

.fb-logo img,
.fb-logo svg {
  display: block;
  height: 26px;
  width: auto;
}

.fb-head h1 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
}

.fb-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

/* ---------------------------------------------------------------------- */
/* 4. Banners / toasts / error summary                                    */
/* ---------------------------------------------------------------------- */

/* The [hidden] attribute must always win over component display rules.
   Without this, class selectors like `.fb-banner { display:flex }` override the
   UA stylesheet's `[hidden] { display:none }` (class beats UA), leaving empty
   bordered cards visible before/after the form even when JS has hidden them. */
[hidden] {
  display: none !important;
}

.fb-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-field);
  border: 1px solid var(--border-brand);
  background: var(--tint-azure);
  color: var(--text-body);
  font-size: 0.92rem;
}

.fb-banner--warn {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.12);
}

.fb-banner--error {
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--error-tint);
  color: var(--error-deep);
}

.fb-banner-action {
  flex-shrink: 0;
  border: 1px solid var(--border-brand);
  background: var(--surface);
  color: var(--azure);
  font-weight: 600;
  font-size: 0.85rem;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-field);
  cursor: pointer;
}

.fb-banner-action:hover {
  background: var(--tint-azure);
}

.fb-error-summary {
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: var(--error-tint);
  color: var(--error-deep);
  border-radius: var(--r-card);
  padding: var(--s-4) var(--s-5);
}

.fb-error-summary h2 {
  font-size: 1rem;
  color: var(--error-deep);
  margin-bottom: var(--s-2);
}

.fb-error-summary ul {
  margin: 0;
  padding-left: var(--s-5);
}

.fb-error-summary a {
  color: var(--error-deep);
  text-decoration: underline;
  font-weight: 500;
}

.fb-toast {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: min(420px, calc(100vw - 2 * var(--s-4)));
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-field);
  background: var(--navy-900);
  color: var(--text-invert);
  box-shadow: var(--elev-pop);
  font-size: 0.9rem;
}

.fb-toast--error {
  background: var(--navy-900);
  border-left: 3px solid var(--error);
}

.fb-toast-retry {
  flex-shrink: 0;
  background: var(--azure);
  color: #fff;
  border: none;
  border-radius: var(--r-field);
  padding: var(--s-1) var(--s-3);
  font-weight: 600;
  cursor: pointer;
}

.fb-toast-retry:hover {
  background: var(--azure-hover);
}

/* ---------------------------------------------------------------------- */
/* 5. Form card                                                           */
/* ---------------------------------------------------------------------- */

.fb-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--elev-card);
  padding: var(--s-7);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.fb-hp {
  position: absolute !important;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

/* execCommand('copy') fallback textarea (only used when the async Clipboard
   API is unavailable) — a static class, never JS-set inline styles. */
.fb-clip-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

.fb-callout {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  background: var(--tint-azure);
  border: 1px solid var(--border-brand);
  border-radius: var(--r-field);
  padding: var(--s-4);
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-body);
}

.fb-callout-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--azure);
  margin-top: 2px;
}

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

.fb-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border: none;
  padding: 0;
  margin: 0;
}

.fb-field > label,
.fb-field > legend,
.fb-label {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-strong);
  padding: 0;
}

.fb-opt {
  color: var(--text-faint);
  font-weight: 400;
}

.fb-req {
  color: var(--error-deep);
  font-weight: 700;
}

.fb-help {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin: 0;
}

.fb-err {
  color: var(--error-deep);
  font-size: 0.84rem;
  margin: 0;
  font-weight: 500;
}

/* ---------------------------------------------------------------------- */
/* 6. Text inputs / textareas                                             */
/* ---------------------------------------------------------------------- */

.fb-field input[type='text'],
.fb-field input[type='email'] {
  width: 100%;
  min-height: 44px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-field);
  background: var(--surface-alt);
  color: var(--text-strong);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.fb-field input[type='text']:focus,
.fb-field input[type='email']:focus {
  outline: none;
  border-color: var(--azure);
  box-shadow: var(--ring);
  background: var(--surface);
}

.fb-field input[aria-invalid='true'] {
  border-color: var(--error);
  background: var(--error-tint);
}

.fb-field input:disabled,
.fb-field textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Placeholders: deliberately faint so example text never competes with real
   input. Lighter than the muted text ramp. */
.fb-field input::placeholder,
.fb-field textarea::placeholder {
  color: var(--text-faint);
  opacity: 0.45;
  font-size: 0.86rem;
}

textarea {
  width: 100%;
  resize: vertical;
  /* Keep a 2-line minimum even after typing collapses field-sizing:content to
     one line: 2×1.5em line-box + 2×--s-3 padding + 2px border (border-box). */
  min-height: 4.75em;
  max-height: 60vh;
  padding: var(--s-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-field);
  background: var(--surface-alt);
  color: var(--text-strong);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  overflow-y: auto;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  /* Pure-CSS auto-grow progressive enhancement — no JS inline-style
     mutation involved (that would be blocked by this page's strict
     style-src CSP). Unsupported browsers just keep the fixed rows + manual
     resize handle + scroll, which stay fully usable. */
  field-sizing: content;
}

textarea:focus {
  outline: none;
  border-color: var(--azure);
  box-shadow: var(--ring);
  background: var(--surface);
}

textarea[aria-invalid='true'] {
  border-color: var(--error);
  background: var(--error-tint);
}

.fb-meta {
  display: flex;
  justify-content: flex-end;
}

.fb-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}

.fb-count--warn {
  color: var(--warning);
}

.fb-count--danger {
  color: var(--error);
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* 7. Radio cards / priority chips                                        */
/* ---------------------------------------------------------------------- */

fieldset.fb-field {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset.fb-field.has-error .fb-radios {
  outline: 1px solid var(--error);
  outline-offset: 4px;
  border-radius: var(--r-field);
}

.fb-radios {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.fb-radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  min-height: 44px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-field);
  background: var(--surface);
  color: var(--text-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
    color var(--transition-fast);
  user-select: none;
}

.fb-radio input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.fb-radio:hover {
  border-color: var(--border-brand);
}

.fb-radio:has(input:focus-visible) {
  outline: 2px solid var(--azure);
  outline-offset: 2px;
}

.fb-radio:has(input:checked),
.fb-radio.is-checked {
  background: var(--azure);
  border-color: var(--azure);
  color: #fff;
}

.fb-radio:has(input:checked)::after,
.fb-radio.is-checked::after {
  content: '\2713';
  font-weight: 700;
  margin-left: var(--s-1);
}

.fb-radio input:disabled {
  cursor: not-allowed;
}

/* Priority: color-escalation chips. Color is secondary — the label + check
   glyph always carry the meaning (WCAG 1.4.1). `.is-checked` is a JS-applied
   fallback for browsers without :has() support. */
.fb-pri .fb-radio.pri-low:has(input:checked),
.fb-pri .fb-radio.pri-low.is-checked {
  background: var(--pri-low);
  border-color: var(--pri-low);
}
.fb-pri .fb-radio.pri-medium:has(input:checked),
.fb-pri .fb-radio.pri-medium.is-checked {
  background: var(--pri-medium);
  border-color: var(--pri-medium);
}
.fb-pri .fb-radio.pri-high:has(input:checked),
.fb-pri .fb-radio.pri-high.is-checked {
  background: var(--pri-high);
  border-color: var(--pri-high);
  color: var(--text-strong);
}
.fb-pri .fb-radio.pri-critical:has(input:checked),
.fb-pri .fb-radio.pri-critical.is-checked {
  background: var(--pri-critical);
  border-color: var(--error-deep);
  color: #fff;
}

/* Category: an actual radio LIST (dot + label), not filled button-cards.
   No card background — rows are transparent and sit directly on the form,
   separated by hairline dividers. Extra gap below the legend. */
.fb-radios--list {
  flex-direction: column;
  gap: 0;
  width: 100%;
  margin-top: var(--s-2);
  border: none;
  border-top: 1px solid var(--hairline);
  border-radius: 0;
  overflow: visible;
}
.fb-radios--list .fb-radio {
  display: flex;
  width: 100%;
  gap: var(--s-3);
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  color: var(--text-body);
  font-weight: 500;
  padding: var(--s-3) var(--s-1);
}
/* custom radio dot (outline → azure filled dot when checked) */
.fb-radios--list .fb-radio::before {
  content: '';
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  background: transparent;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.fb-radios--list .fb-radio:hover {
  background: transparent;
  border-color: transparent;
  border-bottom-color: var(--hairline);
  color: var(--text-heading);
}
.fb-radios--list .fb-radio:hover::before {
  border-color: var(--border-brand);
}
.fb-radios--list .fb-radio:has(input:checked),
.fb-radios--list .fb-radio.is-checked {
  background: transparent;
  color: var(--text-heading);
  font-weight: 600;
}
.fb-radios--list .fb-radio:has(input:checked)::before,
.fb-radios--list .fb-radio.is-checked::before {
  border-color: var(--azure);
  box-shadow: inset 0 0 0 4px var(--azure);
}
/* suppress the button-card checkmark glyph for the list style */
.fb-radios--list .fb-radio::after {
  content: none !important;
}

/* Priority: slim, equal-width segmented chips — thin height, more space below
   the legend, filling the row (wider) instead of tall padded buttons. */
.fb-pri {
  margin-top: var(--s-3);
}
.fb-pri .fb-radio {
  flex: 1 1 0;
  justify-content: center;
  min-height: 0;
  padding: 5px var(--s-2);
  text-align: center;
}
.fb-pri .fb-radio:has(input:checked)::after,
.fb-pri .fb-radio.is-checked::after {
  content: none !important;
}

/* ---------------------------------------------------------------------- */
/* 8. Dropzone + file list                                                */
/* ---------------------------------------------------------------------- */

.fb-dropzone {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  text-align: center;
  padding: var(--s-6) var(--s-4);
  border: 1.5px dashed var(--hairline-strong);
  border-radius: var(--r-card);
  background: var(--surface-alt);
  color: var(--text-body);
  cursor: pointer;
  font-size: 0.94rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.fb-dropzone:hover,
.fb-dropzone.is-dragover {
  border-color: var(--azure);
  background: var(--tint-azure);
  color: var(--text-strong);
}

.fb-dropzone:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.fb-dropzone-icon {
  width: 28px;
  height: 28px;
  color: var(--azure);
}

.fb-dropzone-text u {
  color: var(--azure);
  text-decoration-color: var(--border-brand);
}

.fb-hint {
  display: block;
  color: var(--text-faint);
  font-size: 0.78rem;
  max-width: 46ch;
}


.fb-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

.fb-file {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-areas:
    'thumb meta actions'
    'thumb progress actions'
    'thumb status actions';
  column-gap: var(--s-3);
  row-gap: 2px;
  align-items: center;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-field);
  background: var(--surface-alt);
}

.fb-file--error {
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--error-tint);
}

.fb-file--done {
  border-color: rgba(16, 185, 129, 0.4);
}

.fb-file-thumb {
  grid-area: thumb;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

.fb-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fb-file-thumb svg {
  width: 20px;
  height: 20px;
}

.fb-file-meta {
  grid-area: meta;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  min-width: 0;
}

.fb-file-name {
  font-size: 0.88rem;
  color: var(--text-strong);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fb-file-size {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}

/* Native <progress> (value set via JS as an IDL property, never via
   `style` — keeps the strict style-src CSP honest, and gets an implicit
   role="progressbar" with auto-derived aria-valuenow/min/max for free). */
progress.fb-progress {
  grid-area: progress;
  display: block;
  width: 100%;
  height: 5px;
  border: none;
  border-radius: var(--r-pill);
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--hairline);
  accent-color: var(--azure);
}

progress.fb-progress::-webkit-progress-bar {
  background: var(--hairline);
  border-radius: var(--r-pill);
}

progress.fb-progress::-webkit-progress-value {
  background: var(--azure);
  border-radius: var(--r-pill);
  transition: width var(--transition-med);
}

progress.fb-progress::-moz-progress-bar {
  background: var(--azure);
  border-radius: var(--r-pill);
  transition: width var(--transition-med);
}

.fb-file--queued .fb-progress,
.fb-file--error .fb-progress {
  visibility: hidden;
}

.fb-file--done .fb-progress {
  accent-color: var(--success);
}

.fb-file--done .fb-progress::-webkit-progress-value {
  background: var(--success);
}

.fb-file--done .fb-progress::-moz-progress-bar {
  background: var(--success);
}

.fb-file-status {
  grid-area: status;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.fb-file--error .fb-file-status {
  color: var(--error-deep);
  font-weight: 500;
}

.fb-file--done .fb-file-status {
  color: var(--success);
}

.fb-file-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.fb-file-retry {
  border: 1px solid var(--border-brand);
  background: var(--surface);
  color: var(--azure);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 4px var(--s-2);
  border-radius: var(--r-field);
  cursor: pointer;
}

.fb-file-retry:hover {
  background: var(--tint-azure);
}

.fb-file-remove {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
}

.fb-file-remove svg {
  width: 14px;
  height: 14px;
}

.fb-file-remove:hover {
  color: var(--error-deep);
  border-color: var(--error);
}

/* ---------------------------------------------------------------------- */
/* 9. Turnstile slot                                                      */
/* ---------------------------------------------------------------------- */

#turnstile-widget {
  min-height: 65px;
}

/* ---------------------------------------------------------------------- */
/* 10. Actions / buttons                                                  */
/* ---------------------------------------------------------------------- */

.fb-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  padding-top: var(--s-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border-radius: var(--r-field);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-primary {
  background: var(--azure);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 126, 199, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--azure-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--azure-strong);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-body);
  border-color: var(--hairline-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-brand);
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: fb-spin 0.7s linear infinite;
}

#submit-btn[aria-busy='true'] .btn-spinner {
  display: inline-block;
}

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

/* ---------------------------------------------------------------------- */
/* 11. Success panel                                                      */
/* ---------------------------------------------------------------------- */

.fb-success {
  text-align: center;
  align-items: center;
  gap: var(--s-3);
}

.fb-success-icon {
  width: 52px;
  height: 52px;
  color: var(--success);
}

.fb-success h2 {
  font-size: 1.4rem;
}

.fb-refcode-row {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  border-radius: var(--r-field);
  padding: var(--s-2) var(--s-3);
  margin: var(--s-2) 0;
}

.fb-refcode {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.02em;
}

.fb-copy-btn {
  border: 1px solid var(--border-brand);
  background: var(--surface);
  color: var(--azure);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 4px var(--s-3);
  border-radius: var(--r-field);
  cursor: pointer;
}

.fb-copy-btn:hover {
  background: var(--tint-azure);
}

.fb-copy-confirm {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}

.fb-success-note {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 46ch;
}

/* ---------------------------------------------------------------------- */
/* 12. Responsive                                                         */
/* ---------------------------------------------------------------------- */

@media (max-width: 640px) {
  .fb-page {
    padding: var(--s-5) var(--s-3) calc(var(--s-8) + 64px);
  }

  .fb-card {
    padding: var(--s-5);
    border-radius: var(--r-card);
  }

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

  .fb-radio {
    justify-content: flex-start;
  }

  .fb-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--hairline);
    padding: var(--s-3) var(--s-4);
    justify-content: stretch;
  }

  .fb-actions .btn {
    flex: 1;
  }

  .fb-files {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 480px) and (max-width: 900px) {
  .fb-files {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (min-width: 768px) {
  .fb-head {
    padding-top: var(--s-5);
  }
}
