:root {
  --bg: #23262F;
  --bg-2: #2b2f3a;
  --bg-3: #1b1d24;
  --surface: rgba(255,255,255,0.05);
  --surface-2: rgba(255,255,255,0.08);
  --stroke: rgba(255,255,255,0.08);
  --text: #f3f4f0;
  --muted: #9aa0ad;
  --faint: #6d7380;
  --accent: #B6FF2E;
  --accent-2: #d4ff7a;
  --ok: #B6FF2E;
  --warn: #ffb020;
  --err: #ff6b6b;
  --shadow: 0 18px 50px rgba(0,0,0,0.38);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "Segoe UI", Roboto, "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
html[data-resolved="light"] {
  --bg: #eef1e6;
  --bg-2: #ffffff;
  --bg-3: #e2e6d8;
  --surface: rgba(35,38,47,0.05);
  --surface-2: rgba(35,38,47,0.08);
  --stroke: rgba(35,38,47,0.10);
  --text: #23262F;
  --muted: #5c6270;
  --faint: #8a90a0;
  --accent: #6aa300;
  --accent-2: #4d7a00;
  --shadow: 0 16px 40px rgba(20,22,28,0.08);
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { object-fit: contain; max-width: 100%; height: auto; }
a { color: inherit; }

.app {
  width: min(880px, 100%);
  min-height: 100dvh;
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-t)) max(16px, var(--safe-l)) calc(12px + var(--safe-b)) max(16px, var(--safe-r));
}
.app.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -10px;
  border-radius: 28px;
}

.app-header, .app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--surface); }
.word { font-weight: 700; letter-spacing: 0.2em; font-size: 13px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint); display: inline-block; margin-right: 8px;
}
.status-dot[data-live="on"] { background: var(--ok); box-shadow: 0 0 0 4px rgba(46,229,157,0.14); }
.status-dot[data-live="busy"] { background: var(--accent); }
.status-text { color: var(--muted); font-size: 13px; }
.header-status { display: flex; align-items: center; }

.stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 8px 0 16px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.page { animation: rise 0.28s ease; width: 100%; }
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h1, .display {
  font-size: clamp(26px, 6vw, 40px);
  letter-spacing: -0.045em;
  font-weight: 620;
  margin: 0 0 8px;
}
.page-lead, .sub { color: var(--muted); line-height: 1.45; margin: 0 0 18px; max-width: 38ch; }
.eyebrow {
  letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px;
  color: var(--accent-2); margin: 0 0 8px;
}
.kicker { letter-spacing: 0.14em; text-transform: uppercase; font-size: 11px; color: var(--faint); margin: 0 0 8px; }

.view { width: 100%; text-align: center; }
#page-home { display: flex; flex-direction: column; align-items: center; }

.orb-stage {
  position: relative;
  width: min(240px, 58vw);
  height: min(240px, 58vw);
  margin: 4px auto 18px;
  flex-shrink: 0;
}
.orb-core, .orb-peer, .ring, .link { position: absolute; inset: 0; margin: auto; }
.orb-core {
  width: 16px; height: 16px; border-radius: 50%; background: var(--text);
  box-shadow: 0 0 0 10px rgba(182,255,46,0.10), 0 0 28px rgba(182,255,46,0.28);
  z-index: 3;
}
.ring { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(182,255,46,0.40); opacity: 0; }
.orb-stage[data-mode="waiting"] .ring { animation: expand 2.8s ease-out infinite; }
.orb-peer {
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent-2);
  opacity: 0; transform: translate(68px, -8px); z-index: 3;
}
.orb-stage[data-mode="connecting"] .orb-peer,
.orb-stage[data-mode="connected"] .orb-peer,
.orb-stage[data-mode="transfer"] .orb-peer { opacity: 1; }
.link {
  width: 86px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transform: rotate(-8deg) translate(8px, -6px);
}
.orb-stage[data-mode="connected"] .link,
.orb-stage[data-mode="transfer"] .link { opacity: 0.9; animation: flow 1.8s linear infinite; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
}
.actions.stacked { margin-top: 16px; }
.btn {
  appearance: none; border: 0; background: var(--text); color: var(--bg);
  min-height: 52px; padding: 0 22px; border-radius: 999px; font-weight: 650;
  width: min(320px, 100%);
}
.btn.secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--stroke));
}
.btn.sm { width: auto; min-width: 0; min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--stroke); width: min(200px, 100%); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.text-btn { background: none; border: 0; color: var(--accent-2); min-height: 44px; padding: 0 8px; }
.home-help-btn { margin-top: 8px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: 999px;
  min-height: 40px; min-width: 40px;
}

.privacy { margin-top: 22px; color: var(--faint); font-size: 13px; }
.code { font-family: var(--mono); font-size: clamp(28px, 8vw, 48px); letter-spacing: 0.18em; margin: 8px 0 6px; }
.hint { color: var(--muted); font-size: 14px; }
.qr-wrap { display: inline-block; padding: 10px; background: #fff; border-radius: 16px; margin: 8px 0 18px; }
.glass {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); text-align: left; margin: 12px 0; width: 100%;
}
.peer-card h2 { margin: 0; letter-spacing: 0.12em; font-size: 18px; }
.ready { color: var(--ok); font-size: 13px; margin: 6px 0 0; }

.file-list, .incoming-files, .saved-files, .activity-list, .recent-list {
  list-style: none; padding: 0; margin: 12px 0; width: 100%;
}
.file-list li, .incoming-files li, .saved-files li, .activity-list li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--stroke);
  min-width: 0;
}
.activity-list li { grid-template-columns: 52px minmax(0, 1fr) auto; }
.incoming-files li, .saved-files li { grid-template-columns: 52px minmax(0, 1fr) auto; }
.ext {
  font-size: 11px; letter-spacing: 0.08em; background: var(--surface-2);
  border-radius: 12px; padding: 10px 0; text-align: center;
}
.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sz { color: var(--muted); font-size: 13px; white-space: nowrap; }
.meta-line { color: var(--faint); font-size: 12px; margin: 0; }

.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 16px 0 10px; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
.stats {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums;
}
.pct { font-size: clamp(40px, 12vw, 56px); letter-spacing: -0.05em; margin: 8px 0; }
.code-field, .field {
  width: 100%; min-height: 52px; border-radius: 16px; border: 1px solid var(--stroke);
  background: var(--surface); padding: 0 14px;
}
.code-field {
  text-align: center; letter-spacing: 0.28em; font-family: var(--mono);
  font-size: 22px; text-transform: uppercase; max-width: min(320px, 100%);
}
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 6px; }

.bottom-nav {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 6px 4px;
  margin-top: 8px;
  width: 100%;
  flex-shrink: 0;
}
.nav-item {
  background: none; border: 0; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; font-size: 10px; letter-spacing: 0.04em; min-width: 0; width: 100%;
}
.nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item.is-active { color: var(--text); }
.app-footer { color: var(--faint); font-size: 12px; margin-top: 10px; flex-wrap: wrap; }
.skysoar { display: flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.skysoar img { height: 22px; width: auto; max-width: 96px; border-radius: 4px; }
.skysoar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%); background: var(--bg-3);
  border: 1px solid var(--stroke); padding: 12px 16px; border-radius: 14px; z-index: 40; max-width: 90vw;
}
.toast[data-tone="ok"] { border-color: rgba(46,229,157,0.35); }
.toast[data-tone="err"] { border-color: rgba(255,107,107,0.45); }
.compat { background: var(--surface); border: 1px solid var(--stroke); padding: 14px 16px; border-radius: 16px; margin-bottom: 12px; }

.quick-guide { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 8px 0 18px; }
.quick-guide article { background: var(--surface); border: 1px solid var(--stroke); border-radius: 18px; padding: 14px 16px; }
.quick-guide span { color: var(--accent-2); font-weight: 700; }
.quick-guide h3 { margin: 4px 0; }
.quick-guide p { margin: 0; color: var(--muted); }

.help-layout { display: grid; grid-template-columns: 1fr; gap: 12px; }
.help-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.help-item, .faq { background: var(--surface); border: 1px solid var(--stroke); border-radius: 16px; overflow: hidden; }
.help-item button, .faq button {
  width: 100%; text-align: left; background: none; border: 0; padding: 14px 16px; min-height: 52px; font-weight: 600;
}
.help-item .body, .faq .body { padding: 0 16px 14px; color: var(--muted); line-height: 1.5; }
.compat-list { list-style: none; padding: 0; margin: 0; }
.compat-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--stroke); }

.settings-section { margin: 18px 0; }
.settings-section h2 { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--stroke); min-height: 52px;
  flex-wrap: wrap;
}
.row .hint { max-width: 42ch; }
.row .btn, .row .btn.secondary { width: auto; min-width: 0; }
.toggle { width: 48px; height: 28px; border-radius: 99px; border: 0; background: var(--surface-2); position: relative; flex-shrink: 0; }
.toggle[aria-pressed="true"] { background: var(--accent); }
.toggle i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle[aria-pressed="true"] i { transform: translateX(20px); }

.dev-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px 16px;
}
.dev-card img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; background: var(--bg-3); flex-shrink: 0; }
.dev-card h3 { margin: 0 0 4px; font-size: 16px; }
.dev-card .text-btn { padding: 0; min-height: 32px; }
.about-title { margin: 8px 0 0; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 30;
  display: grid; align-items: end;
}
.sheet {
  background: var(--bg-2); border-radius: 24px 24px 0 0; padding: 18px 18px calc(20px + var(--safe-b));
  border: 1px solid var(--stroke); max-height: 86dvh; overflow: auto;
}
.onboard-sheet { margin: auto 12px 12px; border-radius: 24px; }
.help-tip {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--stroke);
  background: var(--surface); color: var(--muted); font-size: 12px; margin-left: 6px;
}
.tip-pop {
  position: fixed; z-index: 50; max-width: 260px; background: var(--bg-3);
  border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.file-ghost { position: fixed; z-index: 30; pointer-events: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.empty { color: var(--muted); padding: 24px 8px; }

.btn:focus-visible, .nav-item:focus-visible, input:focus-visible, .icon-btn:focus-visible, .toggle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

@media (min-width: 760px) {
  .app { width: min(920px, 100%); padding-left: 28px; padding-right: 28px; }
  .actions { flex-direction: row; justify-content: center; }
  .btn { width: auto; min-width: 200px; }
  .quick-guide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .help-layout { grid-template-columns: 200px minmax(0, 1fr); align-items: start; }
  .help-cats { flex-direction: column; align-items: flex-start; }
  .orb-stage { width: 260px; height: 260px; }
  .bottom-nav { max-width: 560px; margin-left: auto; margin-right: auto; }
}

@media (max-width: 420px) {
  .nav-item span { display: none; }
  .word { letter-spacing: 0.14em; }
  .app-footer { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@keyframes expand { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(14); opacity: 0; } }
@keyframes flow { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.btn { background: var(--accent); color: #23262F; }
html[data-resolved="light"] .btn { color: #23262F; }
.status-dot[data-live="on"] { box-shadow: 0 0 0 4px rgba(182,255,46,0.16); }

.intro-screen {
  position: fixed; inset: 0; z-index: 80;
  background: #23262F; color: #f3f4f0;
  display: grid; place-items: center;
}
.intro-screen[hidden],
.intro-screen.is-done { display: none !important; }
.intro-inner { text-align: center; padding: 24px; }
.intro-logo {
  margin: 0 auto 18px;
  width: 88px; height: 88px;
  display: grid; place-items: center;
  border: 3px solid #B6FF2E;
  border-radius: 50%;
  background: #1b1d24;
  overflow: hidden;
}
.intro-logo-img { width: 56px; height: 56px; object-fit: contain; border-radius: 14px; }
.intro-name { letter-spacing: 0.28em; font-size: 20px; margin: 8px 0 10px; }
.intro-tag { color: #9aa0ad; margin: 0 0 28px; }
.intro-start {
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: #B6FF2E; color: #23262F; font-size: 22px; font-weight: 700;
  z-index: 81; position: relative;
}
.drop-options { width: min(360px, 100%); text-align: left; margin: 0 auto 16px; }
.option-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.field.compact { min-height: 42px; }
.mode-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--muted); font-size: 13px; }
.pending-list, .receiver-list { list-style: none; padding: 0; margin: 10px auto; width: min(360px, 100%); text-align: left; }
.pending-list li, .receiver-list li {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--stroke); font-size: 14px;
}
.pending-list .mini { width: auto; min-width: 0; min-height: 34px; padding: 0 10px; }
.verify-ok { color: var(--ok); }
.verify-bad { color: var(--err); }
