:root {
  color-scheme: dark;
  --background: #171412;
  --panel: #201b18;
  --raised: #29221e;
  --line: #413630;
  --ink: #faf2ec;
  --muted: #c0aea1;
  --accent: #ff9a60;
  --accent-dark: #3b281f;
  font: 15px/1.45 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button, input, select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--raised);
  color: var(--ink);
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 720; white-space: nowrap; }
.mark {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 9px; background: var(--accent); color: #22130c; font-weight: 850;
}
h1, h2, p { margin: 0; }
h1 { font-size: 25px; letter-spacing: -.025em; }
h2 { font-size: 16px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 420px); padding: 30px; display: grid; gap: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.login-card label { display: grid; gap: 5px; color: var(--muted); }
.primary { background: var(--accent); color: #25150c; border-color: transparent; font-weight: 740; }
.error { color: #ffb49a; }
.global-error { padding: 5px 24px; }
.inbox { height: 100dvh; display: flex; flex-direction: column; }
.top, .workspace { padding: 12px 24px; border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; justify-content: space-between; }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.workspace { padding-top: 16px; display: grid; gap: 12px; }
.clinics { display: flex; gap: 8px; overflow-x: auto; padding: 3px; }
.clinics button { flex: none; }
.clinics button[aria-current="true"] { border-color: var(--accent); background: var(--accent-dark); color: var(--accent); }
.panes { flex: 1; display: grid; grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); min-height: 0; }
.left, .conversation { display: flex; flex-direction: column; min-height: 0; }
.left { background: var(--panel); border-right: 1px solid var(--line); }
.list-header, .conversation-header { border-bottom: 1px solid var(--line); padding: 14px 16px; }
.list-header { display: grid; gap: 9px; }
.threads, .history { flex: 1; overflow-y: auto; }
.threads p { padding: 18px 16px; color: var(--muted); }
.thread {
  display: grid; gap: 3px; width: 100%; text-align: left; border: 0;
  border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 12px 16px;
}
.thread:hover:not(:disabled), .thread[aria-current="true"] { background: var(--raised); }
.thread[aria-current="true"] { box-shadow: inset 3px 0 var(--accent); }
.thread .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.thread strong, .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview, .thread time, .contact span { color: var(--muted); font-size: 13px; }
.thread time { flex: none; }
.badge { display: inline-flex; color: var(--accent); background: var(--accent-dark); border-radius: 20px; padding: 2px 8px; font-size: 12px; }
.badge[data-mode="human"] { color: #b8e0cf; background: #21392f; }
.pagination { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); }
.conversation { background: #191614; }
.conversation-header { display: flex; gap: 12px; align-items: center; background: var(--panel); }
.contact { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.conversation-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; }
.history { padding: 14px clamp(12px, 4vw, 52px); }
.messages { display: flex; flex-direction: column; gap: 10px; }
.message { align-self: flex-start; background: var(--raised); border: 1px solid var(--line); max-width: min(86%, 640px); border-radius: 12px; padding: 8px 12px; }
.message[data-author="chatboy"], .message[data-author="human"] { align-self: flex-end; background: var(--accent-dark); }
.message[data-author="human"] { background: #20352c; }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; }
.message small { display: block; color: var(--muted); margin-top: 5px; font-size: 11px; }
.older { display: block; margin: 0 auto 14px; }
.empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; }
footer { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.back { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 680px) {
  .top, .workspace { padding-left: 14px; padding-right: 14px; }
  #account { display: none; }
  .panes { grid-template-columns: 1fr; }
  .empty, .panes:has(#conversation:not([hidden])) .left { display: none; }
  .back { display: block; font-size: 12px; padding: 5px; }
  .conversation-header { padding: 8px; gap: 7px; }
  .conversation-actions button { font-size: 12px; }
}

.reply-form {
  display: flex;
  gap: .65rem;
  align-items: end;
  padding: .7rem 1rem;
  border-top: 1px solid var(--line);
}
.reply-form textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .5rem .7rem;
}
.reply-form textarea:focus-visible { outline: 2px solid var(--accent); }
.reply-jobs {
  padding: .4rem 1rem;
  max-height: 100px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
  overflow-wrap: anywhere;
}
.reply-jobs p { margin: .2rem 0; }
