*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: oklch(17% 0.018 258);
  --surface: oklch(22% 0.022 258);
  --card: oklch(25.5% 0.026 257);
  --border: oklch(33% 0.032 257);

  --indigo: oklch(70% 0.16 275);
  --green: oklch(74% 0.16 152);
  --rose: oklch(72% 0.17 20);

  --text: oklch(93% 0.012 258);
  --muted: oklch(66% 0.022 258);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}
html[data-theme="light"] {
  --bg: oklch(96.5% 0.008 250);
  --surface: oklch(99% 0.004 250);
  --card: oklch(100% 0 0);
  --border: oklch(87% 0.014 250);

  --indigo: oklch(52% 0.15 275);
  --green: oklch(54% 0.13 152);
  --rose: oklch(58% 0.16 20);

  --text: oklch(24% 0.02 258);
  --muted: oklch(46% 0.024 258);
  --shadow: 0 2px 16px rgba(28,32,51,.08);
}

html { color-scheme: light dark; }
body {
  font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; padding: 64px 16px 32px;
  display: flex; flex-direction: column; align-items: center;
  transition: background-color .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in oklch, var(--indigo) 30%, transparent); }

button, input { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--indigo) 35%, transparent);
  border-radius: var(--radius-sm);
}

.theme-toggle {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 50%;
  cursor: pointer; color: var(--muted);
  transition: background-color .2s, border-color .2s, color .15s;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }
.icon-sun { display: none; }
.icon-moon { display: block; }
html[data-theme="light"] .icon-sun { display: block; }
html[data-theme="light"] .icon-moon { display: none; }

header { text-align: center; margin-bottom: 32px; animation: riseIn .5s var(--ease-out-expo) both; }
header h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.6px; }
header p { color: var(--muted); font-size: .92rem; margin-top: 8px; max-width: 480px; }

.card {
  width: 100%; max-width: 440px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  animation: riseIn .5s .05s var(--ease-out-expo) both;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; cursor: pointer; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .15s var(--ease-out-expo), border-color .15s,
    background-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { border-color: color-mix(in oklch, var(--border) 40%, var(--muted)); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary {
  background: var(--indigo); border-color: var(--indigo);
  color: oklch(99% 0.005 258);
  box-shadow: 0 4px 16px color-mix(in oklch, var(--indigo) 40%, transparent);
}
.btn.primary:hover {
  background: color-mix(in oklch, var(--indigo) 88%, black);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--indigo) 48%, transparent);
}

.btn.accent {
  background: var(--green); border-color: var(--green);
  color: oklch(15% 0.02 152);
  box-shadow: 0 4px 14px color-mix(in oklch, var(--green) 35%, transparent);
}
.btn.accent:hover { background: color-mix(in oklch, var(--green) 88%, black); }

.btn.ghost {
  background: transparent; border-color: transparent; color: var(--muted);
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--surface); border-color: var(--border); color: var(--text);
  transform: none;
}

.btn.small { width: auto; padding: 9px 18px; font-size: .82rem; margin: 0 auto; border-radius: 999px; }
.btn.tiny { width: auto; padding: 6px 14px; font-size: .74rem; border-radius: 999px; box-shadow: none; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.field-label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.join-row { display: flex; gap: 10px; }
.code-input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.1rem; letter-spacing: 3px; font-variant-numeric: tabular-nums;
}
.join-row .btn { width: auto; padding: 12px 20px; }

.qr-card {
  background: #fff; border-radius: var(--radius-sm); padding: 16px;
  width: 200px; height: 200px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.qr-card svg { width: 100%; height: 100%; }

.code-display {
  text-align: center; font-size: 1.9rem; font-weight: 700; letter-spacing: 4px;
  font-variant-numeric: tabular-nums; margin-bottom: 14px;
}

.status {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); font-size: .88rem; text-align: center; margin: 18px 0;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--indigo);
  animation: spin .7s linear infinite; flex-shrink: 0;
}

#viewHost .btn.ghost, #viewJoinConnecting .btn.ghost { margin-top: 4px; }

.conn-badge {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: .82rem; font-weight: 600; color: var(--green); margin-bottom: 20px;
}
.conn-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 32px 16px; text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background-color .15s;
}
.dropzone svg { width: 28px; height: 28px; margin-bottom: 10px; color: var(--muted); }
.dropzone p { font-size: .9rem; color: var(--text); }
.dropzone .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.dropzone:hover, .dropzone.dragover { border-color: var(--indigo); background: color-mix(in oklch, var(--indigo) 6%, transparent); }

.file-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.file-col h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.col-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.col-head h3 { flex: 1 1 auto; }
.col-head .btn { flex: 0 0 auto; white-space: nowrap; }
.file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.file-list.empty-list:empty::before {
  content: attr(data-empty); color: var(--muted); font-size: .8rem; font-style: italic;
}

.file-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: .82rem;
}
.file-item .name { font-weight: 600; word-break: break-all; display: block; margin-bottom: 4px; }
.file-item .meta { color: var(--muted); font-size: .74rem; }
.file-item .bar { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 8px; }
.file-item .bar-fill { height: 100%; background: var(--indigo); border-radius: 999px; transition: width .15s; }
.file-item.done .bar-fill { background: var(--green); }
.file-item a.download {
  display: inline-block; margin-top: 8px; color: var(--indigo); font-weight: 600; text-decoration: none;
}
.file-item a.download:hover { text-decoration: underline; }

.banner {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .82rem;
  background: color-mix(in oklch, var(--rose) 14%, transparent);
  border: 1px solid color-mix(in oklch, var(--rose) 35%, transparent);
  color: var(--text);
}

.keep-open-note {
  margin-top: 18px; color: var(--muted); font-size: .8rem; text-align: center; max-width: 440px;
}

footer { margin-top: auto; padding-top: 40px; color: var(--muted); font-size: .76rem; text-align: center; max-width: 480px; }
footer p + p { margin-top: 8px; }
footer .credit { opacity: .75; font-size: .72rem; }

@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 480px) {
  header h1 { font-size: 1.6rem; }
  .card { padding: 26px 20px; }
  .file-lists { grid-template-columns: 1fr; }
}
