/* ===================================================================
   FILE CONVERTER

   Layout order:
     1  reset and base
     2  page shell and header
     3  dropzone
     4  queue toolbar
     5  file rows
     6  format picker
     7  buttons and controls
     8  modal
     9  toasts
    10  motion
    11  responsive
   =================================================================== */

/* ============================================== 1  reset and base === */

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

/* The `hidden` attribute must always win.

   The browser's own `[hidden] { display: none }` lives in the user-agent
   stylesheet, so ANY author rule that sets `display` beats it. That is what
   broke the help panel in the previous build: `.backdrop { display: flex }`
   silently outranked `hidden`, leaving a dialog that rendered on load and
   could not be dismissed. The same trap catches every `display: inline-flex`
   button and `display: grid` panel that also needs to toggle.

   Declaring it once, here, at author level makes the attribute authoritative
   for the whole page rather than leaving each component to remember. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  /* The page owns its own dark surface even before the body paints, so
     there is no white flash on load and overscroll stays in-theme. */
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* A single wide, very low-contrast glow anchors the top of the page so
     the field is not perfectly flat. It is fixed and behind everything, so
     it never repaints during scroll. Tinted with the accent token (not a
     fixed colour) so it follows the theme -- dark mode's own accent here,
     the light theme's forest green further down. */
  background-image: radial-gradient(
    ellipse 90% 42% at 50% -8%,
    var(--accent-wash),
    transparent 70%
  );
  background-attachment: fixed;
  background-repeat: no-repeat;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

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

svg {
  display: block;
  flex: none;
}

.icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

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

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

/* Focus rings are for keyboard users; a click should not leave one behind. */
:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--accent-edge);
  color: var(--ink);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ======================================== 2  page shell and header === */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-7) var(--page-pad) var(--s-8);
}

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
}

.masthead-text {
  min-width: 0;
}

/* The page title doubles as the way home -- same plain-text-link pattern
   the rest of the site uses for its own brand mark (RPA, RAG, COMPASS all
   do this: no separate "back" affordance, the title itself is the link). */
.title-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}

.title-link:hover,
.title-link:focus-visible {
  color: var(--accent);
}

h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.masthead-actions {
  display: flex;
  gap: var(--s-2);
  flex: none;
}

/* Design pass (feedback.md §20): one shared capsule for the help button and
   the appearance button, instead of two loose buttons with no visual
   relationship. The help button keeps its own .btn-ghost surface inside
   the capsule (removing it read as a background nested in a background,
   checked live); the divider is the one added seam between them. */
.masthead-cluster {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.masthead-cluster-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line-strong);
  flex: none;
}

/* ============================================== 3  dropzone === */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--s-4);
  width: 100%;
  padding: var(--s-7) var(--s-5);
  text-align: center;
  background: var(--surface-1);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--ring-inset);
  cursor: pointer;
  transition: border-color var(--t-mid) var(--ease), background var(--t-mid) var(--ease),
    transform var(--t-mid) var(--ease);
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent-edge);
  background: var(--surface-2);
}

/* Dragover is the one moment the dropzone must be unmistakable, so it
   takes a solid accent border and lifts slightly toward the cursor. */
.dropzone.is-dragover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-wash);
  transform: translateY(-2px);
}

.dropzone.is-dragover .dropzone-glyph {
  color: var(--accent);
  transform: translateY(-3px);
}

.dropzone-glyph {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--ink-soft);
  transition: color var(--t-mid) var(--ease), transform var(--t-mid) var(--ease),
    background var(--t-mid) var(--ease);
}

.dropzone-glyph .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.dropzone-title {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dropzone-sub {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  max-width: 44ch;
}

/* The capability strip states plainly what the tool accepts, so a user
   knows before dropping anything rather than after.
   Design pass (feedback.md §20): previously five bordered, backgrounded
   pill chips, competing for attention with the dropzone itself, the one
   focal point this page's own design intent (tokens.css's own comment)
   says it wants. Quieted to plain inline text with a subtly-dotted
   separator between groups instead, same information, far less visual
   weight, so the eye lands on the dropzone first and reads this
   afterward as supporting detail rather than another competing panel. */
.capability-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  row-gap: var(--s-1);
  margin-top: var(--s-1);
}

.cap {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.15rem 0.7rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
}

.cap:not(:last-child) {
  border-right: 1px dotted var(--line-strong);
}

.cap .icon {
  width: 0.95em;
  height: 0.95em;
  color: var(--ink-ghost);
}

/* Once files are queued the dropzone has made its point, so it collapses to
   a single quiet line and gives the vertical space back to the queue. The
   explanatory copy is only useful before the first drop. */
.dropzone.is-compact {
  grid-auto-flow: column;
  justify-content: center;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
}

.dropzone.is-compact .dropzone-sub,
.dropzone.is-compact .capability-strip,
.dropzone.is-compact .privacy-note {
  display: none;
}

.dropzone.is-compact .dropzone-glyph {
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-md);
}

.dropzone.is-compact .dropzone-glyph .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.dropzone.is-compact .dropzone-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

/* The prompt changes wording once the queue has contents, since "drop files
   here" reads oddly when files are already listed below it. */
.dropzone .when-active,
.dropzone.is-compact .when-idle {
  display: none;
}

.dropzone.is-compact .when-active {
  display: inline;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-top: var(--s-4);
  color: var(--ink-faint);
  font-size: var(--text-sm);
}

.privacy-note .icon {
  width: 1em;
  height: 1em;
  color: var(--ok);
}

/* ========================================= 4  queue toolbar === */

.queue {
  margin-top: var(--s-6);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-3) 0;
  margin-bottom: var(--s-3);
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(8px);
}

.toolbar-summary {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.toolbar-summary b {
  color: var(--ink);
  font-weight: 550;
}

.toolbar-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

/* Design pass (feedback.md §20): overflow menu for the toolbar's secondary
   actions, same shape as .settings-wrap/.settings-menu above (ui/theme.js),
   just left-aligned instead of right-aligned to match where this button
   sits in the toolbar. */
.toolbar-more-wrap {
  position: relative;
}

.toolbar-more-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 30;
  display: grid;
  gap: var(--s-1);
  width: 15rem;
  padding: var(--s-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

.toolbar-more-menu[hidden] {
  display: none;
}

/* The four buttons inside keep their existing .btn classes (untouched, so
   main.js's own hidden-state logic needs no changes) but read as a plain
   vertical menu list here rather than the toolbar's own horizontal
   pill-button style, matching the settings menu's own list treatment. */
.toolbar-more-menu .btn {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
}

.toolbar-more-menu .btn:hover {
  background: var(--surface-3);
}

/* ============================================== 5  file rows === */

.rows {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--ring-inset);
  transition: border-color var(--t-mid) var(--ease), background var(--t-mid) var(--ease);
}

.row:hover {
  border-color: var(--line-strong);
}

.row[data-status='done'] {
  border-color: rgba(82, 196, 122, 0.28);
}

.row[data-status='error'] {
  border-color: rgba(242, 100, 90, 0.32);
}

.row[data-status='unsupported'] {
  background: var(--surface-inset);
  border-style: dashed;
}

/* The progress fill is a background layer on the row itself rather than a
   separate bar, so a converting row reads as filling up. */
.row-progress {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.row-progress::after {
  content: '';
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
  background: var(--accent-wash);
  transition: transform var(--t-mid) linear;
}

.row > * {
  position: relative;
}

.row-glyph {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--ink-soft);
  flex: none;
}

.row-glyph .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.row[data-status='done'] .row-glyph {
  background: var(--ok-wash);
  color: var(--ok);
}

.row[data-status='error'] .row-glyph {
  background: var(--danger-wash);
  color: var(--danger);
}

.row-main {
  min-width: 0;
}

.row-name {
  font-size: var(--text-sm);
  font-weight: 500;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 0.55em;
  flex-wrap: wrap;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

/* Separators are drawn by CSS rather than written into the markup. They are
   decoration, not content: a screen reader should read "52 KB, png", not
   "52 KB slash png", and a contrast audit should not treat a delimiter as
   body text. */
/* Attached to the end of the preceding item rather than the start of the
   next one. These lines wrap, and a wrapped line that opens with a stray
   delimiter reads as a typo. */
.row-meta > span:not(:last-child)::after,
.toolbar-summary > span:not(:last-child)::after {
  content: '/';
  color: var(--ink-ghost);
  margin-left: 0.55em;
}

.row-note {
  color: var(--ok);
}

/* A result that came out larger than the source. Stated, not celebrated. */
.row-neutral {
  color: var(--ink-soft);
}

.row-error {
  margin-top: 0.3rem;
  font-size: var(--text-sm);
  color: var(--danger);
  overflow-wrap: anywhere;
}

.row-hint {
  margin-top: 0.3rem;
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

.row-controls {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}

/* Extracted archive contents list under the row that produced them. */
.row-files {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-1);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line-soft);
}

/* =========================================== 6  format picker === */

.picker {
  position: relative;
  display: flex;
  align-items: center;
}

.picker-arrow {
  color: var(--ink-ghost);
  margin-right: var(--s-2);
}

.picker-arrow .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.picker select {
  appearance: none;
  padding: 0.4rem 1.9rem 0.4rem 0.65rem;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.picker select:hover {
  border-color: var(--accent-edge);
}

.picker::after {
  content: '';
  position: absolute;
  right: 0.65rem;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: translateY(-0.12rem) rotate(45deg);
  pointer-events: none;
}

.picker option {
  background: var(--surface-2);
  color: var(--ink);
}

.picker optgroup {
  background: var(--surface-1);
  color: var(--ink-faint);
  font-family: var(--font-sans);
}

/* ==================================== 7  buttons and controls === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 0.5rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.btn .icon {
  width: 1.05em;
  height: 1.05em;
}

/* A press should feel physical. 1px is enough to register as a push. */
.btn:not(:disabled):active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.btn-ok {
  background: var(--ok);
  color: #04210f;
}

.btn-ok:not(:disabled):hover {
  background: #64d98b;
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:not(:disabled):hover {
  border-color: var(--accent-edge);
  color: var(--accent);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-soft);
}

.btn-quiet:not(:disabled):hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: var(--text-xs);
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.btn-icon .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.btn-icon:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn-icon.is-danger:hover {
  background: var(--danger-wash);
  color: var(--danger);
}

/* --- appearance settings lightbulb (styling round) ------------------ */

.settings-wrap {
  position: relative;
}

#theme-btn .icon {
  transition: color var(--t-mid) var(--ease), filter var(--t-mid) var(--ease);
}

#theme-btn:hover .icon,
#theme-btn:focus-visible .icon,
#theme-btn[aria-expanded="true"] .icon {
  color: var(--accent);
  filter: drop-shadow(0 0 5px var(--accent)) drop-shadow(0 0 10px var(--accent-edge));
}

.settings-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  display: grid;
  gap: var(--s-1);
  width: 11rem;
  padding: var(--s-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

.settings-menu[hidden] {
  display: none;
}

.settings-menu-label {
  margin: 0.1rem var(--s-2) 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.settings-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0.45rem var(--s-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.settings-menu button:hover,
.settings-menu button:focus-visible {
  background: var(--surface-3);
  color: var(--ink);
}

.settings-menu button[aria-checked="true"] {
  color: var(--accent);
}

/* A small dot rather than a second icon font/glyph -- consistent with how
   sparingly this page otherwise uses colour to mean something specific
   (tokens.css's own "status colours are never used decoratively" rule). */
.settings-menu button[aria-checked="true"]::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.btn-round {
  border-radius: var(--r-md);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.link:hover {
  color: var(--accent-bright);
}

/* Spinner is the one perpetual animation on the page. It is allowed
   because it communicates that work is genuinely still running. */
.spinner {
  width: 0.95em;
  height: 0.95em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.22rem 0.5rem;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

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

.badge-accent {
  background: var(--accent-wash);
  color: var(--accent);
}

.badge-warn {
  background: var(--warn-wash);
  color: var(--warn);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--ink-faint);
}

/* --- per-item settings disclosure ---------------------------------- */

.settings {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-1);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line-soft);
}

.field {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.field-label {
  min-width: 5.5rem;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.field-value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-soft);
  min-width: 3.5rem;
}

input[type='range'] {
  flex: 1;
  min-width: 8rem;
  height: 1.25rem;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 0.9rem;
  height: 0.9rem;
  margin-top: -0.4rem;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
  transition: transform var(--t-fast) var(--ease);
}

input[type='range']:hover::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
}

input[type='range']::-moz-range-thumb {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.segmented button {
  padding: 0.3rem 0.7rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button[aria-pressed='true'] {
  background: var(--surface-3);
  color: var(--accent);
}

/* ================================================== 8  modal === */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(var(--s-5), 5vh) var(--s-4);
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

/* THE BUG FIX.

   `display: flex` above is an author rule, so it beats the user-agent
   `[hidden] { display: none }` on specificity. In the previous build that
   meant the help panel rendered open on load and no amount of setting
   `hidden = true` could close it. Restating the rule as an author-level
   declaration puts the attribute back in charge. `!important` guarantees
   it, whatever display value a future variant of this panel needs. */
.backdrop[hidden] {
  display: none !important;
}

.modal {
  width: 100%;
  max-width: 46rem;
  max-height: min(86vh, 52rem);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
}

.modal-head h2 {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.modal-body {
  padding: var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-body > * + * {
  margin-top: var(--s-4);
}

.modal-body p {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  max-width: 62ch;
  text-wrap: pretty;
}

.modal-body h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.cat {
  padding-top: var(--s-4);
  border-top: 1px solid var(--line-soft);
}

.cat:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

.pill {
  padding: 0.2rem 0.5rem;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.pill-ok {
  background: var(--ok-wash);
  color: var(--ok);
  border-color: rgba(82, 196, 122, 0.24);
}

/* "Not available in this browser".

   These carry real information, so the text stays above WCAG AA rather than
   being dimmed into unreadability. The dashed border and the struck-through
   label do the signalling instead, which also means the state is not
   communicated by colour alone. */
.pill-off {
  background: transparent;
  color: var(--ink-faint);
  border-style: dashed;
  text-decoration: line-through;
  text-decoration-color: var(--ink-ghost);
}

.inputs-line {
  margin-top: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

/* --- the extended-engine consent block ----------------------------- */

.notice {
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background: var(--surface-inset);
}

.notice-warn {
  border-color: rgba(224, 164, 75, 0.3);
  background: var(--warn-wash);
}

.notice h3 {
  color: var(--warn);
  margin-bottom: var(--s-2);
}

.notice p {
  font-size: var(--text-sm);
}

.notice-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

/* ================================================= 9  toasts === */

.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--s-5);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: center;
  pointer-events: none;
  width: min(30rem, calc(100vw - 2 * var(--s-4)));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  pointer-events: auto;
  animation: toast-in var(--t-mid) var(--ease);
}

.toast .icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.toast-ok .icon {
  color: var(--ok);
}

.toast-error {
  border-color: rgba(242, 100, 90, 0.4);
}

.toast-error .icon {
  color: var(--danger);
}

.toast.is-leaving {
  animation: toast-out var(--t-mid) var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

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

.page-footer {
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

/* ================================================= 10  motion === */

/* Rows enter with a short rise. This is the only entrance animation on
   the page and it exists to show which row was just added when several
   files are dropped at once. */
@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.row {
  animation: row-in var(--t-mid) var(--ease);
}

/* A completed row pulses its border once. It confirms the state change
   at the moment it happens and then stops, rather than looping. */
@keyframes settle {
  50% {
    border-color: var(--ok);
  }
}

.row[data-status='done'] {
  animation: settle var(--t-slow) var(--ease);
}

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

  /* The spinner is the exception: it is the only signal that a long job
     is still alive, so it keeps turning, just slowly enough not to
     provoke anyone. */
  .spinner {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ============================================= 11  responsive === */

/* Small vertical screens are the primary target, so the layout is built
   mobile-first and these queries add room rather than take it away. */

@media (max-width: 40rem) {
  .page {
    padding: var(--s-5) var(--s-4) var(--s-7);
  }

  .masthead {
    flex-direction: column;
    gap: var(--s-4);
  }

  .masthead-actions {
    width: 100%;
  }

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

  .dropzone {
    padding: var(--s-5) var(--s-4);
    gap: var(--s-3);
  }

  .dropzone-glyph {
    width: 2.5rem;
    height: 2.5rem;
  }

  .dropzone-title {
    font-size: var(--text-base);
  }

  /* At one chip per line the strip becomes a wall five rows deep and pushes
     the actual controls off screen. Shrinking the chips lets them pack, and
     the strip returns to being a hint rather than the main event. */
  .cap {
    font-size: 0.75rem; /* was 0.625rem, *1.2 per the styling round */
    padding: 0.25rem 0.45rem;
    letter-spacing: 0;
  }

  /* row-gap only, matching the base rule (feedback.md §20): the old `gap`
     shorthand here would reintroduce a column-gap the quieter chip style
     no longer wants, since chips are now separated by their own dotted
     border-right and padding instead of a flex gap. */
  .capability-strip {
    row-gap: var(--s-1);
  }

  /* Rows become two rows of their own: identity on top, controls below
     at full width, so the select and buttons stay comfortably tappable
     instead of being squeezed into a narrow third column. */
  .row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .row-controls {
    grid-column: 1 / -1;
    justify-content: space-between;
    width: 100%;
    padding-top: var(--s-3);
    border-top: 1px solid var(--line-soft);
  }

  .picker {
    flex: 1;
  }

  .picker select {
    width: 100%;
  }

  .toolbar {
    position: static;
  }

  .toolbar-actions {
    width: 100%;
  }

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

  .page-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Every interactive target reaches the 44px comfortable minimum on touch,
   without inflating the same controls for mouse users. The small variants
   get the same floor: "small" should mean less padding, not a target that
   is harder to hit. */
@media (pointer: coarse) {
  .btn,
  .btn-sm {
    min-height: 2.75rem;
  }

  .btn-icon {
    width: 2.75rem;
    height: 2.75rem;
  }

  .picker select {
    min-height: 2.75rem;
  }

  .segmented button {
    min-height: 2.5rem;
    padding-inline: 0.9rem;
  }
}

/* At desktop widths the queue gains a second column, because rows are
   short and a single tall column wastes the horizontal space. */
@media (min-width: 90rem) {
  .rows {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* Stretch rather than start, so two rows sitting side by side share a
       height. With `start` the shorter card floats and the grid looks
       ragged whenever one filename or metadata line wraps. */
    align-items: stretch;
  }

  /* Rows that expanded to show settings or extracted files span the full
     width, so their contents are not crushed into half a column. */
  .row:has(.settings),
  .row:has(.row-files) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 137.5rem) {
  .rows {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
