:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #1b1d20;
  background: #f4f5f6;
  letter-spacing: 0;
  --line: #d9dde2;
  --muted: #68717d;
  --accent: #19775d;
  --accent-dark: #0f5e49;
  --surface: #ffffff;
  --warm: #f1ede4;
  --danger: #b3261e;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f5f6; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-form { width: min(100%, 360px); display: grid; gap: 18px; }
.login-form h1 { margin: 0 0 8px; font-size: 24px; }
.login-form label { display: grid; gap: 7px; color: #414851; font-size: 14px; }
.login-form input { min-height: 44px; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; background: var(--surface); }
.login-form input:focus, textarea:focus { outline: 2px solid #90c7b7; outline-offset: 1px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; color: white; background: var(--accent); font-weight: 700; font-size: 23px; border-radius: 6px; }
.brand-mark.small { width: 34px; height: 34px; font-size: 17px; flex: 0 0 auto; }
.error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }
.product-thesis { margin: -8px 0 0; color: var(--muted); line-height: 1.4; }

.app-shell { height: 100vh; display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); background: var(--surface); }
.room-rail { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f7f8f8; }
.rail-header { min-height: 64px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rail-header > div:nth-child(2) { min-width: 0; flex: 1; display: grid; gap: 2px; }
.rail-header span { color: var(--muted); font-size: 12px; }
.icon-command { width: 36px; height: 36px; border: 0; background: transparent; font-size: 22px; color: #4b535c; border-radius: 4px; }
.icon-command:hover { background: #e8ebed; }

.room-list { overflow: auto; padding: 8px; }
.room-button { width: 100%; min-height: 58px; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.room-button:hover { background: #e9ecee; }
.room-button.active { background: #dfeae6; }
.room-avatar { width: 36px; height: 36px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 50%; color: var(--accent-dark); font-weight: 700; }
.room-copy { min-width: 0; display: grid; gap: 3px; }
.room-copy strong, .room-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-copy span { color: var(--muted); font-size: 12px; }

.operator-summary { margin-top: auto; border-top: 1px solid var(--line); padding: 14px; }
.operator-summary h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.operator-summary dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 0; font-size: 12px; }
.operator-summary dt { color: var(--muted); }
.operator-summary dd { margin: 0; font-weight: 600; }
.invite-form { display: grid; gap: 7px; margin-top: 12px; }
.invite-form select, .invite-form input { width: 100%; min-height: 34px; border: 1px solid var(--line); border-radius: 4px; background: white; padding: 0 7px; }

.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #eef0ef; }
.conversation-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.conversation-header h1 { margin: 0; font-size: 17px; }
.conversation-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.connection-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-state.online { color: var(--accent-dark); }

.messages { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 18px max(18px, calc((100% - 900px) / 2)); }
.empty-state { margin: auto; color: var(--muted); text-align: center; }
.message { align-self: flex-start; max-width: min(76%, 720px); padding: 9px 11px; border: 1px solid #d6dadd; border-radius: 6px; background: var(--surface); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.message.mine { align-self: flex-end; background: #e1f0ea; border-color: #c7dfd6; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.42; }
.message.deleted > :not(.message-meta):not(.message-delivery) { display: none; }
.message.deleted::before { content: "Данные удалены автором"; color: var(--muted); font-style: italic; }
.message-note { margin-top: 6px; color: var(--muted); font-size: 11px; }
.message-delivery { min-width: 0; display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.message-delivery span { min-width: 0; overflow-wrap: anywhere; }
.delivery-inbox { color: var(--accent-dark); }
.delivery-outbox.state-local_pending, .delivery-outbox.state-retryable { color: #8a5a16; }
.message-commands { display: flex; gap: 4px; margin-top: 7px; }
.message-commands button { border: 0; background: transparent; color: var(--accent-dark); padding: 3px 5px; }
.message-meta { display: flex; gap: 8px; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 11px; }
.message-attachments { display: grid; gap: 5px; margin-top: 8px; }
.message-attachments a { color: var(--accent-dark); overflow-wrap: anywhere; }

.composer { border-top: 1px solid var(--line); padding: 10px max(14px, calc((100% - 920px) / 2)); background: var(--surface); }
.composer textarea { width: 100%; min-height: 48px; max-height: 160px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.send-state { min-width: 0; flex: 1; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.primary-command, .secondary-command { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; padding: 0 14px; font-weight: 600; }
.primary-command { border: 1px solid var(--accent); color: white; background: var(--accent); }
.primary-command:hover { background: var(--accent-dark); }
.secondary-command { border: 1px solid var(--line); color: #333a41; background: white; }
.secondary-command:hover { background: #f1f3f4; }
.attachment-strip { display: flex; gap: 6px; overflow: auto; }
.attachment-chip { max-width: 260px; padding: 5px 8px; margin-bottom: 7px; background: var(--warm); border-radius: 4px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.consent-panel { min-width: 0; display: grid; gap: 7px; margin: 8px 0; padding: 10px; border: 1px solid var(--line); background: #f7f8f8; font-size: 13px; }
.consent-panel label { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 7px; overflow-wrap: anywhere; }
.consent-panel.granted { border-color: #9ac9ba; background: #eef7f3; }
.consent-panel.granted label, .consent-panel.granted #grant-consent { display: none; }
.consent-panel.granted #withdraw-consent { display: inline-flex; }
.recording-state { min-height: 18px; color: var(--danger); font-weight: 600; font-size: 13px; }
.recording-draft { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; padding: 9px; border: 1px solid #d8aaa6; background: #fff6f5; font-size: 12px; }
.secondary-command.danger { color: var(--danger); border-color: #d8aaa6; }

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 70px minmax(0, 1fr); }
  .rail-header { justify-content: center; padding: 10px 6px; }
  .rail-header > div:nth-child(2), .rail-header .icon-command, .room-copy, .operator-summary { display: none; }
  .room-list { padding: 7px; }
  .room-button { grid-template-columns: 1fr; justify-items: center; padding: 7px 0; }
  .message { max-width: 90%; }
  .messages { padding: 12px; }
  .conversation-header { padding: 10px 12px; }
  .conversation-header h1 { font-size: 15px; }
  .connection-state { display: none; }
  .composer { padding: 9px; }
  .composer-actions { flex-wrap: wrap; }
  .send-state { flex-basis: 100%; order: -1; }
  .primary-command, .secondary-command { min-width: 0; padding-inline: 10px; }
  .file-command { padding: 0 10px; }
}
