/* The chat page's own rules. The rest is style.css, which every page of ours loads. */
main { max-width: 72rem; }
h2 { font: 600 1.1rem/1.3 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#home-pick { color: var(--muted); font-size: 0.9rem; }

.chat { display: grid; grid-template-columns: 19rem minmax(0, 1fr); gap: 1rem; margin-top: 0.8rem; height: calc(100vh - 9rem); min-height: 28rem; }
.topics-pane, .conversation-pane { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-height: 0; }
.topics-pane { display: flex; flex-direction: column; padding: 0.8rem; overflow-y: auto; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.topic { display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; border-radius: 12px; padding: 0.5rem 0.6rem; border-color: transparent; box-shadow: none; }
.topic:hover:not(:disabled) { transform: none; background: var(--accent-soft); color: inherit; }
.topic[aria-current="true"] { background: var(--bg-2); border-color: var(--accent); }
.topic-icon { flex: none; display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%; background: var(--bg-2); color: var(--accent); font: 600 1rem/1 "Iowan Old Style", Georgia, serif; border: 1px solid var(--line); }
.topic-icon.alerts { background: var(--accent-soft); }
.topic-words { min-width: 0; flex: 1; display: grid; line-height: 1.3; }
.topic-words strong { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-words small, .topic-side small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-side { display: grid; justify-items: end; gap: 0.15rem; }
.count { min-width: 1.3rem; padding: 0 0.4rem; border-radius: 999px; background: #d92d20; color: #fff; font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.3rem; }
.waiting { background: var(--new); border-radius: 10px; padding: 0.6rem 0.7rem; font-size: 0.9rem; }
.devices { margin-top: auto; padding-top: 0.8rem; font-size: 0.9rem; }
.devices summary { cursor: pointer; color: var(--muted); }
.devices ul { list-style: none; padding: 0; display: grid; gap: 0.3rem; }
code { font-size: 0.9em; background: var(--bg-2); padding: 0.05rem 0.3rem; border-radius: 4px; }

.conversation-pane { display: flex; flex-direction: column; overflow: hidden; }
.conversation-pane > div { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pick { margin: auto; padding: 2rem; }
.conv-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); }
.conv-title { flex: 1; min-width: 0; }
.back { display: none; font-size: 1.4rem; line-height: 1; padding: 0.1rem 0.6rem; }
.members-line { border: 0; box-shadow: none; padding: 0; color: var(--muted); font-size: 0.9rem; background: none; }
.members-line:hover:not(:disabled) { transform: none; }
.members { list-style: none; margin: 0; padding: 0.5rem 1rem; display: grid; gap: 0.2rem; border-bottom: 1px solid var(--line); background: var(--bg-2); font-size: 0.92rem; }
.danger { color: var(--bad); }

.messages { flex: 1; overflow-y: auto; padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.day { align-self: center; color: var(--muted); font-size: 0.8rem; font-weight: 600; margin: 0.6rem 0 0.2rem; }
.system { align-self: center; max-width: 34rem; text-align: center; color: var(--muted); font-size: 0.82rem; }
.alert { display: flex; gap: 0.6rem; background: var(--accent-soft); border-radius: 12px; padding: 0.6rem 0.8rem; }
.alert small { color: var(--muted); }
.msg { display: flex; flex-direction: column; max-width: 34rem; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.who { color: var(--muted); font-size: 0.8rem; font-weight: 600; margin: 0.4rem 0 0.1rem 0.7rem; }
.line { display: flex; align-items: center; gap: 0.35rem; }
.mine .line { flex-direction: row-reverse; }
.bubble { padding: 0.5rem 0.85rem; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.theirs .bubble { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.mine .bubble { background: var(--accent); color: var(--card); border-bottom-right-radius: 4px; }
.bubble.unreadable { font-style: italic; color: var(--muted); }
.reactions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.15rem; }
.chip { font-size: 0.82rem; padding: 0.05rem 0.5rem; box-shadow: none; }
.chip.own { background: var(--accent-soft); border-color: var(--accent); }
.chip.add { opacity: 0; color: var(--muted); }
.msg:hover .chip.add, .chip.add:focus-visible { opacity: 1; }
@media (hover: none) { .chip.add { opacity: 1; } }
.picker { display: inline-flex; gap: 0.2rem; }
.receipt { border: 0; box-shadow: none; padding: 0 0.3rem; background: none; color: var(--muted); font-size: 0.75rem; }
.receipt:hover:not(:disabled) { transform: none; }
.empty { align-self: center; margin-top: 3rem; }

.composer { display: flex; align-items: flex-end; gap: 0.6rem; padding: 0.7rem 1rem; border-top: 1px solid var(--line); }
.composer textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer textarea { flex: 1; resize: none; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 0.45rem 0.85rem; max-height: 9rem; field-sizing: content; }
#send, .primary { background: var(--accent); border-color: var(--accent); color: var(--card); }
#send:hover:not(:disabled), .primary:hover:not(:disabled) { color: var(--card); filter: brightness(1.06); }
.read-only { padding: 0.8rem 1rem; border-top: 1px solid var(--line); margin: 0; text-align: center; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--fg); box-shadow: var(--shadow); padding: 1.2rem 1.4rem; max-width: 28rem; width: calc(100% - 2rem); }
dialog::backdrop { background: rgba(30, 20, 12, 0.35); }
dialog h2 { margin-bottom: 0.8rem; }
dialog label { display: grid; gap: 0.3rem; }
dialog fieldset { border: 0; padding: 0; margin: 0.8rem 0 0; }
dialog legend { font-weight: 600; margin-bottom: 0.3rem; }
.people { display: grid; gap: 0.3rem; max-height: 16rem; overflow-y: auto; }
.people label { display: flex; gap: 0.5rem; align-items: baseline; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin: 1rem 0 0; }

@media (max-width: 48rem) {
  .chat { grid-template-columns: 1fr; height: auto; }
  body.in-topic .topics-pane { display: none; }
  body:not(.in-topic) .conversation-pane { display: none; }
  .conversation-pane { height: calc(100vh - 8rem); }
  .back { display: inline-block; }
}
