/* bizzle — Fleet tier design language.
 *
 * Tokens, surfaces, and motion are carried over from dfu-cl's fleet tier:
 * near-black canvas lit by a radial source, layered panels, tight hardware
 * radii, Inter for text and Sora for display, blue accent triad.
 *
 * The house motion rule comes with them, and it is the one thing not to
 * "simplify": wires are always present and thin, traffic is a discrete pulse
 * that fires and stops. That rule was written for bots placing orders and it
 * happens to describe this app exactly — a frame either goes or it does not.
 * Nothing here loops on the traffic layer, so a still screen means a still
 * link rather than a broken animation.
 */

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

:root {
  /* Surfaces — near-black canvas lit by a radial source, layered panels */
  --color-background: #04050a;
  --color-background-near: #12151c;
  --color-slip: #020308;
  --color-surface-0: #080b13;
  --color-surface-1: #0a0d15;
  --color-surface-2: #0c1019;
  --color-surface-3: #11151f;

  --color-foreground: #e7ebf2;
  --color-foreground-secondary: #828b9e;
  --color-foreground-tertiary: #4c5466;

  --color-border: #161a25;
  --color-border-strong: #20262f;

  /* Accent triad: solid / 10% wash / 35% line / 55% glow */
  --color-accent: #3b7bf0;
  --color-accent-bright: #5a93ff;
  --color-accent-muted: rgba(59, 123, 240, 0.1);
  --color-accent-line: rgba(59, 123, 240, 0.35);
  --color-accent-glow: rgba(59, 123, 240, 0.55);

  --color-yes: #29b07a;
  --color-yes-secondary: #3ecf94;
  --color-yes-line: rgba(41, 176, 122, 0.35);

  --color-no: #e2495c;
  --color-no-secondary: #f06a7b;
  --color-no-line: rgba(226, 73, 92, 0.35);

  --color-warning: #f0a742;
  --color-warning-line: rgba(240, 167, 66, 0.35);

  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Tight, hardware-like radii */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 6px;
  --radius-xl: 10px;

  --ease-snappy: cubic-bezier(0.16, 1, 0.3, 1);
  --text-2xs: 0.6875rem;

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.012em;
  background-color: var(--color-background);
  background-image: radial-gradient(130% 130% at 32% 22%, var(--color-background-near) 0%, var(--color-background) 74%);
  background-attachment: fixed;
  color: var(--color-foreground);
  overscroll-behavior-y: none;
}

h1, h2 { margin: 0; font-family: var(--font-display); letter-spacing: -0.03em; font-weight: 600; }
h1 { font-size: 15px; }
h2 { font-size: 15px; }

.num { font-variant-numeric: tabular-nums; }

/* Uppercase wide-tracked micro-label */
.eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-foreground-tertiary);
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--color-accent-line);
  outline-offset: 2px;
}

* { scrollbar-width: thin; scrollbar-color: var(--color-surface-3) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1d2433; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #2a3346; }

/* ── The lit backdrop ───────────────────────────────────────────────────────
   A band of hairlines at the top of the page, faded out through a radial mask
   so it never reaches the content below. The halo sits under the lattice and
   gives the band a light source. Deliberately near-invisible: at 1.6% white it
   reads as surface texture rather than as a grid you are meant to look at. */

.bg {
  position: fixed;
  inset: 0 0 auto 0;
  height: 62vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  mask-image: radial-gradient(132% 100% at 62% -8%, #000 22%, transparent 94%);
  -webkit-mask-image: radial-gradient(132% 100% at 62% -8%, #000 22%, transparent 94%);
}
.bg-halo {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(46% 60% at 72% -10%, var(--color-accent-muted), transparent 70%);
}
.bg-rules {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.016) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── Elevation: recessed slip → well → raised card ─────────────────────── */

.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0, rgba(255, 255, 255, 0) 88px),
    var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 14px 30px -20px rgba(0, 0, 0, 0.7);
  transition: border-color 0.16s ease, box-shadow 0.2s ease;
}

.well {
  background: var(--color-surface-0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.slip {
  background: var(--color-slip);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.85),
    inset 0 1px 2px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

/* A hairline that fades to nothing at both ends. It separates without drawing
   a box around anything, which is why almost nothing below is boxed. */
.rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--color-border-strong) 22%,
    var(--color-border-strong) 78%,
    transparent 100%
  );
}

/* ── App bar ───────────────────────────────────────────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) clamp(16px, 4vw, 28px) 0;
  background: color-mix(in srgb, var(--color-background) 85%, transparent);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--color-border);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand .mark {
  width: 15px; height: 15px; border-radius: var(--radius-xs);
  background: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-background), inset 0 0 0 5px var(--color-accent), 0 0 12px -2px var(--color-accent-glow);
}
.brand .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.03em; }
.brand .proto {
  font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-foreground-tertiary);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-xs); padding: 1px 5px;
}

.ident { display: flex; align-items: center; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: 500;
  color: var(--color-foreground-secondary);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xs); padding: 3px 7px;
}
.dot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: var(--color-foreground-tertiary);
}
/* Only a genuinely live link gets the live dot. Blinking for a peer we have
   merely seen once would make the signal a lie. */
.badge.live { color: var(--color-yes-secondary); border-color: var(--color-yes-line); }
.badge.live .dot { background: var(--color-yes); box-shadow: 0 0 6px var(--color-yes-line); animation: blink 1.6s ease-in-out infinite; }
.badge.stale { color: var(--color-warning); border-color: var(--color-warning-line); }
.badge.stale .dot { background: var(--color-warning); box-shadow: 0 0 6px var(--color-warning-line); }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Segmented control ─────────────────────────────────────────────────── */

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 2px; padding: 2px;
  background: var(--color-surface-0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.mode {
  appearance: none; background: none; border: 0;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--color-foreground-secondary);
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition: color 0.14s ease, background-color 0.14s ease;
}
.mode:hover { color: var(--color-foreground); }
.mode[aria-selected="true"] {
  color: var(--color-foreground);
  background: var(--color-surface-3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.pair-open { margin-left: auto; align-self: center; }

/* ── Paired banner ─────────────────────────────────────────────────────── */

.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 20px;
  padding: 9px 12px;
  background: var(--color-accent-muted);
  border: 1px solid var(--color-accent-line);
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  position: relative; z-index: 1;
}
.banner .dot { background: var(--color-accent); box-shadow: 0 0 6px var(--color-accent-glow); }
.banner span { flex: 1; min-width: 0; }
.banner b { font-variant-numeric: tabular-nums; }

/* ── Pairing ───────────────────────────────────────────────────────────── */

.pairing {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--color-background) 86%, transparent);
  backdrop-filter: blur(24px);
  overflow-y: auto;
}
.pair-panel {
  width: min(420px, 100%);
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0, rgba(255, 255, 255, 0) 130px),
    var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 28px 70px -24px rgba(0, 0, 0, 0.9);
}
/* The pairing code is read by a phone's own camera app from across a desk, so
   it is deliberately small and low-density — nothing like the data frames. */
.plate.pair-plate { max-width: 240px; margin: 0 auto; padding: 10px; }
.pair-panel .plate.pair-plate { margin-top: 16px; }

#qr-pair, #qr-pair-inline { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.steps {
  margin: 16px 0 0; padding: 0 0 0 18px;
  color: var(--color-foreground-secondary);
  display: flex; flex-direction: column; gap: 6px;
}
.steps li::marker { color: var(--color-foreground-tertiary); font-variant-numeric: tabular-nums; }
.steps b { color: var(--color-foreground); font-weight: 600; }

.pair-url {
  margin: 14px 0 0;
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--color-foreground-tertiary);
  word-break: break-all;
}
.pair-warn {
  margin-top: 10px; padding: 8px 10px;
  color: var(--color-warning);
  border: 1px solid var(--color-warning-line);
  border-radius: var(--radius-sm);
}

/* ── Stage ─────────────────────────────────────────────────────────────── */

.stage {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 28px) calc(64px + env(safe-area-inset-bottom));
}

/* One job at a time. The phase comes from what the link is actually doing,
   not from a mode the reader has to choose first. */
body[data-phase="connect"] .work,
body[data-phase="connect"] .details,
body[data-phase="connect"] .phase-hide-connect { display: none; }
body:not([data-phase="connect"]) #hero-connect { display: none; }

/* Mid-transfer, the drop zone is an invitation to start a second one. */
body[data-phase="active"] #drop { display: none; }

.work { display: flex; flex-direction: column; gap: 24px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.panel { padding: 12px; }
.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 26px;
}
.head-actions { display: flex; gap: 6px; }

/* ── Connect hero ──────────────────────────────────────────────────────── */

.hero { display: flex; flex-direction: column; gap: 10px; }
.hero h1 {
  font-family: var(--font-display); font-size: clamp(21px, 4vw, 26px);
  font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin: 0;
}
.lede {
  margin: 0; max-width: 52ch;
  color: var(--color-foreground-secondary); font-size: 14px; line-height: 1.55;
}

.connect { display: flex; flex-direction: column; gap: 18px; margin-top: 16px; }

/* One primary path, laid out as one object: the code and what to do with it. */
.pair-row { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
.pair-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pair-body .steps { margin: 0; }

/* The secondary path is a line of text with a button on it, not a rival card. */
.connect-alt {
  display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
  padding-top: 4px;
}
.alt-line {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  color: var(--color-foreground-secondary);
}

@media (min-width: 680px) {
  .pair-row { flex-direction: row; align-items: flex-start; gap: 20px; padding: 20px; }
  .pair-row .plate.pair-plate { flex: none; margin: 0; }
  .pair-body { flex: 1; padding-top: 2px; }
}

/* ── Details disclosure ────────────────────────────────────────────────── */

.details { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--color-border); }
.details-toggle {
  appearance: none; background: none; border: 0; padding: 0;
  display: flex; align-items: center; gap: 6px;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--color-foreground-tertiary); cursor: pointer;
  transition: color 0.14s ease;
}
.details-toggle:hover { color: var(--color-foreground-secondary); }
.details-toggle .chev { transition: transform 0.18s var(--ease-snappy); }
.details-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.details-body { display: flex; flex-direction: column; gap: 20px; margin-top: 18px; }

/* Only show the camera panel when this device is actually meant to be reading
   — a dark empty rectangle is not information. */
.mode-send .scan { display: none; }

/* Reading codes makes our own screen the back-channel: it still has to be on
   screen for ACKs, but as a strip rather than a half-empty panel. */
.mode-receive .display { display: flex; align-items: center; gap: 14px; }
.mode-receive .display .head { order: 2; flex: 1; min-height: 0; flex-wrap: wrap; }
.mode-receive .display .plate { order: 1; width: 76px; flex: none; margin: 0; }
.mode-receive .display .readout,
.mode-receive .display .tick { display: none; }
.mode-receive .display .head h2 { display: flex; flex-direction: column; white-space: nowrap; }
.mode-receive .display .head h2::after {
  content: 'back-channel';
  font-family: var(--font-sans); font-size: 11px; font-weight: 400;
  letter-spacing: 0; color: var(--color-foreground-tertiary);
}

/* On the device that is reading, the camera is the job. Put it first and let
   the outgoing side sit under it. */
.mode-receive .work > .instruments { order: 1; }
.mode-receive .work > #sec-payload { order: 2; }
.mode-receive .work > #sec-chat { order: 3; }
.mode-receive .instruments { flex-direction: column-reverse; }

/* ── The transmit plate ────────────────────────────────────────────────── */

.plate {
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  aspect-ratio: 1;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid;
  place-items: center;
  transition: max-width 0.25s var(--ease-snappy);
}
#qr { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

/* One frame leaving is one pulse. It fires and stops — nothing here loops. */
.tick {
  position: absolute; left: 12px; right: 12px; top: 38px;
  height: 1px; background: var(--color-accent);
  opacity: 0; pointer-events: none;
}
.tick.fire { animation: tick 340ms var(--ease-snappy) 1; }
@keyframes tick {
  0% { opacity: 0; transform: scaleX(0.2); }
  35% { opacity: 0.9; }
  100% { opacity: 0; transform: scaleX(1); }
}

/* ── Camera ────────────────────────────────────────────────────────────── */

.viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #000;
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
.hud {
  position: absolute; left: 8px; bottom: 8px; right: 8px;
  display: flex; gap: 6px;
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--color-foreground-secondary);
  pointer-events: none;
}
.hud span {
  background: color-mix(in srgb, var(--color-background) 78%, transparent);
  border: 1px solid var(--color-border);
  padding: 2px 6px; border-radius: var(--radius-xs);
}
.viewport-off {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--color-foreground-tertiary);
  font-family: var(--font-mono); font-size: var(--text-2xs);
}
.viewport.live .viewport-off { display: none; }

.cam-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Readouts ──────────────────────────────────────────────────────────── */

.readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
@media (min-width: 420px) {
  .readout { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.readout > div { background: var(--color-surface-0); padding: 7px 9px; min-width: 0; }
.readout dt {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--color-foreground-tertiary);
}
.readout dd {
  margin: 3px 0 0;
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Controls ──────────────────────────────────────────────────────────── */

.btn {
  appearance: none; font: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  background: var(--color-surface-3);
  color: var(--color-foreground-secondary);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  transition: color 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}
.btn:hover { color: var(--color-foreground); border-color: var(--color-foreground-tertiary); }
a.btn { text-decoration: none; display: inline-block; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  border-color: transparent;
  box-shadow: 0 6px 18px -6px var(--color-accent-glow);
}
.btn-primary:hover { background: var(--color-accent-bright); border-color: transparent; color: #fff; }

.linkbtn {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--color-accent-bright); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--color-foreground-tertiary);
}
.field > span b {
  color: var(--color-foreground); font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}
select, input[type="text"] {
  appearance: none; font: inherit; font-size: 13px; width: 100%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  transition: border-color 0.14s ease;
}
select:focus, input[type="text"]:focus { outline: none; border-color: var(--color-accent-line); }
input[type="range"] { width: 100%; accent-color: var(--color-accent); }

.settings { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .settings { grid-template-columns: 1fr 1fr; } }
.note {
  margin: 0; color: var(--color-foreground-tertiary); font-size: 12px; line-height: 1.55;
}
.settings .note { grid-column: 1 / -1; }

/* ── Payload ───────────────────────────────────────────────────────────── */

.drop {
  padding: 20px 16px; text-align: center;
  color: var(--color-foreground-secondary);
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.drop p { margin: 0; }
.drop p + p { margin-top: 5px; }
.drop.over { border-color: var(--color-accent-line); }

.transfers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.transfers:empty { display: none; }
.tr { padding: 10px 11px; }
.tr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tr-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-dir {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: var(--radius-xs);
  border: 1px solid var(--color-border-strong); color: var(--color-foreground-tertiary);
}
.tr-dir.out { color: var(--color-accent-bright); border-color: var(--color-accent-line); background: var(--color-accent-muted); }
.tr-dir.in { color: var(--color-yes-secondary); border-color: var(--color-yes-line); }
.tr-meta {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--color-foreground-tertiary); margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.bar-track {
  height: 3px; border-radius: 999px; margin: 9px 0 6px;
  background: var(--color-surface-3); overflow: hidden;
}
.bar-fill { height: 100%; width: 0; background: var(--color-accent); transition: width 0.25s var(--ease-snappy); }
.tr.done .bar-fill { background: var(--color-yes); }
.tr.bad .bar-fill { background: var(--color-no); }
/* The chunk map is reference, not progress — the bar above already carries
   that. Kept short and muted so the two do not compete. */
.grid {
  display: block; width: 100%; height: 8px;
  image-rendering: pixelated; border-radius: var(--radius-xs);
  opacity: 0.7;
}
.tr-actions { display: flex; gap: 6px; margin-top: 9px; }
.tr-actions:empty { display: none; }

/* ── Messages ──────────────────────────────────────────────────────────── */

.chat {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 200px; overflow-y: auto;
}
.chat:empty { display: none; }
.chat li {
  max-width: 82%; padding: 6px 10px; border-radius: var(--radius-md);
  word-break: break-word;
}
.chat li.out {
  align-self: flex-end;
  background: var(--color-accent-muted);
  border: 1px solid var(--color-accent-line);
}
.chat li.in {
  align-self: flex-start;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
}
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; }

/* ── Log ───────────────────────────────────────────────────────────────── */

.log {
  list-style: none; margin: 0; padding: 10px 11px;
  font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 1.7;
  max-height: 220px; overflow-y: auto;
}
.log li { display: flex; gap: 10px; color: var(--color-foreground-secondary); }
.log .t { color: var(--color-foreground-tertiary); flex: none; font-variant-numeric: tabular-nums; }
.log .lv { flex: none; width: 30px; font-size: 9px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; padding-top: 3px; }
.log .lv-tx { color: var(--color-accent-bright); }
.log .lv-rx { color: var(--color-warning); }
.log .lv-ok { color: var(--color-yes-secondary); }
.log .lv-err { color: var(--color-no-secondary); }
.log .lv-link { color: var(--color-foreground-tertiary); }

/* ── Fullscreen plate ──────────────────────────────────────────────────── */

.fullscreen {
  position: fixed; inset: 0; z-index: 50;
  background: #fff; display: grid; place-items: center; padding: 16px;
}
#qr-full { width: min(92vw, 92vh); height: min(92vw, 92vh); image-rendering: pixelated; }
.fullscreen .btn {
  position: absolute; top: 16px; right: 16px;
  background: #fff; color: #3f4756; border-color: #d3d7e0;
}
.fullscreen .btn:hover { color: #0a0d15; border-color: #9aa2b2; }

/* ── Desktop ───────────────────────────────────────────────────────────── */

.instruments { display: flex; flex-direction: column; gap: 16px; }

@media (min-width: 760px) {
  /* Two panels side by side only when both are carrying something. */
  .mode-duplex .instruments { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .log, .chat { max-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}
