:root {
  --bg: #0a0b0d;
  --bg-1: #0e1013;
  --surface: #131519;
  --surface-2: #1a1d22;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #f3f4f6;
  --text-dim: #9a9fa8;
  --text-faint: #5f636b;
  --accent: #6e7cf6;
  --accent-soft: rgba(110, 124, 246, 0.14);
  --accent-2: #3ee6ad;
  --accent-2-soft: rgba(62, 230, 173, 0.14);
  --danger: #f0655a;
  --warn: #f5b955;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
::selection { background: var(--accent); color: white; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 420px at 14% -8%, rgba(110, 124, 246, 0.16), transparent 60%),
    radial-gradient(560px 360px at 100% 8%, rgba(62, 230, 173, 0.10), transparent 60%);
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

button, input, textarea { font-family: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ================= pairing screen ================= */

#pairScreen {
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.card {
  width: 100%;
  background: linear-gradient(180deg, var(--surface), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card-pair {
  max-width: 440px;
  padding: 8px 28px 28px;
  animation: rise 0.5s var(--ease);
}

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

.hero {
  display: flex;
  justify-content: center;
  padding: 22px 0 4px;
}
.hero-svg { width: 100%; max-width: 260px; height: auto; overflow: visible; }
#heroPath {
  animation: dash-flow 3.5s linear infinite;
}
@keyframes dash-flow {
  to { stroke-dashoffset: -140; }
}
.hero-node {
  animation: node-in 0.6s var(--ease) backwards, node-glow 2.6s ease-in-out infinite;
  transform-origin: center;
}
.hero-node-a { animation-delay: 0.05s, 0.6s; }
.hero-node-b { animation-delay: 0.2s, 0.6s; }
@keyframes node-in {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes node-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(110, 124, 246, 0)); }
  50% { filter: drop-shadow(0 0 6px rgba(110, 124, 246, 0.55)); }
}

.title {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 4px 0 8px;
}

.sub {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
  text-align: center;
  margin: 0 0 24px;
}

.segmented {
  position: relative;
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.segmented-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.35s var(--ease);
  z-index: 0;
}
.segmented:has(.tab[data-tab="join"].active) .segmented-thumb {
  transform: translateX(100%);
}
.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 560;
  transition: color 0.25s var(--ease);
}
.tab.active { color: var(--text); }

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fade-in 0.3s var(--ease);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.5; }
.hint.small { font-size: 12px; color: var(--text-faint); }

.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 580;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn-primary:active, .btn-secondary:active, .btn-ghost:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, #7885f8, var(--accent));
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 20px -8px rgba(110, 124, 246, 0.7);
}
.btn-primary:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 10px 24px -8px rgba(110, 124, 246, 0.85); }
.btn-primary svg { transition: transform 0.2s var(--ease); }
.btn-primary:hover svg { transform: translateX(2px); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: #1e2127; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); }

.icon-check { color: var(--accent-2); }
.btn-secondary.copied .icon-copy { display: none; }
.btn-secondary:not(.copied) .icon-check { display: none; }
.btn-secondary.copied { border-color: rgba(62, 230, 173, 0.4); background: var(--accent-2-soft); }
.btn-secondary.copy-failed { border-color: rgba(240, 101, 90, 0.4); background: rgba(240, 101, 90, 0.12); color: var(--danger); }
.btn-secondary.copy-failed .icon-copy { display: none; }

.code-box {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  animation: fade-in 0.3s var(--ease);
}
.code-display {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  background: var(--surface-2);
  background-image: linear-gradient(135deg, var(--accent-soft), transparent 60%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 8px;
  color: var(--text);
  user-select: all;
}

.code-input {
  width: 100%;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 8px;
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.code-input::placeholder { color: var(--text-faint); font-weight: 500; }
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.code-input.shake { animation: shake 0.4s; border-color: var(--danger); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.footnote {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 22px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
}
.footnote svg { flex-shrink: 0; margin-top: 1px; }

/* ================= app screen ================= */

#appScreen { padding: 0 16px 24px; }
.shell { max-width: 980px; margin: 0 auto; width: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 4px;
}

.brand-mini { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.brand-mini-icon { width: 20px; height: 20px; border-radius: 5px; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  margin-left: auto;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(245, 185, 85, 0.18);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.dot.ok { background: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-2-soft); animation: none; }
.dot.p2p { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: none; }
.dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(240, 101, 90, 0.18); animation: none; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.dot-tiny {
  display: inline-block;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-faint);
  margin-right: 6px;
}

.content {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  animation: fade-in 0.4s var(--ease);
}

.panel {
  background: linear-gradient(180deg, var(--surface), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.25s var(--ease);
}
.panel:hover { border-color: var(--border-hover); }

.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--border);
}
.panel-icon-clip { background: var(--accent-soft); color: var(--accent); }
.panel-icon-file { background: var(--accent-2-soft); color: var(--accent-2); }
.panel h2 { margin: 0 0 3px; font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.panel-hint { margin: 0; color: var(--text-dim); font-size: 12px; line-height: 1.5; }

textarea {
  width: 100%;
  min-height: 108px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 13px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
textarea::placeholder { color: var(--text-faint); }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.clip-remote-wrap { margin-top: 14px; }
.clip-remote-label {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.muted { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.btn-secondary.small { margin-top: 10px; padding: 8px 13px; font-size: 12px; }

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 30px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.drop-icon { color: var(--text-faint); transition: color 0.2s var(--ease), transform 0.2s var(--ease); }
.drop-zone.drag { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.drop-zone.drag .drop-icon { color: var(--accent); transform: translateY(-3px); }
.drop-zone p { margin: 0; }

.file-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13px;
  animation: item-in 0.3s var(--ease);
}
@keyframes item-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.file-icon {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 540; }
.file-item .meta { color: var(--text-dim); font-size: 11.5px; margin-top: 1px; }
.file-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 7px;
}
.file-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.15s ease-out;
}

.foot-note { text-align: center; color: var(--text-faint); font-size: 11.5px; padding: 20px 8px 4px; line-height: 1.6; }

@media (max-width: 760px) {
  .content { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .code-display { font-size: 21px; letter-spacing: 2px; }
  .status span:not(.dot) { display: none; }
}
