/* ============================================================
   blue / black / white
   ============================================================ */

:root {
  --bg:         #06080c;
  --panel:      #0d1117;
  --panel-2:    #141b24;
  --line:       #1c242f;
  --text:       #eef2f7;
  --muted:      #6b7684;
  --blue:       #2d7dff;
  --blue-dim:   #17427f;
  --blue-glow:  rgba(45, 125, 255, .35);
  --danger:     #ff4d4d;
  --ok:         #29d17c;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

::selection { background: var(--blue); color: #000; }

body {
  font-family: var(--mono);
  font-size: 14px;
  margin: 0;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(45,125,255,.09), transparent 60%),
    var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  letter-spacing: .01em;
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #1e2733;
  border: 2px solid var(--bg);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--blue-dim); }

/* ---------- controls ---------- */
button {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--blue);
  border-radius: 2px;
  padding: 9px 16px;
  background: var(--blue);
  color: #04070d;
  text-transform: lowercase;
  letter-spacing: .06em;
  transition: box-shadow .18s ease, background .18s ease, transform .08s ease;
}
button:hover {
  background: #4d91ff;
  box-shadow: 0 0 0 1px var(--blue), 0 0 18px var(--blue-glow);
}
button:active { transform: translateY(1px); }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.ghost:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(45,125,255,.07);
  box-shadow: 0 0 14px rgba(45,125,255,.15);
}

input, textarea {
  font: inherit;
  font-family: var(--mono);
  padding: 11px 12px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  width: 100%;
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 140px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input::placeholder, textarea::placeholder { color: #46505d; }
input:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 0 20px rgba(45,125,255,.14);
}

.hidden { display: none !important; }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
  background: rgba(0,0,0,.35);
}
header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, var(--blue), transparent 45%);
}
header .brand {
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--text);
}
header .brand::before {
  content: "▌";
  color: var(--blue);
  margin-right: 8px;
  animation: blink 1.4s step-end infinite;
}
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .15 } }

header .who { color: var(--muted); font-size: 12px; margin-right: 12px; }

/* ---------- landing ---------- */
#landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  animation: rise .45s ease both;
}
#landing h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
#landing h1::after {
  content: ".";
  color: var(--blue);
}
#landing p { margin: 10px 0 0; color: var(--muted); }

.bigbtns { display: flex; gap: 16px; }
.bigbtns button {
  padding: 18px 52px;
  font-size: 15px;
  letter-spacing: .16em;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- cards / forms ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--blue);
  border-radius: 2px;
  padding: 26px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 40px rgba(45,125,255,.07);
  animation: rise .3s ease both;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.center { flex: 1; display: flex; align-items: center; justify-content: center; }

.err {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  letter-spacing: .04em;
}
.link {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: color .15s ease;
}
.link:hover { color: var(--blue); }

/* ---------- app shell ---------- */
#app { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: 250px;
  border-right: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,.012);
}
#sidebar .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .22em;
  color: #3f4a58;
  margin: 18px 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.chatitem {
  padding: 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-left: 2px solid transparent;
  transition: background .15s ease, border-color .15s ease, padding-left .15s ease;
}
.chatitem:hover {
  background: var(--panel-2);
  border-left-color: var(--blue-dim);
  padding-left: 16px;
}
.chatitem.active {
  background: linear-gradient(90deg, rgba(45,125,255,.14), transparent);
  border-left-color: var(--blue);
}
.chatitem .num { color: #3f4a58; font-size: 11px; }
.chatitem .tag {
  font-size: 9px;
  color: var(--blue);
  border: 1px solid var(--blue-dim);
  padding: 1px 5px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#chathead {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}
#chathead .title {
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
#chathead .sub { color: var(--blue); font-size: 11px; letter-spacing: .1em; }

#log { flex: 1; overflow-y: auto; padding: 18px 22px; }

.msg {
  padding: 2px 0;
  line-height: 1.5;
  animation: slidein .22s ease both;
}
.msg .who {
  font-weight: 700;
  margin-right: 10px;
  color: var(--blue);
  flex-shrink: 0;
}
.msg .who::before { content: "> "; color: var(--blue-dim); }

.sys {
  color: #465262;
  font-style: normal;
  font-size: 12px;
  letter-spacing: .06em;
  border: none;
}
.sys::before { content: "── "; color: var(--blue-dim); }

@keyframes slidein {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- composer ---------- */
#composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: rgba(0,0,0,.3);
}
#composer button { flex-shrink: 0; }
#readonly {
  padding: 16px 22px;
  border-top: 1px solid var(--blue-dim);
  background: rgba(45,125,255,.06);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: .04em;
}

/* ---------- modal ---------- */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.reqrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.reqrow:last-child { border: none; }
.reqrow button { padding: 6px 12px; font-size: 12px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  padding: 11px 15px;
  border-radius: 2px;
  border-left: 2px solid;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0,0,0,.7);
  animation: toastin .18s ease both;
  max-width: 340px;
}
.toast.ok {
  border-left-color: var(--ok);
  color: #8ff0bd;
  box-shadow: 0 18px 50px rgba(0,0,0,.7), 0 0 22px rgba(41,209,124,.12);
}
.toast.bad {
  border-left-color: var(--danger);
  color: #ffb0b0;
  box-shadow: 0 18px 50px rgba(0,0,0,.7), 0 0 22px rgba(255,77,77,.18);
}
.toast.out { opacity: 0; transform: translateX(12px); transition: all .3s ease; }
@keyframes toastin {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- message layout ---------- */
.msgtop { display: flex; align-items: baseline; }
.msgtop .text { flex: 1; min-width: 0; white-space: pre-wrap; }
.msg .time {
  color: #3a4553;
  font-size: 10px;
  margin-left: 12px;
  flex-shrink: 0;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

/* ---------- hover reaction bar ---------- */
.reactbar {
  display: inline-flex;
  gap: 3px;
  margin-left: 10px;
  opacity: 0;
  transition: opacity .12s ease;
  flex-shrink: 0;
}
.msg:hover .reactbar { opacity: 1; }
button.react {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: inherit;
  padding: 1px 6px;
  font-size: 13px;
  line-height: 1.3;
  border-radius: 2px;
  text-transform: none;
  letter-spacing: 0;
}
button.react:hover {
  border-color: var(--blue);
  background: rgba(45,125,255,.10);
  box-shadow: 0 0 12px rgba(45,125,255,.18);
}

/* ---------- reaction chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 0; }
.chips.empty { margin: 0; }
button.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 1px 8px;
  font-size: 11px;
  line-height: 1.6;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
button.chip:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--blue-dim);
  box-shadow: none;
}
button.chip.mine {
  border-color: var(--blue);
  background: rgba(45,125,255,.13);
  color: #9dc4ff;
}
button.chip:disabled { cursor: default; opacity: .55; }