:root {
  color-scheme: light;
  --ink: #172f29;
  --muted: #50675e;
  --accent: #13634f;
  --paper: #fcfdfb;
  --canvas: #eaf0e9;
  --line: #d5e1d8;
  font: 16px/1.55 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); }
button, textarea { font: inherit; }
button, .file-button {
  padding: .55rem .9rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
button:hover, .file-button:hover { background: #e9f3eb; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible, .compose-row:has(input:focus-visible) .file-button { outline: 3px solid #238c73; outline-offset: 3px; }
.workspace { max-width: 1080px; margin: 3vh auto; background: var(--paper); border: 1px solid var(--line); }
.masthead { min-height: 3.7rem; display: flex; align-items: center; justify-content: space-between; padding: .6rem 1.4rem; border-bottom: 1px solid var(--line); }
.masthead strong { color: var(--accent); font-size: 1.08rem; }
.masthead a { font-size: .85rem; }
.gate { min-height: 20rem; padding: clamp(1.3rem, 6vw, 4rem); }
#accounts, #threads { display: grid; gap: .55rem; justify-items: start; }
#accounts input { width: min(100%, 16rem); padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .55rem; }
#gate-error, #feedback { color: #9c3328; }
.panes { display: flex; min-height: 0; height: 80vh; height: 80dvh; }
#inbox { flex: 0 0 240px; border-right: 1px solid var(--line); background: #f1f6ee; padding: 1.25rem 1rem; overflow: auto; }
#inbox h2 { margin: 0 0 .75rem; font-size: 1rem; }
#threads button { width: 100%; text-align: left; }
#threads button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #ddede2; font-weight: 650; }
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.conversation-header { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.3rem; border-bottom: 1px solid var(--line); }
#avatar { width: 2.5rem; height: 2.5rem; display: grid; flex: none; place-items: center; background: #dbebe0; color: var(--accent); border-radius: 50%; font-weight: 700; }
h1 { margin: 0; }
.conversation-header h1 { font-size: 1.1rem; line-height: 1.25; }
#identity, #connection, .stamp, .empty { color: var(--muted); font-size: .82rem; margin: 0; }
#connection { margin-left: auto; text-align: right; }
#messages { display: flex; flex-direction: column; gap: .9rem; flex: 1; min-height: 8rem; overflow: auto; padding: 1.15rem 1.3rem; background: #f6f9f4; }
.message { align-self: flex-start; max-width: min(85%, 36rem); overflow-wrap: anywhere; }
.message.mine { align-self: flex-end; text-align: right; }
.bubble { margin-top: .15rem; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: .75rem .75rem .75rem .2rem; background: white; white-space: pre-wrap; text-align: left; }
.mine .bubble { background: #dfeee4; border-color: #c9e0d0; border-radius: .75rem .75rem .2rem .75rem; }
.bubble img { display: block; max-width: min(100%, 20rem); max-height: 15rem; object-fit: contain; border-radius: .4rem; }
.bubble p { margin: 0; }
#composer { flex: none; padding: .75rem 1.2rem max(.75rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.compose-row { display: flex; gap: .5rem; align-items: center; }
#attachment { position: absolute; width: 1px; height: 1px; opacity: 0; }
textarea { flex: 1; min-width: 0; padding: .55rem; resize: vertical; max-height: 7rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--ink); }
#send { background: var(--accent); color: white; border-color: var(--accent); }
#pending { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: .5rem; padding-left: .5rem; background: #edf5ef; overflow-wrap: anywhere; font-size: .85rem; }
#feedback { font-size: .82rem; }
#feedback:not(:empty) { padding-top: .35rem; }
@media (max-width: 700px) {
  .workspace { margin: 0; border: 0; }
  .panes { height: calc(100vh - 3.7rem); height: calc(100dvh - 3.7rem); flex-direction: column; }
  #inbox { flex: 0 0 auto; max-height: 28%; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem .75rem; }
  #inbox h2 { margin-bottom: .25rem; }
  #threads { display: flex; flex-wrap: wrap; }
  #threads button { width: auto; }
  #messages, .conversation-header, #composer { padding-inline: .75rem; }
}
