:root { color-scheme: light; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; color: #202124; background: #fff; --muted: #6b7280; --line: #e5e7eb; --accent: #2563eb; }
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nickname-screen { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px; }
.nickname-form { width: min(100%, 320px); display: flex; flex-direction: column; }
.nickname-form h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.025em; margin: 0 0 10px; }
.nickname-form > p { color: var(--muted); font-size: .9375rem; line-height: 1.5; margin: 0 0 24px; }
.nickname-form input { width: 100%; padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 7px; outline: none; margin-bottom: 12px; color: #202124; background: #fff; }
.nickname-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #2563eb12; }
.nickname-form .form-error { margin: 0 0 12px; color: #b42318; font-size: .875rem; }
.primary-button { background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 11px 20px; font-weight: 500; font-size: .9375rem; }
.primary-button:hover:enabled { background: #1d4ed8; }
.chat-screen { width: 100%; max-width: 1100px; height: 100%; margin: 0 auto; display: flex; flex-direction: column; border-inline: 1px solid var(--line); }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 17px 28px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-heading h1 { margin: 0 0 6px; font-size: 1rem; font-weight: 600; }
.connection-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8125rem; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }
.status-dot[data-state=online] { background: #16a34a; }
.status-dot[data-state=offline], .status-dot[data-state=connecting] { background: #ca8a04; }
.joined-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.identity-avatar { height: 30px; width: 30px; flex-shrink: 0; display: grid; place-items: center; background: #eef2ff; border-radius: 50%; color: #4f46e5; font-size: .75rem; font-weight: 600; }
#identity-name { font-weight: 500; font-size: .875rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-button { background: none; border: 0; color: var(--muted); font-size: .875rem; padding: 7px 8px; border-radius: 5px; }
.text-button:hover:enabled { background: #f3f4f6; color: #202124; }
.message-history { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.history-content { min-height: 100%; display: flex; flex-direction: column; padding: 24px 28px; }
.empty-state { margin: auto; padding: 24px; color: #9ca3af; font-size: .875rem; text-align: center; }
.sent-messages { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.sent-message { width: 100%; min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; padding: 0 3px 7px; font-size: .75rem; color: var(--muted); }
.message-meta strong { color: #374151; font-size: .8125rem; font-weight: 500; overflow-wrap: anywhere; }
.message-meta time { margin-left: auto; white-space: nowrap; }
.message-meta span { order: 3; }
.message-body { background: #f1f3f5; border-radius: 10px; padding: 12px 16px; }
.markdown-body { overflow-wrap: anywhere; line-height: 1.6; font-size: 1rem; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 12px; white-space: pre-wrap; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.3; margin: 18px 0 10px; font-size: 1.15em; }
.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body pre { white-space: pre; overflow: auto; background: #e6e9ee; border-radius: 6px; padding: 12px; max-width: 100%; }
.markdown-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .875em; background: #e6e9ee; padding: 2px 4px; border-radius: 3px; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 3px solid #c7cdd6; margin: 12px 0; padding-left: 12px; color: #4b5563; }
.markdown-body ul, .markdown-body ol { padding-left: 24px; }
.markdown-body a { color: #1d4ed8; }
.markdown-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.markdown-body td, .markdown-body th { border: 1px solid #cdd2d9; padding: 6px 10px; }
.composer-dock { padding: 12px 28px max(10px, env(safe-area-inset-bottom)); flex-shrink: 0; border-top: 1px solid var(--line); background: #fff; }
.composer { border: 1px solid #d1d5db; border-radius: 10px; overflow: hidden; background: #fff; }
.composer:focus-within { border-color: #9ca3af; }
.composer-toolbar { display: flex; align-items: center; padding: 7px 10px; gap: 14px; border-bottom: 1px solid #f0f1f3; }
.editor-modes { display: flex; gap: 2px; }
.mode-button { border: none; background: transparent; color: var(--muted); font-size: .875rem; padding: 6px 9px; border-radius: 5px; }
.mode-button[aria-pressed=true] { background: #f0f1f3; color: #202124; font-weight: 500; }
.format-tools { display: flex; border-left: 1px solid var(--line); padding-left: 10px; gap: 2px; }
.format-tools button { border: 0; border-radius: 4px; width: 30px; height: 28px; background: none; color: #4b5563; }
.format-tools button:hover:enabled { background: #f0f1f3; }
.code-symbol { font-family: ui-monospace, monospace; font-size: .8125rem; }
.expand-button { margin-left: auto; }
.editor-area { min-height: 64px; }
textarea { display: block; resize: none; width: 100%; min-height: 64px; max-height: min(220px, 30dvh); overflow-y: auto; border: none; background: transparent; color: #202124; outline: none; padding: 12px 16px; line-height: 1.5; tab-size: 2; }
textarea::placeholder { color: #9ca3af; }
.message-preview { padding: 12px 16px; min-height: 64px; max-height: min(220px, 30dvh); overflow-y: auto; }
.preview-empty { color: #9ca3af; }
.composer-actions { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px 16px; }
.character-count { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.compose-help { color: var(--muted); font-size: .75rem; }
.send-button { margin-left: auto; padding: 8px 20px; min-width: 78px; }
.composer-status { display: flex; align-items: baseline; gap: 12px; min-height: 22px; padding: 6px 2px 0; color: var(--muted); font-size: .75rem; }
#send-feedback { margin: 0; }
#send-feedback[data-kind=error] { color: #b42318; }
#sent-count { margin-left: auto; white-space: nowrap; }
.composer.expanded .editor-area { height: min(48dvh, 520px); }
.composer.expanded textarea, .composer.expanded .message-preview { height: 100% !important; max-height: none; }
@media (max-width: 600px) {
  .chat-screen { border: none; }
  .chat-header { padding: 13px 16px; gap: 12px; }
  .identity-avatar { display: none; }
  .joined-identity { flex-wrap: wrap; justify-content: flex-end; gap: 2px 8px; max-width: 55%; }
  #identity-name { max-width: 140px; }
  #change-id { padding: 3px 0; font-size: .8125rem; }
  .history-content { padding: 20px 16px; }
  .composer-dock { padding: 10px 12px max(8px, env(safe-area-inset-bottom)); }
  .composer-toolbar { gap: 5px; padding-inline: 6px; }
  .format-tools { padding-left: 5px; }
  .compose-help { display: none; }
  .composer.expanded .editor-area { height: 40dvh; }
}
@media (max-height: 500px) { .chat-header { padding-block: 8px; } .composer.expanded .editor-area { height: 30dvh; } }
