@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/static/fonts/DejaVuSansMono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/static/fonts/DejaVuSansMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/static/fonts/DejaVuSansMono-Oblique.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/static/fonts/DejaVuSansMono-BoldOblique.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}
@font-face {
  font-family: "Segoe UI";
  src: url("/static/fonts/Segoe UI.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Segoe UI";
  src: url("/static/fonts/Segoe UI Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Segoe UI";
  src: url("/static/fonts/Segoe UI Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "Segoe UI";
  src: url("/static/fonts/Segoe UI Bold Italic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}

:root {
  --bg: #1c1c1c;
  --panel: #2a2a2a;
  --ink: #f3f3f3;
  --mute: #111;
  --dim: #9a9a9a;
  --line: #111;
  --yell: #ffd000;
  --ok: #ffd000;
  --bad: #6a6a6a;
  --rad: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
header {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid #3a3a3a;
  padding-bottom: 0;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-left: auto;
}
.tabs button {
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  padding: .55rem 1rem .45rem;
  background: transparent;
  color: var(--dim);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
}
.tabs button:hover { filter: none; color: var(--ink); }
.tabs button.on {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--yell);
}
.mark {
  height: 3.2rem;
  width: auto;
  flex-shrink: 0;
}
h1.brand {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.clip {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: .4rem;
  flex-shrink: 0;
}
.strip form { margin: 0; display: flex; }
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.stage > section {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.stage > section[hidden] { display: none; }
.stage > #tab-live {
  display: flex;
  flex-direction: row;
  gap: .5rem;
  overflow: hidden;
  min-height: 0;
}
.stage > #tab-live[hidden] { display: none; }
label.pick {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .4rem;
  flex: 1;
  min-width: 12rem;
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}
label.pick select { flex: 1; min-width: 0; width: auto; }
#edit { max-width: 42rem; flex-direction: column; align-items: stretch; gap: .75rem; }
#tab-server { gap: .75rem; }
#part select { flex: 1; min-width: 0; }
fieldset {
  border: 1px solid var(--line);
  margin: 0;
  padding: .75rem;
  min-width: 0;
  background: var(--panel);
  border-radius: var(--rad);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
legend {
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--yell);
  padding: 0 .35rem;
}
p.hint { margin: 0; color: var(--dim); font-size: .8rem; }
label.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .25rem;
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--dim);
  min-width: 0;
  flex: 1;
}
.row { display: flex; gap: .4rem; flex-wrap: wrap; align-items: flex-end; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.actions button { flex: 1; }
label.field input, label.field select, label.field textarea { flex: none; width: 100%; }
textarea {
  width: 100%;
  min-height: 3.5rem;
  font: inherit;
  color: var(--ink);
  background: var(--mute);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: .4rem .5rem;
  resize: vertical;
}
label { display: flex; align-items: center; gap: .35rem; }
label.check { color: var(--dim); font-size: .85rem; }
#st {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: .25rem .55rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--rad);
  min-width: 12rem;
  flex: 1.4;
}
#st .chip {
  flex-shrink: 0;
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--bad);
  color: var(--ink);
}
#st.up .chip { background: var(--ok); color: var(--mute); }
#st.down .chip { background: #8a1f1f; color: #fff; }
#st .meta { color: var(--dim); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tab-live[hidden] { display: none; }
.chlist, .nicks {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.chlist { flex: 0 0 12rem; }
.nicks { flex: 0 0 11rem; }
.chlist h2, .nicks h2, .pane h2 {
  margin: 0;
  padding: .45rem .6rem;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.chlist ul, .nicks ul {
  list-style: none;
  margin: 0;
  padding: .25rem;
  flex: 1;
}
.chlist li, .nicks li {
  padding: .35rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chlist li.on, .nicks li:hover, .chlist li:hover { background: var(--mute); }
.chlist li.on { color: var(--yell); }
.chlist li.srv { color: var(--dim); font-weight: 600; }
.chlist li.srv.on { color: var(--yell); }
.nicks li {
  font-family: "DejaVu Sans Mono", ui-monospace, monospace;
  font-size: .85rem;
}
.nicks .px {
  display: inline-block;
  width: .85em;
  color: var(--yell);
}
.joinf {
  margin: 0;
  padding: .4rem;
  border-top: 1px solid var(--line);
}
.pane {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  overflow: hidden;
}
#msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: .5rem .7rem;
  font-family: "DejaVu Sans Mono", ui-monospace, monospace;
  font-size: .85rem;
}
.m { display: grid; grid-template-columns: 4.4rem auto minmax(0, 1fr); gap: .45rem; margin: 0 0 .25rem; }
.m .tm { color: var(--dim); }
.m .nk { color: var(--yell); font-weight: 700; }
.m.sys .nk, .m.sys .tx { color: var(--dim); font-weight: 400; }
.m .tx { white-space: pre-wrap; word-break: break-word; }
.composer { margin: 0; padding: .4rem; border-top: 1px solid var(--line); }
form {
  margin: .5rem 0;
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: stretch;
}
form[hidden] { display: none; }
input {
  min-width: 0;
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--mute);
  border: 1px solid var(--line);
  padding: .4rem .5rem;
  border-radius: var(--rad);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--yell);
}
input[type="checkbox"] { flex: none; width: auto; }
select {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--mute);
  border: 1px solid var(--line);
  padding: .4rem .5rem;
  border-radius: var(--rad);
}
button {
  font: inherit;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--mute);
  background: var(--yell);
  border: 1px solid var(--line);
  padding: .4rem .75rem;
  border-radius: var(--rad);
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.danger { background: var(--mute); color: var(--yell); }
.logbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  color: var(--dim);
  font-size: .85rem;
}
#log {
  font-family: "DejaVu Sans Mono", ui-monospace, monospace;
  background: var(--mute);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: .6rem;
  min-height: 0;
  overflow: auto;
  margin: 0;
  flex: 1;
  font-size: .82rem;
  white-space: normal;
}
.logrow {
  display: grid;
  grid-template-columns: 5.2rem 4.5rem minmax(0, 1fr);
  gap: .5rem;
  margin: 0 0 .2rem;
}
.logrow .tm, .logrow .kd { color: var(--dim); }
.logrow .ln { white-space: pre-wrap; word-break: break-word; }
#tab-import { gap: .6rem; }
#tab-links { gap: .5rem; }
#linkq { flex: 1; min-width: 8rem; }
.linkrow {
  display: grid;
  grid-template-columns: 8.6rem 5.5rem 5rem minmax(0, 1fr);
  gap: .45rem;
  margin: 0 0 .35rem;
  align-items: baseline;
}
.linkrow .tm, .linkrow .kd, .linkrow .nk { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkrow .ln { min-width: 0; }
.linkrow a { color: var(--yell); text-decoration: none; word-break: break-word; }
.linkrow a:hover { text-decoration: underline; }
.linkrow .dom { color: var(--dim); font-size: .8rem; margin-left: .25rem; }
#linkmore { align-self: flex-start; }
.drop {
  position: relative;
  flex-shrink: 0;
  min-height: 7rem;
  border: 2px dashed var(--line);
  border-radius: var(--rad);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--dim);
  padding: 1rem;
}
.drop.on { border-color: var(--yell); color: var(--yell); }
.drop p { margin: 0; pointer-events: none; }
.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.implist {
  font-family: "DejaVu Sans Mono", ui-monospace, monospace;
  background: var(--mute);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: .6rem;
  min-height: 0;
  overflow: auto;
  flex: 1;
  font-size: .82rem;
}
body.login {
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.card {
  width: min(22rem, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
}
.card .mark { height: 5rem; }
.login form {
  width: 100%;
  margin: 0;
  flex-direction: column;
  align-items: stretch;
}
.login label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .3rem;
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--dim);
}

#tab-ai { gap: .75rem; align-items: stretch; }
#aiform { max-width: 42rem; flex-direction: column; align-items: stretch; }
#aichat { max-width: 42rem; }
label.samp {
  display: grid;
  grid-template-columns: 7.5rem 1fr 4.2rem;
  gap: .35rem;
  align-items: center;
  color: var(--dim);
  font-size: .8rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}
label.samp output { color: var(--ink); font-variant-numeric: tabular-nums; }
.samps { display: flex; flex-direction: column; gap: .35rem; margin-top: .45rem; }
#tab-ai details summary { cursor: pointer; color: var(--dim); font-weight: 700; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
#aichatlog {
  min-height: 6rem;
  max-height: 14rem;
  overflow: auto;
  background: var(--mute);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: .4rem .5rem;
}
#aichatlog p { margin: .2rem 0; white-space: pre-wrap; }
#aichatform { display: flex; gap: .4rem; }
#aichatform input { flex: 1; min-width: 0; }

@media (max-width: 700px) {
  .tabs { width: 100%; margin-left: 0; }
  .tabs button { flex: 1; }
  form { flex-direction: column; }
  button { width: 100%; }
  .stage > #tab-live { flex-direction: column; }
  .chlist, .nicks { flex: 0 0 auto; max-height: 8rem; }
  .joinf, .composer { flex-direction: row; flex-wrap: nowrap; }
  .joinf button, .composer button { width: auto; }
  .logrow { grid-template-columns: 5.2rem minmax(0, 1fr); }
  .logrow .kd { display: none; }
  .linkrow { grid-template-columns: 5.2rem minmax(0, 1fr); }
  .linkrow .kd, .linkrow .nk { display: none; }
}
