/* OriEra WorldChat — dark engine-room styling */
:root {
  color-scheme: dark;
  --bg: #0b0e16; --panel: #121724; --line: #232a3d; --ink: #e6e9f2;
  --muted: #8a91a8; --acc: #76b900; --acc2: #5b8def; --warn: #ffb454;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
header h1 { font-size: 15px; margin: 0; letter-spacing: .4px; }
header h1 span { color: var(--acc); }
header .tag { font-size: 11px; color: var(--muted); margin-left: 10px; }
.brand { display: flex; align-items: baseline; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; }

button {
  font: inherit; cursor: pointer; border-radius: 6px;
  border: 1px solid var(--acc2); background: var(--acc2); color: #fff; padding: 6px 12px;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--acc2); }
button.small { padding: 3px 8px; font-size: 11px; }
button.danger { color: #ff9a9a; }
button:disabled { opacity: .45; cursor: default; }

.badge { font-size: 11px; padding: 4px 10px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.badge.offline { color: var(--muted); border-color: var(--line); }
.badge.live { color: #b8f7c0; border-color: #2f7d43; background: rgba(47, 125, 67, .18); }
.badge.busy { color: var(--warn); border-color: #7a5a20; }

main { flex: 1; display: grid; grid-template-columns: 380px 1fr 320px; overflow: hidden; }

/* ---------- chat ---------- */
#chat-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px; }
.msg { margin-bottom: 10px; max-width: 94%; }
.msg .who { font-size: 10px; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .6px; }
.msg .bubble { padding: 7px 11px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.msg.user { margin-left: auto; }
.msg.user .bubble { background: #1f2a44; color: #cfe0ff; }
.msg.world .bubble { background: #171d2b; }
.msg.narr .bubble { background: #1a2438; color: #c9d6f5; font-style: italic; }
.msg.tool .bubble { background: #10231a; color: #7fd18a; font-size: 11px; }
.msg.director .bubble { background: #241a10; color: #ffcf8f; border: 1px solid #4a3a1c; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chips code { font-size: 10px; background: #0d1420; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: #9fb6e8; }
#input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#chat-input { flex: 1; background: #0d1119; border: 1px solid var(--line); color: var(--ink); padding: 8px 10px; border-radius: 6px; font: inherit; min-width: 0; }
#suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }
#suggestions .chip { font-size: 11px; padding: 3px 8px; border-radius: 12px; border: 1px solid var(--line); background: #0d1119; color: var(--muted); }
#suggestions .chip:hover { color: var(--ink); border-color: var(--acc2); }

/* ---------- world ---------- */
#world-pane { position: relative; min-width: 0; }
#world { width: 100%; height: 100%; display: block; cursor: grab; background: #0a0e1a; }
#hud {
  position: absolute; top: 10px; left: 10px; font-size: 11px; color: #aab3c8;
  background: rgba(5, 8, 14, .65); border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 6px; pointer-events: none; white-space: pre;
}

/* ---------- telemetry ---------- */
#tele-pane { border-left: 1px solid var(--line); overflow-y: auto; }
.panel { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 11px; margin: 0 0 8px; color: var(--acc); text-transform: uppercase; letter-spacing: .8px; }
.panel .hint { color: var(--muted); font-size: 10px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.muted { color: var(--muted); font-size: 11px; }

#router-log { display: flex; flex-direction: column; gap: 3px; max-height: 180px; overflow-y: auto; }
.rlog { font-size: 10.5px; display: flex; gap: 6px; align-items: baseline; }
.rlog .tier { min-width: 52px; text-align: center; border-radius: 3px; padding: 0 3px; font-weight: 700; }
.rlog .tier.fast { background: #14301f; color: #7fd18a; }
.rlog .tier.narrate { background: #14243a; color: #7fb2ff; }
.rlog .tier.heavy { background: #382714; color: #ffb454; }
.rlog .tier.local { background: #22283a; color: #9aa3bd; }
.rlog .meta { color: var(--muted); }
.rlog .note { color: var(--warn); }

#allocator { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.alloc-row { display: grid; grid-template-columns: 58px 1fr 44px; gap: 6px; align-items: center; font-size: 10.5px; }
.alloc-bar { height: 8px; background: #0d1119; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.alloc-bar i { display: block; height: 100%; transition: width .4s; }
.alloc-row.fast i { background: #3f9e63; }
.alloc-row.narrate i { background: #3a6fc4; }
.alloc-row.heavy i { background: #c98a3d; }
.credits { font-size: 11px; display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.credits b { color: var(--ink); }
.credits .saved b { color: var(--acc); }
.counters { display: flex; flex-wrap: wrap; gap: 8px; font-size: 10.5px; color: var(--muted); }
.counters b { color: var(--ink); }

#slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slot { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #0d1119; aspect-ratio: 4/3; }
.slot canvas { width: 100%; height: 100%; display: block; }
.slot .label { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9px; padding: 2px 5px; background: rgba(5, 8, 14, .75); color: var(--muted); display: flex; justify-content: space-between; }
.slot .label .st.ok { color: #7fd18a; }
.slot .label .st.busy { color: var(--warn); }
.slot .label .st.local { color: #9aa3bd; }

#mem-list { font-size: 11px; display: flex; flex-direction: column; gap: 3px; max-height: 150px; overflow-y: auto; margin-bottom: 8px; }
.mem-item { display: flex; gap: 6px; }
.mem-item .who { color: var(--acc2); min-width: 58px; }
#beats { font-size: 10.5px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; max-height: 90px; overflow-y: auto; }
.beat { border-left: 2px solid #4a3a1c; padding-left: 6px; }
.mem-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- dialog ---------- */
dialog {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; min-width: 480px; max-width: 560px; padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 8px; font-size: 14px; }
dialog label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
dialog label.inline { display: inline-flex; gap: 6px; align-items: center; }
dialog input[type=text], dialog input[type=password] {
  display: block; width: 100%; margin-top: 3px; background: #0d1119;
  border: 1px solid var(--line); color: var(--ink); padding: 7px 9px; border-radius: 6px; font: inherit; font-size: 12px;
}
dialog .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
dialog .row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
dialog .row.right { justify-content: flex-end; }

footer {
  padding: 6px 16px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--muted);
}
footer b { color: var(--ink); }
footer code { color: #9fb6e8; }

@media (max-width: 1080px) {
  main { grid-template-columns: 300px 1fr 260px; }
}

/* narrow screens: single-column stack — chat + world first, telemetry after
   (chat keeps its own scroll; the world keeps a fixed visible height) */
@media (max-width: 900px) {
  body { height: auto; min-height: 100vh; }
  main { display: flex; flex-direction: column; overflow: visible; }
  #chat-pane { order: 1; height: 52vh; min-height: 340px; border-right: none; border-bottom: 1px solid var(--line); }
  #world-pane { order: 2; height: 44vh; min-height: 300px; }
  #tele-pane { order: 3; border-left: none; border-top: 1px solid var(--line); overflow: visible; }
  header { flex-wrap: wrap; }
  dialog { min-width: 0; width: 92vw; }
}
