@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --ink: #f4f7f5;
  --muted: #8d9b97;
  --quiet: #53635f;
  --panel: #111917;
  --panel-deep: #0b100f;
  --line: rgba(180, 210, 199, .13);
  --accent: #91e6b2;
  --accent-strong: #4fc987;
  --accent-soft: rgba(145, 230, 178, .11);
  --warning: #f0c674;
  --shadow: 0 30px 100px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, rgba(53, 139, 102, .15), transparent 30rem),
    radial-gradient(circle at 85% 85%, rgba(62, 85, 121, .14), transparent 28rem),
    #080d0c;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.psyirc { min-height: 100vh; padding: 4vh 4vw; }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.brand-mark { color: var(--ink); font-size: 1.2rem; font-weight: 700; letter-spacing: -.04em; }
.brand-mark span { color: var(--accent); }
.eyebrow { margin: 0 0 .45rem; color: var(--accent); font: 500 .66rem/1.2 'DM Mono', monospace; letter-spacing: .14em; text-transform: uppercase; }

.auth-card {
  width: min(100%, 480px);
  margin: 8vh auto 0;
  padding: clamp(2rem, 6vw, 4rem);
  background: rgba(17, 25, 23, .9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card h1 { margin: .35rem 0 .75rem; font-size: clamp(2.2rem, 7vw, 3.8rem); line-height: .98; letter-spacing: -.07em; }
.auth-card h1 span { color: var(--accent); }
.auth-intro { margin: 0 0 2.25rem; color: var(--muted); line-height: 1.6; }
.auth-card form { display: grid; gap: .55rem; }
.auth-card label { margin-top: .5rem; color: var(--muted); font-size: .78rem; }
.auth-card label span { color: var(--quiet); }
.auth-card input, .message-form input {
  width: 100%;
  color: var(--ink);
  background: var(--panel-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.auth-card input { padding: .9rem 1rem; }
.auth-card input:focus, .message-form input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.primary-button, .send-button {
  color: #09110d;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  transition: transform .18s, background .18s;
}
.primary-button { margin-top: 1rem; padding: .95rem; }
.primary-button:hover, .send-button:hover { background: #b4f1ca; transform: translateY(-1px); }
.form-status { min-height: 1.25rem; margin: .35rem 0 0; color: var(--warning); font-size: .78rem; }
.small-note { margin: 1.8rem 0 0; color: var(--quiet); font-size: .7rem; line-height: 1.6; }

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  width: min(1180px, 100%);
  min-height: min(780px, 88vh);
  margin: 0 auto;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 1.35rem; background: rgba(8, 13, 12, .7); border-right: 1px solid var(--line); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.65rem; }
.network-dot, .live-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 4px rgba(79, 201, 135, .12); }
.identity-card { display: flex; align-items: center; gap: .75rem; padding: .85rem; background: var(--accent-soft); border: 1px solid rgba(145, 230, 178, .14); border-radius: 10px; }
.avatar { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; color: #09110d; background: var(--accent); border-radius: 50%; font-weight: 700; }
.identity-card strong { display: block; max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.presence { display: flex; align-items: center; gap: .35rem; margin-top: .18rem; color: var(--muted); font: .66rem 'DM Mono', monospace; }
.presence i { width: 5px; height: 5px; background: var(--accent-strong); border-radius: 50%; }
.room-nav { margin-top: 1.8rem; }
.nav-label { margin: 0 .3rem .6rem; color: var(--quiet); font: 500 .62rem 'DM Mono', monospace; letter-spacing: .12em; }
.members-label { margin-top: 1.6rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .65rem .75rem; color: var(--muted); text-align: left; background: transparent; border: 1px solid transparent; border-radius: 7px; }
.nav-item:hover, .nav-item.is-active { color: var(--ink); background: var(--accent-soft); border-color: rgba(145, 230, 178, .1); }
.room-symbol { color: var(--accent); font: 1rem 'DM Mono', monospace; }
.nav-badge { margin-left: auto; color: var(--accent); font: .58rem 'DM Mono', monospace; }
.member-list { flex: 1; min-height: 80px; overflow-y: auto; }
.member { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .3rem; color: var(--muted); text-align: left; background: transparent; border: 0; border-radius: 6px; }
.member:hover, .member.is-selected { color: var(--ink); background: rgba(255, 255, 255, .04); }
.member .member-avatar { display: grid; place-items: center; width: 25px; height: 25px; color: var(--panel-deep); background: #70817c; border-radius: 50%; font-size: .66rem; font-weight: 700; }
.member.is-online .member-avatar { background: var(--accent); }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.member-status { margin-left: auto; width: 5px; height: 5px; background: var(--quiet); border-radius: 50%; }
.member.is-online .member-status { background: var(--accent-strong); }
.empty-members { color: var(--quiet); font-size: .72rem; line-height: 1.5; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
#connection-label { color: var(--quiet); font: .6rem 'DM Mono', monospace; text-transform: uppercase; }
.logout-button { padding: 0; color: var(--muted); background: none; border: 0; font-size: .7rem; }
.logout-button:hover { color: var(--ink); }

.chat-panel { display: flex; min-width: 0; flex-direction: column; }
.chat-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 2rem 2.4rem 1.35rem; border-bottom: 1px solid var(--line); }
.chat-header h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.35rem); letter-spacing: -.06em; }
.chat-header h1::first-letter { color: var(--accent); }
.chat-header p:not(.eyebrow) { margin: .4rem 0 0; color: var(--muted); font-size: .78rem; }
.header-status { display: flex; align-items: center; gap: .55rem; padding-top: .3rem; color: var(--muted); font: .66rem 'DM Mono', monospace; white-space: nowrap; }
.message-list { display: flex; min-height: 0; height: min(58vh, 560px); flex-direction: column; gap: .3rem; padding: 1.3rem 2.4rem; overflow-y: auto; overscroll-behavior: contain; background: linear-gradient(90deg, rgba(145, 230, 178, .015), transparent 35%); }
.message-list::-webkit-scrollbar, .member-list::-webkit-scrollbar { width: 5px; }
.message-list::-webkit-scrollbar-thumb, .member-list::-webkit-scrollbar-thumb { background: rgba(145, 230, 178, .2); border-radius: 10px; }
.empty-state { margin: auto; color: var(--quiet); font: .75rem 'DM Mono', monospace; }
.message { display: grid; grid-template-columns: 74px minmax(0, auto) 1fr; align-items: baseline; gap: .7rem; padding: .55rem .65rem; border-radius: 7px; animation: appear .22s ease both; }
.message:hover { background: rgba(255, 255, 255, .025); }
.message-time { color: var(--quiet); font: .65rem 'DM Mono', monospace; }
.message-author { overflow: hidden; color: var(--accent); text-overflow: ellipsis; white-space: nowrap; font: 500 .73rem 'DM Mono', monospace; }
.message-author.is-self { color: #b4f1ca; }
.message-body { min-width: 0; color: #dbe4e0; word-break: break-word; white-space: pre-wrap; font-size: .87rem; line-height: 1.5; }
.message-proof { grid-column: 2 / -1; min-width: 0; color: var(--quiet); font: .58rem 'DM Mono', monospace; }
.message-proof button { max-width: 100%; padding: 0; overflow: hidden; color: inherit; text-overflow: ellipsis; white-space: nowrap; background: transparent; border: 0; }
.message-proof button:hover { color: var(--accent); }
.message-proof.is-copied { color: var(--accent); }
.history-status { min-height: 1.25rem; padding: 0 2.4rem; color: var(--warning); font: .65rem 'DM Mono', monospace; }
.message-form { display: flex; gap: .7rem; padding: .7rem 2.4rem 1rem; }
.message-form input { min-width: 0; padding: .85rem 1rem; }
.send-button { flex: 0 0 auto; padding: 0 1.15rem; }
.send-button span { margin-left: .3rem; font: .7rem 'DM Mono', monospace; }
.integrity-note { padding: 0 2.4rem 1.3rem; color: var(--quiet); font: .62rem/1.5 'DM Mono', monospace; }
.lock-icon { color: var(--accent); margin-right: .3rem; }

html.psb-chat-embed, html.psb-chat-embed body { width: 100%; height: 100%; min-height: 100%; overflow: hidden; }
body.psb-chat-embed { background: #080d0c; }
.psb-chat-embed .psyirc { width: 100%; height: 100%; min-height: 0; padding: 0; }
.psb-chat-embed .app-shell { width: 100%; height: 100%; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.psb-chat-embed .chat-panel { min-height: 0; }
.psb-chat-embed .message-list { height: auto; flex: 1 1 auto; scrollbar-width: none; }
.psb-chat-embed .message-list::-webkit-scrollbar, .psb-chat-embed .member-list::-webkit-scrollbar { width: 0; height: 0; }
.psb-chat-embed .member-list { scrollbar-width: none; }

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

@media (max-width: 760px) {
  .psyirc { padding: 0; }
  .app-shell { min-height: 100vh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .sidebar { min-height: auto; padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading { margin-bottom: .9rem; }
  .identity-card { display: none; }
  .room-nav { display: flex; align-items: center; gap: .5rem; margin-top: 0; }
  .room-nav .nav-label { display: none; }
  .room-nav .members-label { display: block; margin: 0 0 0 auto; }
  .nav-item { width: auto; }
  .member-list { display: flex; gap: .25rem; max-height: 42px; min-height: 0; }
  .member { width: auto; padding: .35rem; }
  .member-name { max-width: 80px; }
  .member-status { display: none; }
  .sidebar-footer { display: none; }
  .chat-header { padding: 1.25rem 1rem 1rem; }
  .message-list { height: 58vh; padding: 1rem .65rem; }
  .message-form { padding: .7rem 1rem 1rem; }
  .history-status, .integrity-note { padding-left: 1rem; padding-right: 1rem; }
  .message { grid-template-columns: 57px minmax(0, auto) 1fr; gap: .45rem; padding-left: .4rem; padding-right: .4rem; }
  .message-proof { grid-column: 2 / -1; }
  .auth-card { margin: 0; min-height: 100vh; border: 0; border-radius: 0; }
  .psb-chat-embed .app-shell { height: 100%; }
  .psb-chat-embed .message-list { height: auto; }
}
