
:root {
  color-scheme: light;
  --ink: #18332c;
  --muted: #456059;
  --green: #18664f;
  --line: #d6e2dc;
  --paper: #fff;
  --canvas: #edf4ef;
  --outgoing: #d3ecde;
  --alert: #8b3b27;
  font: 16px/1.45 system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
button, input, textarea, summary { font: inherit; }
button, input, textarea, summary { color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .4rem .7rem;
  min-height: 2.5rem;
}
input, textarea {
  min-width: 0;
  padding: .65rem .75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .5rem;
}
.primary { background: var(--green); border-color: var(--green); color: white; font-weight: 650; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-panel { width: min(100%, 25rem); background: var(--paper); padding: 2rem; border-radius: 1rem; }
.login-panel h1 { margin-bottom: 1.5rem; }
.login-panel form { display: grid; gap: .65rem; }
#login-error, #send-status { color: var(--alert); font-size: .875rem; overflow-wrap: anywhere; }
.inbox { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.masthead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .15rem .9rem;
  background: var(--paper); border-bottom: 1px solid var(--line); padding: .65rem 1rem;
}
.masthead h1 { font-size: 1.25rem; }
#availability { grid-column: 1; grid-row: 2; font-size: .8125rem; color: var(--muted); }
#availability.history-stale { color: var(--alert); background: #fff0e8; padding: .2rem .4rem; border-radius: .25rem; justify-self: start; }
.account { grid-column: 2; grid-row: 1 / span 2; position: relative; }
.account summary { padding: .5rem 0; }
.account div {
  position: absolute; z-index: 1; right: 0; display: grid; gap: .35rem; padding: .5rem;
  width: max-content; background: var(--paper); border: 1px solid var(--line); border-radius: .5rem;
}
.workspace { flex: 1; min-height: 0; display: flex; }
.thread-pane {
  width: 100%; background: var(--paper); display: flex; flex-direction: column; gap: .6rem; padding: .75rem;
}
#filters { display: flex; gap: .3rem; flex-wrap: wrap; }
#filters button { font-size: .875rem; padding-inline: .6rem; }
#filters [aria-pressed=true] { background: var(--outgoing); border-color: var(--green); }
#thread-list { flex: 1; min-height: 0; overflow: auto; padding: .15rem; }
#thread-list > p { color: var(--muted); padding: .6rem; }
.thread {
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  text-align: left; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .55rem; padding: .7rem .45rem;
}
.thread[aria-current=true], .thread:hover { background: var(--canvas); }
.title, .preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.preview, .stamp, .lead { color: var(--muted); font-size: .8125rem; }
.stamp, .unread { justify-self: end; }
.unread { color: white; background: var(--green); border-radius: 1rem; padding: 0 .45rem; font-size: .8125rem; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .25rem; }
.chip { background: var(--canvas); padding: .1rem .35rem; border-radius: .3rem; font-size: .75rem; }
.conversation { display: none; flex: 1; min-width: 0; flex-direction: column; }
.has-thread .conversation { display: flex; }
.has-thread .thread-pane { display: none; }
#empty { margin: auto; color: var(--muted); }
#conversation-header {
  display: flex; align-items: center; gap: .65rem; padding: .7rem 1rem;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
#contact { font-size: 1rem; overflow-wrap: anywhere; }
#contact-info { font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
#messages {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: flex-start;
  gap: .55rem; padding: 1rem; overflow-y: auto;
}
.bubble {
  flex-shrink: 0; max-width: min(88%, 36rem); background: var(--paper); border-radius: .25rem .85rem .85rem;
  padding: .5rem .7rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.out { align-self: flex-end; background: var(--outgoing); border-radius: .85rem .25rem .85rem .85rem; }
.bubble small { display: block; color: var(--muted); text-align: right; margin-top: .25rem; }
#reply-form {
  background: var(--paper); border-top: 1px solid var(--line);
  padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom)); display: grid; gap: .45rem;
}
#reply { width: 100%; resize: vertical; max-height: 25vh; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
#count { font-size: .8125rem; color: var(--muted); }
@media (min-width: 768px) {
  .thread-pane, .has-thread .thread-pane { display: flex; width: clamp(19rem, 34vw, 27rem); border-right: 1px solid var(--line); }
  .conversation { display: flex; }
  #back { display: none; }
  #messages { padding-inline: clamp(1rem, 4vw, 4rem); }
}
