/* ==========================================================================
   EasyShare design system
   Tokens → base → layout → components → utilities → responsive
   ========================================================================== */

:root {
  /* Brand */
  --brand-50: #e9fff7;
  --brand-100: #c4ffe9;
  --brand-200: #8dfad2;
  --brand-300: #4df0b4;
  --brand-400: #21e09c;
  --brand-500: #0fc584;
  --brand-600: #08a06b;
  --brand-700: #077a53;

  /* Secondary (info / links / data) */
  --sky-300: #7fd8ff;
  --sky-400: #45c4ff;
  --sky-500: #1aa9ee;

  /* Neutrals — deep teal-slate */
  --n-900: #051519;
  --n-850: #071e24;
  --n-800: #0a2831;
  --n-700: #0e3540;
  --n-600: #164953;
  --n-500: #2a6570;
  --n-400: #6f9aa2;
  --n-300: #a8c9cd;
  --n-200: #d3e8e8;
  --n-100: #eef8f7;

  /* Semantic */
  --bg: var(--n-900);
  --bg-elevated: rgba(10, 40, 49, 0.72);
  --bg-sunken: rgba(5, 21, 25, 0.5);
  --surface: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(33, 224, 156, 0.1);
  --surface-active: rgba(33, 224, 156, 0.16);

  --text: #f2fbfa;
  --text-soft: var(--n-200);
  --text-muted: var(--n-300);
  --text-faint: var(--n-400);
  --text-on-brand: #032a20;

  --border: rgba(168, 201, 205, 0.16);
  --border-strong: rgba(77, 240, 180, 0.42);
  --focus: var(--brand-300);

  --success: var(--brand-300);
  --success-bg: rgba(33, 224, 156, 0.12);
  --info: var(--sky-400);
  --info-bg: rgba(69, 196, 255, 0.12);
  --warning: #ffce6a;
  --warning-bg: rgba(255, 206, 106, 0.12);
  --danger: #ff8f83;
  --danger-bg: rgba(255, 143, 131, 0.12);

  /* Spacing scale (4px base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* Radius */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(2, 14, 17, 0.3);
  --sh-2: 0 8px 20px rgba(2, 14, 17, 0.28);
  --sh-3: 0 18px 44px rgba(2, 14, 17, 0.4);
  --sh-brand: 0 10px 26px rgba(15, 197, 132, 0.28);

  /* Type */
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --t-xs: 0.75rem;
  --t-sm: 0.85rem;
  --t-base: 0.95rem;
  --t-md: 1.05rem;
  --t-lg: 1.2rem;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-1: 0.16s;
  --dur-2: 0.26s;
  --dur-3: 0.42s;

  /* Layout */
  --page: 1080px;
  --gutter: clamp(1rem, 4vw, 2rem);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 7.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 620px at 4% -10%, rgba(33, 224, 156, 0.26), transparent 58%),
    radial-gradient(900px 540px at 98% 2%, rgba(69, 196, 255, 0.2), transparent 55%),
    radial-gradient(820px 520px at 50% 108%, rgba(8, 160, 107, 0.16), transparent 60%),
    linear-gradient(170deg, #061b21 0%, var(--n-900) 34%, #072229 68%, #05171c 100%);
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 4.4vw, 2.1rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--t-md);
}

h3 {
  font-size: var(--t-base);
}

p { margin: 0; }

a {
  color: var(--brand-300);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

img, svg, video { max-width: 100%; }

::selection {
  background: rgba(33, 224, 156, 0.28);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

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

.hidden { display: none !important; }
/* Off-screen panels keep their keyframes ticking otherwise, which costs
   battery on phones for animation nobody can see. */
.hidden,
.hidden * { animation-play-state: paused !important; }

/* ---------- App bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(5, 21, 25, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.appbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--sp-3) var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  justify-content: space-between;
  /* The status cluster grows as peers connect; wrapping keeps narrow phones
     from pushing the page into a horizontal scroll. */
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--r-md);
  min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border-strong), var(--sh-2);
}

.logo-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.logo-plate {
  transform-origin: 32px 32px;
  animation: plate-breathe 5s ease-in-out infinite;
  transition: fill var(--dur-2) ease;
}
.logo-node { transform-origin: center; transform-box: fill-box; }
.logo-node-a { animation: node-pulse 2.4s ease-in-out infinite; }
.logo-node-b { animation: node-pulse 2.4s ease-in-out 1.2s infinite; }
.logo-arc { stroke-dasharray: 28 72; animation: arc-flow 2.4s linear infinite; }
.logo-arc-bot { animation-direction: reverse; animation-duration: 3.2s; }

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 15px;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(33, 224, 156, 0.3), rgba(69, 196, 255, 0.1), transparent 72%);
  animation: halo 3.4s ease-in-out infinite;
}
.brand:hover .brand-mark { box-shadow: 0 0 0 1px var(--brand-300), var(--sh-brand); }
.brand:hover .logo-plate { fill: #10404a; }

.brand-word {
  font-family: var(--display);
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-easy { color: var(--text); }
.brand-share { color: var(--brand-300); font-style: italic; }

.appbar-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

/* Narrow phones: shrink the wordmark and let the status cluster take the row */
@media (max-width: 560px) {
  .appbar-inner { gap: var(--sp-2); }
  .brand-mark { width: 32px; height: 32px; }
  .brand-word { font-size: 1.25rem; }
  .appbar-meta { gap: var(--sp-1); }
}
@media (max-width: 400px) {
  .brand-word { font-size: 1.1rem; }
}

/* ---------- Version chip (compact release info) ---------- */

.version-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--t-xs);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease, color var(--dur-1) ease;
}
.version-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.version-chip-num {
  font-family: var(--mono);
  color: var(--brand-300);
}
.version-chip-date { color: var(--text-faint); }
.version-chip-icon {
  width: 1.1rem;
  height: 1.1rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 0.65rem;
  line-height: 1;
}

/* Pairing-sound toggle in the app bar */
.sound-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  min-width: 2.15rem;
  height: 2.15rem;
  min-height: 2.15rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--brand-300);
  cursor: pointer;
  flex: none;
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease, color var(--dur-1) ease;
}
.sound-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.sound-chip[aria-pressed="false"] { color: var(--text-faint); }
.sound-chip-icon { display: grid; place-items: center; }

/* Invite-card sound switch */
.sound-switch {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  cursor: pointer;
  position: relative;
}
.sound-switch:hover { border-color: var(--border-strong); }
.sound-switch-ui {
  position: relative;
  flex: none;
  width: 2.4rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  border-radius: var(--r-pill);
  background: var(--n-600);
  border: 1px solid var(--border-strong);
  transition: background var(--dur-1) ease;
}
.sound-switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #eef8f7;
  transition: transform var(--dur-1) var(--ease);
}
.sound-switch input:checked + .sound-switch-ui {
  background: var(--brand-600);
  border-color: var(--brand-400);
}
.sound-switch input:checked + .sound-switch-ui::after {
  transform: translateX(1.05rem);
}
.sound-switch input:focus-visible + .sound-switch-ui {
  outline: 2px solid var(--brand-300);
  outline-offset: 2px;
}
.sound-switch-copy { display: grid; gap: 0.15rem; min-width: 0; }
.sound-switch-title { font-size: var(--t-sm); font-weight: 600; color: var(--text); }
.sound-switch-help { font-size: var(--t-xs); color: var(--text-muted); line-height: 1.4; }

/* ---------- Connection status ---------- */

.conn-wrap { position: relative; }

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease;
}
.conn-pill:hover { border-color: var(--border-strong); }

/* Signal meter — four bars, filled by measured round-trip grade */
.conn-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.75rem;
}
.conn-bars span {
  width: 3px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.22;
  transition: opacity var(--dur-1) ease, height var(--dur-1) ease;
}
.conn-bars span:nth-child(1) { height: 25%; }
.conn-bars span:nth-child(2) { height: 50%; }
.conn-bars span:nth-child(3) { height: 75%; }
.conn-bars span:nth-child(4) { height: 100%; }
.conn-bars span.is-on { opacity: 1; }

.conn-pill[data-grade='fair'] { color: var(--warning); }
.conn-pill[data-grade='weak'] { color: var(--danger); }

.conn-pill-text { font-variant-numeric: tabular-nums; }

.conn-peers {
  display: inline-grid;
  place-items: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.2rem;
  border-radius: var(--r-pill);
  background: var(--surface-active);
  color: var(--brand-200);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.conn-details-wrap {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  z-index: 50;
  width: min(20rem, calc(100vw - 2rem));
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: #08262e;
  box-shadow: var(--sh-3);
  animation: pop-in var(--dur-2) var(--ease);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.conn-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.conn-details-title {
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.conn-details-close {
  border: 0;
  background: none;
  padding: 0 var(--sp-1);
  color: var(--text-faint);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.conn-details-close:hover { color: var(--text); }
.conn-details { display: grid; gap: 0.15rem; }
.cd-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(168, 201, 205, 0.09);
}
.cd-row:last-child { border-bottom: 0; }
.cd-k { color: var(--text-faint); font-size: var(--t-xs); font-weight: 600; }
.cd-v {
  color: var(--text-soft);
  font-size: var(--t-xs);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cd-v.ok { color: var(--success); }
.cd-v.warn { color: var(--warning); }
.conn-details-foot {
  margin-top: var(--sp-2);
  color: var(--text-faint);
  font-size: 0.68rem;
}
@media (max-width: 620px) {
  .conn-details-wrap { right: calc(-1 * var(--sp-2)); }
}
.conn-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--r-pill);
  background: var(--text-faint);
  flex: none;
}
.conn-pill[data-state='online'] {
  color: var(--success);
  border-color: rgba(77, 240, 180, 0.34);
  background: var(--success-bg);
}
.conn-pill[data-state='online'] .conn-dot { background: var(--success); }
.conn-pill[data-state='connecting'],
.conn-pill[data-state='reconnecting'] {
  color: var(--warning);
  border-color: rgba(255, 206, 106, 0.34);
  background: var(--warning-bg);
}
.conn-pill[data-state='connecting'] .conn-dot,
.conn-pill[data-state='reconnecting'] .conn-dot {
  background: var(--warning);
  animation: pulse-dot 1.1s var(--ease) infinite;
}
.conn-pill[data-state='offline'] {
  color: var(--danger);
  border-color: rgba(255, 143, 131, 0.34);
  background: var(--danger-bg);
}
.conn-pill[data-state='offline'] .conn-dot { background: var(--danger); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.72); }
}

.reconnect-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: var(--page);
  margin: var(--sp-3) auto 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid rgba(255, 206, 106, 0.34);
  border-radius: var(--r-md);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: var(--t-sm);
  font-weight: 600;
  box-shadow: var(--sh-2);
}
.reconnect-text { flex: 1; min-width: 0; }
.reconnect-spinner {
  width: 1rem;
  height: 1rem;
  flex: none;
  border-radius: var(--r-pill);
  border: 2px solid rgba(255, 206, 106, 0.3);
  border-top-color: var(--warning);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .reconnect-spinner { animation-duration: 2.4s; }
  .conn-pill .conn-dot { animation: none; }
}
@media (max-width: 560px) {
  .reconnect-banner {
    margin-inline: var(--gutter);
    flex-wrap: wrap;
  }
}

/* ---------- Identity chip ---------- */

.identity-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 12rem;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-soft);
  font-size: var(--t-xs);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease;
}
.identity-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.identity-avatar {
  display: grid;
  place-items: center;
  color: var(--brand-300);
  flex: none;
}
.identity-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-edit {
  color: var(--text-faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: none;
}
.identity-chip:hover .identity-edit { color: var(--brand-300); }
@media (max-width: 620px) {
  .identity-edit { display: none; }
  .identity-chip { max-width: 8rem; }
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: var(--sp-2);
  color: var(--brand-300);
  font: inherit;
  font-size: var(--t-xs);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--brand-200); }

/* ---------- Layout ---------- */

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.hero {
  padding: var(--sp-6) 0 var(--sp-2);
  display: grid;
  gap: var(--sp-3);
  align-items: start;
  max-width: 46rem;
  transition: opacity var(--dur-2) var(--ease);
}

/* Progressive disclosure: the intro and reference material step aside once the
   user is pairing or actively sharing, so the working area is all that's left.
   Step 2 used to keep the tagline, which pushed the invite/QR below the fold. */
body[data-step='2'] .hero,
body[data-step='3'] .hero,
body[data-step='2'] .learn,
body[data-step='3'] .learn {
  display: none;
}

.hero-copy { display: grid; gap: var(--sp-3); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  align-self: start;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--success-bg);
  color: var(--brand-200);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.eyebrow-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: var(--r-pill);
  background: var(--brand-300);
  box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.2);
}

.tagline {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 5.6vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  max-width: 22ch;
  min-height: 1.1em;
}

.trust {
  color: var(--text-muted);
  font-size: var(--t-md);
  line-height: 1.6;
  max-width: 46ch;
  min-height: 3em;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.has-caret::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 0.14em;
  vertical-align: -0.1em;
  background: var(--brand-300);
  animation: caret 1s steps(1) infinite;
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  backdrop-filter: blur(14px);
  box-shadow: var(--sh-2);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.section-label {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0;
}

.lede {
  color: var(--text-muted);
  margin: 0;
}
.lede.tight { font-size: var(--t-sm); }

.hint {
  color: var(--text-faint);
  font-size: var(--t-sm);
  margin: 0;
}
.hint.tight { font-size: var(--t-xs); }

.subcard {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  background: var(--surface);
  transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) ease;
}
.subcard:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.1);
}

/* ---------- Privacy card ---------- */

.privacy-card {
  background:
    linear-gradient(150deg, rgba(33, 224, 156, 0.12), transparent 46%),
    linear-gradient(330deg, rgba(69, 196, 255, 0.1), transparent 44%),
    var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  backdrop-filter: blur(14px);
  box-shadow: var(--sh-3);
}

.privacy-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.privacy-shield {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(145deg, rgba(33, 224, 156, 0.3), rgba(69, 196, 255, 0.18));
  color: var(--brand-200);
}
.privacy-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.privacy-sub {
  color: var(--text-faint);
  font-size: var(--t-xs);
}

.privacy-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
}
.privacy-points li {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background var(--dur-2) ease, border-color var(--dur-2) ease, transform var(--dur-2) ease;
}
.privacy-points li:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.privacy-icon {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--success-bg);
  color: var(--brand-300);
}
.privacy-points strong {
  display: block;
  font-size: var(--t-base);
  font-weight: 600;
  margin-bottom: 0.1rem;
}
.privacy-points p {
  color: var(--text-muted);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.privacy-note {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--t-xs);
}

/* ---------- Steps ---------- */

.steps {
  position: sticky;
  top: 65px;
  z-index: 20;
  padding: var(--sp-3) 0;
  background: linear-gradient(180deg, rgba(5, 21, 25, 0.9), rgba(5, 21, 25, 0.55) 70%, transparent);
  backdrop-filter: blur(8px);
}
.steps-list {
  list-style: none;
  margin: 0;
  padding: var(--sp-1);
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-1);
}
.step { flex: 1 1 0; min-width: 0; }
.step-btn {
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 600;
  border-radius: var(--r-pill);
  cursor: default;
  transition: color var(--dur-2) ease, background var(--dur-2) ease;
}
.step-btn:not(:disabled) { cursor: pointer; }
.step-btn:not(:disabled):hover { color: var(--text); background: var(--surface); }
.step-num {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 700;
  transition: background var(--dur-2) ease, color var(--dur-2) ease, border-color var(--dur-2) ease, transform var(--dur-2) ease;
}
.step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.step.is-current .step-btn { color: var(--text); background: var(--surface); }
.step.is-current .step-num {
  background: linear-gradient(145deg, var(--brand-200), var(--brand-400));
  border-color: transparent;
  color: var(--text-on-brand);
  box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.18);
  animation: pop var(--dur-3) var(--ease);
}
.step.is-done .step-btn { color: var(--brand-300); }
.step.is-done .step-num {
  background: var(--success-bg);
  border-color: var(--brand-400);
  color: var(--brand-300);
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.6rem;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: var(--t-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--dur-1) ease, background var(--dur-1) ease,
    border-color var(--dur-1) ease, box-shadow var(--dur-1) ease, color var(--dur-1) ease, filter var(--dur-1) ease;
}
.btn:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { --btn-bd: var(--border-strong); --btn-bg: var(--surface-hover); transform: translateY(-1px); }
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn.primary {
  --btn-bg: linear-gradient(135deg, var(--brand-200), var(--brand-400) 46%, var(--brand-500));
  --btn-fg: var(--text-on-brand);
  --btn-bd: transparent;
  box-shadow: var(--sh-brand);
}
@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover { filter: brightness(1.06); --btn-bd: transparent; }
}
.btn.ghost { --btn-bg: transparent; }
.btn.danger { --btn-fg: var(--danger); --btn-bd: rgba(255, 143, 131, 0.35); --btn-bg: var(--danger-bg); }
.btn.sm { min-height: 2.1rem; padding: var(--sp-1) var(--sp-3); font-size: var(--t-sm); }
.btn.block { width: 100%; }
.btn-icon { width: 1.05em; height: 1.05em; flex: 0 0 auto; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* ---------- Forms ---------- */

.field { display: grid; gap: var(--sp-2); }
.field-label {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text-soft);
}
.field-help { color: var(--text-faint); font-size: var(--t-xs); }

.input,
.textarea {
  width: 100%;
  min-width: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-size: var(--t-md);
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease, background var(--dur-1) ease;
}
.input::placeholder,
.textarea::placeholder { color: var(--text-faint); }
.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.14);
  background: rgba(7, 34, 41, 0.7);
}
.textarea { resize: vertical; min-height: 5.5rem; line-height: 1.5; }

.input-code {
  text-align: center;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-family: var(--mono);
  font-size: 1.15rem;
}

.input-group {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}
.input-group .input { flex: 1; }

/* Checkbox rows */
.check-list { display: grid; gap: var(--sp-2); }
.recipient-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--t-base);
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease;
}
.recipient-item:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.recipient-item input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--brand-400);
  flex: 0 0 auto;
}

/* Chips (TTL presets) */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.chip {
  appearance: none;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-1) ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-selected {
  background: var(--success-bg);
  border-color: var(--brand-400);
  color: var(--brand-200);
}

/* ---------- Status / feedback ---------- */

.status {
  margin: 0;
  font-weight: 600;
  font-size: var(--t-base);
  min-height: 1.4em;
  transition: color var(--dur-2) ease;
}
.status.ok { color: var(--success); }
.status.warn { color: var(--warning); }
.status.err { color: var(--danger); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  animation: slide-up var(--dur-2) var(--ease);
}
.alert.is-waiting { border-color: rgba(255, 206, 106, 0.4); background: var(--warning-bg); }
.alert.is-ok { border-color: var(--border-strong); background: var(--success-bg); }
.alert.is-err { border-color: rgba(255, 143, 131, 0.4); background: var(--danger-bg); }

.activity {
  position: sticky;
  top: 120px;
  z-index: 15;
  max-width: var(--page);
  margin: 0 auto var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-2);
  backdrop-filter: blur(12px);
  font-size: var(--t-sm);
  font-weight: 600;
  animation: slide-up var(--dur-2) var(--ease);
}
.activity.is-waiting { border-color: rgba(255, 206, 106, 0.4); color: var(--warning); }
.activity.is-ok { border-color: var(--border-strong); color: var(--brand-200); }

/* Loaders */
.loader-bar {
  height: 3px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, transparent, var(--brand-300), var(--sky-400), transparent);
  background-size: 220% 100%;
  animation: bar-slide 1.2s linear infinite;
}
.boot-loader { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }
.boot-loader.is-done {
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-3) ease;
}
.loader-caption { color: var(--text-faint); font-size: var(--t-sm); }
.loader-dots { display: inline-flex; gap: 0.3rem; align-items: center; flex: 0 0 auto; }
.loader-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: var(--r-pill);
  background: currentColor;
  opacity: 0.35;
  animation: dot 1s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Progress */
.progress {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  width: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--sky-400), var(--brand-200), var(--brand-400));
  background-size: 220% 100%;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--dur-2) ease-out;
}
.progress.is-active .bar { animation: bar-slide 1.4s linear infinite; }
.progress-label {
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--text-muted);
  min-width: 3.2rem;
  text-align: right;
}

/* Empty state */
.empty-state {
  display: grid;
  gap: var(--sp-2);
  justify-items: center;
  text-align: center;
  padding: var(--sp-5) var(--sp-4);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--text-faint);
}
.empty-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
}
.empty-state strong { color: var(--text-soft); font-weight: 600; }
.empty-state p { font-size: var(--t-sm); max-width: 34ch; }

/* ---------- Panels (flow) ---------- */

.shell {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--sp-2) var(--gutter) var(--sp-7);
  display: grid;
  gap: var(--sp-5);
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  backdrop-filter: blur(14px);
  box-shadow: var(--sh-2);
  animation: slide-up var(--dur-3) var(--ease);
}
.panel-head { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.panel-body { display: grid; gap: var(--sp-4); }

.pair-chooser { display: grid; gap: var(--sp-4); }
/* Once an invite exists (or a join is in flight) the chooser is in the way —
   the QR / waiting status should occupy the screen without a manual scroll. */
#pair-panel.is-focused .pair-chooser { display: none; }
#pair-panel.is-focused .panel-head .lede { display: none; }

/* After a device is connected, keep inviting possible without blocking Share. */
#pair-panel.is-sharing {
  padding: var(--sp-3) var(--sp-4);
}
#pair-panel.is-sharing .panel-head { display: none; }
#pair-panel.is-sharing .consent { margin-top: 0; }
#pair-panel.is-sharing .session {
  padding: var(--sp-3);
  gap: var(--sp-2);
}
#pair-panel.is-sharing:not(.is-invite-open) .session .next-step,
#pair-panel.is-sharing:not(.is-invite-open) .session .qr,
#pair-panel.is-sharing:not(.is-invite-open) .session .sound-switch,
#pair-panel.is-sharing:not(.is-invite-open) .session .hint,
#pair-panel.is-sharing:not(.is-invite-open) .session .tech-details,
#pair-panel.is-sharing:not(.is-invite-open) .session .code-actions {
  display: none;
}
#pair-panel.is-sharing:not(.is-invite-open) .code {
  font-size: clamp(1.15rem, 4vw, 1.45rem);
  letter-spacing: 0.12em;
}
#pair-panel.is-sharing .code-label { font-size: 0.68rem; }

.greeting {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-muted);
  font-size: var(--t-sm);
}
.greeting strong { color: var(--brand-200); }

/* Session / invite */
.session {
  display: grid;
  gap: var(--sp-3);
  justify-items: center;
  text-align: center;
  padding: var(--sp-5) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(33, 224, 156, 0.08), transparent 60%), var(--surface);
  /* Clear the sticky app bar + step strip when we scroll this into view. */
  scroll-margin-top: 7.5rem;
}
.code-label {
  color: var(--text-faint);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.code {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 8vw, 2.9rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--brand-200);
  word-break: break-all;
  margin: 0;
}
.ttl { color: var(--text-faint); font-weight: 500; letter-spacing: 0; text-transform: none; }
.qr {
  display: inline-flex;
  padding: var(--sp-3);
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
}
.qr canvas, .qr img { display: block; width: 176px; height: 176px; }

/* Join target */
.join-target {
  display: grid;
  gap: var(--sp-1);
  justify-items: center;
  text-align: center;
  padding: var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--info-bg);
  scroll-margin-top: 7.5rem;
}
.join-target-title {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.join-target-name {
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--sky-300);
}
.join-target-meta { color: var(--text-faint); font-size: var(--t-xs); }
.join-target-meta code { color: var(--text-soft); }

/* Pair status */
.pair-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--dur-2) ease, background var(--dur-2) ease;
}
.pair-status.is-waiting { border-color: rgba(255, 206, 106, 0.4); background: var(--warning-bg); }
.pair-status.is-ok { border-color: var(--border-strong); background: var(--success-bg); }
.pair-status.is-err { border-color: rgba(255, 143, 131, 0.4); background: var(--danger-bg); }

/* Scanner */
.scanner { display: grid; gap: var(--sp-3); scroll-margin-top: 7.5rem; }
.scanner video {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--r-md);
  background: #000;
  border: 1px solid var(--border);
}

/* Consent */
.consent {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  background: var(--success-bg);
  animation: slide-up var(--dur-2) var(--ease);
  scroll-margin-top: 7.5rem;
}
.consent.is-attention { animation: slide-up var(--dur-2) var(--ease), attention 2s ease-in-out infinite; }
.consent-head { display: grid; gap: 0.15rem; }
.consent-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.consent-item {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  animation: slide-up var(--dur-2) var(--ease);
}
.consent-info { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; min-width: 0; }
.consent-from-id { color: var(--text-faint); font-size: var(--t-xs); }
.consent-timer { color: var(--warning); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.consent-actions { display: flex; gap: var(--sp-2); }

/* Session invite loader */
.session-loader { display: grid; gap: var(--sp-2); }

/* Paired celebration — a single sweep the first time a device links up */
.paired-burst {
  height: 0;
  position: relative;
}
.paired-burst.is-on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, transparent, var(--brand-300), var(--accent), transparent);
  animation: paired-sweep 1.3s var(--ease);
}
@keyframes paired-sweep {
  0% { opacity: 0; transform: scaleX(0.2); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: scaleX(1); }
}
.transfer-panel-paired { animation: paired-glow 1.8s var(--ease); }
.status.is-flash { animation: flash 1.2s var(--ease) 2; }

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

.xfer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  justify-content: space-between;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.xfer-head-main { display: grid; gap: var(--sp-1); min-width: 0; }
.peer-line { color: var(--text-faint); font-size: var(--t-xs); }
.peer-roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.peer-roster li {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.2rem var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--t-xs);
  color: var(--text-muted);
}
.peer-roster li::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: var(--r-pill);
  background: var(--warning);
}
.peer-roster li.ok { color: var(--brand-200); border-color: var(--border-strong); }
.peer-roster li.ok::before { background: var(--brand-300); box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.18); }

.peer-roster .peer-name { font-weight: 600; }
.peer-roster .peer-state { color: var(--text-faint); }
.peer-roster .peer-state::before { content: "· "; }

/* Live per-device link quality, refreshed once a second from WebRTC stats */
.peer-roster .peer-live:empty { display: none; }
.peer-roster .peer-live {
  padding: 0.05rem 0.4rem;
  border-radius: var(--r-sm);
  background: var(--surface-active);
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.peer-roster .peer-live[data-path='direct'] { color: var(--success); }
.peer-roster .peer-live[data-path='relayed'] { color: var(--warning); }

.share-workspace { display: grid; gap: var(--sp-4); }
@media (min-width: 860px) {
  .share-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

.compose-card, .feed-card { min-width: 0; display: grid; gap: var(--sp-4); align-content: start; }

.file-drop {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--success-bg);
  cursor: pointer;
  transition: border-color var(--dur-2) ease, background var(--dur-2) ease, transform var(--dur-2) ease;
}
.file-drop:hover { background: var(--surface-active); }
.file-drop.is-dragover { transform: scale(1.01); border-color: var(--brand-200); background: var(--surface-active); }
.file-drop-icon {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--brand-300);
}
.file-drop-text { display: grid; gap: 0.1rem; min-width: 0; }
.file-drop-title { font-weight: 600; }
#btn-clear-files { justify-self: start; }
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-faint);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Item feed */
.item-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.item-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  background: var(--surface);
  display: grid;
  gap: var(--sp-3);
  animation: slide-up var(--dur-2) var(--ease);
  transition: border-color var(--dur-2) ease;
}
.item-card:hover { border-color: var(--border-strong); }
.item-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
}
.item-kind {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-on-brand);
  background: linear-gradient(135deg, var(--brand-200), var(--brand-400));
  border-radius: var(--r-pill);
  padding: 0.15rem var(--sp-2);
}
.item-from { color: var(--text-faint); font-size: var(--t-xs); }
.item-card-body {
  color: var(--text-soft);
  font-size: var(--t-base);
  white-space: pre-wrap;
  word-break: break-word;
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  max-height: 12rem;
  overflow: auto;
}
.item-status-badges { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.status-badge {
  font-size: var(--t-xs);
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 0.15rem var(--sp-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
  background: var(--surface);
}
.status-badge.status-sending { color: var(--warning); border-color: rgba(255, 206, 106, 0.4); background: var(--warning-bg); }
.status-badge.status-sent { color: var(--brand-200); border-color: var(--border-strong); background: var(--success-bg); }
.status-badge.status-received { color: var(--sky-300); border-color: rgba(69, 196, 255, 0.4); background: var(--info-bg); }
.status-badge.status-downloaded {
  color: var(--text-on-brand);
  background: linear-gradient(135deg, var(--brand-200), var(--brand-500));
  border-color: transparent;
}
.status-badge.status-error { color: var(--danger); border-color: rgba(255, 143, 131, 0.4); background: var(--danger-bg); }
.status-badge.status-paused {
  color: var(--warning);
  border-color: rgba(255, 206, 106, 0.4);
  background: var(--warning-bg);
}
.peer-roster li.warn { color: var(--warning); }
.peer-roster li.warn::before { background: var(--warning); }
.item-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.item-actions .btn { min-height: 2.1rem; padding: var(--sp-1) var(--sp-3); font-size: var(--t-sm); }

/* ---------- Learn section (collapsed reference material) ---------- */

.learn {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}
.learn-title {
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: var(--sp-1);
}

.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--dur-1) ease, background var(--dur-1) ease;
}
.disclosure[open] {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.disclosure-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  list-style: none;
  min-height: 3rem;
}
.disclosure-summary::-webkit-details-marker { display: none; }
.disclosure-summary:hover { background: var(--surface-hover); }
.disclosure-summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.disclosure-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--brand-300);
}
.disclosure-label {
  display: grid;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}
.disclosure-label strong {
  font-size: var(--t-base);
  color: var(--text);
}
.disclosure-label span {
  font-size: var(--t-sm);
  color: var(--text-muted);
}
.disclosure-chevron {
  display: grid;
  place-items: center;
  color: var(--text-faint);
  flex: none;
  transition: transform var(--dur-2) var(--ease);
}
.disclosure[open] .disclosure-chevron { transform: rotate(180deg); }
.disclosure-body {
  padding: 0 var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
}

.faq { display: grid; gap: var(--sp-3); margin: 0; }
.faq dt {
  font-weight: 600;
  color: var(--text);
  font-size: var(--t-base);
}
.faq dd {
  margin: var(--sp-1) 0 0;
  color: var(--text-muted);
  font-size: var(--t-sm);
  line-height: 1.6;
}

/* Compact inline disclosure used inside panels for optional settings */
.inline-disclosure {
  margin-top: var(--sp-3);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}
.inline-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  cursor: pointer;
  list-style: none;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text-muted);
  min-height: 2rem;
}
.inline-disclosure > summary::-webkit-details-marker { display: none; }
.inline-disclosure > summary:hover { color: var(--text); }
.inline-disclosure-value {
  color: var(--brand-300);
  font-family: var(--mono);
  font-size: var(--t-xs);
}
.inline-disclosure[open] > summary { margin-bottom: var(--sp-3); }

/* ---------- Showcase ---------- */

.showcase { display: grid; gap: var(--sp-4); }
.showcase-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.4rem, 3.6vw, 1.9rem);
}
.showcase-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .showcase-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .showcase-grid { grid-template-columns: repeat(2, 1fr); } }
.showcase-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: transform var(--dur-2) ease, border-color var(--dur-2) ease, box-shadow var(--dur-2) ease;
}
@media (hover: hover) and (pointer: fine) {
  .showcase-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--sh-2); }
}
.showcase-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 280 / 160;
  background: var(--n-800);
}
.showcase-card figcaption { display: grid; gap: 0.15rem; padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.showcase-card figcaption strong { font-size: var(--t-base); font-weight: 600; }
.showcase-card figcaption span { color: var(--text-muted); font-size: var(--t-sm); line-height: 1.45; }

/* ---------- Release notes (compact) ---------- */

.release-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-sm);
}
.release-strip-label {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.release-strip-version {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--brand-200);
}
.release-strip-date { color: var(--text-muted); }
.release-strip .btn { margin-left: auto; }

.release-strip-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}
.release-strip-inline .release-strip-label { letter-spacing: 0.06em; }

/* Dialog */
dialog.modal {
  width: min(560px, calc(100vw - 2rem));
  max-height: min(80vh, 720px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: #08262e;
  color: var(--text);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
dialog.modal::backdrop {
  background: rgba(3, 14, 17, 0.7);
  backdrop-filter: blur(4px);
}
dialog.modal[open] { animation: modal-in var(--dur-2) var(--ease); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--t-md); font-weight: 600; }
.modal-close {
  appearance: none;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: all var(--dur-1) ease;
}
.modal-close:hover { color: var(--text); border-color: var(--border-strong); }
.modal-body {
  padding: var(--sp-4);
  overflow-y: auto;
  max-height: calc(80vh - 4.5rem);
  display: grid;
  gap: var(--sp-2);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
}
.confirm-modal { max-width: 26rem; }
.confirm-text { color: var(--text-soft); font-size: var(--t-sm); line-height: 1.55; }

/* ---------- Invite code actions, next steps, toasts ---------- */

.code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
  margin-bottom: var(--sp-3);
}
.btn-icon { display: inline-flex; margin-right: 0.35rem; }

.next-step {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
}
.next-step-title {
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-300);
  margin-bottom: var(--sp-2);
}
.next-step-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
  color: var(--text-soft);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.next-step-list strong { color: var(--text); word-break: break-all; }

.card-sub {
  color: var(--text-faint);
  font-size: var(--t-sm);
  margin-top: 0.15rem;
}

/* Internal identifiers stay available but out of the main flow */
.tech-details {
  margin-top: var(--sp-2);
  font-size: var(--t-xs);
  color: var(--text-faint);
}
.tech-details > summary {
  cursor: pointer;
  list-style: none;
  color: var(--text-faint);
  padding: 0.2rem 0;
}
.tech-details > summary::-webkit-details-marker { display: none; }
.tech-details > summary:hover { color: var(--text-muted); }
.tech-details p { margin-top: var(--sp-1); }
.tech-details code { font-family: var(--mono); }

/* Confirmation that a newly paired link is encrypted — a real dialog, not a
   toast at the bottom of the screen that can sit under other notices. */
.secure-modal {
  width: min(26rem, calc(100vw - 2rem));
  max-width: 26rem;
  text-align: center;
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-color: rgba(77, 240, 180, 0.5);
  background: linear-gradient(180deg, rgba(33, 224, 156, 0.16), #08262e 42%);
}
.secure-modal-icon {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto var(--sp-3);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(33, 224, 156, 0.16);
  color: var(--success);
  box-shadow: 0 0 0 6px rgba(33, 224, 156, 0.08);
}
.secure-modal .modal-title {
  font-size: var(--t-lg, 1.25rem);
  font-weight: 700;
  color: var(--brand-200);
}
.secure-modal-lead {
  margin: var(--sp-2) 0 0;
  color: var(--text);
  font-size: var(--t-base);
}
.secure-modal-lead strong { color: var(--brand-200); }
.secure-modal-copy {
  margin: var(--sp-2) 0 0;
  color: var(--text-soft);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.secure-modal .modal-foot {
  border: 0;
  justify-content: center;
  padding: var(--sp-4) 0 0;
}
/* Fallback when <dialog>.showModal is missing or rejected */
dialog.secure-modal.is-fallback {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  margin: 0;
  display: grid;
  z-index: 200;
}
body.secure-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(3, 14, 17, 0.7);
  backdrop-filter: blur(4px);
  z-index: 199;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: var(--sp-2);
  width: max-content;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: #08262e;
  color: var(--text);
  font-size: var(--t-sm);
  font-weight: 600;
  box-shadow: var(--sh-3);
  animation: toast-in var(--dur-2) var(--ease);
}
.toast.is-ok { border-color: rgba(77, 240, 180, 0.4); color: var(--success); }
.toast.is-err { border-color: rgba(255, 138, 138, 0.4); color: var(--danger); }
.toast.is-out { animation: toast-out var(--dur-2) var(--ease) forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(10px); }
}

.release-item { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.release-item.is-latest { border-color: var(--border-strong); background: var(--success-bg); }
.release-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.release-version { font-family: var(--mono); font-weight: 700; font-size: var(--t-sm); color: var(--brand-200); }
.release-meta-wrap { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.release-title { font-size: var(--t-base); font-weight: 600; }
.release-meta { color: var(--text-faint); font-size: var(--t-xs); }
.release-latest-pill {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-on-brand);
  background: var(--brand-300);
  border-radius: var(--r-pill);
  padding: 0.12rem var(--sp-2);
}
.release-chevron {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg);
  transition: transform var(--dur-2) ease;
}
.release-item.is-open .release-chevron { transform: rotate(-135deg); }
.release-body { padding: 0 var(--sp-4) var(--sp-4); }
.release-notes {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-soft);
  font-size: var(--t-sm);
  line-height: 1.55;
}
.release-notes li { margin: 0.25rem 0; }

/* ---------- Footer ---------- */

.foot {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--sp-4) var(--gutter) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: center;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: var(--t-xs);
}
.foot-conn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--mono);
}

/* ---------- Animations ---------- */

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}
@keyframes bar-slide {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes caret {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes paired-glow {
  0% { box-shadow: var(--sh-2); }
  35% { box-shadow: 0 0 0 3px rgba(33, 224, 156, 0.28), var(--sh-3); }
  100% { box-shadow: var(--sh-2); }
}
@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(33, 224, 156, 0); }
  50% { box-shadow: 0 0 0 6px rgba(33, 224, 156, 0.12); }
}
@keyframes plate-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
@keyframes node-pulse {
  0%, 100% { opacity: 0.88; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}
@keyframes arc-flow { to { stroke-dashoffset: -100; } }
@keyframes halo {
  0%, 100% { opacity: 0.4; transform: scale(0.96); }
  50% { opacity: 0.9; transform: scale(1.05); }
}

/* ---------- Responsive ---------- */

/* Phones */
@media (max-width: 599px) {
  .appbar-inner { padding: var(--sp-2) var(--gutter); }
  .brand-word { font-size: 1.35rem; }
  .brand-mark { width: 34px; height: 34px; }
  .steps { top: 57px; }
  .activity { top: 108px; }
  .panel { padding: var(--sp-4); border-radius: var(--r-lg); }
  /* Keep the step names on phones — "1 2 3" alone tells the user nothing.
     Only the inactive labels collapse, so the current step stays readable. */
  .step-label { font-size: 0.68rem; }
  .step:not(.is-current) .step-label { display: none; }
  .step-btn { justify-content: center; gap: var(--sp-1); }
  .input-group { flex-direction: column; }
  .input-group .btn { width: 100%; }
  .xfer-head { flex-direction: column; align-items: stretch; }
  .xfer-head .btn { width: 100%; }
  .release-strip .btn { margin-left: 0; width: 100%; }
  .version-chip-date { display: none; }
}

/* Tablets */
@media (min-width: 600px) and (max-width: 859px) {
  .share-workspace { grid-template-columns: 1fr; }
}

/* Large screens & TV */
@media (min-width: 1280px) {
  :root { --t-base: 1rem; --t-md: 1.1rem; }
  .btn { min-height: 2.85rem; }
  .step-btn { min-height: 3rem; }
}

/* Touch / TV pointers */
@media (pointer: coarse) {
  #clip-send-hint { display: none; }
  .btn, .chip, .step-btn, .modal-close, .sound-chip { min-height: 2.75rem; }
  .sound-chip { min-width: 2.75rem; width: 2.75rem; }
  .input, .textarea { font-size: 16px; }
  .privacy-points li:hover,
  .showcase-card:hover { transform: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .loader-bar { animation: none; background: var(--brand-400); opacity: 0.7; }
  .loader-dots span { animation: none; opacity: 0.7; }
  .logo-packet, .logo-packet-delay { display: none; }
  .has-caret::after { animation: none; opacity: 1; }
}

/* High contrast */
@media (prefers-contrast: more) {
  :root {
    --border: rgba(210, 235, 235, 0.4);
    --text-muted: var(--n-200);
    --text-faint: var(--n-300);
  }
}
