:root {
  --bg: #070b14;
  --bg-2: #0d1424;
  --surface: #141c2e;
  --surface-2: #1b2540;
  --line: rgba(230, 238, 255, 0.1);
  --text: #f3f6ff;
  --muted: #8b97b3;
  --mint: #3ee0b5;
  --mint-dim: rgba(62, 224, 181, 0.16);
  --sky: #7eb4ff;
  --sky-dim: rgba(126, 180, 255, 0.14);
  --danger: #ff6b7a;
  --warn: #ffc857;
  --ok: #3ee0b5;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  background:
    radial-gradient(900px 520px at 110% -10%, rgba(62, 224, 181, 0.14), transparent 50%),
    radial-gradient(700px 420px at -20% 110%, rgba(126, 180, 255, 0.12), transparent 46%),
    var(--bg);
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  mask-image: linear-gradient(#000, transparent 92%);
}

.app {
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  animation: rise 0.28s ease;
}

.screen.is-active {
  display: flex;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  margin: 4px 0 2px;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.mode-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  font-size: 0.82rem;
  padding: 12px 8px;
  border-radius: 12px;
  min-height: 48px;
}

.mode-toggle button.is-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.actions {
  display: grid;
  gap: 12px;
}

.card-btn {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: inherit;
  border-radius: var(--radius);
  padding: 18px 16px;
  min-height: 92px;
  box-shadow: var(--shadow);
}

.card-btn strong {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.card-btn span {
  color: var(--muted);
  font-size: 0.9rem;
}

.card-btn.send {
  box-shadow: var(--shadow), 0 0 0 1px var(--mint-dim);
}

.card-btn.receive {
  box-shadow: var(--shadow), 0 0 0 1px var(--sky-dim);
}

.note {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.note strong {
  color: var(--text);
  font-weight: 650;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.back {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  min-width: 44px;
  min-height: 44px;
  font: inherit;
}

.screen-title {
  margin: 0;
  font-size: 1.05rem;
}

.peer-code {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 4px;
}

.peer-code span {
  width: 42px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: 0;
}

.qr-wrap {
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  margin: 0 auto;
  width: min(100%, 308px);
}

.qr-wrap canvas,
.qr-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(255, 200, 87, 0.12);
  animation: pulse 1.4s ease infinite;
}

.status-pill.is-live .dot {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(62, 224, 181, 0.14);
}

@keyframes pulse {
  50% {
    transform: scale(0.75);
    opacity: 0.65;
  }
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.82rem;
  color: var(--muted);
}

input[type="text"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px;
  min-height: 52px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 700;
}

textarea {
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  min-height: 96px;
  resize: vertical;
}

.btn,
button.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  border-radius: 14px;
  min-height: 52px;
  padding: 0 16px;
  cursor: pointer;
}

.btn-primary {
  background: var(--mint);
  color: #06241c;
  box-shadow: 0 8px 24px rgba(62, 224, 181, 0.2);
}

.btn-sky {
  background: var(--sky);
  color: #071225;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.35);
}

.stack {
  display: grid;
  gap: 10px;
}

.steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.steps li + li {
  margin-top: 8px;
}

.scan-stage {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background: #000;
  aspect-ratio: 3 / 4;
}

.scan-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-corners {
  pointer-events: none;
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(62, 224, 181, 0.85);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}

.drop {
  border: 1.5px dashed rgba(230, 238, 255, 0.22);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: rgba(20, 28, 46, 0.55);
}

.drop.is-over {
  border-color: var(--mint);
  background: var(--mint-dim);
}

.drop p {
  margin: 0 0 12px;
  color: var(--muted);
}

.progress {
  display: grid;
  gap: 8px;
}

.bar {
  height: 10px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--sky));
  border-radius: inherit;
  transition: width 0.16s linear;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.result {
  text-align: center;
  padding: 8px 0;
}

.result h3 {
  margin: 0 0 6px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: min(420px, calc(100% - 24px));
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 20;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error {
  border-color: rgba(255, 107, 122, 0.45);
}

.file-chip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: 14px;
  border: 1px solid var(--line);
}

.file-chip small {
  color: var(--muted);
}

.noscript {
  padding: 24px;
  text-align: center;
}

button:disabled {
  opacity: 0.5;
}

@media (hover: hover) and (pointer: fine) {
  .card-btn:hover,
  .btn:hover,
  .mode-toggle button:hover,
  .back:hover {
    filter: brightness(1.08);
  }
}
