:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #687084;
  --line: #e2e5ee;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --wait: #d97706;
  --bad: #dc2626;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #171b24;
    --text: #e6e9ef;
    --muted: #98a1b3;
    --line: #2a3040;
    --accent: #818cf8;
    --accent-text: #0f1218;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

main { max-width: 560px; margin: 0 auto; padding: 32px 16px 48px; }

header { text-align: center; margin-bottom: 24px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; }
.tagline { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

button, input { font: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primary {
  width: 100%;
  padding: 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.link {
  display: block;
  margin: 20px auto 0;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
}

input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.row { display: flex; gap: 8px; }
.or { margin: 16px 0 8px; text-align: center; color: var(--muted); font-size: 0.9rem; }
#code-input { text-align: center; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 600; }
#code-input::placeholder { letter-spacing: normal; font-weight: 400; text-transform: none; }
.error { margin: 12px 0 0; text-align: center; color: var(--bad); }

.label {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.code {
  margin: 0 0 12px;
  text-align: center;
  font: 700 2.4rem/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.15em;
}
.qr { display: flex; justify-content: center; margin-bottom: 14px; }
.qr svg { width: 180px; height: 180px; padding: 6px; border-radius: 10px; background: #fff; }
.hint { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 0.85rem; }

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
  color: var(--muted);
}
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--wait); }
#invite[hidden] + .status { margin-top: 0; }
.status.ok { color: var(--text); font-weight: 600; }
.status.ok .dot { background: var(--ok); }
.status.bad .dot { background: var(--bad); }
.route {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font: 0.75rem/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-line;
  cursor: help;
}

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 20px;
  padding: 32px 16px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop strong { color: var(--accent); font-size: 1.05rem; }
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.list { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.item-head, .item-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.item.in .name::before { content: "↓ "; color: var(--ok); }
.item.out .name::before { content: "↑ "; color: var(--accent); }
.size, .info { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.item.failed .info { color: var(--bad); }
.save { color: var(--accent); font-weight: 600; }
.preview { display: block; max-width: 100%; max-height: 160px; margin-top: 8px; border-radius: 8px; }

progress {
  width: 100%;
  height: 6px;
  margin: 8px 0 4px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--line);
  appearance: none;
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.item.done progress::-webkit-progress-value { background: var(--ok); }
.item.done progress::-moz-progress-bar { background: var(--ok); }

footer { margin-top: 24px; text-align: center; color: var(--muted); font-size: 0.8rem; }
