/* Global Conflict 1940 — war-room styling: dark map table, brass and khaki, typewritten dossiers. */
:root {
  --bg: #12161a;
  --bg-2: #1a2026;
  --panel: #1f262d;
  --panel-2: #262f37;
  --line: #36424d;
  --ink: #e6dfcc;
  --ink-dim: #a39c8a;
  --brass: #c9a25a;
  --brass-2: #e0bd73;
  --olive: #6b7a4b;
  --red: #b5483b;
  --green: #7fa35a;
  --blue: #5b84a8;
  --radius: 6px;
  --head: "Oswald", "Arial Narrow", sans-serif;
  --type: "Special Elite", "Courier New", monospace;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(201,162,90,.08), transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(255,255,255,.025) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(255,255,255,.025) 47px 48px),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
}

a { color: var(--brass-2); }
h1, h2, h3 { font-family: var(--head); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin: 0; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: rgba(18,22,26,.92); position: sticky; top: 0; z-index: 5;
}
.brand { font-family: var(--head); font-size: 20px; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); text-decoration: none; }
.brand small { color: var(--ink-dim); font-size: 12px; letter-spacing: .2em; margin-left: 6px; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.topbar nav a { color: var(--ink-dim); text-decoration: none; font-family: var(--head); text-transform: uppercase; letter-spacing: .08em; font-size: 13px; padding: 6px 10px; border-radius: var(--radius); }
.topbar nav a:hover, .topbar nav a.active { color: var(--ink); background: var(--panel); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }

/* ── Panels & forms ────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.panel h2 { font-size: 16px; color: var(--brass); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.panel h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }

label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-dim); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
.hint { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--brass);
  background: var(--brass); color: #1b1710; cursor: pointer;
  font-family: var(--head); font-size: 14px; text-transform: uppercase; letter-spacing: .1em;
}
button:hover { background: var(--brass-2); }
button.ghost { background: transparent; color: var(--brass-2); }
button.ghost:hover { background: rgba(201,162,90,.12); }
button.danger { background: transparent; border-color: var(--red); color: #e08a7e; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.msg { margin-top: 12px; font-size: 14px; min-height: 1.2em; }
.msg.err { color: #e08a7e; }
.msg.ok { color: var(--green); }

/* ── Login / enlist ────────────────────────────────────── */
.gate { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 420px; }
.gate-title { text-align: center; margin-bottom: 22px; }
.gate-title h1 { font-size: 34px; color: var(--brass); letter-spacing: .14em; line-height: 1.1; }
.gate-title p { font-family: var(--type); color: var(--ink-dim); margin: 8px 0 0; }
.tabs { display: flex; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--ink-dim); }
.tabs button.on { color: var(--brass-2); border-bottom-color: var(--brass); }
.gate-card form button[type=submit] { width: 100%; margin-top: 18px; }

/* ── HQ ────────────────────────────────────────────────── */
.hq { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .hq { grid-template-columns: 1fr; } }

.dossier { text-align: center; }
.portrait {
  width: 160px; height: 160px; margin: 4px auto 12px; border-radius: 4px; overflow: hidden;
  border: 3px solid var(--brass); background: var(--bg-2); position: relative;
  box-shadow: 0 0 0 6px var(--panel), 0 0 0 7px var(--line);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; filter: sepia(.15) contrast(1.05); }
.portrait .initials { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--head); font-size: 56px; color: var(--brass); }
.dossier .name { font-family: var(--head); font-size: 24px; letter-spacing: .08em; text-transform: uppercase; }
.dossier .homeland { font-family: var(--type); color: var(--ink-dim); }
.dossier .motto { font-family: var(--type); font-style: italic; margin: 8px 0 0; color: var(--ink); }
.badge { display: inline-block; font-family: var(--head); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; background: var(--olive); color: #eef0e2; margin-left: 6px; vertical-align: middle; }

.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 4px; }
.record div { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 4px; }
.record b { display: block; font-family: var(--head); font-size: 26px; line-height: 1.1; }
.record span { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); }
.record .w b { color: var(--green); }
.record .l b { color: #e08a7e; }
.record .d b { color: var(--blue); }

details.edit { text-align: left; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
details.edit summary { cursor: pointer; font-family: var(--head); text-transform: uppercase; letter-spacing: .1em; color: var(--brass-2); font-size: 13px; }

/* ── Roster ────────────────────────────────────────────── */
.roster { width: 100%; border-collapse: collapse; }
.roster th { text-align: left; font-family: var(--head); font-weight: 500; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; color: var(--ink-dim); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.roster td { padding: 8px; border-bottom: 1px solid rgba(54,66,77,.6); vertical-align: middle; }
.roster tr.me td { background: rgba(201,162,90,.07); }
.roster .num { text-align: center; font-family: var(--head); font-size: 17px; }
.who { display: flex; align-items: center; gap: 10px; }
.thumb { width: 40px; height: 40px; border-radius: 3px; border: 1px solid var(--line); background: var(--bg-2); flex: none; overflow: hidden; display: grid; place-items: center; font-family: var(--head); color: var(--brass); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.who .sub { font-size: 12px; color: var(--ink-dim); font-family: var(--type); }
.rank { font-family: var(--head); color: var(--ink-dim); width: 28px; }
@media (max-width: 600px) { .roster .hide-sm { display: none; } }

.empty { color: var(--ink-dim); font-family: var(--type); text-align: center; padding: 20px; }

/* ── Admin ─────────────────────────────────────────────── */
.codes { font-family: var(--type); font-size: 18px; color: var(--brass-2); }
.mono { font-family: var(--type); }
.small-input { width: 64px; padding: 5px; text-align: center; }
.stack > * + * { margin-top: 20px; }

/* ══════════════════════════════════════════════════════════
   CHAT — one panel, docked at the bottom or in its own window
   ══════════════════════════════════════════════════════════ */
body.has-chat-dock { padding-bottom: var(--chat-dock-h, 42px); }

.chat { display: flex; flex-direction: column; background: var(--panel); color: var(--ink); min-height: 0; }
.chat-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  border-top: 1px solid var(--brass); box-shadow: 0 -8px 24px rgba(0,0,0,.45);
}
.chat-window-page { padding: 0; height: 100vh; overflow: hidden; }
.chat-window { position: fixed; inset: 0; }

.chat-head {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 41px; flex: none; padding: 0 12px; background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.chat-grip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; }
.chat-grip::after { content: ""; position: absolute; left: 50%; top: 2px; width: 44px; height: 3px; margin-left: -22px; border-radius: 2px; background: var(--line); }
.chat-dock.collapsed .chat-grip, .chat-dock.popped .chat-grip { display: none; }
.chat-title {
  background: none; border: none; padding: 0; color: var(--brass-2); font-size: 15px;
  display: inline-flex; align-items: center; gap: 8px;
}
.chat-title:hover { background: none; color: var(--brass); }
.chat-window .chat-title { cursor: default; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-dim); display: inline-block; }
.chat[data-state=online] .chat-dot, .chat-popped .chat-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.chat[data-state=reconnecting] .chat-dot, .chat[data-state=connecting] .chat-dot { background: var(--brass); }
.chat[data-state=offline] .chat-dot { background: var(--red); }
.chat-unread { background: var(--red); color: #fff; font-family: var(--body); font-size: 11px; font-weight: 600; letter-spacing: 0; border-radius: 9px; padding: 1px 7px; }
.chat-online-count { font-size: 12px; color: var(--ink-dim); }
.chat-actions { margin-left: auto; display: flex; gap: 6px; }
.chat-btn { padding: 4px 10px; font-size: 12px; background: transparent; color: var(--ink-dim); border-color: var(--line); }
.chat-btn:hover { background: var(--panel); color: var(--ink); }

.chat-body { flex: 1; display: flex; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 14px; min-width: 0; }
.chat-roster { width: 160px; flex: none; border-left: 1px solid var(--line); padding: 8px 12px; overflow-y: auto; }
.chat-roster h3 { font-size: 11px; color: var(--ink-dim); letter-spacing: .14em; margin-bottom: 6px; }
.chat-roster ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.chat-roster li { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-roster li::before { content: "●"; color: var(--green); font-size: 9px; margin-right: 6px; vertical-align: 2px; }
@media (max-width: 640px) { .chat-roster { display: none; } }

.chat-empty { color: var(--ink-dim); font-family: var(--type); text-align: center; padding: 18px; }
.chat-day { text-align: center; margin: 10px 0 4px; font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .12em; }
.chat-day span { background: var(--panel); padding: 0 10px; }
.chat-day { background: linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }
.chat-msg { display: flex; gap: 10px; padding: 6px 0; }
.chat-thumb { width: 34px; height: 34px; font-size: 13px; }
.chat-thumb .initials { position: static; font-size: 13px; }
.chat-main { min-width: 0; flex: 1; }
.chat-meta { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.chat-meta b { color: var(--brass-2); font-weight: 600; }
.chat-msg.mine .chat-meta b { color: var(--ink); }
.chat-meta .badge { margin-left: 0; font-size: 9px; padding: 1px 5px; }
.chat-meta time { color: var(--ink-dim); font-size: 11px; }
.chat-line { position: relative; padding: 1px 22px 1px 0; border-radius: 3px; }
.chat-line.mention { background: rgba(201,162,90,.13); box-shadow: inset 2px 0 var(--brass); padding-left: 6px; }
.chat-text { white-space: normal; overflow-wrap: anywhere; font-size: 14px; }
.chat-del { position: absolute; right: 0; top: 0; display: none; padding: 0 6px; font-size: 14px; line-height: 1.3; background: transparent; border: none; color: var(--ink-dim); }
.chat-line:hover .chat-del { display: block; }
.chat-del:hover { color: #e08a7e; background: transparent; }

.chat-compose { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); flex: none; }
.chat-compose textarea { resize: none; min-height: 38px; max-height: 120px; line-height: 1.4; }
.chat-compose button { flex: none; }
.chat-error { position: absolute; left: 12px; right: 12px; bottom: 58px; background: #3a1f1b; border: 1px solid var(--red); color: #f0b4aa; font-size: 13px; padding: 6px 10px; border-radius: var(--radius); }

.chat-dock.collapsed .chat-body, .chat-dock.collapsed .chat-compose { display: none; }
.chat-popped { display: none; }
.chat-dock.popped > :not(.chat-popped) { display: none; }
.chat-dock.popped .chat-popped { display: flex; align-items: center; gap: 12px; height: 41px; padding: 0 12px; background: var(--panel-2); color: var(--ink-dim); font-size: 13px; }
