@import url("./brand-tokens.css");

:root {
  color-scheme: light;
  --ink: var(--safest-ink-950);
  --muted: var(--safest-stone-650);
  --line: var(--safest-line);
  --paper: var(--safest-parchment-50);
  --white: var(--safest-paper);
  --green: var(--safest-evergreen-800);
  --green-dark: var(--safest-evergreen-950);
  --lime: var(--safest-lime-400);
  --soft-green: var(--safest-mint-100);
  --danger: var(--safest-danger-700);
  --sans: var(--safest-font-sans);
  --serif: var(--safest-font-serif);
  font-family: var(--sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.sidebar { min-width: 0; padding: 28px 22px; border-right: 1px solid var(--line); background: #edf1ed; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: block; flex: 0 0 40px; border-radius: 12px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: var(--muted); margin-top: 1px; }

.lab-note { padding: 14px; border: 1px solid #cbd8ce; border-radius: 14px; background: rgba(255,255,255,.58); font-size: 13px; font-weight: 700; }
.lab-note p { margin: 8px 0 0; color: var(--muted); font-weight: 400; line-height: 1.45; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #35a46d; box-shadow: 0 0 0 4px rgba(53,164,109,.12); }
.nav-label, .eyebrow { margin: 0 0 9px; color: #879089; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.rooms { display: grid; gap: 5px; }
.room-button { width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; text-align: left; color: #566159; }
.room-button::before { content: "#"; margin-right: 10px; color: #99a29b; font-weight: 700; }
.room-button:hover { background: rgba(255,255,255,.65); color: var(--ink); }
.room-button.active { background: var(--white); color: var(--green-dark); font-weight: 750; box-shadow: 0 1px 3px rgba(24,45,32,.06); }

.identity { margin-top: auto; }
.identity label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.identity-row { display: flex; align-items: center; gap: 9px; }
.avatar { flex: 0 0 35px; height: 35px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: white; font-weight: 800; }
.identity input { min-width: 0; width: 100%; padding: 9px 10px; border: 1px solid #cbd4cd; border-radius: 9px; background: rgba(255,255,255,.8); outline: none; }
.identity input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,69,.1); }
.identity p { margin: 8px 0 0 44px; color: #879089; font-size: 11px; line-height: 1.4; }

.chat { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--white); }
.chat-header { min-height: 108px; padding: 24px clamp(24px, 5vw, 72px) 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chat-header h1 { margin: 0; font: 560 clamp(23px, 3vw, 30px)/1.1 var(--serif); letter-spacing: -.025em; }
.chat-header p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.live-pill { padding: 8px 12px; border-radius: 999px; background: var(--soft-green); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.live-pill span { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #32a56b; }

.messages { overflow-y: auto; padding: 28px clamp(24px, 5vw, 72px); scroll-behavior: smooth; }
.empty-state { min-height: 100%; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state span { font-size: 27px; color: var(--green); }
.empty-state h2 { margin: 10px 0 4px; color: var(--ink); font: 560 20px/1.2 var(--serif); }
.empty-state p { margin: 0; font-size: 13px; }
.message { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 11px 0; }
.message + .message { border-top: 1px solid #f0f2f0; }
.message-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--green-dark); background: var(--soft-green); font-weight: 800; }
.message-main { min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-meta strong { font-size: 13px; }
.message-meta time { color: #9aa19c; font-size: 11px; }
.message-body { margin: 4px 0 7px; white-space: pre-wrap; overflow-wrap: anywhere; color: #344039; font-size: 14px; line-height: 1.55; }
.reply-preview { margin: 2px 0 8px; padding: 7px 10px; border-left: 2px solid #9bc4aa; background: #f6f9f6; color: #6a756d; border-radius: 0 7px 7px 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-actions { opacity: 0; display: flex; gap: 6px; transition: opacity .15s ease; }
.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; }
.message-actions button { padding: 3px 7px; border: 0; border-radius: 6px; background: transparent; color: #7b857e; font-size: 11px; }
.message-actions button:hover { background: var(--paper); color: var(--ink); }
.message-actions .report:hover { color: var(--danger); }

.composer-wrap { padding: 14px clamp(24px, 5vw, 72px) 22px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.composer { border: 1px solid #cfd7d1; border-radius: 15px; background: #fafcfa; box-shadow: 0 5px 20px rgba(24,45,32,.05); overflow: hidden; }
.composer:focus-within { border-color: #7ca98c; box-shadow: 0 0 0 3px rgba(23,107,69,.08), 0 5px 20px rgba(24,45,32,.05); }
.composer textarea { display: block; width: 100%; max-height: 160px; resize: none; padding: 13px 15px 5px; border: 0; outline: 0; background: transparent; color: var(--ink); line-height: 1.5; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px 9px 15px; }
.composer-footer > span { color: #969e98; font-size: 10px; }
.composer-footer button, .dialog-actions button { padding: 8px 13px; border: 0; border-radius: 9px; background: var(--green); color: white; font-size: 12px; font-weight: 800; }
.composer-footer button:hover, .dialog-actions button:hover { background: var(--green-dark); }
.composer-footer button:disabled { opacity: .45; cursor: not-allowed; }
.reply-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid #d9e2db; border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--soft-green); font-size: 12px; }
.reply-bar span { color: var(--muted); margin-right: 6px; }
.reply-bar button, .icon-button { border: 0; background: transparent; color: var(--muted); font-size: 20px; }
.notice { min-height: 14px; margin: 6px 2px 0; color: var(--danger); font-size: 11px; }
.notice a { margin-left: 8px; color: var(--green); font-weight: 800; text-decoration: underline; text-decoration-color: var(--lime); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.notice a:hover { color: var(--green-dark); }

dialog { width: min(440px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(14,34,22,.25); }
dialog::backdrop { background: rgba(15,28,20,.46); backdrop-filter: blur(3px); }
#report-form { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font: 560 23px/1.2 var(--serif); }
#report-form label { display: grid; gap: 7px; margin-top: 15px; color: var(--ink); font-size: 12px; font-weight: 750; }
#report-form label em { color: #969e98; font-style: normal; font-weight: 400; }
#report-form select, #report-form textarea { width: 100%; padding: 10px 11px; border: 1px solid #cfd7d1; border-radius: 9px; outline: 0; background: white; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-actions .secondary { background: #edf1ed; color: var(--ink); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); gap: 13px; }
  .brand, .lab-note, .identity label, .identity p, .nav-label { display: none; }
  .identity { order: 2; margin: 0; }
  .identity-row { position: absolute; top: 16px; right: 16px; width: 150px; }
  .identity input { background: white; }
  .sidebar nav, .rooms { min-width: 0; }
  .rooms { width: 100%; display: flex; gap: 6px; overflow-x: auto; padding-right: 170px; }
  .room-button { width: auto; white-space: nowrap; padding: 8px 10px; }
  .chat { height: calc(100vh - 64px); }
  .chat-header { min-height: 86px; padding: 18px 18px 15px; }
  .chat-header p:last-child { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .messages { padding: 18px; }
  .composer-wrap { padding: 10px 14px 14px; }
  .message-actions { opacity: 1; }
}
