/*
 * Device Inbox visual language:
 * zinc neutrals, true-black dark canvas, 0.5rem control radius, rounded-xl grouped cards,
 * hairline borders, glass dialogs, dense 13–14px type.
 */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter Variable", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 0.5rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --control-radius: 0.5rem;

  --zinc-25: #fcfcfc;
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-500: #71717a;
  --zinc-800: #27272a;
  --zinc-900: #18181b;

  --background: var(--zinc-25);
  --foreground: var(--zinc-900);
  --card: #fff;
  --popover: #fff;
  --primary: oklch(0.488 0.217 264);
  --primary-foreground: #fff;
  --secondary: var(--zinc-50);
  --secondary-foreground: var(--zinc-800);
  --muted: var(--zinc-50);
  --muted-foreground: var(--zinc-500);
  --accent: var(--zinc-100);
  --accent-foreground: var(--zinc-900);
  --border: var(--zinc-200);
  --input: var(--zinc-300);
  --ring: var(--primary);
  --error: #ef4444;
  --error-foreground: #b91c1c;
  --error-surface: color-mix(in srgb, var(--error) 8%, transparent);
  --destructive: var(--error);
  --success: #10b981;
  --success-foreground: #047857;
  --warning: #f59e0b;
  --warning-foreground: #b45309;
  --warning-surface: color-mix(in srgb, var(--warning) 8%, transparent);
  --info: #3b82f6;
  --info-foreground: #1d4ed8;

  --sidebar: var(--zinc-50);
  --sidebar-row-hover: var(--zinc-100);
  --sidebar-row-selected: #fff;
  --sidebar-border: var(--border);
  --sidebar-muted: color-mix(in srgb, var(--muted-foreground) 85%, var(--sidebar));

  --glass-blur: 12px;
  --glass-opacity: 80%;
  --glass-saturation: 1.14;
  --dialog-border: color-mix(in srgb, var(--foreground) 10%, transparent);
  --dialog-shadow: 0 24px 64px -24px rgb(0 0 0 / 65%);
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 5%);
  --control-highlight: inset 0 1px rgb(255 255 255 / 16%);
  --input-surface: var(--background);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --sidebar-width: 16rem;
  --tabbar-height: 64px;
  --topbar-height: 52px;
  --content-max: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #000;
    --foreground: #f5f5f5;
    --card: #111111;
    --popover: #111111;
    --primary: oklch(0.571 0.21 264);
    --secondary: rgb(255 255 255 / 3%);
    --secondary-foreground: #f5f5f5;
    --muted: rgb(255 255 255 / 3%);
    --muted-foreground: #a3a3a3;
    --accent: rgb(255 255 255 / 4%);
    --accent-foreground: #f5f5f5;
    --border: rgb(255 255 255 / 8%);
    --input: rgb(255 255 255 / 11%);
    --error: color-mix(in srgb, #ef4444 90%, #fff);
    --error-foreground: #f87171;
    --error-surface: color-mix(in srgb, var(--error) 16%, transparent);
    --success-foreground: #34d399;
    --warning-foreground: #fbbf24;
    --warning-surface: color-mix(in srgb, var(--warning) 16%, transparent);
    --info-foreground: #60a5fa;
    --sidebar: var(--card);
    --sidebar-row-hover: rgb(255 255 255 / 6%);
    --sidebar-row-selected: rgb(255 255 255 / 8%);
    --glass-blur: 16px;
    --glass-saturation: 1.08;
    --dialog-border: rgb(255 255 255 / 8%);
    --dialog-shadow: inset 0 1px rgb(255 255 255 / 4%), 0 24px 72px -20px rgb(0 0 0 / 90%);
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 40%);
    --input-surface: color-mix(in srgb, var(--input) 32%, transparent);
  }
}

/* ---------- Base ---------- */
/* Dense control sizing is gated on (min-width: 640px) and (not (pointer: coarse)): touch tablets and landscape phones keep touch-sized controls. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (min-width: 640px) and (not (pointer: coarse)) { body { font-size: 14px; } }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; padding: 0.05em 0.3em; border-radius: var(--radius-sm); background: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }

.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; }
.offscreen { position: fixed; top: 0; left: -9999px; opacity: 0; width: 1px; height: 1px; }
.skip-link { position: fixed; left: 0.75rem; top: -3rem; z-index: 100; padding: 0.5rem 0.75rem; border-radius: var(--control-radius); background: var(--primary); color: var(--primary-foreground); text-decoration: none; font-weight: 500; }
.skip-link:focus { top: 0.75rem; }
.muted { color: var(--muted-foreground); }
.mono { font-family: var(--font-mono); }

.icon { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.spinner {
  width: 1rem; height: 1rem; flex: none; display: inline-block;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--muted-foreground) 30%, transparent);
  border-top-color: var(--muted-foreground);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Logo ---------- */
.logo {
  display: inline-grid; place-items: center; flex: none;
  width: 1.75rem; height: 1.75rem; border-radius: var(--radius-md);
  background: var(--foreground); color: var(--background);
}
.logo .icon { width: 1rem; height: 1rem; stroke-width: 2; }
.logo-sm { width: 1.5rem; height: 1.5rem; }
.logo-sm .icon { width: 0.875rem; height: 0.875rem; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  flex-shrink: 0;
  height: 2.25rem; padding: 0 calc(0.75rem - 1px);
  border: 1px solid transparent; border-radius: var(--control-radius);
  font-size: 15px; font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; background: transparent; color: var(--foreground);
  transition: background-color 120ms, border-color 120ms, box-shadow 120ms, color 120ms, scale 120ms;
  user-select: none; -webkit-user-select: none;
}
.btn .icon { width: 1.125rem; height: 1.125rem; margin: 0 -0.125rem; color: var(--btn-icon, currentColor); }
.btn:active:not(:disabled) { scale: 0.97; }
.btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring), 0 0 0 1px var(--background); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.64; pointer-events: none; }
.btn[aria-busy="true"] { cursor: progress; }
@media (pointer: coarse) { .btn::after { content: ""; position: absolute; inset: 50% auto auto 50%; translate: -50% -50%; width: 100%; height: 100%; min-width: 44px; min-height: 44px; } }
@media (min-width: 640px) and (not (pointer: coarse)) {
  .btn { height: 2rem; font-size: 14px; }
  .btn .icon { width: 1rem; height: 1rem; }
}

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); box-shadow: var(--control-highlight), 0 1px 2px color-mix(in srgb, var(--primary) 24%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 90%, transparent); }
.btn-destructive { background: var(--destructive); border-color: var(--destructive); color: #fff; box-shadow: var(--control-highlight), 0 1px 2px color-mix(in srgb, var(--destructive) 24%, transparent); }
.btn-destructive:hover { background: color-mix(in srgb, var(--destructive) 90%, transparent); }
.btn-outline { --btn-icon: var(--muted-foreground); border-color: var(--input); background: var(--popover); box-shadow: var(--shadow-xs); }
.btn-outline:hover { background: color-mix(in srgb, var(--accent) 50%, var(--popover)); }
@media (prefers-color-scheme: dark) {
  .btn-outline { background: color-mix(in srgb, var(--input) 32%, transparent); box-shadow: inset 0 1px rgb(255 255 255 / 6%); }
  .btn-outline:hover { background: color-mix(in srgb, var(--input) 64%, transparent); }
}
.btn-ghost { --btn-icon: var(--muted-foreground); }
.btn-ghost:hover { background: var(--accent); }
.btn-ghost-muted { color: var(--muted-foreground); }
.btn-ghost-muted:hover { background: var(--accent); color: var(--foreground); }
.btn-ghost-destructive { color: var(--muted-foreground); }
.btn-ghost-destructive:hover { background: var(--accent); color: var(--destructive); }

.btn-sm { height: 2rem; gap: 0.375rem; padding: 0 calc(0.625rem - 1px); }
.btn-xs { height: 1.75rem; gap: 0.375rem; padding: 0 calc(0.5rem - 1px); font-size: 14px; }
.btn-xs .icon { width: 1rem; height: 1rem; }
.btn-lg { height: 2.5rem; padding: 0 calc(0.875rem - 1px); }
@media (min-width: 640px) and (not (pointer: coarse)) {
  .btn-sm { height: 1.75rem; }
  .btn-xs { height: 1.5rem; font-size: 12px; }
  .btn-xs .icon { width: 0.875rem; height: 0.875rem; }
  .btn-lg { height: 2.25rem; }
}
.btn-icon { width: 2.25rem; padding: 0; }
.btn-icon-sm { width: 2rem; height: 2rem; padding: 0; }
.btn-icon-xs { width: 1.75rem; height: 1.75rem; padding: 0; }
@media (min-width: 640px) and (not (pointer: coarse)) {
  .btn-icon { width: 2rem; height: 2rem; }
  .btn-icon-sm { width: 1.75rem; height: 1.75rem; }
  .btn-icon-xs { width: 1.5rem; height: 1.5rem; }
}
/* Icon-only buttons from iconButton({ showLabel: false }) stay square at any size. */
.btn-icon-only { padding: 0; aspect-ratio: 1; }
.btn-pill { border-radius: 999px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Inputs ---------- */
.input {
  display: block; width: 100%; min-width: 0;
  height: 2.375rem; padding: 0 calc(0.75rem - 1px);
  border: 1px solid var(--input); border-radius: var(--radius-lg);
  background: var(--input-surface); color: var(--foreground);
  font-size: 16px; line-height: 1.4;
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
@media (min-width: 640px) and (not (pointer: coarse)) { .input { height: 2rem; font-size: 14px; } }
.input::placeholder { color: var(--muted-foreground); opacity: 1; }
.input:focus-visible { border-color: var(--ring); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ring) 24%, transparent); }
.input:disabled { opacity: 0.64; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: color-mix(in srgb, var(--destructive) 50%, transparent); }
.input[aria-invalid="true"]:focus-visible { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--destructive) 18%, transparent); }
.input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.input[type="number"]::-webkit-inner-spin-button, .input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.textarea { height: auto; min-height: 4.5rem; padding: 0.5rem calc(0.75rem - 1px); resize: vertical; line-height: 1.45; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%), linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background: var(--popover); color: var(--foreground); }
.input-code { font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.12em; text-transform: uppercase; height: 3rem; text-align: center; }
@media (min-width: 640px) and (not (pointer: coarse)) { .input-code { height: 2.75rem; font-size: 18px; } }
.input-row { display: flex; gap: 0.5rem; }
.input-row .input { flex: 1; }
.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix .input { padding-right: 3.75rem; text-align: right; font-variant-numeric: tabular-nums; }
.input-suffix span { position: absolute; right: 0.75rem; color: var(--muted-foreground); font-size: 13px; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.field + .field { margin-top: 0.75rem; }
.field-label { font-size: 13px; font-weight: 500; color: var(--foreground); }
.field-hint { font-size: 12px; color: var(--muted-foreground); }

/* Switch */
.switch {
  --thumb: 1.25rem;
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  position: relative; display: inline-block;
  width: calc(var(--thumb) * 2 - 2px); height: calc(var(--thumb) + 2px);
  border-radius: 999px; background: var(--input);
  transition: background-color 200ms;
  cursor: pointer;
}
.switch::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: calc(var(--thumb) - 2px); height: calc(var(--thumb) - 2px);
  border-radius: 999px; background: var(--background);
  box-shadow: 0 1px 2px rgb(0 0 0 / 10%);
  transition: translate 150ms var(--ease-drawer);
}
.switch:checked { background: var(--primary); }
.switch:checked::before { translate: calc(var(--thumb) - 4px) 0; }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.switch:disabled { opacity: 0.64; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .switch:not(:checked)::before { background: var(--muted-foreground); } }
@media (min-width: 640px) and (not (pointer: coarse)) { .switch { --thumb: 1rem; } }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-lg); background: var(--accent); border: 1px solid var(--border); }
.segment { position: relative; display: inline-flex; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span { display: inline-flex; align-items: center; height: 2rem; padding: 0 0.75rem; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; color: var(--muted-foreground); transition: background-color 120ms, color 120ms; }
.segment input:checked + span { background: var(--popover); color: var(--foreground); box-shadow: var(--shadow-xs); }
.segment input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--ring); }
.segment input:disabled { cursor: not-allowed; }
.segment input:disabled + span { opacity: 0.64; }
@media (min-width: 640px) and (not (pointer: coarse)) { .segment span { height: 1.625rem; font-size: 13px; } }
@media (prefers-color-scheme: dark) { .segment input:checked + span { background: rgb(255 255 255 / 10%); } }

/* ---------- Alerts / badges ---------- */
.alert { margin: 0; padding: 0.625rem 0.875rem; border: 1px solid var(--border); border-radius: var(--radius-xl); font-size: 13px; line-height: 1.45; color: var(--foreground); }
.alert-error { border-color: color-mix(in srgb, var(--error) 32%, transparent); background: var(--error-surface); color: var(--error-foreground); }
.alert-warning { border-color: color-mix(in srgb, var(--warning) 32%, transparent); background: var(--warning-surface); color: var(--warning-foreground); }
.alert-info { border-color: color-mix(in srgb, var(--info) 32%, transparent); background: color-mix(in srgb, var(--info) 5%, transparent); }
.alert-inset { margin: 0.75rem; }
.badge { display: inline-flex; align-items: center; height: 1.25rem; padding: 0 0.375rem; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; white-space: nowrap; background: color-mix(in srgb, var(--info) 10%, transparent); color: var(--info-foreground); }
.note-box { margin-top: 1.5rem; padding: 0.75rem; border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--background) 55%, transparent); font-size: 12px; line-height: 1.6; color: var(--muted-foreground); }

/* ---------- Standalone pages (boot, join) ---------- */
.standalone {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: max(2.5rem, env(safe-area-inset-top)) 1rem max(2.5rem, env(safe-area-inset-bottom));
}
.standalone-card {
  width: 100%; max-width: 36rem; padding: 1.5rem;
  border: 1px solid var(--dialog-border); border-radius: var(--radius-2xl);
  background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  box-shadow: var(--dialog-shadow);
}
@media (prefers-color-scheme: dark) { .standalone-card { background: var(--card); } }
.brand-line { display: flex; align-items: center; gap: 0.5rem; color: var(--muted-foreground); }
.brand-line .brand-name { color: var(--foreground); font-size: 15px; }
.standalone-title { margin-top: 1.5rem; font-size: 1.25rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.standalone-title:focus { outline: none; }
.standalone-desc { margin-top: 0.5rem; font-size: 14px; color: var(--muted-foreground); }
.standalone-card > .alert { margin-top: 1.25rem; }
.boot-status { display: flex; align-items: center; gap: 0.625rem; margin-top: 1.5rem; color: var(--muted-foreground); font-size: 14px; }
.boot-error .btn-row { margin-top: 1.25rem; }

.join-identity { display: grid; grid-template-columns: minmax(0, 1fr) 8.5rem; gap: 0.75rem; margin-top: 1.5rem; }
.join-identity .field + .field { margin-top: 0; }
@media (max-width: 380px) { .join-identity { grid-template-columns: 1fr; } }
.join-step { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.join-step .btn-block + .btn-block { margin-top: -0.25rem; }

/* Option cards */
.option-grid { display: grid; gap: 0.75rem; }
@media (min-width: 520px) { .option-grid { grid-template-columns: 1fr 1fr; } }
.option {
  display: flex; align-items: flex-start; gap: 0.75rem; min-height: 5.5rem; padding: 1rem;
  text-align: left; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius-lg); background: var(--card);
  transition: background-color 120ms, border-color 120ms, scale 120ms;
}
.option:hover { background: color-mix(in srgb, var(--muted) 40%, var(--card)); border-color: var(--border); }
.option:active:not(:disabled) { scale: 0.99; }
.option:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.option:disabled, .option[aria-busy="true"] { opacity: 0.64; }
@media (prefers-color-scheme: dark) { .option { background: rgb(255 255 255 / 3.5%); border-color: transparent; } .option:hover { background: rgb(255 255 255 / 6%); } }
.option-icon { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; margin-top: 0.125rem; border-radius: var(--radius-md); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: var(--background); color: var(--muted-foreground); }
.option:hover .option-icon { color: var(--foreground); }
.option-text { min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.option-title { font-size: 14px; font-weight: 500; }
.option-desc { font-size: 12px; line-height: 1.55; color: var(--muted-foreground); }
.link-only { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius-lg); background: var(--card); font-size: 13px; line-height: 1.55; color: var(--muted-foreground); }
.link-only strong { font-weight: 500; color: var(--foreground); }
@media (prefers-color-scheme: dark) { .link-only { background: rgb(255 255 255 / 3.5%); border-color: transparent; } }

.match-panel { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 1.25rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); text-align: center; }
.match-label { font-size: 12px; font-weight: 500; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.06em; }
.match-code { font-family: var(--font-mono); font-size: 3.5rem; line-height: 1; font-weight: 600; letter-spacing: 0.16em; padding-left: 0.16em; font-variant-numeric: tabular-nums; }
.match-help { max-width: 20rem; font-size: 13px; color: var(--muted-foreground); }
.waiting-line { display: flex; align-items: center; gap: 0.5rem; font-size: 13px; color: var(--muted-foreground); }
.countdown { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; outline: none; padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 1.5rem); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.625rem;
  height: calc(var(--topbar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) calc(env(safe-area-inset-right) + 0.75rem) 0 calc(env(safe-area-inset-left) + 0.75rem);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
}
.topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Connection indicator */
.conn { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }
.conn-dot { position: relative; width: 0.5rem; height: 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--muted-foreground) 40%, transparent); }
.conn[data-state="live"] .conn-dot { background: var(--success); }
.conn[data-state="connecting"] .conn-dot, .conn[data-state="reconnecting"] .conn-dot { background: var(--warning); animation: pulse 2s steps(8) infinite; }
.conn[data-state="offline"] .conn-dot { background: var(--destructive); }
.conn[data-state="offline"] .conn-label { color: var(--error-foreground); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem; text-decoration: none; color: var(--muted-foreground); font-size: 12px; font-weight: 500; }
.tab:focus-visible { outline: none; }
.tab:focus-visible .tab-pill { box-shadow: inset 0 0 0 2px var(--ring); }
.tab-pill { position: relative; display: grid; place-items: center; width: 3.5rem; height: 2rem; border-radius: 999px; transition: background-color 150ms; }
.tab-pill .icon { width: 1.375rem; height: 1.375rem; }
.tab.is-active { color: var(--foreground); }
.tab.is-active .tab-pill { background: var(--accent); }
@media (prefers-color-scheme: dark) { .tab.is-active .tab-pill { background: rgb(255 255 255 / 10%); } }
.tab-badge { position: absolute; top: 0; right: 0.625rem; min-width: 1rem; height: 1rem; padding: 0 0.25rem; border-radius: 999px; background: var(--destructive); color: #fff; font-size: 10px; font-weight: 600; line-height: 1rem; text-align: center; box-shadow: 0 0 0 2px var(--background); }

/* Sidebar (wide screens) */
@media (min-width: 768px) {
  .app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100dvh;
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    background: var(--sidebar); border-right: 1px solid var(--sidebar-border);
  }
  .topbar, .tabbar { display: none; }
  .main { padding-bottom: 3rem; }
}
.sidebar-head { display: flex; align-items: center; gap: 0.625rem; padding: 0.25rem 0.625rem 0.75rem; }
.sidebar-brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-brand .brand-name { font-size: 14px; }
.sidebar-host { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 0.5rem; height: 2rem; padding: 0 0.625rem;
  border-radius: var(--control-radius); text-decoration: none;
  font-size: 14px; font-weight: 500; color: color-mix(in srgb, var(--muted-foreground) 92%, var(--foreground));
  transition: background-color 100ms, color 100ms;
}
.nav-item .icon { color: var(--sidebar-muted); }
.nav-item:hover { background: var(--sidebar-row-hover); color: var(--foreground); }
.nav-item:hover .icon { color: var(--foreground); }
.nav-item.is-active { background: var(--sidebar-row-selected); color: var(--foreground); box-shadow: var(--shadow-xs); }
.nav-item.is-active .icon { color: var(--foreground); }
.nav-item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.nav-item > span:nth-child(2) { flex: 1; }
.nav-count { font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.nav-badge { min-width: 1.125rem; height: 1.125rem; padding: 0 0.3rem; border-radius: 999px; background: var(--destructive); color: #fff; font-size: 11px; font-weight: 600; line-height: 1.125rem; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem 0.625rem 0.25rem; border-top: 1px solid var(--sidebar-border); }
.sidebar-me { display: flex; flex-direction: column; font-size: 12px; line-height: 1.35; min-width: 0; }
.me-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Views ---------- */
.view {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 1.25rem calc(env(safe-area-inset-right) + 0.75rem) 0 calc(env(safe-area-inset-left) + 0.75rem);
  display: flex; flex-direction: column; gap: 1rem;
}
@media (min-width: 640px) { .view { padding: 2rem 1.25rem 0; gap: 1.25rem; } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding: 0 0.25rem; }
.page-heading { min-width: 0; }
.page-heading h1 { font-size: 1.375rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.page-heading h1:focus { outline: none; }
.page-sub { margin-top: 0.25rem; font-size: 13px; color: var(--muted-foreground); }
.footnote { padding: 0 0.25rem; font-size: 12px; color: var(--muted-foreground); }

.sections { display: flex; flex-direction: column; gap: 1.5rem; }
.section { display: flex; flex-direction: column; gap: 0.625rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.75rem; }
.section-title { padding: 0 0.25rem; font-size: 15px; font-weight: 600; }

/* Grouped card */
.group { position: relative; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-xs); overflow: hidden; }
@media (prefers-color-scheme: dark) { .group { background: color-mix(in srgb, var(--card) 100%, transparent); } }
.group > * + * { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.group-pad { padding: 0.875rem; display: flex; flex-direction: column; gap: 0.5rem; }
.group-pad > * + * { border-top: 0; }
.group-pad .btn-row { margin-top: 0.25rem; }
@media (min-width: 640px) { .group-pad { padding: 1rem; } }

/* Settings row */
.row { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; margin: 0; min-width: 0; border-left: 0; border-right: 0; border-bottom: 0; }
@media (min-width: 640px) {
  .row { padding: 0.75rem 1rem; }
  .row:not(.row-stack) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2rem; }
}
.row-fieldset { border-top-width: 0; }
.group > .row-fieldset + *, .group > * + .row-fieldset { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.row:has(> .row-value), .row:has(> .row-control .switch) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; }
.input-suffix { max-width: 11rem; }
.row-stack { display: flex; flex-direction: column; gap: 0.625rem; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.row-title { font-size: 14px; font-weight: 500; color: var(--foreground); }
.row-desc { max-width: 42rem; font-size: 12px; line-height: 1.5; color: var(--muted-foreground); text-wrap: pretty; }
.row-error { font-size: 12px; color: var(--error-foreground); }
.row-control { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
@media (min-width: 640px) {
  .row-control { justify-content: flex-end; }
  .row-control .input { width: 14rem; }
  .row-control .input-suffix .input { width: 9rem; }
  .row-control-wide .input { width: 18rem; }
}
.row-value { font-size: 13px; color: var(--muted-foreground); overflow-wrap: anywhere; }
.row[data-state="saving"] .row-title::after { content: " · Saving…"; font-weight: 400; color: var(--muted-foreground); }
.row-note { display: flex; gap: 0.5rem; align-items: flex-start; padding: 0.625rem 0.75rem; font-size: 12px; line-height: 1.55; color: var(--muted-foreground); background: color-mix(in srgb, var(--muted) 60%, transparent); }
.row-note .icon { margin-top: 0.125rem; color: var(--warning); width: 0.875rem; height: 0.875rem; }
@media (min-width: 640px) { .row-note { padding: 0.625rem 1rem; } }
.row-actions { padding: 0 0.75rem 0.75rem; }
.is-locked .segmented { opacity: 0.8; }

/* ---------- Empty states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; padding: 2.5rem 1.5rem; border: 1px dashed var(--border); border-radius: var(--radius-xl); }
.empty-inline { border: 0; padding: 1.75rem 1rem; }
.empty-compact { padding: 1rem; }
.empty-compact .empty-title { font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
.group > * + .empty-inline { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.empty-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin-bottom: 0.25rem; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); box-shadow: var(--shadow-xs); }
.empty-icon .icon { width: 1.125rem; height: 1.125rem; }
.empty-title { font-size: 14px; font-weight: 600; }
.empty-desc { max-width: 22rem; font-size: 13px; color: var(--muted-foreground); }
.empty .btn { margin-top: 0.5rem; }
.empty-line { padding: 1rem; font-size: 13px; color: var(--muted-foreground); text-align: center; }
.loading-line { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1.25rem; font-size: 13px; color: var(--muted-foreground); }

/* ---------- Composer ---------- */
.composer {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-2xl);
  background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
  transition: border-color 120ms, box-shadow 120ms;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--ring) 55%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 14%, transparent); }
@media (prefers-color-scheme: dark) { .composer { box-shadow: 0 14px 32px -18px rgb(0 0 0 / 75%); } }
.composer-text {
  display: block; width: 100%; min-height: 3.25rem; max-height: 20rem;
  padding: 0.875rem 1rem 0.375rem; border: 0; outline: none; resize: none;
  background: transparent; font-size: 16px; line-height: 1.5;
}
@media (min-width: 640px) and (not (pointer: coarse)) { .composer-text { font-size: 14px; } }
.composer-text::placeholder { color: var(--muted-foreground); opacity: 1; }
.composer-foot { display: flex; align-items: center; gap: 0.25rem; padding: 0.375rem 0.5rem 0.5rem; }
.composer-to { width: auto; max-width: 10rem; height: 2.25rem; font-size: 16px; margin-left: auto; border-color: transparent; background-color: transparent; box-shadow: none; color: var(--muted-foreground); }
.composer-to:hover { background-color: var(--accent); color: var(--foreground); }
@media (min-width: 640px) and (not (pointer: coarse)) { .composer-to { max-width: 9rem; height: 1.75rem; font-size: 12px; } }
.item-agent { padding: 0 0.375rem; border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: 11px; }
.item-delivery.is-delivered { color: var(--success-foreground, var(--info-foreground)); }
.composer-hint { flex: 1; min-width: 0; padding-left: 0.375rem; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 419px) { .composer-hint { display: none; } }

.uploads { display: flex; flex-direction: column; gap: 0.375rem; padding: 0 0.625rem 0.25rem; }
.upload { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.375rem 0.5rem 0.625rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--background); }
.upload > .icon { color: var(--muted-foreground); }
.upload-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.upload-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-meta { font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.upload-track { height: 3px; border-radius: 999px; background: var(--accent); overflow: hidden; margin-top: 0.125rem; }
.upload-bar { display: block; height: 100%; width: 0; background: var(--primary); transition: width 150ms linear; }
.upload.is-error { border-color: color-mix(in srgb, var(--error) 32%, transparent); background: var(--error-surface); }
.upload.is-error .upload-meta { color: var(--error-foreground); }
.upload.is-error .upload-bar { background: var(--destructive); }

/* Usage meter */
.usage { display: flex; flex-direction: column; gap: 0.375rem; padding: 0 0.25rem; }
.usage-text { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.usage-text span:empty { display: none; }
.usage-text span:last-child { margin-left: auto; }
.meter { height: 3px; border-radius: 999px; background: var(--accent); overflow: hidden; }
@media (prefers-color-scheme: dark) { .meter { background: rgb(255 255 255 / 8%); } }
.meter-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: color-mix(in srgb, var(--foreground) 45%, transparent); transition: width 300ms; }
.meter-fill.is-warn { background: var(--warning); }

/* ---------- Inbox items ---------- */
.item-list { display: flex; flex-direction: column; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-xs); overflow: hidden; }
.item-list:has(> .empty) { border: 0; background: transparent; box-shadow: none; }
.item-list > .empty { border: 1px dashed var(--border); }
.item { display: flex; gap: 0.75rem; padding: 0.75rem 0.75rem 0.5rem; min-width: 0; }
.item + .item { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
@media (min-width: 640px) { .item { padding: 0.875rem 1rem 0.625rem; } }
.item-icon { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: var(--radius-md); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: var(--background); color: var(--muted-foreground); }
.kind-link .item-icon { color: var(--info-foreground); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.item-title { font-weight: 500; overflow-wrap: anywhere; }
.item-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.item-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.text-link { color: var(--info-foreground); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--info-foreground) 35%, transparent); text-underline-offset: 2px; }
.text-link:hover { text-decoration-color: currentColor; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.item-sender { font-weight: 500; color: color-mix(in srgb, var(--muted-foreground) 70%, var(--foreground)); }
.dot { opacity: 0.6; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem; margin: 0.125rem 0 0 -0.5rem; }
.item-actions .spacer { flex: 1; }
@media (pointer: coarse) { .item-actions { gap: 0.5rem; } .item-actions .btn-icon-xs { width: 2.25rem; height: 2.25rem; } }

/* Host actions: inline on wide screens, a bottom sheet behind "More" on phones. */
.item-more, .item-menu-title, .item-delivery .when-narrow { display: none; }
.item-menu[popover]:not(:popover-open) { display: contents; }
@media (max-width: 639px) {
  .item-meta .item-to.is-all { display: none; }
  .item-delivery .when-wide { display: none; }
  .item-delivery .when-narrow { display: inline; }
  .item-more { display: inline-flex; }
  .item-menu[popover]:not(:popover-open) { display: none; }
  .item-menu[popover] {
    inset: auto 0 0; width: 100%; max-width: none; margin: 0;
    display: flex; flex-direction: column; gap: 0.125rem;
    padding: 0.5rem 0.5rem calc(env(safe-area-inset-bottom) + 0.75rem);
    border: 1px solid var(--dialog-border); border-width: 1px 0 0; border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    background: var(--popover); color: var(--foreground);
    box-shadow: var(--dialog-shadow);
  }
  .item-menu:popover-open { animation: sheet-up 220ms var(--ease-drawer); }
  .item-menu::backdrop { background: color-mix(in srgb, var(--background) 50%, transparent); }
  .item-menu-title { display: block; padding: 0.5rem 0.75rem 0.375rem; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
  .item-menu .btn { justify-content: flex-start; width: 100%; height: 3rem; padding: 0 0.75rem; gap: 0.75rem; font-size: 15px; color: var(--foreground); }
  .item-menu .btn .icon { width: 1.25rem; height: 1.25rem; color: var(--muted-foreground); }
}

/* ---------- Devices ---------- */
.device-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; min-width: 0; }
@media (min-width: 640px) { .device-row { padding: 0.75rem 1rem; } }
.device-icon { position: relative; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none; border-radius: var(--radius-lg); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: var(--background); color: var(--muted-foreground); }
.device-icon .icon { width: 1.125rem; height: 1.125rem; }
.presence { position: absolute; right: -3px; bottom: -3px; width: 0.75rem; height: 0.75rem; border-radius: 999px; background: color-mix(in srgb, var(--muted-foreground) 45%, var(--card)); box-shadow: 0 0 0 2px var(--card); }
.presence.is-online { background: var(--success); }
.device-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.device-name-line { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.device-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta { display: flex; flex-wrap: wrap; gap: 0.25rem; font-size: 12px; color: var(--muted-foreground); }
.status-online { color: var(--success-foreground); font-weight: 500; }
.device-actions { display: flex; gap: 0.125rem; flex: none; }
/* Touch: space adjacent icon buttons so their 44px hit areas don't overlap. */
@media (pointer: coarse) { .device-actions { gap: 0.75rem; } }
@media (max-width: 479px) { .hide-narrow { display: none; } }

/* ---------- Control: clipboard, files ---------- */
.clip-result { display: flex; flex-direction: column; gap: 0.5rem; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem; padding: 0.5rem 0.625rem; font-size: 13px; background: color-mix(in srgb, var(--muted) 60%, transparent); }
.crumb { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.75rem; padding: 0 0.375rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted-foreground); font-weight: 500; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.crumb:hover { background: var(--accent); color: var(--foreground); }
.crumb.is-current { color: var(--foreground); }
.crumb .icon { width: 0.875rem; height: 0.875rem; }
.crumb-sep { width: 0.75rem; height: 0.75rem; color: color-mix(in srgb, var(--muted-foreground) 60%, transparent); }
.file-list { display: flex; flex-direction: column; max-height: 60dvh; overflow-y: auto; }
.file-row { display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 3rem; padding: 0.5rem 0.75rem; border: 0; background: transparent; text-align: left; text-decoration: none; color: var(--foreground); transition: background-color 100ms; }
.file-row + .file-row { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.file-row:hover { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.file-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
@media (min-width: 640px) and (not (pointer: coarse)) { .file-row { min-height: 2.75rem; padding: 0.375rem 1rem; } }
.file-icon { display: grid; place-items: center; flex: none; color: var(--muted-foreground); }
.file-icon.is-dir { color: var(--info-foreground); }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.file-trail { color: color-mix(in srgb, var(--muted-foreground) 70%, transparent); width: 0.875rem; height: 0.875rem; }

/* ---------- Join request sheet (top) ---------- */
.request-sheet {
  position: fixed; z-index: 60; top: 0; left: 0; right: 0;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.5rem) calc(env(safe-area-inset-right) + 0.5rem) 0 calc(env(safe-area-inset-left) + 0.5rem);
  pointer-events: none;
}
@media (min-width: 768px) { .request-sheet { left: var(--sidebar-width); align-items: center; padding-top: 0.75rem; } }
.request {
  pointer-events: auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.75rem; align-items: start;
  width: 100%; max-width: 34rem; padding: 0.875rem;
  border: 1px solid var(--dialog-border); border-radius: var(--radius-2xl);
  background: color-mix(in srgb, var(--popover) 88%, transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  box-shadow: var(--dialog-shadow);
  animation: sheet-in 260ms var(--ease-drawer);
}
@keyframes sheet-in { from { opacity: 0; translate: 0 -12px; } }
.request-icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.request-main { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
.request-title { font-size: 14px; overflow-wrap: anywhere; }
.request-title strong { font-weight: 600; }
.request-meta { font-size: 13px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.request-code { font-family: var(--font-mono); font-size: 18px; font-weight: 600; letter-spacing: 0.12em; color: var(--foreground); }
.request-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
@media (min-width: 520px) {
  .request { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .request-actions { grid-column: auto; display: flex; }
}

/* ---------- Dialogs ---------- */
.dialog {
  width: calc(100% - 2rem); max-width: 32rem; max-height: calc(100dvh - 2rem);
  margin: auto; padding: 0; overflow: auto;
  border: 1px solid var(--dialog-border); border-radius: var(--radius-2xl);
  color: var(--foreground);
  background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  box-shadow: var(--dialog-shadow);
}
@media (prefers-color-scheme: dark) { .dialog { background: color-mix(in srgb, var(--card) 92%, transparent); } }
.dialog[open] { animation: dialog-in 200ms ease-out; }
.dialog::backdrop { background: color-mix(in srgb, var(--background) 60%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes dialog-in { from { opacity: 0; scale: 0.98; } }
.dialog-wide { max-width: 44rem; }
.dialog-header { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.5rem 1.5rem 1rem; padding-right: 3rem; }
.dialog-title { font-size: 1.25rem; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.dialog-desc { font-size: 14px; color: var(--muted-foreground); }
.dialog-body { padding: 0 1.5rem 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.dialog-footer { display: flex; flex-direction: column-reverse; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 72%, transparent); }
.dialog-close { position: absolute; top: 0.5rem; right: 0.5rem; }
@media (min-width: 640px) { .dialog-footer { flex-direction: row; justify-content: flex-end; } }
/* Mobile: bottom sheet */
@media (max-width: 639px) {
  .dialog { width: 100%; max-width: none; margin: auto 0 0; max-height: calc(100dvh - 3rem); border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; border-left: 0; border-right: 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .dialog[open] { animation: sheet-up 260ms var(--ease-drawer); }
  .dialog-header { padding: 1.25rem 1.25rem 0.75rem; padding-right: 3rem; }
  .dialog-body { padding: 0 1.25rem 1rem; }
  .dialog-footer { padding: 0.75rem 1.25rem; flex-direction: row-reverse; }
  .dialog-footer .btn { flex: 1; }
}
@keyframes sheet-up { from { translate: 0 2rem; opacity: 0; } }

/* Invite dialog */
.invite-body { display: grid; gap: 1.25rem; }
@media (min-width: 640px) { .invite-body { grid-template-columns: 15rem minmax(0, 1fr); align-items: start; } }
.qr-wrap { position: relative; justify-self: center; width: min(100%, 16rem); }
.qr { display: grid; place-items: center; aspect-ratio: 1; width: 100%; padding: 0.5rem; border-radius: var(--radius-xl); background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.qr svg { display: block; width: 100%; height: 100%; }
.qr .spinner { border-color: rgb(0 0 0 / 15%); border-top-color: rgb(0 0 0 / 60%); }
.qr-fallback { padding: 1rem; font-size: 13px; color: #52525b; text-align: center; }
.qr-wrap.is-expired .qr { opacity: 0.12; filter: blur(2px); }
.qr-expired { position: absolute; inset: 0; display: grid; place-items: center; }
.qr-expired span { padding: 0.375rem 0.75rem; border-radius: 999px; background: var(--foreground); color: var(--background); font-size: 13px; font-weight: 600; }
.invite-side { display: flex; flex-direction: column; gap: 0.875rem; min-width: 0; }
.invite-side .field + .field { margin-top: 0; }
.invite-code { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
.invite-expiry { font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* ---------- Drop overlay ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 1.5rem; background: color-mix(in srgb, var(--background) 70%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); pointer-events: none; }
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 2.5rem 3rem; border: 2px dashed color-mix(in srgb, var(--primary) 60%, transparent); border-radius: var(--radius-2xl); background: var(--card); font-weight: 600; box-shadow: var(--dialog-shadow); }
.drop-card .icon { width: 1.75rem; height: 1.75rem; color: var(--primary); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 80; left: 0; right: 0;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 0.5rem);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 0 0.75rem; pointer-events: none;
}
/* Shown as a manual popover (top layer, above dialogs): undo the UA popover box. */
.toasts[popover] { inset: auto 0 calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 0.5rem); width: auto; height: auto; margin: 0; border: 0; background: transparent; color: inherit; overflow: visible; }
.toasts[popover]:not(:popover-open) { display: flex; }
@media (min-width: 768px) {
  .toasts, .toasts[popover] { left: auto; right: 1rem; bottom: 1rem; align-items: flex-end; width: 24rem; padding: 0; }
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.625rem;
  width: 100%; max-width: 24rem; padding: 0.625rem 0.5rem 0.625rem 0.75rem;
  border: 1px solid var(--dialog-border); border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--popover) 92%, transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 35%);
  font-size: 13px; line-height: 1.45;
  animation: toast-in 200ms var(--ease-drawer);
  transition: opacity 160ms, translate 160ms;
}
.toast.is-leaving { opacity: 0; translate: 0 4px; }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }
.toast-icon { display: grid; place-items: center; height: 1.25rem; color: var(--muted-foreground); }
.toast-icon .icon { width: 0.875rem; height: 0.875rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-error .toast-text { color: var(--error-foreground); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 0.0625rem; }
.toast-close { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: color-mix(in srgb, var(--muted-foreground) 80%, transparent); }
.toast-close:hover { color: var(--foreground); }
.toast-close .icon { width: 0.75rem; height: 0.75rem; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
  .btn:active:not(:disabled), .option:active:not(:disabled) { scale: none; }
}

/* ---------- Items addressed to this device ---------- */
.item.is-for-me { box-shadow: inset 3px 0 0 var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.item-for-you { padding: 0 0.375rem; border-radius: var(--radius-lg); background: var(--primary); color: var(--primary-foreground); font-size: 11px; font-weight: 600; }

/* ---------- Share sheet ---------- */
.share-preview { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; max-height: 40dvh; overflow: auto; }
.share-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; padding: 0.5rem 0.625rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); }
.share-file { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 14px; min-width: 0; }
.share-file-name { overflow-wrap: anywhere; min-width: 0; }
.share-file-size { color: var(--muted-foreground); flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Vault ---------- */
.vault-row { display: flex; align-items: center; gap: 0.75rem; width: 100%; min-width: 0; padding: 0.625rem 0.75rem; border: 0; background: transparent; color: var(--foreground); text-align: left; font: inherit; }
@media (min-width: 640px) { .vault-row { padding: 0.625rem 1rem; } }
button.vault-row { cursor: pointer; transition: background-color 100ms; }
button.vault-row:hover { background: color-mix(in srgb, var(--accent) 70%, transparent); }
button.vault-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.vault-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.vault-name { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; overflow-wrap: anywhere; }
.vault-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem 0.5rem; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.vault-row .device-actions { align-self: center; }
.group > * + .vault-row, .vault-row + .vault-row { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.group > .crumbs { border-top: 0; }
#vault-upload-dialog input[type="file"] { height: auto; padding: 0.375rem 0.5rem; max-width: 100%; }
.page-header > .btn-row { flex: none; flex-wrap: nowrap; }
.page-sub code { font-family: var(--font-mono); font-size: 12px; }
