/* ==========================================================================
   Design Tokens & Global Base Styles
   ========================================================================== */

:root {
  /* Brand colours */
  --rfa-main-blue: #2c2f88;
  --rfa-green:     #76b82a;
  --rfa-blue:      #00a7e2;
  --rfa-purple:    #5d317f;
  --rfa-white:     #ffffff;

  /* Neutrals */
  --colour-bg:          #f4f5f9;
  --colour-surface:     #ffffff;
  --colour-border:      #d8d9e6;
  --colour-text:        #1a1a2e;
  --colour-text-muted:  #5a5a72;
  --colour-error:       #c0392b;
  --colour-error-bg:    #fdecea;
  --colour-success-bg:  #f0f8e6;
  --colour-warning:     #b25c00;
  --colour-warning-bg:  #fff4e0;
  --colour-warning-border: #f0c277;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;   /* 4px  */
  --space-2: 0.5rem;    /* 8px  */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Typography */
  --font-family: "Century Gothic", Arial, sans-serif;
  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-base: 1rem;
  --font-size-lg:   1.125rem;
  --font-size-xl:   1.5rem;
  --font-size-2xl:  2rem;

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(44, 47, 136, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(44, 47, 136, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 28px rgba(44, 47, 136, 0.10), 0 4px 8px rgba(0, 0, 0, 0.06);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

/* Enforce the HTML hidden attribute regardless of CSS display rules */
[hidden] {
  display: none !important;
}

/* ==========================================================================
   Base
   ========================================================================== */

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--colour-text);
  background-color: var(--colour-bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--rfa-main-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  /* Horizontal padding is intentionally tighter than the main-content cap
     so the title and nav icons sit close to the viewport edges and read as
     the outermost chrome on the page. */
  padding: var(--space-4) var(--space-4);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.20);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  /* Slightly wider than the widest screen (Collections at 1440px) so the
     header bar visually frames the content rather than tucking inside it. */
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--rfa-white);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  margin-left: calc(-1 * var(--space-2));
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

/* RFA brand mark sits to the left of the page title. Height is the single
   knob — width auto-scales from the SVG's aspect ratio so the logo grows
   responsively if the header height ever changes. */
.site-logo {
  height: 2.5rem;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.site-title-text {
  line-height: 1.2;
}

.site-title:hover {
  color: var(--rfa-white);
  background-color: rgba(255, 255, 255, 0.10);
  text-decoration: none;
}

.site-title:focus-visible {
  outline: 2px solid var(--rfa-blue);
  outline-offset: 3px;
}

.site-nav {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.nav-link {
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover {
  color: var(--rfa-white);
  background-color: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.nav-link:focus-visible {
  outline: 2px solid var(--rfa-blue);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.nav-link--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.85);
}

.nav-link--icon:hover {
  color: var(--rfa-white);
}

.nav-link--icon svg {
  display: block;
}

.nav-link--external {
  margin-left: var(--space-2);
  border: 1px solid rgba(255, 255, 255, 0.42);
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--rfa-white);
  text-transform: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-link--external:hover {
  background-color: #000;
  border-color: #fff;
  color: #fff;
}

.nav-link--external:focus-visible {
  border-color: var(--rfa-blue);
}

/* ==========================================================================
   Main content area
   ========================================================================== */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* ==========================================================================
   Utility
   ========================================================================== */

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

/* ==========================================================================
   Screens — shared
   ========================================================================== */

.screen-heading {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--rfa-main-blue);
  margin-bottom: var(--space-8);
  line-height: 1.2;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
  line-height: 1.4;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  box-shadow: 0 2px 6px rgba(44, 47, 136, 0.28);
}

.btn--primary:hover {
  background-color: #23266e;
  box-shadow: 0 4px 12px rgba(44, 47, 136, 0.36);
  text-decoration: none;
  color: var(--rfa-white);
}

.btn--primary:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 3px;
}

.btn--primary:disabled,
.btn--primary[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--secondary {
  background-color: transparent;
  color: var(--rfa-main-blue);
  border: 2px solid var(--rfa-main-blue);
}

.btn--secondary:hover {
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  text-decoration: none;
}

.btn--secondary:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 3px;
}

.btn--success {
  background-color: var(--rfa-green);
  color: var(--rfa-white);
  box-shadow: 0 2px 6px rgba(118, 184, 42, 0.28);
}

.btn--success:hover {
  background-color: #5fa020;
  box-shadow: 0 4px 12px rgba(118, 184, 42, 0.36);
  text-decoration: none;
  color: var(--rfa-white);
}

.btn--success:focus-visible {
  outline: 3px solid var(--rfa-green);
  outline-offset: 3px;
}

.btn--danger {
  background-color: var(--colour-error);
  color: var(--rfa-white);
}

.btn--danger:hover {
  background-color: #96281b;
  text-decoration: none;
  color: var(--rfa-white);
}

.btn--danger:focus-visible {
  outline: 3px solid var(--colour-error);
  outline-offset: 3px;
}

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Confirm dialog — "are you sure?" modal for destructive actions
   ========================================================================== */

.confirm-dialog {
  /* Restore the browser's dialog centring, which the global `* { margin: 0 }`
     reset removes — without this the modal sits in the top-left corner. */
  margin: auto;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  max-width: 420px;
  width: calc(100vw - var(--space-8));
}

.confirm-dialog::backdrop {
  background: rgba(20, 22, 60, 0.55);
}

.confirm-dialog-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--rfa-main-blue);
  margin: 0 0 var(--space-3);
  word-break: break-word;
}

.confirm-dialog-message {
  margin: 0 0 var(--space-5);
  color: var(--colour-text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ==========================================================================
   Form
   ========================================================================== */

.form-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--colour-text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.form-back-link:hover {
  color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.06);
  text-decoration: none;
}

.form-back-link:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

.form-card {
  background: var(--colour-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(44, 47, 136, 0.06);
  padding: var(--space-8);
}

.form-card .screen-heading {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--colour-border);
}

#submit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-field label {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  letter-spacing: 0.02em;
}

.form-field input,
.form-field textarea {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--colour-text);
  background-color: var(--colour-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.14);
}

.form-field input[type="file"] {
  padding: var(--space-2);
  cursor: pointer;
  border-style: dashed;
}

.form-field input[type="file"]:hover {
  border-color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.02);
}

/* Image dropzone — click-to-choose or drag-and-drop, sized to match the
   prompt box's initial height (and intentionally not resizable, so dragging
   the prompt taller never stretches this box). */
.image-dropzone {
  --dropzone-height: 9.75rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--dropzone-height);
  padding: var(--space-3);
  border: 1.5px dashed var(--colour-border);
  border-radius: var(--radius-md);
  background-color: var(--colour-surface);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.image-dropzone:hover,
.image-dropzone:focus-within {
  border-color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.02);
}

.image-dropzone--dragover {
  border-color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.06);
}

.image-dropzone.is-invalid {
  border-color: var(--colour-error);
}

/* Visually hidden, but still focusable/operable as the real file input. */
.image-dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.image-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  height: 100%;
  min-height: 0;
  pointer-events: none;
  color: var(--colour-text-muted);
}

.image-dropzone-preview {
  display: block;
  flex: 1 1 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(var(--dropzone-height) - 2.75rem);
  object-fit: contain;
  border-radius: var(--radius-sm);
  background-color: var(--colour-bg);
  box-shadow: var(--shadow-sm);
}

.image-dropzone-preview[hidden] {
  display: none !important;
}

.image-dropzone-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.image-dropzone-primary {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--colour-text);
}

.image-dropzone-secondary {
  font-size: var(--font-size-xs);
}

.image-dropzone-filename {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--rfa-main-blue);
  word-break: break-all;
}

.image-dropzone-filename:empty {
  display: none;
}

/* Once a file is chosen, swap the prompts for the preview + filename. */
.image-dropzone--has-file .image-dropzone-primary,
.image-dropzone--has-file .image-dropzone-secondary,
.image-dropzone--has-file .image-dropzone-icon {
  display: none;
}

.image-dropzone--has-file {
  padding: var(--space-2);
}

/* Keep the draft prompt box at the same initial height as the dropzone. */
.submission-card--draft #draft-prompt {
  height: 9.75rem;
}

.form-field textarea {
  resize: vertical;
  min-height: 96px;
}

/* Invalid state */
.form-field input.is-invalid,
.form-field textarea.is-invalid {
  border-color: var(--colour-error);
}

.form-field input.is-invalid:focus,
.form-field textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.14);
}

.field-error {
  font-size: var(--font-size-sm);
  color: var(--colour-error);
  min-height: 1.2em;
}

/* Reference images — a thumbnail strip above an always-visible drag-and-drop
   box (click or drop to add more). This same box+strip layout is reused
   read-only on saved cards (see .reference-preview below), just without the
   delete button or the drop/click behaviour. */
.reference-images-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-3);
}

.reference-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.reference-image-grid:empty {
  display: none;
}

.reference-image-tile {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 2px solid var(--colour-border);
  background-color: var(--colour-bg);
  transition: border-color var(--transition-fast);
}

.reference-image-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hovering/focusing a thumbnail (or marking it active) highlights it; the
   larger box elsewhere on the page is what actually shows the image. */
.reference-image-tile:hover,
.reference-image-tile:focus-within,
.reference-image-tile.is-active {
  border-color: var(--rfa-main-blue);
}

.reference-image-delete-btn {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.reference-image-tile:hover .reference-image-delete-btn,
.reference-image-delete-btn:focus-visible {
  opacity: 1;
}

.reference-image-delete-btn:hover {
  background-color: var(--colour-error);
  border-color: var(--colour-error);
  color: var(--rfa-white);
}

.reference-image-delete-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 2px;
}

/* Drag-and-drop box for adding reference images — click or drop. Hovering a
   thumbnail above shows that image here instead of the prompt; the saved-card
   read-only box below (.reference-preview-box) matches this height so a
   submitted card takes up no more space than the form did while editing. */
.reference-dropzone {
  --reference-dropzone-height: 10rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--reference-dropzone-height);
  padding: var(--space-3);
  border: 1.5px dashed var(--colour-border);
  border-radius: var(--radius-md);
  background-color: var(--colour-surface);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.reference-dropzone:hover,
.reference-dropzone:focus-within {
  border-color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.02);
}

.reference-dropzone--dragover {
  border-color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.06);
}

.reference-dropzone-preview {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.reference-dropzone--previewing .image-dropzone-content {
  display: none;
}

.reference-dropzone--previewing .reference-dropzone-preview {
  display: block;
}

/* Read-only reference image display: the same thumbnail strip as above, plus
   a fixed-size box (same height as .reference-dropzone) instead of the
   dropzone, since saved versions can't add more images. */
.reference-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.reference-preview-box {
  height: 10rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  background-color: var(--colour-bg);
  overflow: hidden;
}

.reference-preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}


/* Error banner */
.error-banner {
  background-color: var(--colour-error-bg);
  border: 1px solid var(--colour-error);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: var(--colour-error);
  font-size: var(--font-size-sm);
  grid-column: 1 / -1;
}

.error-banner[hidden] {
  display: none;
}

/* Submit button row */
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-2);
}

#submit-btn {
  min-width: 140px;
}

/* ==========================================================================
   Loading state
   ========================================================================== */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-8);
  color: var(--colour-text-muted);
  font-size: var(--font-size-base);
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--colour-border);
  border-top-color: var(--rfa-main-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-4);
  background: var(--colour-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(44, 47, 136, 0.06);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: rgba(44, 47, 136, 0.06);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--rfa-main-blue);
  line-height: 1.2;
}

.empty-state-message {
  font-size: var(--font-size-base);
  color: var(--colour-text-muted);
  max-width: 380px;
  line-height: 1.6;
}

/* ==========================================================================
   Success screen
   ========================================================================== */

.screen--success {
  max-width: 600px;
  margin: var(--space-4) auto 0;
}

.success-card {
  background: var(--colour-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-12) var(--space-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-6);
  border: 1px solid rgba(44, 47, 136, 0.06);
}

.success-card .screen-heading {
  margin-bottom: 0;
}

.success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--rfa-green);
  color: var(--rfa-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(118, 184, 42, 0.35);
}

.success-message {
  font-size: var(--font-size-lg);
  color: var(--colour-text-muted);
  max-width: 420px;
  line-height: 1.6;
}

.success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

/* ==========================================================================
   Collections screen
   ========================================================================== */

.screen--collections {
  max-width: 100%;
}

/* Collections benefits from a wider canvas so the Latest Date column lands
   inside the viewport on standard 1440-class displays without horizontal
   scrolling. Scoped via :has() so the form-heavy screens (Submit, Settings,
   Detail) stay at the calmer 1200px cap defined on `.main-content` above. */
.main-content:has(.screen--collections) {
  max-width: 1440px;
}

/* Hero banner */
.collections-hero {
  background: linear-gradient(135deg, var(--rfa-main-blue) 0%, #1e226b 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  color: var(--rfa-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  box-shadow: var(--shadow-lg);
}

.collections-hero-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.2;
}

.collections-hero-subtitle {
  font-size: var(--font-size-base);
  opacity: 0.8;
  margin-top: var(--space-2);
  font-weight: 400;
}

/* Status / error message */
.collections-status {
  padding: var(--space-4);
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.collections-status.status--error {
  color: var(--colour-error);
  background: var(--colour-error-bg);
  border: 1px solid var(--colour-error);
}

/* Table card */
.table-card {
  background: var(--colour-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(44, 47, 136, 0.06);
  overflow: hidden;
  width: 100%;
}

/* Table wrapper enables horizontal scroll on small viewports */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.collections-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
  background-color: var(--colour-surface);
}

.collections-table thead {
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
}

.collections-table th {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.collections-table td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--colour-border);
  vertical-align: middle;
  white-space: nowrap;
  color: var(--colour-text);
}

.collections-table td:first-child {
  font-weight: 700;
}

.collection-row {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.collection-row:hover {
  background-color: rgba(44, 47, 136, 0.04);
}

.collection-row:hover td:first-child {
  color: var(--rfa-main-blue);
}

/* Admin-only delete column: hug the button so it doesn't widen the table. */
.collection-row-actions-header,
.collection-row-actions {
  width: 1%;
  white-space: nowrap;
}

/* Reveal the delete button on row hover/focus (mirrors the settings rows).
   Scoped to (hover: hover) so touch devices keep the button visible. */
@media (hover: hover) {
  .collection-row .row-delete-btn {
    opacity: 0;
  }

  .collection-row:hover .row-delete-btn,
  .collection-row:focus-within .row-delete-btn,
  .row-delete-btn:focus-visible {
    opacity: 1;
  }
}

.collection-row:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: -2px;
}

.collections-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Detail screen
   ========================================================================== */

.screen--detail {
  max-width: 100%;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--colour-text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.back-link:hover {
  color: var(--rfa-main-blue);
  background-color: rgba(44, 47, 136, 0.06);
  text-decoration: none;
}

.back-link:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

.detail-card {
  background: var(--colour-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(44, 47, 136, 0.06);
  padding: var(--space-8);
}

/* Detail layout: a single full-width column. Children (collection-header,
   submissions-stack) stretch to the card's full content width — the old
   2-column grid was a leftover from the per-submission detail and forced
   blocks into the left half of the card. */
.detail-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Heading row: page title on the left, Add Prompt button on the right. */
.detail-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--colour-border);
}

/* Reset the heading's standalone bottom margin/border since the row owns them. */
.detail-heading-row .screen-heading {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Action cluster on the right of the heading row (e.g. Download + Add). */
.detail-heading-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Box style for multiline prose blocks (e.g. submission prompts). */
.detail-multiline {
  white-space: pre-wrap;
  font-size: var(--font-size-sm);
  background: rgba(44, 47, 136, 0.03);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--colour-border);
  line-height: 1.65;
}

/* Copy-to-clipboard button on prompt field */
.detail-prompt {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.detail-prompt:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover,
.copy-btn--copied:hover {
  background-color: var(--rfa-main-blue);
  border-color: var(--rfa-main-blue);
  color: var(--rfa-white);
}

.copy-btn--copied,
.copy-btn--copied:hover {
  opacity: 1;
  background-color: var(--rfa-green);
  border-color: var(--rfa-green);
  color: var(--rfa-white);
}
.copy-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 2px;
}

.detail-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  object-fit: contain;
  border: 1px solid var(--colour-border);
  box-shadow: var(--shadow-sm);
}

/* Detail status */
#detail-status.status--error {
  color: var(--colour-error);
  padding: var(--space-4) 0;
}


/* ==========================================================================
   Responsive — global breakpoints
   ========================================================================== */

/* Tablet and below */
@media (max-width: 768px) {
  .main-content {
    padding: var(--space-6) var(--space-4);
  }

  .screen-heading {
    font-size: var(--font-size-xl);
  }

  .collections-hero {
    padding: var(--space-6);
  }

  .collections-hero-title {
    font-size: var(--font-size-xl);
  }

  .form-card {
    padding: var(--space-6);
  }

  .success-card {
    padding: var(--space-8) var(--space-6);
  }

  .detail-card {
    padding: var(--space-6);
  }
}

/* Mobile */
@media (max-width: 480px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .nav-link--external {
    margin-left: 0;
  }

  .site-logo {
    height: 2rem;
  }

  .main-content {
    padding: var(--space-4) var(--space-3);
  }

  .collections-hero {
    padding: var(--space-6) var(--space-4);
    flex-direction: column;
    align-items: flex-start;
  }

  .collections-hero .btn {
    width: 100%;
    justify-content: center;
  }

  #submit-form {
    grid-template-columns: 1fr;
  }

  .success-actions {
    flex-direction: column;
    width: 100%;
  }

  .success-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .success-card {
    padding: var(--space-8) var(--space-4);
  }
}

/* Ensure h1 focus outline is tasteful (set by JS focus management) */
h1[tabindex="-1"]:focus {
  outline: none;
}


/* ==========================================================================
   Combobox (typable filtering dropdown on the submit form)
   ========================================================================== */

.combobox {
  position: relative;
}

/* The visible text input inherits all base .form-field input styling. These
   rules layer on the chevron + extra right padding so it reads as a dropdown
   the same way the old <select> did. */
.combobox-input {
  cursor: text;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a5a72' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: calc(var(--space-4) * 2 + 14px);
}

/* Square off the bottom corners so the input visually fuses with the open
   listbox underneath. */
.combobox-input[aria-expanded="true"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.combobox-listbox {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  /* No top padding: the sticky "+ Add new…" anchors to top:0 of the padding
     edge, so any padding above it would let scrolling rows peek through. */
  padding: 0 0 var(--space-1);
  list-style: none;
  background-color: var(--colour-surface);
  border: 1.5px solid var(--rfa-main-blue);
  border-top: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.combobox-option {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-base);
  color: var(--colour-text);
  cursor: pointer;
  /* Long labels wrap onto a second line rather than being clipped. */
  word-break: break-word;
}

.combobox-option--active,
.combobox-option:hover {
  background-color: rgba(44, 47, 136, 0.08);
}

/* Pinned "+ Add new…" entry sits at the top of the list and stays visible
   when the list scrolls — always one keystroke / click away. */
.combobox-option--add-new {
  color: var(--rfa-green);
  font-weight: 700;
  border-bottom: 1px solid var(--colour-border);
  position: sticky;
  top: 0;
  background-color: var(--colour-surface);
}

/* Use an opaque green tint (not an rgba over white) so when the row is
   sticky-pinned and matches scroll beneath, those rows can't bleed through
   the hover/active background. */
.combobox-option--add-new.combobox-option--active,
.combobox-option--add-new:hover {
  background-color: var(--colour-success-bg);
}

.combobox-empty {
  padding: var(--space-3) var(--space-4);
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
  text-align: center;
}

/* ==========================================================================
   Settings screen
   ========================================================================== */

.screen--settings {
  max-width: 100%;
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.settings-intro {
  color: var(--colour-text-muted);
  font-size: var(--font-size-base);
  margin-top: calc(-1 * var(--space-4));
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--colour-border);
  /* Account for the sticky site header so smooth-scrolls land below it. */
  scroll-margin-top: 80px;
}

.settings-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--rfa-main-blue);
  line-height: 1.2;
}

.settings-section-helper {
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
  margin-top: calc(-1 * var(--space-2));
}

.lookup-add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: stretch;
}

.lookup-add-form--paired {
  grid-template-columns: 1fr 1fr auto;
}

.lookup-add-form input {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--colour-text);
  background-color: var(--colour-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

.lookup-add-form input:focus {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.14);
}

.lookup-add-form .btn {
  padding: var(--space-3) var(--space-5);
}

.lookup-section-error {
  margin: 0;
  min-height: 1.2em;
}

.lookup-section-error:empty {
  min-height: 0;
}

/* Search input that filters the list below it. */
.lookup-search {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  background-color: var(--colour-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lookup-search:focus {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.14);
}

/* Scroll-bounded wrapper so a hundreds-of-rows list never pushes the page. */
.lookup-list-wrap {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  background-color: var(--colour-surface);
}

.lookup-list {
  display: flex;
  flex-direction: column;
}

.lookup-row--hidden {
  display: none !important;
}

.lookup-loading,
.lookup-empty {
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
  padding: var(--space-4) var(--space-3);
  text-align: center;
}

.lookup-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--colour-border);
  background-color: var(--colour-surface);
  transition: background-color var(--transition-fast);
  font-size: var(--font-size-sm);
}

.lookup-row:last-child {
  border-bottom: none;
}

.lookup-row:hover {
  background-color: rgba(44, 47, 136, 0.04);
}

.lookup-row--editing {
  background-color: rgba(44, 47, 136, 0.06);
  flex-wrap: wrap;
  /* Highlight the row being edited even though we no longer have a per-row
     border to colour. */
  box-shadow: inset 3px 0 0 var(--rfa-main-blue);
}

.lookup-row-values {
  display: flex;
  flex: 1 1 auto;
  gap: var(--space-4);
  align-items: center;
  min-width: 0;
}

.lookup-row-value {
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  word-break: break-word;
}

.lookup-row-value--name {
  font-weight: 700;
  flex: 1 1 auto;
}

.lookup-row-value--number {
  color: var(--colour-text-muted);
  font-family: monospace;
  font-size: var(--font-size-sm);
  flex: 0 0 auto;
}

.lookup-row-input {
  flex: 1 1 0;
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  background-color: var(--colour-surface);
}

.lookup-row-input:focus {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.14);
}

.lookup-row-actions {
  display: flex;
  gap: var(--space-1);
  flex: 0 0 auto;
}

/* Hover-reveal action buttons — mirrors the prompt copy button on the detail
   page. Scoped to (hover: hover) so touch devices (where hover is sticky)
   keep the buttons visible at all times. Edit-mode rows always show their
   Save/Cancel actions regardless of hover state. */
@media (hover: hover) {
  .lookup-row .lookup-action-btn {
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast),
                background-color var(--transition-fast), border-color var(--transition-fast);
  }

  .lookup-row:hover .lookup-action-btn,
  .lookup-row:focus-within .lookup-action-btn,
  .lookup-action-btn:focus-visible,
  .lookup-row--editing .lookup-action-btn {
    opacity: 1;
  }
}

.lookup-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.lookup-action-btn:hover {
  background-color: var(--rfa-main-blue);
  border-color: var(--rfa-main-blue);
  color: var(--rfa-white);
}

.lookup-action-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 2px;
}

.lookup-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lookup-action-btn--danger:hover {
  background-color: var(--colour-error);
  border-color: var(--colour-error);
  color: var(--rfa-white);
}

.lookup-action-btn--primary {
  background-color: var(--rfa-green);
  border-color: var(--rfa-green);
  color: var(--rfa-white);
}

.lookup-action-btn--primary:hover {
  background-color: #5fa020;
  border-color: #5fa020;
  color: var(--rfa-white);
}

.lookup-row-error {
  flex: 1 1 100%;
  font-size: var(--font-size-sm);
  color: var(--colour-error);
  min-height: 1.2em;
}

.lookup-row-error:empty {
  display: none;
}

@media (max-width: 600px) {
  .lookup-add-form,
  .lookup-add-form--paired {
    grid-template-columns: 1fr;
  }

  .lookup-add-form .btn {
    justify-content: center;
  }

  .lookup-row {
    flex-wrap: wrap;
  }

  .lookup-row-values {
    flex: 1 1 100%;
  }
}

/* ==========================================================================
   Detail image — hover-reveal download button
   ========================================================================== */

.detail-image-wrap {
  position: relative;
}

.image-download-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}

.detail-image-wrap:hover .image-download-btn,
.image-download-btn:focus-visible {
  opacity: 1;
}

.image-download-btn:hover {
  background-color: var(--rfa-main-blue);
  border-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  text-decoration: none;
}

/* Brief post-click confirmation flash — mirrors the prompt copy button. */
.image-download-btn--downloaded,
.image-download-btn--downloaded:hover {
  opacity: 1;
  background-color: var(--rfa-green);
  border-color: var(--rfa-green);
  color: var(--rfa-white);
}

.image-download-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 2px;
}

/* ==========================================================================
   Submit form — extras
   ========================================================================== */

/* Soft amber advisory shown when the chosen filename doesn't start with
   "ai-". Distinct from the red `.field-error` because it's non-blocking. */
.field-warning {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--colour-warning);
  background-color: var(--colour-warning-bg);
  border: 1px solid var(--colour-warning-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  line-height: 1.5;
}

.field-warning[hidden] {
  display: none !important;
}

.form-field-hint {
  color: var(--colour-text-muted);
  font-weight: 400;
  font-size: var(--font-size-xs);
  margin-left: var(--space-2);
}

.form-field-helper {
  font-size: var(--font-size-xs);
  color: var(--colour-text-muted);
  line-height: 1.5;
}

.form-field-helper code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background-color: rgba(44, 47, 136, 0.06);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

/* ==========================================================================
   Collections — toolbar / search box
   ========================================================================== */

.collections-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--colour-border);
  background-color: var(--colour-surface);
}

/* Date / period filter: a small label, a segmented pill group of preset
   ranges, and a Clear button that only appears when a period is active. */
.collections-period-filter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--colour-text-muted);
  flex-wrap: wrap;
}

.collections-period-label {
  font-weight: 600;
  white-space: nowrap;
}

.period-group {
  display: inline-flex;
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--colour-surface);
}

.period-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--colour-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  /* Faux vertical dividers between buttons — kept on the left so the first
     button stays clean. */
  border-left: 1px solid var(--colour-border);
}

.period-btn:first-child {
  border-left: none;
}

.period-btn:hover {
  background-color: rgba(44, 47, 136, 0.06);
}

.period-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--rfa-main-blue);
}

.period-btn--active,
.period-btn--active:hover {
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
}

.period-clear {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--colour-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.period-clear:hover,
.period-clear:focus-visible {
  background-color: var(--rfa-main-blue);
  border-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  outline: none;
}

.collections-search {
  width: 100%;
  max-width: 420px;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  background-color: var(--colour-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.collections-search:focus {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.14);
}

.collection-row--hidden {
  display: none !important;
}

#collections-no-results {
  padding: var(--space-6);
}

/* ==========================================================================
   Collection detail — header (meta strip) + submission stack
   ========================================================================== */

.collection-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background-color: rgba(44, 47, 136, 0.03);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

/* Sticky, collapsing detail header (Job + Asset screens). It pins just under
   the site header and shrinks once the user scrolls past it, so the asset/job
   context stays visible while reviewing the stack below. `top` is set inline
   in JS to the live site-header height. The `is-collapsed` class is toggled by
   an IntersectionObserver watching a sentinel placed above the header. */
.screen--detail .collection-header {
  position: sticky;
  z-index: 20;
  transition: padding var(--transition-base), gap var(--transition-base),
    background-color var(--transition-base), box-shadow var(--transition-base),
    border-color var(--transition-base);
}

.screen--detail .collection-header .collection-meta {
  transition: gap var(--transition-base);
}

.screen--detail .collection-header .asset-name-text,
.screen--detail .collection-header .collection-meta dd,
.screen--detail .collection-header .collection-meta dt {
  transition: font-size var(--transition-base);
}

.screen--detail .collection-header.is-collapsed {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  gap: var(--space-2);
  background-color: var(--colour-success-bg);
  box-shadow: var(--shadow-md);
}

.screen--detail .collection-header.is-collapsed .collection-meta {
  gap: var(--space-1) var(--space-6);
}

.screen--detail .collection-header.is-collapsed .meta-item--name {
  flex-basis: auto;
}

.screen--detail .collection-header.is-collapsed .collection-meta dt {
  font-size: 10px;
}

.screen--detail .collection-header.is-collapsed .collection-meta dd,
.screen--detail .collection-header.is-collapsed .asset-name-text {
  font-size: var(--font-size-sm);
}

/* The sentinel is a zero-height marker just above the sticky header; it never
   shows but lets the observer detect when the header becomes pinned. The
   negative bottom margin cancels the parent flex `gap` so the sentinel doesn't
   push the header down. */
.header-collapse-sentinel {
  height: 0;
  margin: 0 0 calc(var(--space-6) * -1);
}

@media (prefers-reduced-motion: reduce) {
  .screen--detail .collection-header,
  .screen--detail .collection-header .collection-meta,
  .screen--detail .collection-header .asset-name-text,
  .screen--detail .collection-header .collection-meta dd,
  .screen--detail .collection-header .collection-meta dt {
    transition: none;
  }
}

.collection-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-8);
  margin: 0;
}

.collection-meta .meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.collection-meta dt {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--colour-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.collection-meta dd {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--colour-text);
  margin: 0;
}

/* Per-submission sub-meta row (User / Tool chips) rendered just under the
   filename header so each card stays self-describing without crowding the
   prompt/image area. */
.submission-card-submeta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.submeta-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background-color: rgba(44, 47, 136, 0.06);
  font-size: var(--font-size-xs);
  color: var(--colour-text);
}

.submeta-chip-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--colour-text-muted);
}

.submeta-chip-value {
  font-weight: 700;
}

.submission-card-notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background-color: rgba(44, 47, 136, 0.03);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
}

.submission-card-notes-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--colour-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.submission-card-notes-text {
  font-size: var(--font-size-sm);
  color: var(--colour-text);
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 0;
}

/* Three-up meta inputs above the prompt/image grid in the add-prompt form. */
.submission-card-meta-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-4);
}

@media (max-width: 767px) {
  .submission-card-meta-form {
    grid-template-columns: 1fr;
  }
}

.submissions-stack {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Tiny right-aligned strip above the submission stack — currently just
   the "Download prompt history" action. Lives inside `.detail-layout`
   between the collection-header and the stack itself. */
.stack-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-2);
}

.stack-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.stack-toolbar-btn-icon {
  display: inline-flex;
  line-height: 0;
}

.stack-toolbar-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.submission-card {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.submission-card--draft {
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.10);
  background-color: rgba(44, 47, 136, 0.02);
}

.submission-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--colour-border);
}

.submission-card-filename {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--rfa-main-blue);
  word-break: break-all;
  line-height: 1.3;
}

.filename-version {
  color: var(--rfa-green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding-left: 2px;
}

.submission-card-date {
  font-size: var(--font-size-xs);
  color: var(--colour-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.submission-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  align-items: start;
}

.submission-context-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.submission-reference-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.submission-prompt-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.submission-prompt {
  /* Reuses .detail-multiline + .detail-prompt for background and copy-btn
     positioning; only the layout properties are unique here. */
  margin: 0;
  min-height: 160px;
}

.submission-content-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--colour-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.submission-prompt-text {
  display: block;
  white-space: pre-wrap;
}

.submission-image-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
}

.submission-generated-image-wrap {
  width: 100%;
}

.submission-image {
  width: 100%;
  height: auto;
  max-height: 480px;
  border-radius: var(--radius-md);
  object-fit: contain;
  border: 1px solid var(--colour-border);
  box-shadow: var(--shadow-sm);
  background-color: var(--colour-bg);
}

.submission-card-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Settings — admin-only badge */
.settings-admin-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background-color: var(--rfa-purple);
  color: var(--rfa-white);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Mobile: stack the submission card body */
@media (max-width: 767px) {
  .submission-card-body {
    grid-template-columns: 1fr;
  }
  .submission-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .collection-meta {
    gap: var(--space-3) var(--space-5);
  }
}

/* ==========================================================================
   New Job form (home screen)
   ========================================================================== */

.new-job-form {
  margin-bottom: var(--space-6);
}

/* ==========================================================================
   Asset grid (Job screen) — one card per Asset
   ========================================================================== */

.assets-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.assets-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
  /* Keep siblings compact when one card grows to reveal its archive button. */
  align-items: start;
}

.asset-card--hidden {
  display: none !important;
}

.asset-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.asset-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Admin-only delete button overlaid on the card thumbnail, hover-revealed.
   The card is the positioning context; the button sits outside the link so
   clicking it can't navigate. Touch devices keep it visible. */
.asset-card-delete-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  background: var(--colour-surface);
}

@media (hover: hover) {
  .asset-card .asset-card-delete-btn {
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast),
                background-color var(--transition-fast), border-color var(--transition-fast);
  }

  .asset-card:hover .asset-card-delete-btn,
  .asset-card:focus-within .asset-card-delete-btn,
  .asset-card-delete-btn:focus-visible {
    opacity: 1;
  }
}

/* The link wraps only the thumbnail; the meta block (editable name, badge,
   archive button) sits below it as a sibling so its controls aren't links. */
.asset-card-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.asset-card-link:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: -3px;
}

.asset-card-thumb {
  aspect-ratio: 4 / 3;
  background-color: var(--colour-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.asset-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-card-thumb-empty {
  font-size: var(--font-size-sm);
  color: var(--colour-text-muted);
}

.asset-card-meta {
  padding: var(--space-3) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.asset-card-filename {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--rfa-main-blue);
  word-break: break-all;
  line-height: 1.3;
}

.asset-card-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.asset-card-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background-color: var(--colour-success-bg);
  color: var(--rfa-green);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.asset-card-date {
  font-size: var(--font-size-xs);
  color: var(--colour-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* Inline-editable name on asset cards. Reuses the filename-edit widget from
   the asset header; the view-mode name doubles as a link into the asset. */
.asset-card-filename .filename-edit-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
}

.asset-card-filename .asset-name-text {
  word-break: break-all;
  line-height: 1.3;
}

.asset-name-text--link {
  text-decoration: none;
}

.asset-name-text--link:hover {
  text-decoration: underline;
}

.asset-card-filename .filename-edit-input {
  min-width: 0;
  flex: 1;
}

/* Slightly smaller pencil so it optically matches the name's line box. */
.asset-card-filename .filename-edit-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}

/* The lucide-style pencil path sits high in its 24×24 viewBox; a 2px nudge
   centres the glyph with the name text. */
.asset-card-filename .filename-edit-btn svg {
  width: 13px;
  height: 13px;
  transform: translateY(2px);
}

/* Archive sits in the document flow (bottom-right of the meta stack) so the
   card can grow to make room for it on hover — no overlay on the date. */
.asset-card-archive-btn {
  align-self: flex-end;
  padding: 3px var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-full);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition-fast), max-height var(--transition-fast),
              margin-top var(--transition-fast), background var(--transition-fast),
              color var(--transition-fast), border-color var(--transition-fast);
}

.asset-card-archive-btn:hover {
  background: var(--rfa-main-blue);
  color: var(--rfa-white);
  border-color: var(--rfa-main-blue);
}

.asset-card-archive-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 1px;
}

.asset-card-archive-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Hover-reveal: collapse the archive row at rest so cards stay compact, then
   expand it (and fade in the edit pencil) on hover. Touch devices keep both
   visible since hover is sticky/unavailable. */
@media (hover: hover) {
  .asset-card .filename-edit-btn {
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast),
                color var(--transition-fast), border-color var(--transition-fast);
  }

  .asset-card .asset-card-archive-btn {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    /* Negate the parent flex gap so a collapsed button doesn't leave a hole. */
    margin-top: calc(-1 * var(--space-2));
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    pointer-events: none;
  }

  .asset-card:hover .filename-edit-btn,
  .asset-card:focus-within .filename-edit-btn,
  .asset-card .filename-edit-btn:focus-visible {
    opacity: 1;
  }

  .asset-card:hover .asset-card-archive-btn,
  .asset-card:focus-within .asset-card-archive-btn,
  .asset-card .asset-card-archive-btn:focus-visible {
    max-height: 2rem;
    opacity: 1;
    margin-top: 0;
    padding-top: 3px;
    padding-bottom: 3px;
    border-width: 1px;
    pointer-events: auto;
  }
}

/* Active / Archived segmented toggle at the top of the job screen */
.assets-view-toggle {
  display: inline-flex;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
}

.assets-view-toggle-btn {
  padding: var(--space-1) var(--space-4);
  border: none;
  background: transparent;
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.assets-view-toggle-btn:hover {
  color: var(--rfa-main-blue);
}

.assets-view-toggle-btn[aria-pressed="true"] {
  background: var(--rfa-main-blue);
  color: var(--rfa-white);
}

.assets-view-toggle-btn:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: -3px;
}

/* ==========================================================================
   Version badge + card title (Asset screen)
   ========================================================================== */

.submission-card-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.version-badge {
  display: inline-block;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background-color: var(--rfa-main-blue);
  color: var(--rfa-white);
  font-size: var(--font-size-xs);
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Inline editable asset name (asset header) — shared by every version */
.filename-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.asset-name-text {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--rfa-main-blue);
  word-break: break-word;
}

/* Let the editable name sit on its own full-width line above the other meta */
.meta-item--name {
  flex-basis: 100%;
}

.filename-edit-btn,
.filename-edit-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  background: var(--colour-surface);
  color: var(--colour-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.filename-edit-btn:hover,
.filename-edit-action:hover {
  background: var(--colour-bg);
  color: var(--rfa-main-blue);
  border-color: var(--rfa-main-blue);
}

.filename-edit-btn:focus-visible,
.filename-edit-action:focus-visible {
  outline: 3px solid var(--rfa-blue);
  outline-offset: 1px;
}

.filename-edit-save:hover {
  color: var(--rfa-green);
  border-color: var(--rfa-green);
}

.filename-edit-action[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.filename-edit-input {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--rfa-main-blue);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  min-width: 220px;
  max-width: 100%;
}

.filename-edit-input:focus-visible {
  outline: none;
  border-color: var(--rfa-main-blue);
  box-shadow: 0 0 0 3px rgba(44, 47, 136, 0.12);
}

.filename-edit-error {
  flex-basis: 100%;
  color: var(--colour-error);
  font-size: var(--font-size-xs);
}
