:root {
  --paper: #f2f4f7;
  --ink: #13213c;
  --slate: #5a6478;
  --rule: #d4dae3;
  --tint: #dce4f2;
  --tint-line: #c3cfe6;
  --window: #ffffff;
  --ok: #1c7a52;
  --danger: #b42318;
  --focus: #2f5bea;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1526;
    --ink: #e7ecf6;
    --slate: #9aa5bc;
    --rule: #28334f;
    --tint: #16203b;
    --tint-line: #24335d;
    --window: #0a1020;
    --ok: #5bc794;
    --danger: #ff8a7a;
    --focus: #8ea8ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.masthead, main, .foot {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 640px) {
  .masthead, main, .foot { padding-left: 24px; padding-right: 24px; }
}

.masthead { padding-top: 20px; padding-bottom: 8px; }

.wordmark {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

main { flex: 1; padding-bottom: 56px; }

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 1.25rem + 3.4vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 36px 0 16px;
  max-width: 17ch;
  text-wrap: balance;
}

h2 { font-size: 1.08rem; font-weight: 650; margin: 0 0 4px; }

p { margin: 0; }

.lede { color: var(--slate); font-size: 1.06rem; max-width: 36rem; }

.hint { color: var(--slate); font-size: 0.9rem; }

.error { color: var(--danger); font-size: 0.95rem; margin: 0 0 12px; }
.error:empty { display: none; }

/* ---------- home ---------- */

.paths {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 40px;
  border-top: 1px solid var(--rule);
}

.path { padding: 24px 0 28px; display: flex; flex-direction: column; align-items: flex-start; }
.path > p:first-of-type { color: var(--slate); margin-bottom: 20px; }
.path + .path { border-top: 1px solid var(--rule); }

@media (min-width: 720px) {
  .paths { grid-template-columns: 1fr 1fr; }
  .path:first-child { padding-right: 32px; }
  .path + .path { border-top: 0; border-left: 1px solid var(--rule); padding-left: 32px; }
}

.field { display: block; font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }

select, input[type="text"] {
  font: inherit;
  color: inherit;
  background: var(--window);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  width: 100%;
}

input[type="text"] { font-family: var(--serif); font-size: 1.1rem; }
input::placeholder { color: var(--slate); opacity: 0.6; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.95rem;
  margin: 16px 0 22px;
  cursor: pointer;
}
.check input { margin-top: 4px; accent-color: var(--ink); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--slate); font-size: 0.85rem; margin-top: 2px; }

.slots {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 14px 0 6px;
  width: 100%;
  counter-reset: slot;
}
.slots li {
  counter-increment: slot;
  font-family: var(--serif);
  font-size: clamp(0.82rem, 0.6rem + 1.2vw, 1rem);
  text-align: center;
  color: var(--slate);
}
.slots li span {
  display: block;
  min-height: 1.6em;
  border-bottom: 2px solid var(--rule);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slots li::after {
  content: counter(slot);
  display: block;
  font: 600 0.7rem/1 var(--sans);
  color: var(--slate);
  margin-top: 5px;
}
.slots li.ok { color: var(--ink); }
.slots li.ok span { border-color: var(--ok); }
.slots li.bad { color: var(--danger); }
.slots li.bad span { border-color: var(--danger); }

#join-form .hint { margin-bottom: 20px; }

.how { margin-top: 32px; border-top: 1px solid var(--rule); padding-top: 18px; }
.how summary { cursor: pointer; font-weight: 600; }
.how ul { color: var(--slate); padding-left: 1.2em; margin: 12px 0 0; max-width: 38rem; }
.how li + li { margin-top: 8px; }

/* ---------- buttons ---------- */

button, .button { font: inherit; cursor: pointer; border-radius: 6px; line-height: 1.3; }

.primary {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 11px 20px;
  font-weight: 600;
  text-decoration: none;
}
.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
.primary:disabled { opacity: 0.35; cursor: not-allowed; background: var(--ink); }

.quiet {
  background: var(--window);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 7px 14px;
}
.quiet:hover:not(:disabled) { border-color: var(--slate); }
.quiet:disabled { opacity: 0.45; cursor: not-allowed; }

.link {
  background: none;
  border: 0;
  color: var(--slate);
  padding: 7px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }

.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid currentColor;
  padding: 10px 18px;
  font-weight: 600;
}
.danger.armed { background: var(--danger); border-color: var(--danger); color: var(--paper); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

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

/* ---------- busy ---------- */

#busy { padding-top: 64px; }
.busy-title { font-family: var(--serif); font-size: 1.6rem; margin-bottom: 18px; }
.progress-line { height: 3px; width: 100%; max-width: 22rem; background: var(--rule); overflow: hidden; border-radius: 2px; margin-bottom: 14px; }
.progress-line span { display: block; height: 100%; width: 35%; background: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .progress-line span { animation: slide 1.1s ease-in-out infinite alternate; }
}
@keyframes slide { from { transform: translateX(-10%); } to { transform: translateX(200%); } }

/* ---------- session: the code slip (a window envelope) ---------- */

.slip {
  margin: 28px 0 20px;
  padding: 16px;
  border-radius: 10px;
  background-color: var(--tint);
  background-image:
    repeating-linear-gradient(135deg, var(--tint-line) 0 1.5px, transparent 1.5px 6px),
    repeating-linear-gradient(45deg, var(--tint-line) 0 1px, transparent 1px 11px);
}

.window {
  background: var(--window);
  border: 1px solid var(--tint-line);
  border-radius: 6px;
  padding: 22px 20px 16px;
}

.code {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  counter-reset: word;
}
.code li { counter-increment: word; display: flex; flex-direction: column; }
.code .word {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 1rem + 3.3vw, 2.6rem);
  line-height: 1.05;
}
.code li::after {
  content: counter(word);
  font: 600 0.72rem/1 var(--sans);
  color: var(--slate);
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
}

.slip-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 14px;
}
.slip-foot p { font-size: 0.95rem; font-weight: 600; }
.slip-actions { display: flex; gap: 8px; }

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 20px;
  color: var(--slate);
  font-size: 0.95rem;
  margin-bottom: 20px;
}
.presence { display: flex; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--slate); margin-right: 9px; flex: none; }
.dot.live { background: var(--ok); }
.dot.waiting { background: transparent; border: 1.5px solid var(--slate); }

.notice {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-left: 3px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-radius: 0 6px 6px 0;
}
.notice.info { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, transparent); }
#insecure { margin-top: 24px; }

.drop {
  border: 1.5px dashed color-mix(in srgb, var(--slate) 60%, transparent);
  border-radius: 10px;
  padding: 26px 20px 22px;
  text-align: center;
  color: var(--slate);
  transition: background-color 0.15s, border-color 0.15s;
}
.drop p { margin-top: 10px; font-size: 0.95rem; }
.drop .upload-note { color: var(--ink); font-weight: 600; }
.drop .upload-note:empty { display: none; }
body.dragging .drop { border-color: var(--ink); border-style: solid; background: var(--tint); }

.files { list-style: none; margin: 24px 0 0; padding: 0; }
.files:empty { display: none; }

.file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}
.file:last-child { border-bottom: 1px solid var(--rule); }
.file-text { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-detail { color: var(--slate); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.file.failed .file-detail { color: var(--danger); }
.file-actions { display: flex; align-items: center; gap: 6px; }
.bar { grid-column: 1 / -1; height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }

@media (max-width: 480px) {
  .file { grid-template-columns: minmax(0, 1fr); }
}

.empty { color: var(--slate); margin-top: 20px; }

.end { margin-top: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }

/* ---------- ended ---------- */

#ended .lede { margin-bottom: 28px; }

.foot { padding-bottom: 28px; color: var(--slate); font-size: 0.85rem; }
.foot p { border-top: 1px solid var(--rule); padding-top: 20px; }
