/* Hexeria Chat. Same palette as the rest of the family, so the products read
   as siblings without sharing a stylesheet. */

:root {
  --bg: #0b1016;
  --panel: #121821;
  --raised: #1a222d;
  --line: #262f3b;
  --ink: #e8e3d8;
  --dim: #94a0ab;
  --accent: #d8b872;
  --danger: #e5695f;
  --mine: #243244;
  --theirs: #1a222d;
}

* { box-sizing: border-box; }
/* The hidden attribute is UA-stylesheet display:none, which LOSES to any
   author display rule -- our flex/grid containers would all render while
   "hidden" without this. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  /* App-shell layout: the page itself never scrolls. The only scroll
     container is #messages, which is what keeps the composer on screen no
     matter how long a conversation gets. */
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica,
        Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100vh; height: 100dvh; }
#app.loading > * { display: none; }

/* --- the signed-out gate -------------------------------------------------- */

#gate, #outage {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-card {
  text-align: center;
  max-width: 380px;
}
.gate-card h1 {
  margin: 0 0 6px;
  font: 600 26px/1.2 ui-serif, Georgia, serif;
  letter-spacing: .14em; text-transform: uppercase;
}
.gate-sub { margin: 0 0 26px; color: var(--dim); }
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.btn:hover { background: var(--accent); color: #12161b; }
.btn.ghost { border-color: var(--line); color: var(--dim); }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); background: none; }

/* --- the shell ------------------------------------------------------------ */

#shell {
  height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr;
}

#sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex; flex-direction: column;
  /* Grid items default to min-height:auto too -- without these the
     conversation list pushes the sidebar tall instead of scrolling inside
     it, the same trap as the messages pane. */
  min-width: 0; min-height: 0;
}

#me {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
#me-name { font-weight: 600; }
#logout-link { color: var(--dim); font-size: 12.5px; text-decoration: none; }
#logout-link:hover { color: var(--ink); }

#new-dm { padding: 12px 12px 4px; }
#new-dm-name {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit; font-size: 14px;
}
#new-dm-name:focus { outline: none; border-color: var(--accent); }
.quiet-error {
  margin: 6px 14px 0; font-size: 12.5px; color: var(--danger);
}

#conversations { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.conv {
  display: block; width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: 0; border-radius: 8px;
  background: none; color: var(--ink);
  font: inherit; cursor: pointer;
}
.conv:hover { background: var(--raised); }
.conv.active { background: var(--raised); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; }
.conv-unread {
  min-width: 20px; padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent); color: #12161b;
  font-size: 11.5px; font-weight: 700; text-align: center;
}
.conv-preview {
  margin-top: 2px;
  color: var(--dim); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.empty { padding: 18px 16px; color: var(--dim); font-size: 13.5px; }

/* --- the conversation pane ------------------------------------------------ */

/* min-height: 0 down the whole chain, or the flex default of min-height:auto
   lets content push each level taller than its parent -- at which point the
   PAGE scrolls, #messages never does, scrollTop writes go nowhere, and the
   composer slides out of view. Both reported bugs were this one line. */
#pane { display: flex; min-width: 0; min-height: 0; }
#pane-empty {
  margin: auto; color: var(--dim);
}
#conversation {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}
#conv-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
#conv-header h2 { margin: 0; font-size: 16px; }

#messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; }
#load-earlier {
  display: block; margin: 0 auto 14px;
  padding: 5px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--dim);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
#load-earlier:hover { color: var(--ink); border-color: var(--ink); }

#message-list { list-style: none; margin: 0; padding: 0; }
.msg {
  max-width: 72%;
  margin: 2px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--theirs);
  overflow-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
}
.msg.mine { margin-left: auto; background: var(--mine); }
.msg.first { margin-top: 12px; }
.msg-meta {
  display: block;
  margin-bottom: 2px;
  font-size: 11.5px; color: var(--dim);
}
.msg.deleted { color: var(--dim); font-style: italic; }
.msg-edited { font-size: 11px; color: var(--dim); margin-left: 6px; }

.msg-actions {
  position: absolute; top: 4px; right: 8px;
  display: none; gap: 6px;
}
.msg.mine:hover .msg-actions { display: flex; }
.msg-actions button {
  border: 0; background: none; padding: 0;
  color: var(--dim); font-size: 11.5px; cursor: pointer;
}
.msg-actions button:hover { color: var(--ink); }

#composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
#composer-input {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  font: inherit;
  max-height: 40vh;
}
#composer-input:focus { outline: none; border-color: var(--accent); }
#composer-send {
  padding: 10px 20px;
  border: 1px solid var(--accent); border-radius: 10px;
  background: none; color: var(--accent);
  font: inherit; cursor: pointer;
}
#composer-send:hover { background: var(--accent); color: #12161b; }

/* --- small screens -------------------------------------------------------- */

@media (max-width: 720px) {
  #shell { grid-template-columns: 1fr; }
  #shell.conversing #sidebar { display: none; }
  #shell:not(.conversing) #pane { display: none; }
  .msg { max-width: 88%; }
}
