:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #16181d;
  background: #f7f6f2;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, textarea { font: inherit; }
a { color: inherit; }
.paper { min-height: 100vh; background: #f7f6f2; }
.app-body { height: 100dvh; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.wordmark { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: .08em; text-decoration: none; }
.wordmark span { color: #e8590c; }
.app-header { min-height: 64px; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e2d9; background: #fff; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.header-actions form { margin: 0; }
.signed-in { color: #66707c; }
.mention-link { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.header-button { padding: 8px 10px; border: 1px solid #e5e2d9; border-radius: 8px; background: #fff; color: #66707c; font-size: 14px; font-weight: 700; }
.header-button:hover { color: #16181d; background: #f7f6f2; }
.chat-dialog { width: min(520px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 32px)); padding: 0; border: 0; border-radius: 14px; background: transparent; color: #16181d; }
.chat-dialog::backdrop { background: rgba(22, 24, 29, .55); backdrop-filter: blur(2px); }
.dialog-card { overflow: hidden; border: 1px solid #d6d1c6; border-radius: 14px; background: #fff; box-shadow: 0 22px 70px rgba(22, 24, 29, .28); }
.dialog-header { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e5e2d9; }
.dialog-header h2 { margin: 0; font-size: 22px; }
.dialog-header p { margin: 4px 0 0; color: #66707c; }
.dialog-body { max-height: min(560px, calc(100dvh - 150px)); padding: 20px; overflow-y: auto; }
.help-copy p { margin: 0 0 14px; line-height: 1.5; }
.help-copy p:last-child { margin-bottom: 0; }
.help-copy code, .message-body code, .mention-card code { padding: 2px 5px; border-radius: 4px; background: #f0eee8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.chat-shell { width: 100%; min-height: 0; display: grid; grid-template-columns: 240px minmax(360px, 1fr) 240px; max-width: 1500px; margin: 0 auto; }
.room-nav, .members { padding: 24px 16px; overflow-y: auto; }
.room-nav { border-right: 1px solid #e5e2d9; }
.members { border-left: 1px solid #e5e2d9; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 8px 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.rooms { display: grid; gap: 4px; }
.room-link { min-height: 44px; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; border-radius: 8px; text-decoration: none; color: #66707c; }
.room-link:hover { background: #fff; color: #16181d; }
.room-link.active { background: #16181d; color: #fff; font-weight: 700; }
.room-badges { display: flex; align-items: center; gap: 6px; }
.badge { min-width: 24px; height: 24px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: #e5e2d9; color: #16181d; font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.room-link.active .badge { background: #fff; }
.badge.orange { background: #e8590c; color: #fff; }
.mention-dot { color: #e8590c; font: 800 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.new-room { padding: 20px 8px 0; margin-top: 20px; border-top: 1px solid #e5e2d9; }
.new-room label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.new-room div { display: flex; gap: 6px; }
.new-room input { min-width: 0; width: 100%; padding: 8px; border: 1px solid #e5e2d9; border-radius: 8px; background: #fff; }
.chat-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #fff; }
.chat-title { min-height: 74px; padding: 16px 24px; border-bottom: 1px solid #e5e2d9; display: flex; align-items: center; justify-content: space-between; }
.chat-title h1 { margin: 0; font-size: 24px; }
.chat-title > div { display: flex; align-items: center; gap: 14px; }
.live-state { font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #1a7f4e; text-transform: uppercase; letter-spacing: .08em; }
.live-state i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #1a7f4e; }
.message-scroll { min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; }
.message-content { width: 100%; min-height: 100%; flex: 0 0 auto; padding: 20px 24px; display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 4px; }
.message { padding: 10px 0; display: flex; gap: 12px; }
.avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: #16181d; color: #fff; display: flex; align-items: center; justify-content: center; font: 800 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.message-body { min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-meta span, .message-meta time { color: #66707c; font-size: 14px; }
.message-body p, .mention-card p { margin: 4px 0 0; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-link { color: #0b63ce; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.message-link:hover { text-decoration-thickness: 2px; }
mark { padding: 1px 3px; border-radius: 4px; background: #fff1e8; color: #b94708; font-weight: 700; }
.composer { padding: 16px 24px 20px; border-top: 1px solid #e5e2d9; background: #fff; }
.composer-input { position: relative; }
.composer textarea { width: 100%; min-height: 88px; max-height: 180px; resize: vertical; padding: 12px; border: 1px solid #e5e2d9; border-radius: 10px; color: #16181d; background: #fff; }
.mention-menu { position: absolute; z-index: 15; left: 0; right: 0; bottom: calc(100% + 8px); max-height: 240px; padding: 6px; overflow-y: auto; border: 1px solid #d6d1c6; border-radius: 10px; background: #fff; box-shadow: 0 16px 42px rgba(22, 24, 29, .18); }
.mention-option { width: 100%; padding: 8px; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 10px; border-radius: 7px; background: #fff; color: #16181d; text-align: left; }
.mention-option[hidden] { display: none; }
.mention-option .avatar { width: 36px; height: 36px; flex-basis: 36px; }
.mention-option strong, .mention-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-option small { margin-top: 2px; color: #66707c; font-size: 13px; }
.mention-option:hover, .mention-option.active { background: #f0eee8; }
.composer textarea:focus, input:focus { outline: 2px solid #e8590c; outline-offset: 1px; }
.composer-row { min-height: 38px; margin-top: 8px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.tag-hint { margin-right: auto; color: #66707c; font-size: 14px; }
button { cursor: pointer; border: 0; }
button.primary { padding: 10px 18px; border-radius: 8px; background: #16181d; color: #fff; font-weight: 700; }
button.primary:hover { background: #343943; }
button.quiet { padding: 8px 10px; border: 1px solid #e5e2d9; border-radius: 8px; background: #fff; color: #66707c; font-size: 14px; font-weight: 700; }
button:disabled { opacity: .55; cursor: wait; }
.member-list { display: grid; gap: 14px; }
.member { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.member strong, .member span { display: block; overflow: hidden; text-overflow: ellipsis; }
.member span { margin-top: 2px; color: #66707c; font-size: 14px; }
.online { width: 10px; height: 10px; border-radius: 50%; background: #1a7f4e; }
.roster-warning, .inline-error { color: #b42318; font-size: 14px; }
.empty { margin: auto; color: #66707c; }
.htmx-indicator { opacity: 0; color: #66707c; font-size: 14px; transition: opacity 150ms ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.login-shell { min-height: 100vh; padding: 32px; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 440px; padding: 32px; border: 1px solid #e5e2d9; border-radius: 14px; background: #fff; }
.login-card h1 { margin: 28px 0 24px; font-size: 36px; letter-spacing: -.03em; }
.login-form { display: grid; gap: 10px; }
.login-form label { margin-top: 6px; font-weight: 700; }
.login-form input { width: 100%; padding: 12px; border: 1px solid #e5e2d9; border-radius: 8px; }
.login-form button { margin-top: 12px; justify-self: start; }
.form-error { margin-bottom: 16px; padding: 12px; border-radius: 8px; background: #fff1f0; color: #b42318; }
.share-shell { min-height: calc(100vh - 64px); padding: 48px 24px; display: grid; place-items: start center; }
.share-card { width: 100%; max-width: 720px; padding: 32px; border: 1px solid #e5e2d9; border-radius: 14px; background: #fff; }
.share-kicker { margin: 0 0 12px; color: #e8590c; font: 800 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }
.share-card h1 { margin: 0; font-size: 36px; letter-spacing: -.03em; }
.share-summary { margin: 12px 0 28px; color: #66707c; line-height: 1.5; }
.share-card audio { width: 100%; }
.share-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.share-action { padding: 10px 16px; border: 1px solid #d6d1c6; border-radius: 8px; background: #fff; font-weight: 700; text-decoration: none; }
.share-action.primary { border-color: #16181d; background: #16181d; color: #fff; }
.share-note { margin: 24px 0 0; color: #66707c; font-size: 14px; }
.mentions-panel { grid-template-rows: auto minmax(0, 1fr); }
.mention-list { padding: 20px 24px; overflow-y: auto; display: grid; align-content: start; gap: 12px; }
.mention-card { padding: 16px; border: 1px solid #e5e2d9; border-radius: 10px; color: #16181d; text-decoration: none; }
.mention-card:hover { border-color: #c9c4b8; }
.mention-card.unread { border: 2px solid #e8590c; }
.mention-card-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.mention-card span, .mention-card time { color: #66707c; font-size: 14px; }
.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; }

@media (max-width: 980px) {
  .chat-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .members { display: none; }
}

@media (max-width: 700px) {
  .app-header { min-height: 0; padding: 10px 12px; flex-direction: column; align-items: stretch; gap: 10px; }
  .app-header > .wordmark { align-self: flex-start; }
  .signed-in { display: none; }
  .header-actions { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .header-actions > * { min-width: 0; }
  .header-actions form { display: flex; }
  .header-button, .mention-link, .header-actions form .quiet { width: 100%; min-height: 40px; padding: 7px 6px; justify-content: center; font-size: 13px; }
  .chat-shell { min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .room-nav { padding: 12px 16px; border-right: 0; border-bottom: 1px solid #e5e2d9; overflow: visible; }
  .section-title { display: none; }
  .rooms { display: flex; overflow-x: auto; gap: 8px; }
  .room-link { flex: 0 0 auto; border: 1px solid #e5e2d9; background: #fff; }
  .new-room { display: none; }
  .chat-panel { min-height: 0; }
  .chat-title { min-height: 60px; padding: 12px 16px; }
  .message-content { padding: 14px 16px; }
  .composer { padding: 12px 16px; }
  .mention-menu { max-height: min(200px, 35dvh); }
  .tag-hint { display: none; }
  .chat-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .dialog-header { padding: 16px; }
  .dialog-body { max-height: calc(100dvh - 100px); padding: 16px; }
  .share-shell { min-height: auto; padding: 20px 12px; }
  .share-card { padding: 22px 18px; }
  .share-card h1 { font-size: 30px; }
  .share-action { width: 100%; text-align: center; }
}
