:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #5f6b67;
  --line: #dfe5e2;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --here: #1f9d55;
  --away: #a3aca8;
  --mine: #e3f1ec;
  --theirs: #eef1f0;
  --error-bg: #fdecea;
  --ok-bg: #e7f4ee;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --card: #1b211f;
    --text: #e6ecea;
    --muted: #9aa6a1;
    --line: #2c3532;
    --accent: #3fa58a;
    --accent-text: #0d1311;
    --danger: #f2827a;
    --here: #4cc985;
    --away: #5b6662;
    --mine: #1f3a32;
    --theirs: #232b28;
    --error-bg: #3a1f1d;
    --ok-bg: #1b3329;
  }
}

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

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

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

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
p { margin: 0 0 8px; }
code { font-size: .9em; background: var(--theirs); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}
.narrow { max-width: 420px; margin: 48px auto; }

.bar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; }

.hint { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); margin: 0; }
.error { color: var(--danger); }
.notice { color: var(--muted); }

.flash p:last-child { margin: 0; }
.flash.error { background: var(--error-bg); color: var(--text); }
.flash.ok { background: var(--ok-bg); }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label .hint { font-size: .85rem; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.stack label { width: 100%; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.grid .wide { grid-column: 1 / -1; }
.grid .wide .hint { margin-left: 12px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr 1fr; } .grid .len { grid-column: 1 / -1; } }

button, .button {
  font: inherit;
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.danger { color: var(--danger); }
.danger.big { background: var(--danger); border-color: var(--danger); color: #fff; }
.link { border: 0; background: none; color: var(--muted); padding: 4px; }
.big { padding: 12px 22px; font-size: 1.05rem; min-width: 120px; }

/* invitation list */
.rooms { list-style: none; margin: 0; padding: 0; }
.room { border-top: 1px solid var(--line); padding: 12px 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.room:first-child { border-top: 0; padding-top: 0; }
.room .who { display: flex; flex-direction: column; }
.room .when { text-align: right; }
.room .chips { grid-column: 1 / -1; }
.room .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.room .more { grid-column: 1 / -1; }
.room .more summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.room .more form { margin-top: 10px; }
.chip { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--theirs); color: var(--muted); margin-right: 6px; }
.chip.open { background: var(--ok-bg); color: var(--text); }
.chip.here { background: var(--here); color: #fff; }
.contacts { list-style: none; margin: 0; padding: 0; }
.contact { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding: 8px 0; }
.contact:first-child { border-top: 0; }
.contact .who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.contact .who .hint { overflow-wrap: anywhere; }
@media (max-width: 520px) { .contact { flex-wrap: wrap; } }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 12px; }

/* the room */
.head h1 { margin-bottom: 2px; }
.presence { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-weight: 600; }
.presence .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--away); flex: none; }
.presence.here .dot { background: var(--here); box-shadow: 0 0 0 4px color-mix(in srgb, var(--here) 25%, transparent); }

.callbox { text-align: center; }
.call-status { font-size: 1.15rem; font-weight: 600; min-height: 1.6em; margin-bottom: 4px; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.call-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.callbox .hint { min-height: 1.3em; margin: 0; }

.msgs { list-style: none; margin: 0 0 12px; padding: 0; max-height: 45vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msgs:empty::before { content: "No messages yet."; color: var(--muted); font-size: .9rem; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--theirs); align-self: flex-start; }
.msg.me { background: var(--mine); align-self: flex-end; }
.msg.system { background: none; align-self: center; color: var(--muted); font-size: .85rem; padding: 2px 0; text-align: center; }
.msg .meta { display: block; font-size: .75rem; color: var(--muted); }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.system .meta { display: inline; margin-right: 6px; }

.say { display: flex; gap: 8px; align-items: flex-end; }
.say textarea { resize: vertical; min-height: 44px; }
