:root {
  --bg: #fbfbfa; --fg: #1d1d1b; --dim: #85857f; --line: #e4e4df; --field: #fff;
  --accent: #1d1d1b; --accent-fg: #fbfbfa;
  --warn: #c0392b; --sys: #946700; --dm: #8e44ad;
  --n0: #c0392b; --n1: #2e8b3e; --n2: #a07800; --n3: #2c64c4; --n4: #9b3fb0; --n5: #16867f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --fg: #e4e4df; --dim: #7c7c76; --line: #2a2a28; --field: #1d1d1b;
    --accent: #e4e4df; --accent-fg: #151514;
    --warn: #ff6b5b; --sys: #d9a93a; --dm: #c68be0;
    --n0: #ff7a6b; --n1: #6fcf7f; --n2: #e0bf4a; --n3: #7aa7ff; --n4: #d58cf0; --n5: #5fd0c6;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.5 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}
input, button { font: inherit; color: inherit; }
input {
  width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 6px;
  padding: .55em .75em; outline: none;
}
input:focus { border-color: var(--dim); }
button {
  border: 1px solid var(--line); border-radius: 6px; background: none; padding: .35em .8em; cursor: pointer;
}

/* login and waiting */
#login, #waiting { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
#login .card, #login-form, #waiting .card { width: 100%; max-width: 380px; display: flex; flex-direction: column; }

/* saved chats */
.section { margin: 0 0 .5em; font-weight: 600; }
#sessions { list-style: none; margin: 0 0 .8em; padding: 0; display: flex; flex-direction: column; gap: .5em; }
#sessions li { display: flex; gap: .4em; }
.session {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  padding: .55em .8em; background: var(--field);
}
.session:hover:not(:disabled) { border-color: var(--dim); }
.session:disabled { opacity: .6; cursor: default; }
.session b, .session span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session span { color: var(--dim); font-size: .85em; }
.forget { flex: none; width: 2.6em; color: var(--dim); }
#add-session { align-self: flex-start; }
#cancel-add { margin-top: .6em; color: var(--dim); }
#waiting p { margin: 0 0 .8em; }
.fp-big { font-size: 1.1em; font-weight: 600; letter-spacing: .03em; }
#wait-cancel { align-self: flex-start; margin-top: .6em; }
h1 { margin: 0; font-size: 1.6em; letter-spacing: .02em; }
.sub { margin: .1em 0 1.6em; color: var(--dim); }
label { margin: .9em 0 .35em; font-weight: 600; }
#join {
  margin-top: 1.4em; padding: .6em; background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
#join:disabled { opacity: .6; cursor: default; }
#login-error { min-height: 1.5em; margin: .8em 0 0; color: var(--warn); }
.fine { margin: 1.2em 0 0; color: var(--dim); font-size: .85em; }
noscript { color: var(--warn); }

/* chat */
#chat { height: 100%; display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: .6em; padding: .6em 16px;
  border-bottom: 1px solid var(--line); color: var(--dim);
}
header b { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#online { flex: 1; white-space: nowrap; }
#dot { flex: none; width: .55em; height: .55em; border-radius: 50%; background: var(--dim); }
#dot.on { background: var(--n1); }
#dot.off { background: var(--warn); }

/* admins: the waitlist button and its panel */
#waitlist-count {
  display: inline-block; min-width: 1.5em; margin-left: .3em; padding: 0 .4em; border-radius: 1em;
  background: var(--warn); color: #fff; font-size: .8em; text-align: center;
}
#waitlist {
  position: fixed; z-index: 5; top: 3.4em; right: 16px; width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 5em); overflow-y: auto; padding: .8em 1em;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.hint { margin: .5em 0; color: var(--dim); font-size: .85em; }
.request { display: flex; align-items: center; gap: .6em; padding: .55em 0; border-top: 1px solid var(--line); }
.who-box { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.request .who { font-weight: 600; }
.request .fp { color: var(--dim); font-size: .85em; overflow-wrap: anywhere; }
.request .approve { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
#log { flex: 1; overflow-y: auto; padding: .8em 16px; }
#msgs > div { white-space: pre-wrap; overflow-wrap: anywhere; }
#older { display: block; margin: 0 auto .8em; color: var(--dim); }
#send-form { display: flex; gap: .5em; padding: .7em 16px; border-top: 1px solid var(--line); }
#attach { flex: none; width: 2.6em; font-size: 1.1em; line-height: 1; }

/* images in the log: a placeholder of the right shape until it's decrypted */
.img {
  display: grid; place-items: center; width: min(100%, 360px); max-height: 360px;
  margin: .35em 0 .2em; padding: 0; overflow: hidden; border-radius: 8px;
  background: var(--line); color: var(--dim); font-size: .85em; cursor: pointer;
}
.img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.img-label { padding: 1.5em .8em; }

#viewer {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .8em; padding: 16px; background: rgba(0, 0, 0, .85);
}
#viewer img { max-width: 100%; max-height: calc(100% - 4em); object-fit: contain; }
#viewer-bar { display: flex; gap: .6em; }
#viewer-bar a, #viewer-bar button {
  color: #fff; border: 1px solid rgba(255, 255, 255, .4); border-radius: 6px; padding: .35em .9em; text-decoration: none;
}
.ts, .info { color: var(--dim); }
.sys { color: var(--sys); }
.warn { color: var(--warn); font-weight: 600; }
.tag { color: var(--dm); }
.name { font-weight: 700; }
.n0 { color: var(--n0); } .n1 { color: var(--n1); } .n2 { color: var(--n2); }
.n3 { color: var(--n3); } .n4 { color: var(--n4); } .n5 { color: var(--n5); }

/* narrow phones: keep the header on one line */
@media (max-width: 480px) {
  header { gap: .4em; }
  header button { padding: .3em .55em; }
  #online { font-size: .8em; }
}
