:root {
  color-scheme: light dark;
  font:
    100%/1.45 system-ui,
    sans-serif;
  --bg: #f5fbf7;
  --card: #fff;
  --text: #162b3c;
  --line: #b9cbd9;
  --accent: #026b5d;
  --bubble: #d9f2ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513;
    --card: #1a2834;
    --text: #e9f0f7;
    --line: #4a6274;
    --accent: #84d5c4;
    --bubble: #283f52;
  }
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
main {
  max-width: 42rem;
  margin: auto;
  min-height: 100vh;
  background: var(--card);
  padding: max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}
header,
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.7rem;
}
a {
  color: var(--accent);
  font-weight: 650;
}
h1 {
  font-size: 1.7rem;
}
h2 {
  font-size: 1.2rem;
}
.field-hint {
  margin: -0.3rem 0 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
}
#entry button { width: 100%; }
form,
section,
details {
  margin: 1rem 0;
}
label {
  display: block;
  margin: 0.7rem 0;
}
.check {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  min-height: 44px;
}
input:not([type="checkbox"]),
textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  border: 1px solid var(--line);
  padding: 0.7rem;
  border-radius: 0.55rem;
  background: var(--card);
  color: inherit;
  font: inherit;
}
input::placeholder {
  color: color-mix(in srgb, var(--text) 65%, var(--card));
  opacity: 1;
}
button,
summary {
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
}
button {
  border: 1px solid var(--line);
  background: var(--bubble);
  border-radius: 0.65rem;
  padding: 0.45rem 0.85rem;
}
summary {
  padding: 0.5rem 0;
}
button:disabled {
  opacity: 0.6;
}
form button[type="submit"],
#enter,
#compose button {
  background: #026b5d;
  color: white;
}
#notice {
  overflow-wrap: anywhere;
}
#notice:empty {
  display: none;
}
code {
  overflow-wrap: anywhere;
  user-select: all;
}
ol {
  list-style: none;
  padding: 0;
}
li {
  background: var(--bg);
  border-radius: 1rem;
  padding: 0.65rem 0.9rem;
  margin: 0.45rem 12% 0.45rem 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
li.out {
  margin-left: 12%;
  margin-right: 0;
  background: var(--bubble);
}
small {
  display: block;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

main:has(#conversations:not([hidden])) {
  max-width: 75rem;
}
main:has(#conversations:not([hidden])) #title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#conversations {
  display: grid;
  grid-template-columns: minmax(16rem, 30%) minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: .8rem;
  overflow: hidden;
  height: clamp(24rem, 76dvh, 54rem);
}
#chat-sidebar {
  padding: .85rem 1rem;
  overflow: auto;
  border-inline-end: 1px solid var(--line);
}
#chat-sidebar .bar h2, .thread-header h2 { margin: 0; }
#chat-sidebar .bar { margin-bottom: .6rem; }
.chat-list-row { display: flex; align-items: center; gap: .25rem; }
#chat-list button[data-chat] {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  text-align: start;
  gap: .7rem;
  margin: 0;
  padding: .65rem .55rem;
  border: 0;
  background: transparent;
  color: var(--text);
}
#chat-list button[aria-current] { background: var(--bubble); }
.chat-mute { flex-shrink: 0; margin: 0; padding-inline: .55rem; background: transparent; }
.chat-mute:focus-visible { outline-offset: -3px; }
.chat-mute[aria-pressed="true"] { background: var(--bubble); color: var(--text); }
.chat-mute[aria-disabled="true"] { opacity: .6; }
#chat-notification-status:empty { display: none; }
.chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #17695e;
  color: white;
}
.chat-row-text { display: grid; min-width: 0; }
.chat-row-text strong, .chat-preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-preview { font-size: .875rem; font-weight: 400; }
#thread-placeholder {
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 1.25rem;
}
#thread {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
}
.thread-header, #compose { display: flex; align-items: center; gap: .65rem; padding: .7rem 1rem; }
.thread-header { min-height: 3.75rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.thread-header h2 { overflow-wrap: anywhere; }
#peer-profile {
  flex: 1 0 100%;
  min-width: 0;
  max-height: min(12rem, 35vh);
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding-top: .25rem;
}
#peer-profile p { margin: .25rem 0; white-space: pre-wrap; }
#peer-profile p:empty { display: none; }
#peer-profile-status { font-weight: 650; }
#peer-invitations { margin: .25rem 0 0; }
#to-chats { display: none; }
#timeline { overflow-y: auto; overscroll-behavior: contain; background: var(--bg); padding: 1rem; }
#messages { display: grid; gap: .5rem; margin: 0; }
#messages li { justify-self: start; max-width: min(86%, 38rem); margin: 0; background: var(--card); }
#messages li.out { justify-self: end; background: var(--bubble); }
#messages .private-photo-preview { display: block; max-width: min(100%, 36rem); max-height: 28rem; margin: .65rem 0; border-radius: .65rem; object-fit: contain; }
#messages small { display: flex; gap: .45rem; align-items: baseline; justify-content: end; font-size: .8125rem; margin-top: .2rem; }
.message-actions { position: relative; display: flex; align-items: center; gap: .4rem; border-top: 1px solid var(--line); }
.message-actions:has(#compose[hidden]) { display: none; }
#compose { margin: 0; min-width: 0; flex: 1; }
#photo-picker { margin: 0; }
#photo-picker summary { padding: .7rem .5rem; cursor: pointer; color: var(--accent); }
#send-photo { position: absolute; bottom: 100%; inset-inline-start: 0; z-index: 1; background: var(--card); border: 1px solid var(--line); padding: .85rem; margin: 0; width: min(100%, 24rem); }
#send-photo input { max-width: 100%; }
#compose textarea { flex: 1; min-width: 0; margin: 0; resize: vertical; max-height: 28dvh; }
@media(max-width: 44rem) {
  #conversations { display: block; height: auto; border: 0; overflow: visible; margin: .5rem 0; }
  #chat-sidebar { padding: .3rem 0; border: 0; }
  #thread-placeholder, .thread-open #chat-sidebar { display: none; }
  main:has(#conversations.thread-open:not([hidden])) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
  }
  main:has(#conversations.thread-open:not([hidden])) > * { flex-shrink: 0; }
  main > #conversations.thread-open { flex: 1 1 0; min-height: 12rem; }
  #conversations.thread-open:not([hidden]) ~ :is(details, #backup) { display: none; }
  #peer-profile { margin: 0; }
  #thread { height: 100%; }
  #to-chats { display: inline-block; flex-shrink: 0; }
  .thread-header, #compose { padding: .5rem 0; }
  #timeline { padding: .65rem; }
}

#profile-text-form fieldset { display: grid; gap: .75rem; margin: 0; padding: 0; border: 0; min-width: 0; }

.chat-unread { margin-inline-start: auto; padding: .05rem .45rem; border-radius: 1rem; background: var(--accent); color: var(--card); font-size: .875rem; font-weight: 650; }

#chat-search { display: flex; flex: 1 0 100%; flex-wrap: wrap; min-width: 0; gap: .35rem; align-items: center; }
#chat-search-query { flex: 1 1 10rem; min-width: 0; }
#chat-search-result { margin: 0; }
#chat-search-result:empty { display: none; }
#messages .search-match { outline: 2px solid currentColor; outline-offset: -2px; }
