/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface-2:   #263348;
  --primary:     #6366f1;
  --primary-h:   #4f46e5;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --error:       #ef4444;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --border:      #334155;
  --radius:      14px;
  --radius-sm:   8px;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 64px;
}

.app {
  width: 100%;
  max-width: 560px;
  position: relative;
}

/* ── Language switcher ────────────────────────────────────────────────────── */
.lang-switcher {
  position: absolute;
  top: 24px;
  right: 0;
  display: flex;
  gap: 4px;
}

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.lang-btn:hover { color: var(--text); border-color: var(--text-muted); }

.lang-btn.active {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 32px 0 40px;
}

.logo {
  font-size: 48px;
  margin-bottom: 12px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Role selection ───────────────────────────────────────────────────────── */
.role-grid {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.role-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
  text-align: center;
}

.role-card:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.role-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.role-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.role-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.role-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Back button ──────────────────────────────────────────────────────────── */
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

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

/* ── Flow step wrapper ────────────────────────────────────────────────────── */
.flow-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 32px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.step-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── Drop zone ────────────────────────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  margin-bottom: 16px;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.drop-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.drop-main {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.browse-btn {
  display: inline-block;
  padding: 8px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s;
}

.browse-btn:hover { background: var(--border); }

#file-input { display: none; }

/* ── Selected file card ───────────────────────────────────────────────────── */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.file-icon { font-size: 1.5rem; flex-shrink: 0; }

.file-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size { font-size: 0.82rem; color: var(--text-muted); }

.clear-file {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.clear-file:hover { color: var(--error); }

/* ── Key box ──────────────────────────────────────────────────────────────── */
.key-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.key-text {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--primary);
  user-select: all;
}

.copy-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.copy-btn:hover { background: var(--border); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

/* ── Status badge ─────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 500;
}

.status-badge.waiting {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.status-badge.connected {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.waiting .status-dot {
  background: var(--warning);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-badge.connected .status-dot { background: var(--success); }

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

/* ── Key input (receiver) ─────────────────────────────────────────────────── */
.key-input-group {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.key-input-group input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 2px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s;
}

.key-input-group input::placeholder {
  color: var(--border);
  letter-spacing: 1px;
  font-size: 1rem;
}

.key-input-group input:focus { border-color: var(--primary); }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.connecting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}

.connecting p { color: var(--text-muted); font-size: 0.9rem; }

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ── Transfer card ────────────────────────────────────────────────────────── */
.transfer-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 20px;
}

.t-icon { font-size: 1.5rem; flex-shrink: 0; }

.t-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.t-name {
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-size { font-size: 0.82rem; color: var(--text-muted); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; gap: 8px; }

.progress-bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 99px;
  transition: width 0.3s ease;
}

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

/* ── Done card ────────────────────────────────────────────────────────────── */
.done-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 16px 0 4px;
}

.done-icon { font-size: 3rem; }
.done-card h2 { font-size: 1.3rem; font-weight: 700; }
.done-card p  { color: var(--text-muted); font-size: 0.9rem; }

.done-card .primary-btn,
.done-card .secondary-btn { margin-top: 4px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.primary-btn:hover { background: var(--primary-h); }
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.secondary-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Error message ────────────────────────────────────────────────────────── */
.error-msg {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-msg::before { content: '⚠'; }

/* ── How it works ─────────────────────────────────────────────────────────── */
.how-it-works {
  margin-top: 32px;
  padding: 24px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hiw-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.hiw-columns {
  display: flex;
  gap: 0;
}

.hiw-col {
  flex: 1;
  min-width: 0;
}

.hiw-col:first-child {
  padding-right: 20px;
  border-right: 1px solid var(--border);
}

.hiw-col:last-child {
  padding-left: 20px;
}

.hiw-col-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  font-weight: 600;
}

.hiw-col-icon { font-size: 1rem; }

.hiw-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hiw-steps li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.hiw-num {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.hiw-steps strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.hiw-steps p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 460px) {
  .hiw-columns { flex-direction: column; gap: 20px; }
  .hiw-col:first-child {
    padding-right: 0;
    border-right: none;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
  }
  .hiw-col:last-child { padding-left: 0; }
}

.hiw-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Reconnect banner ─────────────────────────────────────────────────────── */
.reconnect-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  color: var(--warning);
  font-size: 0.88rem;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(245, 158, 11, 0.3);
  border-top-color: var(--warning);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.75s linear infinite;
}

/* ── Terms of Service footer ──────────────────────────────────────────────── */
.tos-footer {
  text-align: center;
  padding: 16px 24px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
