:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #1b1d2a;
  --muted: #676b80;
  --border: #e2e4ee;
  --accent: #6d4dff;
  --accent-2: #0fb5d4;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --track: #eceef6;
  --shadow: 0 1px 2px rgb(20 20 40 / 6%), 0 4px 16px rgb(20 20 40 / 5%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020;
    --card: #181a2e;
    --text: #e9eaf5;
    --muted: #9a9db8;
    --border: #2a2d47;
    --accent: #8b72ff;
    --accent-2: #22d3ee;
    --track: #25283f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

header { text-align: center; margin-bottom: 28px; }
h1 {
  margin: 0;
  font-size: 2rem;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.logo { width: 40px; height: 40px; }
.tagline { color: var(--muted); margin: 8px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 18px;
  transition: filter .15s, background .15s;
}
button:disabled { opacity: .5; cursor: default; }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  font-weight: 600;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.secondary { background: var(--track); color: var(--text); border-color: var(--border); }
button.secondary:hover:not(:disabled) { filter: brightness(.97); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }
button.big { width: 100%; padding: 16px; font-size: 1.1rem; }
button.small { padding: 6px 12px; font-size: .9rem; }
button.ok { background: var(--ok); color: #fff; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: .9rem;
  margin: 20px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.join { display: flex; gap: 8px; }
.join input {
  flex: 1;
  min-width: 0;
  font: 600 1.4rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .15em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.join input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.label {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.code-card { text-align: center; }
.code {
  font: 700 2.6rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .12em;
  margin: 4px 0 12px;
  user-select: all;
}
.code-actions { display: flex; justify-content: center; gap: 8px; }

.status { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.waiting { background: var(--warn); animation: pulse 1.4s infinite; }
.dot.connected { background: var(--ok); }
.dot.error { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

.security { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.security > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.emoji { font-size: 1.6rem; letter-spacing: .15em; }

.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.note { margin: -4px 4px 16px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 36px 20px;
  border: 2px dashed var(--border);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone input { display: none; }
.dropzone:hover:not(.disabled), .dropzone.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--card));
}
.dropzone.disabled { cursor: not-allowed; opacity: .55; }
.dz-title { font-weight: 600; font-size: 1.05rem; }
.dz-hint { color: var(--muted); font-size: .88rem; }

.transfers { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.transfer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.transfer .row { display: flex; align-items: center; gap: 12px; }
.transfer .dir {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--track);
}
.transfer.out .dir { color: var(--accent); }
.transfer.in .dir { color: var(--accent-2); }
.transfer .info { flex: 1; min-width: 0; }
.transfer .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer .meta { color: var(--muted); font-size: .85rem; }
.transfer .meta.err { color: var(--err); }
.transfer .meta.ok { color: var(--ok); }
.transfer .actions { display: flex; gap: 6px; flex: none; }
.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
  margin-top: 10px;
}
.progress > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .1s linear;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--err);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 20%);
}
.toast.info { background: var(--text); color: var(--bg); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

@media (max-width: 480px) {
  main { padding-top: 20px; }
  h1 { font-size: 1.6rem; }
  .code { font-size: 2rem; }
  .transfer .row { flex-wrap: wrap; }
  .transfer .actions { width: 100%; justify-content: flex-end; }
}
