/* Ephemeral: cool vellum paper, navy ink, one ultramarine seal. System fonts
   only: no third-party requests, nothing that could leak a visit. */

:root {
  --paper: #EEF2F6;
  --sheet: #F8FAFC;
  --ink: #14233B;
  --slate: #5B6A7F;
  --line: #CBD4DE;
  --seal: #3346D3;
  --seal-ink: #FFFFFF;
  --live: #1F7A55;
  --amber: #A65A12;
  --red: #B3261E;
  --focus: #3346D3;
  --radius-s: 6px;
  --radius-m: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.125rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121C2E;
    --sheet: #17233A;
    --ink: #E3E9F2;
    --slate: #9AA8BD;
    --line: #2C3A54;
    --seal: #7C8CFF;
    --seal-ink: #10172A;
    --live: #4CC38A;
    --amber: #E3A35B;
    --red: #FF8A80;
    --focus: #9AA6FF;
    color-scheme: dark;
  }
}

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

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--sheet);
  border-radius: var(--radius-s);
  padding: 0.4rem 0.8rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--slate); }
.btn-primary { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--seal); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--slate); }
.btn-quiet:hover { color: var(--ink); border-color: var(--line); }
.icon-btn {
  appearance: none; border: 0; background: none; color: var(--slate);
  padding: 0.15rem 0.35rem; border-radius: var(--radius-s); cursor: pointer; font-size: var(--step--1);
}
.icon-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--line) 50%, transparent); }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--sheet);
}

/* ---------- seal (generated from the key fingerprint) ---------- */
.seal { width: 28px; height: 28px; flex: none; }
.seal-lg { width: 88px; height: 88px; }
.seal .rim { fill: var(--seal); }
.seal .cell { fill: var(--seal-ink); }
.seal.forming .cell { animation: form 1.4s ease-in-out infinite alternate; }
.seal.formed .cell { animation: settle 0.6s ease-out both; }
@keyframes form { from { opacity: 0.15; } to { opacity: 0.9; } }
@keyframes settle { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.seal .cell { transform-box: fill-box; transform-origin: center; }

/* ---------- join / unlock ---------- */
.join {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.join-card {
  width: min(34rem, 100%);
  display: grid;
  gap: 1.25rem;
  justify-items: start;
}
.join-card h1 { font-size: var(--step-3); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; max-width: 20ch; text-wrap: balance; }
.lede { font-size: var(--step-1); color: var(--slate); max-width: 34em; }
.join-block { display: grid; gap: 0.75rem; justify-items: start; width: 100%; }
.join-alt { border-top: 1px solid var(--line); padding-top: 1.25rem; }
.join-alt > label, .field > label { font-weight: 600; }
.field { display: grid; gap: 0.4rem; width: 100%; }
.row { display: flex; gap: 0.5rem; width: 100%; }
.check { display: flex; gap: 0.5rem; align-items: center; color: var(--slate); cursor: pointer; }
.hint { font-size: var(--step--1); color: var(--slate); max-width: 40em; }
.deriving { justify-items: center; text-align: center; color: var(--slate); }
.noscript { padding: 2rem; }

/* ---------- room ---------- */
.room {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.seal-btn {
  display: flex; align-items: center; gap: 0.55rem;
  border: 0; background: none; padding: 0.2rem; cursor: pointer; border-radius: 999px;
}
.brand { font-weight: 700; font-size: var(--step-1); letter-spacing: -0.01em; }

.status { font-size: var(--step--1); color: var(--slate); display: flex; align-items: center; gap: 0.4rem; }
.status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--slate);
}
.status[data-state="live"]::before { background: var(--live); }
.status[data-state="reconnecting"]::before, .status[data-state="waiting"]::before, .status[data-state="seeding"]::before { background: var(--amber); }
.status[data-state="closed"]::before { background: var(--red); }

.people { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.person {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--step--1); color: var(--slate);
  padding: 0.1rem 0.5rem 0.1rem 0.35rem; border-radius: 999px;
  border: 1px solid var(--line);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--slate)); flex: none; }
.person.typing .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--slate)) 35%, transparent); }

.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.me {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--line); background: var(--sheet); border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.5rem; cursor: pointer; font-weight: 550;
}

.work {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
}

.pad-wrap { position: relative; min-height: 0; display: flex; }
.pad {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  padding: 1.25rem 1.5rem 3rem;
  background: var(--sheet);
  color: var(--ink);
  font: 400 0.9375rem/1.6 var(--mono);
  tab-size: 4;
  outline: none;
}
.pad:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--focus); }
.pad[readonly] { color: var(--slate); }
.pad-overlay {
  position: absolute; left: 1.5rem; bottom: 1rem;
  font-size: var(--step--1); color: var(--amber);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 0.3rem 0.6rem;
}

.rail {
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 1rem;
  display: grid;
  gap: 1.5rem;
  align-content: start;
}
.panel { display: grid; gap: 0.6rem; }
.panel h2 { font-size: var(--step-0); font-weight: 700; }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-m);
  padding: 0.9rem 1rem;
  font-size: var(--step--1);
  color: var(--slate);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--seal); color: var(--ink); }
.linkish { color: var(--seal); text-decoration: underline; text-underline-offset: 2px; }

.files, .links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }

.file {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) auto;
  gap: 0.15rem 0.6rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: var(--radius-m);
  background: var(--sheet);
  border: 1px solid var(--line);
}
.file .thumb {
  grid-row: span 2;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-s);
  background: var(--paper); display: grid; place-items: center;
  font-size: 0.6875rem; font-weight: 700; color: var(--slate); overflow: hidden;
  border: 0; padding: 0;
}
.file .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
button.thumb { cursor: zoom-in; }
.file .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .meta { font-size: var(--step--1); color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .actions { grid-row: span 2; display: flex; gap: 0.25rem; align-items: center; }
.file .bar-track {
  grid-column: 2 / 4; height: 4px; border-radius: 2px; background: var(--paper); overflow: hidden;
}
.file .bar-fill { height: 100%; width: var(--p, 0%); background: var(--seal); transition: width 0.15s linear; }
.file.failed .meta { color: var(--red); }
.file.waiting .meta { color: var(--amber); }

.links a {
  display: block;
  font-size: var(--step--1);
  color: var(--seal);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-underline-offset: 2px;
}
.empty { font-size: var(--step--1); color: var(--slate); }

.foot {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 1rem;
  border-top: 1px solid var(--line);
  font-size: var(--step--1);
  color: var(--slate);
}
.count { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- code integrity ---------- */
.tamper {
  position: sticky; top: 0; z-index: 40;
  background: var(--red); color: #fff;
  padding: 0.7rem 1rem;
  font-weight: 550;
}
.tamper p { max-width: 70em; }
.tamper p + p { font-weight: 400; margin-top: 0.25rem; font-size: var(--step--1); }
.boot-fallback {
  padding: 2rem 1.25rem; color: var(--slate); max-width: 40em;
  opacity: 0; animation: appear 0.3s ease-out 4s forwards;
}
@keyframes appear { to { opacity: 1; } }

/* ---------- overlays ---------- */
.dragging {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border: 3px dashed var(--seal);
  font-size: var(--step-2); font-weight: 700; color: var(--seal);
  pointer-events: none; z-index: 20;
}
.toasts {
  position: fixed; right: 1rem; bottom: 3rem; display: grid; gap: 0.5rem; z-index: 30; max-width: min(26rem, calc(100% - 2rem));
}
.toast {
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 0.85rem; border-radius: var(--radius-m);
  font-size: var(--step--1);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--ink) 25%, transparent);
}
.toast.error { background: var(--red); color: #fff; }
.toast.warn { background: var(--amber); color: #fff; }

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--sheet); color: var(--ink);
  padding: 1.5rem; width: min(26rem, calc(100% - 2rem));
}
.dialog form { display: grid; gap: 0.8rem; justify-items: start; }
.dialog h2 { font-size: var(--step-2); }
.dialog::backdrop { background: color-mix(in srgb, var(--ink) 40%, transparent); }
.fingerprint { font: 600 var(--step-1)/1.3 var(--mono); letter-spacing: 0.04em; }

.viewer { border: 0; padding: 0; background: transparent; max-width: 92vw; max-height: 92vh; }
.viewer::backdrop { background: color-mix(in srgb, #000 75%, transparent); }
.viewer img { display: block; max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: var(--radius-s); }
.viewer form { display: flex; justify-content: flex-end; }
.viewer-close { border: 0; background: none; color: #fff; padding: 0.4rem; cursor: pointer; font-weight: 600; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .room { height: auto; min-height: 100%; }
  .work { grid-template-columns: 1fr; }
  .pad-wrap { min-height: 55vh; }
  .rail { border-left: 0; border-top: 1px solid var(--line); }
  .bar { gap: 0.6rem; }
  .bar-actions { margin-left: 0; width: 100%; }
  .bar-actions .me { margin-left: auto; }
  .foot { flex-direction: column; gap: 0.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .boot-fallback { opacity: 1; }
}
