/* EsyShare — single shared stylesheet for both pages.
   Design system: token-driven (CSS custom properties), automatic dark mode,
   sharp 2px geometry, flat surfaces, a single corporate blue accent.
   System font stack only — the UI ships zero third-party assets and the
   CSP only allows same-origin styles. */

/* ============ TOKENS ============ */
:root {
  --bg: #f3f4f7;

  --surface: #ffffff;   /* card */
  --surface-2: #f8f9fb; /* nested panels */
  --surface-3: #eef0f4; /* control tracks, chips */
  --border: #dcdfe6;
  --border-strong: #c3c8d4;

  --text: #16181d;
  --text-2: #4b5162;
  --text-3: #7d8394;

  --accent-fg: #1d4ed8;             /* accent as text/icon on surfaces */
  --accent-bg: #1d4ed8;             /* accent as solid fill */
  --accent-bg-hover: #1a44be;
  --accent-soft: #eef3fe;
  --accent-soft-hover: #e2ebfd;
  --accent-soft-border: #d3e0fb;
  --ring: rgba(29, 78, 216, 0.4);

  --ok: #067647;
  --ok-bg: #eefbf4;
  --ok-border: #c8ecd9;
  --ok-dot: #17b26a;
  --warn: #955d0a;
  --warn-bg: #fdf6e7;
  --warn-border: #f3e2bb;
  --warn-dot: #e79008;
  --danger: #b42318;
  --danger-bg: #fdf0ef;
  --danger-border: #f5cecb;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.07);

  --r: 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;

    --surface: #15181d;
    --surface-2: #1a1e24;
    --surface-3: #21262e;
    --border: #2a2f39;
    --border-strong: #3a4150;

    --text: #e8eaef;
    --text-2: #a5abb8;
    --text-3: #6f7684;

    --accent-fg: #85a8ff;
    --accent-bg: #2456e0;
    --accent-bg-hover: #2e61ee;
    --accent-soft: rgba(84, 128, 240, 0.14);
    --accent-soft-hover: rgba(84, 128, 240, 0.22);
    --accent-soft-border: rgba(112, 148, 240, 0.32);
    --ring: rgba(133, 168, 255, 0.45);

    --ok: #47cd89;
    --ok-bg: rgba(23, 178, 106, 0.12);
    --ok-border: rgba(23, 178, 106, 0.35);
    --ok-dot: #47cd89;
    --warn: #f5c04e;
    --warn-bg: rgba(247, 144, 9, 0.12);
    --warn-border: rgba(247, 144, 9, 0.35);
    --warn-dot: #f5c04e;
    --danger: #f97066;
    --danger-bg: rgba(240, 68, 56, 0.12);
    --danger-border: rgba(240, 68, 56, 0.35);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

/* ============ BASE ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* JS toggles visibility via the hidden attribute; make sure no display
   rule can accidentally override it. */
[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 28px 14px 22px;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent-bg);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  text-align: center;
  max-width: 560px;
  width: 100%;
  padding: 30px 30px 24px;
}

/* ============ HEADER ============ */
.app-header {
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--accent-bg);
}

.brand-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.subtitle {
  font-size: 13.5px;
  color: var(--text-2);
  margin-top: 6px;
  text-wrap: balance;
}

.trust-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin-top: 12px;
}

.trust-badges li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px 9px;
}

.trust-badges svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: var(--text-3);
}

/* ============ MODE BAR ============ */
.mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 2px 0 4px;
}

.mode-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}

.mode-option {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-option + .mode-option {
  border-left: 1px solid var(--border-strong);
}

.mode-option:hover:not(.active):not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.mode-option.active {
  background: var(--accent-bg);
  color: #fff;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
}

.mode-toggle:hover:not(:disabled) {
  background: var(--surface-2);
}

.mode-toggle-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
  font-size: 11.5px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.mode-toggle-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.mode-toggle.off .mode-toggle-state {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-2);
}

.mode-toggle.off .mode-toggle-state::before {
  background: var(--text-3);
}

.mode-option:disabled,
.mode-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ============ SECURITY VERIFICATION (Secure mode) ============ */
.security-panel {
  margin: 12px 0 4px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: center;
}

.security-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 8px;
}

.security-head svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--accent-fg);
}

.security-hint {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.security-code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  margin-bottom: 12px;
  word-break: break-all;
}

.security-code.verified {
  color: var(--ok);
}

.security-code.mismatch {
  color: var(--danger);
}

.security-confirm {
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-bg);
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
}

.security-confirm:hover {
  background: var(--accent-bg-hover);
}

.security-reject {
  margin-left: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger-border);
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
}

.security-reject:hover {
  background: var(--danger-bg);
}

/* ============ FOCUS & MOTION ============ */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* The real file input is visually hidden; surface its keyboard focus on
   the styled label that follows it. */
input[type="file"]:focus-visible + .file-input-label {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

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

/* ============ PHASE VISIBILITY (UI_req §7) ============ */
/* Coarse layout is a pure function of body[data-phase]; render() only stamps
   the attribute. Pairing shows while waiting; the transfer UI shows from the
   securing handshake onward (Send stays gated by JS until ready). */
.pairing,
.transfer {
  display: none;
  animation: fade-in 0.2s ease-out both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

[data-phase="waiting"] .pairing {
  display: block;
}

[data-phase="securing"] .transfer,
[data-phase="ready"] .transfer,
[data-phase="reconnecting"] .transfer {
  display: block;
}

/* Broadcast: pairing stays on screen after connect so more devices can keep
   scanning (§10.10)... */
[data-phase="securing"][data-mode="broadcast"] .pairing,
[data-phase="ready"][data-mode="broadcast"] .pairing,
[data-phase="reconnecting"][data-mode="broadcast"] .pairing {
  display: block;
}

/* ...but the typed-code path is QR-only there: ECDH keys are pairwise and
   cannot fan out (§12.1.2). */
[data-mode="broadcast"] .pair-code-block,
[data-mode="broadcast"] .join-section,
[data-mode="broadcast"] .divider {
  display: none;
}

/* Mode bar and countdown are meaningless before init completes or once the
   session is gone (UI-9/§12.4). */
[data-phase="init"] .session-expiry,
[data-phase="expired"] .session-expiry,
[data-phase="error"] .session-expiry,
[data-phase="expired"] .mode-bar,
[data-phase="error"] .mode-bar {
  display: none;
}

/* ============ STATUS (connection banner + toast) ============ */
.status {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 1px solid var(--border);
}

.status::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status.connecting {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.status.connecting::before {
  background: var(--warn-dot);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.status.connected,
.status.success {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.status.connected::before,
.status.success::before {
  background: var(--ok-dot);
}

.status.error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.status.error::before {
  background: var(--danger);
}

/* Transient transfer feedback; shares the .status palette, sits below the
   persistent connection banner and never overwrites it (UI-4). */
.toast {
  margin: 8px 0 0;
  padding: 7px 12px;
  font-size: 12.5px;
}

.session-expiry {
  font-size: 12px;
  color: var(--text-3);
  min-height: 16px;
  margin-top: 8px;
}

/* ============ PAIRING PANEL ============ */
.panel-title {
  margin-top: 18px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}

.qr-code {
  margin: 12px auto 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 264px;
  max-width: 288px;
  background: #fff; /* QR needs a light quiet zone, even in dark mode */
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
}

.qr-code img,
.qr-code canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.qr-placeholder {
  color: #7d8394;
  font-size: 14px;
}

.qr-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
}

/* ============ PAIRING CODE (OTP) ============ */
.pair-code-block {
  margin-top: 16px;
}

.pair-code-hint {
  font-size: 13px;
  color: var(--text-2);
}

.pair-code {
  margin: 10px auto 0;
  width: fit-content;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 7px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  padding: 7px 13px 7px 20px; /* extra left offsets trailing letter-spacing */
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
}

/* Demoted: secondary "remote device" path, quieter than QR / pairing code. */
.remote-share {
  margin: 12px auto 0;
  text-align: center;
}

.link-btn {
  padding: 4px 6px;
  background: none;
  border: none;
  color: var(--accent-fg);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

.remote-share-note {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
}

/* ============ DIVIDER ============ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============ JOIN BY CODE ============ */
.join-section {
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: center;
}

.join-hint {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.join-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.join-input {
  flex: 1 1 auto;
  max-width: 190px;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  transition: border-color 0.15s;
}

.join-input::placeholder {
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: normal;
}

.join-input:focus {
  border-color: var(--accent-bg);
}

.join-btn {
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-bg);
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
}

.join-btn:hover {
  background: var(--accent-bg-hover);
}

.join-error {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
}

/* ============ FILE UPLOAD ============ */
.file-upload-section {
  margin: 16px 0 0;
  padding: 24px 20px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.file-upload-section.dragover {
  border-color: var(--accent-bg);
  background: var(--accent-soft);
}

.upload-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.upload-icon svg {
  width: 22px;
  height: 22px;
}

.upload-label {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
}

.upload-hint {
  color: var(--text-3);
  font-size: 12.5px;
  margin-bottom: 14px;
}

input[type="file"] {
  /* Visually hidden but still focusable for keyboard users. */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.file-input-label {
  display: inline-block;
  padding: 8px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s;
}

.file-input-label:hover {
  background: var(--surface-3);
}

.selected-file {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  max-height: 210px;
  overflow-y: auto;
}

.selected-file-item {
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto; /* icon | meta | remove */
  gap: 10px;
  align-items: center;
  text-align: left;
}

.selected-file-item + .selected-file-item {
  border-top: 1px solid var(--border);
}

.selected-file-item::before {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.selected-file-item > div {
  min-width: 0; /* let the filename ellipsis inside the grid track */
}

.selected-file-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

.selected-file-size {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
}

.icon-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.send-btn {
  margin-top: 16px;
  width: 100%;
  padding: 11px 20px;
  background: var(--accent-bg);
  color: white;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-bg-hover);
}

.send-btn:disabled {
  background: var(--surface-3);
  color: var(--text-3);
  border-color: var(--border);
  cursor: not-allowed;
}

/* ============ PROGRESS BAR ============ */
.upload-progress {
  margin: 14px 0 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 13px;
}

#progress-filename {
  color: var(--text);
  font-weight: 600;
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#progress-percent {
  color: var(--accent-fg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-bg);
  transition: width 0.15s ease-out;
}

.progress-status {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ============ RECEIVED FILES ============ */
.received-file-container {
  margin-top: 16px;
  padding: 14px 16px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: left;
}

.received-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
  gap: 8px;
}

.received-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: normal;
  font-variant-numeric: tabular-nums;
}

.received-actions {
  display: flex;
  gap: 6px;
}

.download-all-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.download-all-btn:hover {
  background: var(--surface-3);
}

.received-empty {
  font-size: 13px;
  color: var(--text-3);
  padding: 10px 0 4px;
  text-align: center;
}

.received-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.received-file-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto; /* icon | name | size | actions */
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color 0.15s;
}

.received-file-item:hover {
  border-color: var(--border-strong);
}

.received-file-item::before {
  content: "";
  width: 18px;
  height: 18px;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.received-file-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.received-file-size {
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--r);
  white-space: nowrap;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Broadcast source tag ("Device 3f2a") on received entries. */
.received-file-source {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  padding: 1px 7px;
  border-radius: var(--r);
  white-space: nowrap;
}

.received-file-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.received-file-actions a,
.received-file-actions .preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--r);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
}

.received-file-actions a {
  color: #fff;
  background: var(--accent-bg);
}

.received-file-actions a:hover {
  background: var(--accent-bg-hover);
}

.received-file-actions .preview-btn {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-strong);
}

.received-file-actions .preview-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* ============ SCROLLBARS ============ */
.selected-file::-webkit-scrollbar,
.received-file-list::-webkit-scrollbar {
  width: 8px;
}

.selected-file::-webkit-scrollbar-track,
.received-file-list::-webkit-scrollbar-track {
  background: transparent;
}

.selected-file::-webkit-scrollbar-thumb,
.received-file-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r);
}

/* ============ INFO FOOTER ============ */
.info {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-2);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--r);
}

.info-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 8px;
}

.info ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  counter-reset: step;
}

.info li {
  counter-increment: step;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.45;
}

.info li::before {
  content: counter(step) ".";
  flex: none;
  min-width: 14px;
  color: var(--text-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.page-foot {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ============ SMALL SCREENS ============ */
@media (max-width: 480px) {
  body {
    padding: 14px 10px 16px;
  }

  .container {
    padding: 24px 18px 18px;
  }

  .brand-name {
    font-size: 22px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .received-file-item {
    grid-template-columns: auto 1fr auto; /* icon | name | actions */
  }

  .received-file-size {
    display: none;
  }
}
