/* ── visual refresh: type + brand ───────────────────────────────────── */
@font-face {
  font-family: "IM Fell English";
  src: url("/static/fonts/im-fell/im-fell-english-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IM Fell English";
  src: url("/static/fonts/im-fell/im-fell-english-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --bg: #14110d;
  --surface: #1d1812;
  --surface-2: #261f17;
  --border: #3a2f24;
  --text: #ede4d3;
  --muted: #9b8a72;
  --accent: #d4a857;
  --accent-fg: #14110d;
  --user: #4a7d8d;
  --error: #d96565;
  --ok: #7ec07e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: "IM Fell English", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* HTML's `hidden` attribute must always win over later CSS display rules.
   Without !important, a `display: flex` rule with equal specificity to
   `[hidden]` (the user-agent default) wins, leaving "hidden" elements
   stubbornly visible. Bit me on the portrait card. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.badge.phase {
  color: var(--accent);
  border-color: var(--accent);
}

#whoami {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  padding: 4px 8px;
}
#whoami strong { color: var(--text); }

header button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
header button:hover { color: var(--text); border-color: var(--accent); }

main#chat-shell {
  display: grid;
  grid-template-rows: 1fr auto auto;
  overflow: hidden;
}

#messages {
  overflow-y: auto;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 760px;
  padding: 12px 16px;
  border-radius: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--user);
  color: var(--text);
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}
.msg.error {
  align-self: flex-start;
  background: rgba(217, 101, 101, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

form#composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
}

textarea#prompt {
  flex: 1;
  resize: vertical;
  min-height: 56px;
  max-height: 240px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px;
  font: inherit;
}
textarea#prompt:focus { outline: none; border-color: var(--accent); }

#send {
  align-self: stretch;
  padding: 0 22px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#send:disabled { opacity: 0.5; cursor: not-allowed; }

.footer-note {
  margin: 0;
  padding: 8px 18px 12px;
  font-size: 11px;
  color: var(--muted);
}

.muted { color: var(--muted); }

/* login screen */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
}
.login-shell h1 {
  margin: 0 0 4px;
  font-size: 17px;
  color: var(--accent);
}
.login-shell p { margin: 0 0 22px; }
.login-shell form { display: flex; flex-direction: column; gap: 14px; }
.login-shell label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.login-shell input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font: inherit;
}
.login-shell input:focus { outline: none; border-color: var(--accent); }
.login-shell button {
  margin-top: 4px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 6px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
}
.login-shell .error {
  background: rgba(217, 101, 101, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}
.login-alt {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
}
.login-alt a {
  color: var(--accent);
  text-decoration: none;
}
.login-alt a:hover { text-decoration: underline; }

/* ── auth page (login / request access) ─────────────────────── */
.auth-shell { text-align: center; }
.auth-mark { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.auth-mark.small { font-size: 28px; }
.auth-shell h1 { font-size: 20px; margin: 0 0 2px; }
.auth-shell .tagline { margin: 0 0 18px; font-size: 12px; font-style: italic; }
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
}
.auth-tabs button.active { background: var(--accent); color: var(--accent-fg); }
.auth-shell form { text-align: left; }
.pw-row { display: flex; gap: 6px; align-items: stretch; }
.pw-row input { flex: 1; }
.pw-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  padding: 0 10px;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.login-shell button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }
.pending-panel { padding: 18px 6px 6px; }
.pending-panel h2 { font-size: 16px; color: var(--accent); margin: 8px 0 6px; }

/* links: stay in the palette, everywhere */
a { color: var(--accent); text-decoration-color: rgba(212, 168, 87, 0.45); }
a:visited { color: #b8934a; }
a:hover { color: #e8c47c; text-decoration-color: currentColor; }

/* brand mark in the header */
header h1 .brand-mark {
  height: 22px;
  width: auto;
  vertical-align: -5px;
  margin-right: 7px;
}

/* display serif where the game speaks */
.auth-shell h1,
.landing-head h2,
.pane-head h2,
.dnd-landing h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* the DM narrates in serif */
.msg.assistant {
  font-family: var(--display);
  font-size: 16.5px;
  line-height: 1.55;
}

/* empty states: a small stage with spot art + one in-voice line */
.empty-stage {
  text-align: center;
  padding: 30px 16px 14px;
  color: var(--muted);
}
.empty-stage img {
  width: 170px;
  height: 170px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  opacity: 0.92;
}
.empty-stage p {
  font-family: var(--display);
  font-style: italic;
  font-size: 15.5px;
  margin: 14px auto 4px;
  max-width: 420px;
  color: var(--muted);
}
