/* LinkDrop desktop UI — guided flow, monochrome design system.
   Hierarchy comes from layered surfaces: page < nested panel < card < raised. */

:root {
  color-scheme: dark;

  /* surfaces (darkest → lightest) */
  --bg: #090909; /* page */
  --input: #0d0d0d; /* fields sit below the card they are in */
  --nested: #111111; /* panels inside cards */
  --card: #161616; /* main cards */
  --raised: #1f1f1f; /* hover / selected rows */
  --raised-2: #262626;

  /* lines */
  --line: #292929;
  --line-strong: #3a3a3a;
  --line-hover: #4d4d4d;

  /* text */
  --text: #f5f5f5;
  --text-2: #a3a3a3;
  --text-3: #777777;

  /* one accent (white) + restrained status colours */
  --accent: #fafafa;
  --accent-ink: #0a0a0a;
  --accent-hover: #d9d9d9;
  --ok: #86d6a6;
  --ok-bg: rgb(134 214 166 / 0.1);
  --ok-line: rgb(134 214 166 / 0.35);
  --warn: #e8e8e8;
  --err: #f28b8b;
  --err-bg: rgb(242 139 139 / 0.1);
  --err-line: rgb(242 139 139 / 0.35);

  /* spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* layout */
  --shell: 1120px;
  --page-pad: var(--s-6);
  --gap: var(--s-4);
  --card-pad: var(--s-5);
  --topbar-h: 64px;

  /* shape */
  --r-card: 16px;
  --r-item: 12px;
  --r-ctl: 10px;
  --r-pill: 999px;

  /* controls */
  --ctl-h: 40px;
  --ctl-h-sm: 32px;

  /* type */
  --font: Inter, "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Ubuntu Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-display: 34px;
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 0;
  font: var(--fs-md) / 1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgb(255 255 255 / 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(255 255 255 / 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, #000 20%, transparent 100%);
}

h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}

button,
input {
  font: inherit;
}

.icon {
  flex: none;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.meta {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

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

/* ================= header ================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgb(9 9 9 / 0.85);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--page-pad); /* full width: Settings sits in the real top-right corner */
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  justify-self: start;
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-ctl);
  background: var(--accent);
  color: var(--accent-ink);
}

.topbar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  min-width: 0;
}

.self-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 220px;
  min-width: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.self-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.self-chip .dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: var(--ctl-h);
  height: var(--ctl-h);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.icon-btn:hover {
  border-color: var(--line-hover);
  background: var(--raised);
}

.icon-btn.small {
  width: var(--ctl-h-sm);
  height: var(--ctl-h-sm);
  border-color: transparent;
  background: transparent;
  color: var(--text-3);
}

.icon-btn.small:hover {
  color: var(--text);
}

/* stepper */
.stepper ol {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
}

.step + .step::before {
  content: "";
  width: 28px;
  height: 1px;
  margin: 0 var(--s-1);
  background: var(--line-strong);
}

.step-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--ctl-h-sm);
  padding: 0 var(--s-3) 0 var(--s-1);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: nowrap;
  cursor: pointer;
}

.step-btn:disabled {
  cursor: default;
}

.step-btn:not(:disabled):hover {
  color: var(--text);
}

.step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 11px;
}

.step[data-state="current"] .step-btn {
  border-color: var(--line-strong);
  background: var(--card);
  color: var(--text);
}

.step[data-state="current"] .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.step[data-state="done"] .step-btn,
.step[data-state="available"] .step-btn {
  color: var(--text-2);
}

.step[data-state="done"] .step-num {
  border-color: var(--ok-line);
  color: var(--ok);
}

.step[data-state="skipped"] .step-num {
  border-style: dashed;
}

.step-compact {
  display: none;
}

.tab .short {
  display: none;
}

/* ================= shell + stage ================= */

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

.stage {
  display: grid;
  gap: var(--s-5);
}

.stage-head {
  display: grid;
  gap: var(--s-2);
  max-width: 720px;
}

.stage-head h1 {
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  outline: none;
}

.lead {
  color: var(--text-2);
  font-size: var(--fs-lg);
}

.eyebrow {
  justify-self: start;
  padding: 3px var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.01em;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: var(--s-2);
  height: var(--ctl-h-sm);
  margin-bottom: var(--s-2);
  padding: 0 var(--s-3) 0 var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.back-btn:hover {
  border-color: var(--line-hover);
  color: var(--text);
}

/* ================= panels / cards ================= */

.panel {
  min-width: 0;
  padding: var(--card-pad);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
}

.panel-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.actions.end {
  justify-content: flex-end;
}

/* ================= buttons ================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--ctl-h);
  padding: 0 var(--s-5);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--line-hover);
  background: var(--raised);
}

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

.btn.small {
  height: var(--ctl-h-sm);
  padding: 0 var(--s-4);
  font-size: var(--fs-sm);
}

.btn.block {
  width: 100%;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

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

.btn.primary:disabled {
  border-color: var(--raised-2);
  background: var(--raised-2);
  color: var(--text-3);
}

.btn.danger {
  border-color: var(--err-line);
  color: var(--err);
}

.btn.danger:hover:not(:disabled) {
  border-color: var(--err);
  background: var(--err-bg);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-decoration: underline;
  text-decoration-color: var(--line-hover);
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

:is(.btn, .icon-btn, .link-btn, .back-btn, .step-btn, .tab, .device, .choice, .session-pill, summary):focus-visible,
.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ================= badges, dots, progress ================= */

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge[data-tone="ok"] {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  color: var(--ok);
}

.badge[data-tone="warn"] {
  border-style: dashed;
  color: var(--warn);
}

.badge[data-tone="err"] {
  border-color: var(--err-line);
  background: var(--err-bg);
  color: var(--err);
}

.badge[data-tone="muted"] {
  color: var(--text-3);
}

.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-bg);
}

.status-dot[data-tone="warn"] {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.08);
}

.status-dot[data-tone="err"] {
  background: var(--err);
  box-shadow: 0 0 0 3px var(--err-bg);
}

progress {
  display: block;
  width: 100%;
  height: 4px;
  margin: 0;
  border: 0;
  border-radius: var(--r-pill);
  overflow: hidden;
  appearance: none;
  background: var(--raised-2);
}

progress::-webkit-progress-bar {
  border-radius: var(--r-pill);
  background: var(--raised-2);
}

progress::-webkit-progress-value {
  border-radius: var(--r-pill);
  background: var(--accent);
}

progress::-moz-progress-bar {
  border-radius: var(--r-pill);
  background: var(--accent);
}

[data-bucket="done"] progress::-webkit-progress-value {
  background: var(--ok);
}

[data-bucket="done"] progress::-moz-progress-bar {
  background: var(--ok);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--raised-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* ================= empty states, notes, alerts ================= */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-6) var(--s-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-item);
  background: var(--nested);
  text-align: center;
}

.empty.compact {
  padding: var(--s-5) var(--s-4);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--s-1);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-2);
}

.empty-title {
  font-weight: 600;
}

.empty-text {
  max-width: 44ch;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.empty b {
  color: var(--text-2);
  font-weight: 500;
}

.note {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.note-icon {
  display: flex;
  padding-top: 2px;
  color: var(--text-3);
}

.note b {
  color: var(--text);
  font-weight: 500;
}

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--err-line);
  border-radius: var(--r-item);
  background: var(--err-bg);
  color: var(--err);
  font-size: var(--fs-sm);
}

.alert .link-btn {
  margin-left: auto;
  color: var(--err);
}

.error {
  color: var(--err);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--err);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

/* ================= step 1 ================= */

.connect-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: var(--gap);
}

.connect-methods {
  display: grid;
  gap: var(--s-4);
}

.discovery-status {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-1);
  padding: var(--s-1);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--nested);
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  border-color: var(--line-strong);
  background: var(--raised);
  color: var(--text);
}

.tab-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--raised-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 20px;
  text-align: center;
}

.tab-count:empty {
  display: none;
}

.tab-panel {
  display: grid;
  gap: var(--s-4);
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.panel-hint {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.device-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.device-list:empty {
  display: none;
}

.device {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 64px;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.device:hover {
  border-color: var(--line-hover);
  background: var(--raised);
}

.device[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--raised);
}

.device-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--card);
  color: var(--text);
}

.device-icon.small {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.device-info {
  display: grid;
  flex: 1;
  min-width: 0;
}

.device-info strong {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-meta {
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--s-5);
}

.phones {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}

.phone {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  width: 216px;
  max-width: 100%;
}

.phone img {
  display: block;
  width: 176px;
  height: 176px;
  max-width: 100%;
  padding: 10px;
  border-radius: var(--r-item);
  background: #ffffff; /* QR codes need a light background */
}

.phone figcaption {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  width: 100%;
  min-width: 0;
}

.url {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--input);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  text-align: center;
  overflow-wrap: anywhere;
  user-select: all;
}

.qr-side {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}

.steps {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  min-height: 22px;
  padding-left: 34px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
}

.steps b {
  color: var(--text);
  font-weight: 500;
}

.phone-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.phone-status .device-list {
  width: 100%;
}

.phone-status-title {
  color: var(--text);
  font-weight: 500;
}

/* connection card */
.connection-card {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-5));
  display: grid;
  gap: var(--s-4);
}

.connection-body {
  min-height: 200px;
  display: grid;
}

.conn-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-5) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
  text-align: center;
}

.conn-state.ready {
  border-color: var(--ok-line);
}

.conn-state .btn {
  margin-top: var(--s-2);
}

.conn-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--s-1);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-2);
}

.conn-icon[data-tone="ok"] {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  color: var(--ok);
}

.conn-icon[data-tone="err"] {
  border-color: var(--err-line);
  background: var(--err-bg);
  color: var(--err);
}

.conn-title {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.conn-text {
  max-width: 32ch;
  color: var(--text-3);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.conn-device {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 100%;
  min-width: 0;
}

.conn-device strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-facts {
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  text-wrap: balance;
}

.connection-card .link-btn {
  justify-self: center;
}

/* ================= step 2 ================= */

.device-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--ctl-h-sm);
}

.device-line:empty {
  display: none;
}

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 100%;
  height: var(--ctl-h-sm);
  padding: 0 var(--s-1) 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--card);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.device-chip > span:not(.badge) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
  min-height: 260px;
  padding: var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.choice:hover:not(:disabled) {
  border-color: var(--line-hover);
  background: #1a1a1a;
}

.choice:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--s-4);
  border-radius: var(--r-item);
  background: var(--accent);
  color: var(--accent-ink);
}

.choice-icon .icon {
  width: 22px;
  height: 22px;
}

.choice-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.choice-text {
  max-width: 36ch;
  color: var(--text-2);
}

.choice-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: auto;
  padding-top: var(--s-4);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.choice-cta [data-icon] {
  display: inline-flex;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--ctl-h);
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.session-pill:hover {
  border-color: var(--line-hover);
}

.session-link:empty {
  display: none;
}

/* send */
.send-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: stretch;
  gap: var(--gap);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 340px;
  border-style: dashed;
  border-color: var(--line-strong);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone.over {
  border-style: solid;
  border-color: var(--accent);
  background: var(--raised);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--s-2);
  border-radius: var(--r-item);
  background: var(--accent);
  color: var(--accent-ink);
}

.dropzone-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dropzone-text {
  margin-bottom: var(--s-3);
  color: var(--text-3);
}

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

.selection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}

.selection .file-list {
  max-height: 320px;
  overflow-y: auto;
}

.selection-foot {
  display: grid;
  gap: var(--s-3);
  margin-top: auto;
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.file-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list:empty {
  display: none;
}

.file-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  min-height: 44px;
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--nested);
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  flex: none;
  padding-right: var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
}

/* receive */
.receive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: var(--gap);
}

.receive-wait {
  display: grid;
  min-height: 320px;
}

.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  text-align: center;
}

.waiting-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--nested);
  box-shadow: 0 0 0 10px rgb(255 255 255 / 0.025), 0 0 0 20px rgb(255 255 255 / 0.015);
}

.waiting-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.waiting-text {
  max-width: 40ch;
  color: var(--text-3);
}

.request {
  display: grid;
  gap: var(--s-3);
}

.request-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.receive-info {
  display: grid;
  gap: var(--s-4);
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
}

.facts dt {
  color: var(--text-3);
}

.facts dd {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.facts dd.mono {
  overflow: hidden;
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= step 3 ================= */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* 5 in a row where they fit */
  gap: var(--s-2);
}

.stat {
  display: grid;
  gap: 2px;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--card);
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-label {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.stat[data-tone="ok"] .stat-value {
  color: var(--ok);
}

.stat[data-tone="err"] .stat-value {
  color: var(--err);
}

.outcome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
}

.outcome[data-outcome="complete"] {
  border-color: var(--ok-line);
}

.outcome[data-outcome="partial"],
.outcome[data-outcome="failed"] {
  border-color: var(--err-line);
}

.outcome .conn-icon {
  margin: 0;
}

.outcome-text {
  flex: 1;
  min-width: 200px;
}

.outcome-title {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.group {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
}

.group[data-active="true"] {
  border-color: var(--line-hover);
}

.group-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.dir-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--nested);
}

.dir-icon.small {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.group-title {
  display: grid;
  flex: 1;
  min-width: 0;
}

.group-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
  list-style: none;
}

.row {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: var(--s-3) var(--s-4);
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  min-width: 0;
  font-size: var(--fs-sm);
}

.row-state {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.row[data-bucket="done"] .row-state {
  color: var(--ok);
}

.row[data-bucket="failed"] .row-state {
  color: var(--err);
}

/* history */
.history {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
}

.history summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.history summary::-webkit-details-marker {
  display: none;
}

.history summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg);
}

.history[open] summary::after {
  transform: rotate(-135deg);
}

.history-list {
  display: grid;
  margin: 0;
  padding: 0 var(--s-5) var(--s-4);
  list-style: none;
}

.history-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}

.history-main {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sm);
}

.history-main strong {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-slot:empty {
  display: none;
}

/* ================= forms ================= */

.field {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
}

.field > label,
.field > .label {
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.field-help {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.field-help:empty {
  display: none;
}

.input {
  width: 100%;
  min-width: 0;
  height: var(--ctl-h);
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--input);
  color: var(--text);
  font-size: var(--fs-md);
  transition: border-color 0.15s;
}

.input.mono {
  font-size: var(--fs-sm);
}

.input::placeholder {
  color: var(--text-3);
}

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

.input:focus {
  border-color: var(--accent);
  outline: none;
}

.input-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.input-row .btn {
  flex: none;
}

.readonly {
  flex: 1;
  min-width: 0;
  height: var(--ctl-h);
  padding: 0 var(--s-3);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--input);
  color: var(--text-2);
  font-size: 11px;
  line-height: calc(var(--ctl-h) - 2px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--input);
  cursor: pointer;
}

.check:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.check-text {
  display: grid;
  gap: 2px;
}

.check-text small {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check input:focus-visible {
  outline: none;
}

/* ================= drawer + dialogs ================= */

dialog {
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.65);
  backdrop-filter: blur(3px);
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

.drawer-form {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.drawer-body {
  display: grid;
  align-content: start;
  gap: var(--s-5);
  padding: var(--s-5);
  overflow-y: auto;
}

.group-box {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
  margin: 0;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
}

.group-box legend {
  padding: 0 var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.drawer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
}

.drawer-foot .error {
  flex: 1 1 100%;
}

.dialog {
  width: min(480px, calc(100vw - 2 * var(--s-4)));
  max-height: calc(100dvh - 2 * var(--s-4));
  border-radius: var(--r-card);
}

.dialog-body {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-5);
}

.dialog-body h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.dialog-body .file-list {
  max-height: 40vh;
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

/* ================= banner + toasts ================= */

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--err-line);
  background: #1d0f0f;
  color: #fecaca;
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: center;
}

.toasts {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  left: var(--s-4);
  z-index: 20;
  display: grid;
  justify-items: end;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  max-width: 420px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--raised);
  color: var(--text);
  pointer-events: auto;
  overflow-wrap: anywhere;
}

.toast.ok {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.toast.error {
  border-color: var(--err-line);
  background: #1d0f0f;
  color: #fecaca;
}

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

@media (max-width: 960px) {
  .topbar-inner {
    grid-template-columns: 1fr auto;
  }

  .stepper {
    display: none;
  }

  /* compact progress: three segments under the header */
  .step-compact {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-1);
    padding: 0 var(--page-pad) var(--s-3);
  }

  .seg {
    height: 3px;
    border-radius: var(--r-pill);
    background: var(--raised-2);
  }

  .seg[data-state="done"],
  .seg[data-state="available"] {
    background: var(--text-3);
  }

  .seg[data-state="current"] {
    background: var(--accent);
  }

  .connect-layout,
  .receive-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .connection-card {
    position: static;
  }
}

@media (max-width: 720px) {
  :root {
    --page-pad: var(--s-4);
    --card-pad: 20px;
    --gap: var(--s-3);
    --fs-display: 28px;
    --topbar-h: 56px;
  }

  .shell {
    padding-top: var(--s-5);
  }

  .self-chip {
    display: none;
  }

  .lead {
    font-size: var(--fs-md);
  }

  .choice-grid,
  .send-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .choice {
    min-height: 0;
    padding: var(--s-5);
  }

  .dropzone {
    min-height: 220px;
  }

  .qr-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .qr-side {
    width: 100%;
  }

  .tab .long {
    display: none;
  }

  .tab .short {
    display: inline;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats .stat:first-child {
    grid-column: 1 / -1;
  }

  .group {
    padding: var(--s-4);
  }

  .outcome .actions,
  .outcome .actions .btn {
    width: 100%;
  }

  .drawer {
    width: 100vw;
    border-left: 0;
  }

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

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation-duration: 0.01s !important;
  }
}

/* ================= phone connection guidance ================= */

.phone-network {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-item);
  background: var(--nested);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.phone-network strong {
  color: var(--text);
  font-weight: 600;
}

.os-row {
  display: block;
  margin: var(--s-1) 0;
  padding-left: var(--s-3);
  border-left: 2px solid var(--line-strong);
}

.other-urls {
  display: grid;
  gap: var(--s-1);
  width: 216px;
  max-width: 100%;
}

.url.small {
  padding: var(--s-1) var(--s-2);
  color: var(--text-2);
}

.help {
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  background: var(--nested);
}

.help summary {
  padding: var(--s-3) var(--s-4);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.help[open] summary {
  color: var(--text);
}

.help-list {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0 var(--s-4) var(--s-4) calc(var(--s-4) + 18px);
  color: var(--text-2);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

/* ================= remote sharing ================= */

#mode-note .note,
#remote-support .alert {
  align-items: center;
}

.join-panel {
  display: grid;
  gap: var(--s-3);
  max-width: 440px;
}

.code-input {
  height: 56px;
  font-size: 24px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

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

.invite-qr img {
  display: block;
  width: 176px;
  height: 176px;
  padding: 10px;
  border-radius: var(--r-item);
  background: #ffffff;
  image-rendering: pixelated;
}

.invite-body {
  display: grid;
  flex: 1;
  gap: var(--s-3);
  min-width: 240px;
}

.invite-code {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.invite .url {
  text-align: left;
}

.label {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.verify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
  border-color: var(--ok-line);
}

.verify .conn-icon {
  margin: 0;
}

.verify-body {
  flex: 1;
  min-width: 200px;
}

.verify-code {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.verify-code strong {
  font-size: 28px;
  letter-spacing: 0.06em;
}

.waiting-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-2);
}

.spinner.small {
  width: 20px;
  height: 20px;
  flex: none;
}

#rs-actions:empty,
#rs-invite:empty,
#mode-note:empty,
#remote-support:empty {
  display: none;
}

@media (max-width: 720px) {
  .invite {
    justify-content: center;
  }

  .invite-body {
    min-width: 0;
    text-align: center;
    justify-items: center;
  }

  .invite .url {
    text-align: center;
  }

  .verify-code {
    justify-items: start;
  }

  .invite-code {
    font-size: 32px;
  }
}
