/* ==========================================================================
   FoE Menu Intake - visual system

   Minimal but modern. Depth comes from layered surfaces and soft shadows, not
   from colour: one accent (FoE green #00AB67) plus a warm-neutral grey ramp.
   Everything sizes off an explicit type scale and radius scale below.
   ========================================================================== */

:root {
  color-scheme: light;

  /* surface ramp, light to deep - this is where the depth comes from */
  --paper:      #F1F5F4;
  --surface:    #FFFFFF;
  --surface-2:  #F7FAF9;
  --surface-3:  #ECF2F0;
  --viewer-bg:  #22282A;

  /* ink ramp */
  --ink:        #18211F;
  --ink-2:      #4C5956;
  --ink-3:      #86918F;

  --line:       #E4EBE9;
  --line-2:     #CFDAD7;

  /* the single accent */
  --green:      #00AB67;
  --green-deep: #00814C;
  --green-wash: #E8F7EF;
  --green-line: #A6DFC5;

  --warn:       #8A5A0B;
  --warn-wash:  #FDF4E3;
  --warn-line:  #EBD3A3;
  --error:      #B12E17;
  --error-wash: #FCEBE7;
  --error-line: #F0C0B5;

  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* type scale */
  --fs-display: 27px;
  --fs-h2:      19px;
  --fs-title:   15px;
  --fs-body:    13.5px;
  --fs-meta:    12px;
  --fs-micro:   10.5px;

  /* radius scale */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;

  /* elevation scale */
  --sh-1: 0 1px 1.5px rgba(24,33,31,.04);
  --sh-2: 0 1px 2px rgba(24,33,31,.035), 0 4px 10px -6px rgba(24,33,31,.10);
  --sh-3: 0 2px 4px rgba(24,33,31,.04), 0 16px 40px -20px rgba(24,33,31,.22);
  --sh-inset: inset 0 1px 0 rgba(255,255,255,.7);

  --ease: cubic-bezier(0.22, 0.68, 0.3, 1);
  --bar-h: 74px;
  --head-h: 66px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
}

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6;
      stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- abstract */

.backdrop { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.backdrop::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(var(--line-2) 1.3px, transparent 1.7px),
    radial-gradient(var(--line-2) .9px, transparent 1.3px);
  background-size: 30px 30px, 15px 15px;
  background-position: 0 0, 7px 7px;
  opacity: .45;
  mask-image: radial-gradient(100% 70% at 96% -12%, #000 0%, rgba(0,0,0,.28) 42%, transparent 72%);
  -webkit-mask-image: radial-gradient(100% 70% at 96% -12%, #000 0%, rgba(0,0,0,.28) 42%, transparent 72%);
}
.ring { position: absolute; border: 1px solid var(--green); border-radius: 50%;
        opacity: .13; animation: drift 26s var(--ease) infinite alternate; }
.ring--c { width: 320px; height: 320px; left: -170px; bottom: -150px; opacity: .09; animation-delay: -15s; }
@keyframes drift { from { transform: none; } to { transform: translate3d(-18px,16px,0) scale(1.04); } }

/* ------------------------------------------------------------- typography */

h1, h2, h3 { font-family: var(--mono); font-weight: 500; letter-spacing: -.02em; margin: 0; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------------ header */

.masthead {
  position: sticky; top: 0; z-index: 6;
  height: var(--head-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(241,245,244,.82);
  backdrop-filter: blur(14px) saturate(1.4);
}
.brand-logo { height: 32px; width: auto; display: block; }
.brand-fallback { font-family: var(--mono); font-size: var(--fs-title); margin: 0; }
.masthead h1 {
  font-size: var(--fs-meta); font-weight: 400; color: var(--ink-3);
  padding-left: 22px; border-left: 1px solid var(--line-2);
  letter-spacing: .02em;
}
.masthead-meta { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: .07em;
  padding: 7px 13px; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-2); white-space: nowrap; text-decoration: none;
  background: var(--surface); box-shadow: var(--sh-1);
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s, transform .16s var(--ease);
}
.chip svg { width: 13px; height: 13px; }
.chip--link:hover {
  border-color: var(--green-line); color: var(--green-deep);
  background: var(--green-wash); box-shadow: var(--sh-2); transform: translateY(-1px);
}
.chip--env {
  border-color: var(--green-line); color: var(--green-deep); background: var(--green-wash);
  box-shadow: none; letter-spacing: .12em; text-transform: uppercase; font-size: 9.5px;
}

/* the selector wears the chip, so the header gains a control and not a widget */
.env-pick { display: inline-flex; align-items: center; gap: 8px; }
.env-pick-label {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap;   /* "Writing to" is two words and belongs on one line */
}
.chip--pick {
  appearance: none; cursor: pointer; padding-right: 22px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23264d3b' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 10px;
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.chip--pick:hover:not(:disabled) { border-color: var(--green-deep); }
.chip--pick:disabled { cursor: not-allowed; opacity: .55; }
/* a live target is not styled like a safe one */
.chip--pick.is-live {
  border-color: var(--amber-line, #d9a441); color: var(--amber-deep, #7a4f05);
  background: var(--amber-wash, #fdf4e3);
}
.env-note { font-size: 10.5px; color: var(--ink-3); }

/* -------------------------------------------------------------------- gate */

.gate { position: relative; z-index: 2; min-height: 100%; display: grid; place-items: center; padding: 48px 24px; }
.gate-card {
  width: 100%; max-width: 408px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 40px;
  box-shadow: var(--sh-3), var(--sh-inset);
  animation: rise .5s var(--ease) both;
}
.gate-card img { height: 34px; margin-bottom: 28px; }
.gate-card h2 { font-size: var(--fs-h2); margin-bottom: 26px; }

/* ------------------------------------------------------------------ fields */

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px;
}
input[type='text'], input[type='password'], select {
  width: 100%; font: inherit; font-size: var(--fs-body); color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--ink-3); }
input:focus, select:focus {
  outline: none; background: var(--surface);
  border-color: var(--green); box-shadow: 0 0 0 3.5px rgba(0,171,103,.15);
}
input:disabled, select:disabled { color: var(--ink-3); background: var(--surface-3); cursor: not-allowed; }
input.is-missing { border-color: var(--warn-line); background: var(--warn-wash); }
input.is-guessed, select.is-guessed {
  border-left: 3px solid var(--green); padding-left: 10px;
  background: linear-gradient(90deg, var(--green-wash) 0%, var(--surface-2) 38%);
}

/* password field with a show/hide toggle sitting inside its right edge */
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 5px; transform: translateY(-50%);
  width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-xs);
  color: var(--ink-3); box-shadow: none;
  transition: color .18s, background .18s;
}
.pw-toggle svg { width: 16px; height: 16px; stroke-width: 1.5; }
/* the base button rule nudges on hover, which would break the centering */
.pw-toggle:hover:not(:disabled),
.pw-toggle:active:not(:disabled) {
  background: var(--surface-3); border-color: transparent; color: var(--ink);
  transform: translateY(-50%); box-shadow: none;
}
.pw-toggle[aria-pressed='true'] { color: var(--green-deep); }

.error-note {
  font-size: var(--fs-meta); color: var(--error); background: var(--error-wash);
  border: 1px solid var(--error-line); border-radius: var(--r-sm);
  padding: 10px 12px; margin: 0 0 14px; animation: rise .28s var(--ease) both;
}
.hint { font-size: var(--fs-meta); color: var(--ink-3); margin: 0; line-height: 1.5; }
.hint b { color: var(--green-deep); font-weight: 600; }

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

button {
  font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: .11em;
  text-transform: uppercase; font-weight: 500;
  padding: 11px 18px; border-radius: var(--r-sm);
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  cursor: pointer; box-shadow: var(--sh-1);
  transition: transform .16s var(--ease), background .2s, border-color .2s, color .2s,
              opacity .2s, box-shadow .2s;
}
button:hover:not(:disabled) {
  background: #0F1614; border-color: #0F1614;
  transform: translateY(-1px); box-shadow: var(--sh-2);
}
button:active:not(:disabled) { transform: translateY(0); box-shadow: var(--sh-1); }
button:disabled { opacity: .3; cursor: not-allowed; box-shadow: none; }
button:focus-visible { outline: none; box-shadow: 0 0 0 3.5px rgba(0,171,103,.3); }

.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) {
  background: var(--surface); color: var(--green-deep); border-color: var(--green-line);
}

.btn-danger { background: var(--error); border-color: var(--error); }
.btn-danger:hover:not(:disabled) { background: #8E2411; border-color: #8E2411; }

.btn-quiet {
  background: transparent; border-color: transparent; color: var(--ink-2);
  padding: 7px 9px; display: inline-flex; align-items: center; gap: 6px; box-shadow: none;
}
.btn-quiet:hover:not(:disabled) {
  background: var(--surface-3); border-color: transparent; color: var(--ink);
  transform: none; box-shadow: none;
}
.btn-quiet svg { width: 13px; height: 13px; }
.btn-block { width: 100%; padding: 13px; }

/* the one primary call to action */
.btn-cta {
  font-size: 11.5px; padding: 14px 28px; letter-spacing: .12em;
  background: var(--green-deep); border-color: var(--green-deep); border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(0,129,76,.16), 0 6px 14px -8px rgba(0,129,76,.32);
}
.btn-cta:hover:not(:disabled) {
  background: #006B3F; border-color: #006B3F;
  box-shadow: 0 1px 2px rgba(0,129,76,.2), 0 9px 20px -10px rgba(0,129,76,.4);
}

/* link styled as a button, for the Open Google Sheets CTA in the action bar */
.btn-link {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: .11em;
  text-transform: uppercase; font-weight: 500; padding: 11px 18px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--ink); background: var(--surface); box-shadow: var(--sh-1);
  transition: color .2s, border-color .2s, box-shadow .2s, transform .16s var(--ease);
}
.btn-link:hover {
  color: var(--green-deep); border-color: var(--green-line);
  box-shadow: var(--sh-2); transform: translateY(-1px);
}
.btn-link svg { width: 14px; height: 14px; }

.icon-btn {
  background: transparent; border-color: transparent; color: var(--ink-2);
  padding: 0; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: var(--r-xs); box-shadow: none;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover:not(:disabled) {
  background: var(--surface-3); border-color: transparent; color: var(--ink);
  transform: none; box-shadow: none;
}
.txt-btn {
  background: transparent; border-color: transparent; color: var(--ink-2);
  padding: 6px 10px; font-size: 9.5px; border-radius: var(--r-xs); box-shadow: none;
}
.txt-btn:hover:not(:disabled) {
  background: var(--surface-3); border-color: transparent; color: var(--ink);
  transform: none; box-shadow: none;
}

/* ---------------------------------------------------------------- dropzone */

.shell { position: relative; z-index: 2; padding: 22px 26px; }

/* fills the same box the workspace does, so the page does not end in a wall of
   empty grey on a tall screen */
#empty { height: calc(100vh - var(--head-h) - var(--bar-h) - 44px); min-height: 380px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  width: 100%; height: 100%; min-height: 380px; padding: 48px 32px; text-align: center;
  background: var(--surface); border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  color: var(--ink); text-transform: none; letter-spacing: normal;
  font-family: var(--sans); font-size: var(--fs-body);
  animation: rise .45s var(--ease) both;
}
.dropzone > * { max-width: 52ch; }
.dz-browse {
  font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: .1em;
  text-transform: uppercase; color: var(--green-deep);
  border: 1px solid var(--green-line); background: var(--green-wash);
  border-radius: 999px; padding: 8px 16px; margin-top: 4px;
}
.dropzone:hover:not(:disabled), .dropzone.is-over {
  background: var(--surface); border-color: var(--green); border-style: solid;
  color: var(--ink); transform: none;
  box-shadow: var(--sh-2), 0 0 0 4px rgba(0,171,103,.06);
}
.dropzone.is-over { animation: pulse 1.2s var(--ease) infinite; }
@keyframes pulse {
  0%,100% { box-shadow: var(--sh-2), 0 0 0 4px rgba(0,171,103,.06); }
  50%     { box-shadow: var(--sh-2), 0 0 0 12px rgba(0,171,103,.03); }
}
.dropzone-icon {
  width: 46px; height: 46px; color: var(--green-deep); stroke-width: 1.3;
  background: var(--green-wash); border-radius: 50%; padding: 11px;
}
.dropzone h2 { font-size: var(--fs-display); }
.dropzone p { margin: 0; color: var(--ink-2); max-width: 52ch; text-wrap: pretty; }
.dropzone code {
  font-family: var(--mono); font-size: var(--fs-meta); color: var(--green-deep);
  background: var(--green-wash); padding: 3px 7px; border-radius: var(--r-xs);
}

/* --------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  /* cards | metadata | viewer - the viewer gets everything left over */
  grid-template-columns: 320px 292px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  height: calc(100vh - var(--head-h) - var(--bar-h) - 44px);
  /* opacity only, never transform: a filled transform animation makes this a
     containing block, which trapped position:fixed children inside the grid. */
  animation: fade .4s var(--ease) both;
}

.cards-col, .meta-col, .detail {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-2);
}

/* ------------------------------------------------------------- file cards */

.cards-col { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
.cards-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
  background: var(--surface-2);
}
.cards-count { font-family: var(--mono); font-size: var(--fs-meta); color: var(--ink-2); }
.cards-count b { color: var(--ink); font-weight: 500; font-size: var(--fs-title); }
.cards-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.cards-head .btn-quiet { margin-left: auto; }

.cards {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 9px;
  background: var(--surface-2);
}

.card {
  position: relative;
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px; padding-right: 46px;
  text-align: left; width: 100%;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: none;
  font-family: var(--sans); font-size: var(--fs-body);
  text-transform: none; letter-spacing: normal; cursor: pointer;
  transition: border-color .18s, box-shadow .2s, transform .16s var(--ease), background .18s;
}
/* selection reads as a green spine rather than a filled block */
.card::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: transparent; transition: background .18s;
}
.card:hover:not(:disabled) {
  background: var(--surface); color: var(--ink);
  border-color: var(--line-2); box-shadow: var(--sh-1); transform: translateY(-1px);
}
.card[aria-current='true'] {
  border-color: var(--green-line); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,171,103,.08);
}
.card[aria-current='true']::before { background: var(--green); }
.card.is-new { animation: slide-in .42s var(--ease) both; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

/* working hairline */
.card[data-status='queued']::after,
.card[data-status='uploading']::after,
.card[data-status='processing']::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  background-size: 45% 100%; background-repeat: no-repeat;
  animation: sweep 1.5s linear infinite;
}
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.card-thumb {
  flex: 0 0 44px; width: 44px; height: 58px;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-xs); overflow: hidden; display: grid; place-items: center;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade .4s var(--ease) both; }
.card-thumb--none { font-family: var(--mono); font-size: 8px; color: var(--ink-3); letter-spacing: .06em; }

.card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; }
.card-name { font-weight: 600; font-size: var(--fs-body); overflow-wrap: anywhere; line-height: 1.35; }
.card-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; align-items: center; }

/* the dustbin is always visible - it used to be opacity:0 until hover, which
   meant nobody could find it, and it is unreachable that way on touch. */
/* Always visible - it used to be opacity:0 until hover, which meant nobody
   could find it. Just the glyph: no box, no border, no shadow. */
.card-kill {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  border-radius: 50%; color: var(--ink-3);
  opacity: 1; box-shadow: none;
  transition: color .18s, background .18s;
}
.card-kill svg { width: 16px; height: 16px; stroke-width: 1.5; }
.card-kill:hover:not(:disabled) {
  background: var(--error-wash); color: var(--error);
  border-color: transparent; transform: none; box-shadow: none;
}
.card-kill:disabled { opacity: .3; }

.tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 7px; border: 1px solid var(--line-2); border-radius: var(--r-xs);
  color: var(--ink-2); white-space: nowrap; background: var(--surface-2);
}
.tag--warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-wash); }
.tag--muted { color: var(--ink-3); border-style: dashed; background: transparent; }
.tag--status[data-status='done'] { color: var(--green-deep); border-color: var(--green-line); background: var(--green-wash); }
.tag--status[data-status='failed'],
.tag--status[data-status='invalid'],
.tag--status[data-status='stalled'] { color: var(--error); border-color: var(--error-line); background: var(--error-wash); }
.tag--status[data-status='uploading'],
.tag--status[data-status='processing'],
.tag--status[data-status='queued'] { color: var(--ink); border-color: var(--ink-3); background: var(--surface-3); }

.tab-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--green-deep); text-decoration: none;
  border: 1px solid var(--green-line); background: var(--green-wash);
  border-radius: var(--r-xs); padding: 3px 7px; transition: background .18s, color .18s;
}
.tab-link:hover { background: var(--green); color: #fff; border-color: var(--green); }
.tab-link svg { width: 11px; height: 11px; }

/* skeleton card while a PDF is being decoded */
.skel {
  display: flex; gap: 12px; padding: 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}
.skel-thumb { flex: 0 0 44px; height: 58px; border-radius: var(--r-xs); }
.skel-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 3px; }
.skel-line { height: 9px; border-radius: 4px; }
.skel-line.w70 { width: 70%; } .skel-line.w45 { width: 45%; } .skel-line.w30 { width: 30%; }
.skel-thumb, .skel-line {
  background: linear-gradient(90deg, var(--surface-3) 25%, #E2EAE7 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* --------------------------------------------------------------- metadata */

.meta-col { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
.meta-head { padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; background: var(--surface-2); }
.meta-head h3 { font-size: var(--fs-title); overflow-wrap: anywhere; line-height: 1.35; }
.meta-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin: 5px 0 0; }
.meta-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; }
.meta-scroll .field:last-of-type { margin-bottom: 12px; }

/* ------------------------------------------------------------------ viewer */

/* The viewer is meant to feel like a reader, so the surround is deliberately
   darker than the app chrome and the page floats on it. */
.detail { display: grid; grid-template-rows: minmax(0, 1fr); height: 100%; min-height: 0; overflow: hidden; }
.viewer { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--viewer-bg); }

.viewer-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); flex: 0 0 auto;
}
.vb-group { display: flex; align-items: center; gap: 3px; }
.vb-right { margin-left: auto; }
.pg-label {
  font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-2);
  min-width: 48px; text-align: center; white-space: nowrap;
}

.viewer-scroll { position: relative; overflow: auto; min-height: 0; padding: 22px; }
.viewer-scroll:focus-visible { outline: 2px solid var(--green); outline-offset: -3px; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }

.viewer-page {
  display: block; background: #fff; border: 0; border-radius: var(--r-xs);
  box-shadow: 0 1px 4px rgba(0,0,0,.3), 0 10px 26px -14px rgba(0,0,0,.45);
  animation: rise .3s var(--ease) both;
}

.viewer-loading {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: rgba(34,40,42,.86);
  font-family: var(--mono); font-size: var(--fs-micro); color: #C6D2CF; letter-spacing: .06em;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.18); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- actionbar */

.actionbar {
  position: sticky; bottom: 0; z-index: 7;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  border-top: 1px solid var(--line);
  background: rgba(241,245,244,.88);
  backdrop-filter: blur(14px) saturate(1.4);
}
.ab-left { display: flex; align-items: center; gap: 12px; margin-right: auto; flex-wrap: wrap; }
.ab-status { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); }
.ab-status b { color: var(--ink-2); font-weight: 500; }
.ab-status[data-tone='ok'] b { color: var(--green-deep); }
.ab-status[data-tone='warn'] b { color: var(--warn); }

/* ---------------------------------------------------------- confirm modal */

.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
  backdrop-filter: blur(3px);
  animation: fade .18s var(--ease) both;
}
.modal-card {
  width: 100%; max-width: 396px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 28px 24px;
  box-shadow: var(--sh-3);
  animation: pop .22s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-icon {
  width: 46px; height: 46px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--error-wash); color: var(--error);
}
.modal-icon svg { width: 21px; height: 21px; stroke-width: 1.5; }
.modal-card h3 { font-size: var(--fs-h2); margin-bottom: 8px; }
.modal-card p { margin: 0 0 22px; color: var(--ink-2); font-size: var(--fs-body); overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }

/* ------------------------------------------------------------------- misc */

.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--bar-h) + 20px);
  transform: translateX(-50%);
  font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: .05em;
  padding: 12px 20px; border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.1); background: var(--ink); color: #fff;
  box-shadow: var(--sh-3); animation: toast-in .34s var(--ease) both; max-width: 78vw;
}
.toast[data-kind='warn'] { background: var(--warn-wash); color: var(--warn); border-color: var(--warn-line); }
.toast[data-kind='error'] { background: var(--error-wash); color: var(--error); border-color: var(--error-line); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%,12px); } to { opacity: 1; transform: translate(-50%,0); } }

.footer { position: relative; z-index: 2; padding: 14px 26px 26px; color: var(--ink-3); font-size: var(--fs-meta); }

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 7px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
.viewer-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); background-clip: content-box; }

@media (max-width: 1400px) { .workspace { grid-template-columns: 276px 258px minmax(0, 1fr); } }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .cards { max-height: 300px; }
  .meta-col { height: auto; }
  .detail { height: 76vh; }
}
@media (max-width: 680px) {
  .shell, .masthead, .footer, .actionbar { padding-left: 16px; padding-right: 16px; }
  .masthead { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 12px; }
  .masthead h1 { padding-left: 0; border-left: 0; }
  .actionbar { height: auto; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
}

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

/* ------------------------------------------------------------- failures */
/*
 * Three voices in one box, deliberately unequal.
 *
 * What happened is the sentence a person reads; what to do about it is the
 * one they act on; and the server's own words are kept small because they are
 * for whoever fixes the cause, not for whoever hit the problem.
 */
.fail-say { margin: 0; font-weight: 500; }
.fail-fix { margin: 6px 0 0; }
.fail-raw {
  margin: 8px 0 0; font-size: 11px; opacity: .65;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  word-break: break-word;
}
