/* CGI:IRC - https://cgiirc.org/ */

:root {
  --bg: #ffffff;          /* message area, from the chosen format */
  --fg: #1d1f24;
  --chrome: #eef0f4;      /* bars and panels */
  --chrome-2: #e1e4ea;
  --line: #cfd4dd;
  --muted: #69707d;
  --accent: #3355bb;
  --accent-fg: #ffffff;
  --act1: #69707d;
  --act2: #1d4fd8;
  --act3: #c62828;
  --danger: #b3261e;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --text-size: 14px;
  color-scheme: light;
}
.dark {
  --chrome: #1f2228;
  --chrome-2: #2a2e36;
  --line: #3a3f49;
  --muted: #9aa1ad;
  --accent: #6d8ef0;
  --accent-fg: #0d1020;
  --act1: #9aa1ad;
  --act2: #8fb0ff;
  --act3: #ff7b72;
  --danger: #ff6b60;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  .login-page {
    --bg: #16181d; --fg: #e3e6ec; --chrome: #1f2228; --chrome-2: #2a2e36;
    --line: #3a3f49; --muted: #9aa1ad; --accent: #6d8ef0; --accent-fg: #0d1020;
    color-scheme: dark;
  }
}
.size-small { --text-size: 12.5px; }
.size-large { --text-size: 17px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--text-size);
  background: var(--chrome);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
kbd {
  font-family: var(--mono); font-size: .85em; padding: 0 .3em;
  border: 1px solid var(--line); border-radius: 3px; background: var(--chrome-2);
}
.noscript { padding: 2em; text-align: center; }

button { cursor: pointer; }
.primary, .danger {
  border: 0; border-radius: var(--radius); padding: .55em 1.1em;
  background: var(--accent); color: var(--accent-fg); font-weight: 600;
}
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.primary:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--accent); padding: .4em 0; text-decoration: underline; }
.icon {
  flex: none; width: 2.2em; height: 2.2em; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted); font-size: 1.1em; line-height: 1;
  display: grid; place-items: center;
}
.icon svg { width: 1.15em; height: 1.15em; fill: currentColor; }
.icon:hover, .icon[aria-pressed="true"] { background: var(--chrome-2); color: var(--fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------------------------------------------------------- login */

.login { min-height: 100%; display: grid; place-items: center; padding: 1rem; background: var(--chrome); }
.login-card {
  width: min(100%, 26rem); background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem;
  box-shadow: 0 10px 30px rgb(0 0 0 / .08);
}
.login-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.login-head h1 { font-size: 1.35rem; margin: 0; }
.login-message { white-space: pre-wrap; color: var(--muted); margin: 0 0 1rem; }
.fields { display: grid; gap: .75rem; }
.field { display: grid; gap: .25rem; }
.field > span { font-size: .85em; color: var(--muted); font-weight: 600; }
.field input, .field select {
  width: 100%; padding: .55em .65em; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg);
}
.field.check { display: flex; align-items: center; gap: .5rem; }
.field.check input { width: auto; }
.login-error { color: var(--danger); margin: .9rem 0 0; }
.login-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 1.2rem; }
.login-foot { margin-top: 1.2rem; font-size: .8em; color: var(--muted); text-align: right; }

/* ----------------------------------------------------------------- chat */

.chat {
  height: 100%; height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.bar {
  display: flex; align-items: center; gap: .2rem; padding: .3rem .4rem;
  background: var(--chrome); border-bottom: 1px solid var(--line);
}
.tabs {
  flex: 1; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: thin;
  scroll-behavior: smooth; min-width: 0;
}
.tab {
  flex: none; display: flex; align-items: center; gap: .3rem; max-width: 14rem;
  padding: .35em .7em; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--fg); white-space: nowrap;
}
.tab .name { overflow: hidden; text-overflow: ellipsis; }
.tab:hover { background: var(--chrome-2); }
.tab[aria-selected="true"] { background: var(--bg); border-color: var(--line); font-weight: 600; }
.tab.act-1 .name { color: var(--act1); }
.tab.act-2 .name { color: var(--act2); font-weight: 600; }
.tab.act-3 .name { color: var(--act3); font-weight: 700; }
.tab.parted .name { font-style: italic; opacity: .7; }
.tab .close {
  border: 0; background: none; padding: 0 .15em; color: var(--muted); font-size: 1.05em; line-height: 1;
  border-radius: 3px;
}
.tab .close:hover { color: var(--danger); background: var(--chrome); }

.topic {
  padding: .35rem .7rem; border-bottom: 1px solid var(--line); background: var(--chrome);
  color: var(--fg); font-size: .92em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: default;
}
.topic.expanded { white-space: normal; }
.topic:empty { display: none; }
.banner {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  padding: .45rem .8rem; background: #fff3cd; color: #5b4300; font-size: .92em;
}
.dark .banner { background: #4a3b10; color: #ffe8a3; }
.banner button { border: 1px solid currentColor; background: transparent; border-radius: var(--radius); padding: .2em .8em; }

.main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.chat > :not(.main) { flex: none; }
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: .4rem .7rem .6rem;
  background: var(--bg); color: var(--fg); overscroll-behavior: contain;
  overflow-wrap: break-word; line-height: 1.45;
}
.line { padding: .05rem 0; white-space: pre-wrap; }
.line time { color: var(--muted); font-family: var(--mono); font-size: .85em; margin-right: .5em; user-select: none; }
.line.hl { background: color-mix(in srgb, var(--act3) 12%, transparent); border-radius: 3px; }
.line.motd { font-family: var(--mono); font-size: .92em; }
.no-ts .line time { display: none; }
.hide-joins .line.k-join, .hide-joins .line.k-part, .hide-joins .line.k-quit { display: none; }
.messages .smilie { height: 1.2em; vertical-align: -.25em; }
.messages a, .topic a { color: var(--accent); word-break: break-all; }
.messages .chan { color: inherit; text-decoration: underline dotted; cursor: pointer; }
.unread-marker { border: 0; border-top: 1px solid var(--act3); margin: .3rem 0; opacity: .6; }

.f-b { font-weight: 700; }
.f-i { font-style: italic; }
.f-u { text-decoration: underline; }
.f-s { text-decoration: line-through; }
.f-u.f-s { text-decoration: underline line-through; }
.f-m { font-family: var(--mono); }

.nicklist {
  flex: none; width: 11.5rem; overflow-y: auto; background: var(--chrome);
  border-left: 1px solid var(--line); font-size: .95em;
}
.nicklist-head { padding: .45rem .7rem; color: var(--muted); font-size: .85em; border-bottom: 1px solid var(--line); }
.nicklist ul { list-style: none; margin: 0; padding: .3rem 0; }
.nicklist li {
  display: flex; gap: .15rem; padding: .12rem .7rem; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.nicklist li:hover, .nicklist li:focus { background: var(--chrome-2); outline: none; }
.nicklist .pfx { width: 1ch; color: var(--muted); font-family: var(--mono); text-align: center; flex: none; }
.nicklist .rank-0 .pfx, .nicklist .rank-1 .pfx { color: var(--act3); }
.nicklist .rank-2 .pfx { color: var(--act2); }
.no-nicklist .nicklist { display: none; }

.input {
  display: flex; align-items: flex-end; gap: .45rem; padding: .45rem .5rem;
  padding-bottom: calc(.45rem + env(safe-area-inset-bottom));
  background: var(--chrome); border-top: 1px solid var(--line);
}
.mynick { flex: none; color: var(--muted); font-weight: 600; padding-bottom: .5em; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.input textarea {
  flex: 1; resize: none; min-height: 2.3em; max-height: 9em; padding: .45em .6em;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg);
  line-height: 1.35;
}
.send { flex: none; }

.popmenu {
  position: fixed; z-index: 20; min-width: 9rem; padding: .25rem 0;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.popmenu .title { padding: .3rem .8rem; color: var(--muted); font-size: .85em; border-bottom: 1px solid var(--line); }
.popmenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .35rem .8rem; }
.popmenu button:hover, .popmenu button:focus { background: var(--chrome-2); outline: none; }

.panel {
  width: min(94vw, 32rem); border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--fg); padding: 1.2rem 1.4rem;
}
.panel::backdrop { background: rgb(0 0 0 / .35); }
.panel h2 { margin: 0 0 .8rem; font-size: 1.15rem; }
.panel .check { display: flex; gap: .55rem; align-items: flex-start; margin: .55rem 0; }
.panel .row { display: flex; gap: .6rem; align-items: center; margin: .8rem 0; }
.panel select { padding: .3em .4em; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.panel-actions { display: flex; gap: .7rem; justify-content: flex-end; align-items: center; margin-top: 1.1rem; }
.panel-actions .link { margin-right: auto; }
.help table { border-collapse: collapse; width: 100%; font-size: .92em; }
.help td { padding: .25rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.help td:first-child { font-family: var(--mono); white-space: nowrap; }

/* -------------------------------------------------------------- narrow */

@media (max-width: 720px) {
  .nicklist {
    position: absolute; inset: 0 0 0 auto; width: min(70vw, 16rem); z-index: 10;
    box-shadow: -8px 0 24px rgb(0 0 0 / .2); transform: translateX(100%);
    transition: transform .18s ease; visibility: hidden;
  }
  .show-nicklist .nicklist { transform: none; visibility: visible; }
  .no-nicklist .nicklist { display: block; }
  .mynick { display: none; }
  .tab { max-width: 9rem; }
  #btn-prev, #btn-next { display: none; }
}
@media (min-width: 721px) {
  .show-nicklist .nicklist { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
.no-users .nicklist, .no-users #btn-users { display: none !important; }
