:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b10;
  color: #eef1f7;
  --panel: #11151e;
  --panel-2: #171c27;
  --border: #2a3140;
  --muted: #929cad;
  --accent: #b5ff6d;
  --accent-ink: #101607;
  --danger: #ff7b8b;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid #8ec8ff; outline-offset: 2px; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #25381c 0, transparent 38%), #090b10; }
.login-card { width: min(420px, 100%); display: grid; gap: 10px; padding: 34px; border: 1px solid var(--border); border-radius: 22px; background: rgba(17, 21, 30, .94); box-shadow: 0 24px 80px rgba(0, 0, 0, .45); }
.login-card h1 { margin: 0; font-size: 2.25rem; letter-spacing: -.05em; }
.login-card .primary { margin-top: 10px; }
.eyebrow { margin: 8px 0 -5px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: var(--accent-ink); background: var(--accent); font-weight: 900; letter-spacing: -.08em; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; }

label { margin-top: 7px; color: #d7dce6; font-size: .88rem; font-weight: 650; }
input, textarea, select { width: 100%; color: inherit; background: #0c0f16; border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; }
textarea { resize: vertical; min-height: 46px; max-height: 160px; }
button { color: inherit; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; }
button.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 800; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
.muted { color: var(--muted); font-size: .86rem; }
.error { min-height: 1.25em; margin: 4px 0 0; color: var(--danger); font-size: .88rem; }
.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; }

.app { min-height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.sidebar { padding: 18px 14px; border-right: 1px solid var(--border); background: var(--panel); overflow-y: auto; }
.sidebar-header { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.push { margin-left: auto; }
.join-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.nav-heading { display: flex; align-items: center; margin: 22px 7px 7px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-heading .icon-button { margin-left: auto; }
.target-list { display: grid; gap: 4px; }
.target-row { display: flex; gap: 4px; }
.target-button { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; text-align: left; background: transparent; border-color: transparent; }
.target-button:hover, .target-button.active { background: var(--panel-2); border-color: var(--border); }
.target-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; color: var(--accent-ink); background: var(--accent); font-size: .72rem; font-weight: 800; text-align: center; }
.icon-button { min-width: 32px; padding: 5px 8px; border-color: transparent; background: transparent; }

.conversation { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto auto; background: #0c0f15; }
.conversation-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); }
.conversation-header h2 { margin: 0 0 3px; font-size: 1.2rem; }
.conversation-header p { margin: 0; }
.load-older { justify-self: center; margin: 10px 0 0; }
.messages { min-height: 0; margin: 0; padding: 18px 24px; overflow-y: auto; list-style: none; }
.message { max-width: 780px; padding: 11px 0; border-bottom: 1px solid rgba(42, 49, 64, .55); }
.message-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.message-sender { font-weight: 800; }
.message-kind { padding: 2px 6px; border-radius: 5px; color: #a9b2c2; background: #202736; font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.message-kind.command { color: #101607; background: var(--accent); }
.message-kind.result { color: #07131a; background: #79d6ff; }
.message-time { color: var(--muted); font-size: .74rem; }
.message-text { margin: 0; color: #e7ebf2; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-actions { margin-top: 5px; }
.message-actions button { padding: 3px 7px; color: var(--muted); font-size: .75rem; background: transparent; border-color: transparent; }
.reply-reference { color: var(--muted); font-size: .78rem; }
.empty-state { align-self: center; justify-self: center; color: var(--muted); padding: 24px; text-align: center; }
.reply-bar { display: flex; align-items: center; gap: 8px; margin: 0 24px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--panel-2); color: #d7dce6; font-size: .84rem; }
.reply-bar .icon-button { margin-left: auto; }
.composer { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; align-items: end; gap: 9px; padding: 14px 24px 18px; border-top: 1px solid var(--border); background: var(--panel); }
.app-error { position: fixed; right: 20px; bottom: 90px; max-width: 420px; padding: 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 38vh) minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .conversation { height: 62vh; }
  .conversation-header, .messages { padding-left: 14px; padding-right: 14px; }
  .composer { grid-template-columns: 1fr auto; padding: 10px 14px; }
  .composer select { grid-column: 1 / -1; }
  .reply-bar { margin: 0 14px; }
}
