:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #211a19;
  background: #f8f5f2;
  --accent: #a33120;
  --line: #e9e1dc;
  --muted: #695e58;
  --tint: #f9ebe4;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
:where(button, a, textarea, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 62px; padding: 10px max(18px, calc((100% - 1280px) / 2));
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 1.27rem; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.topbar a { color: var(--accent); font-size: .86rem; text-decoration: none; white-space: nowrap; }
.topbar a:hover { text-decoration: underline; }
main { width: min(1280px, calc(100% - 36px)); margin: 26px auto; }
.page-heading { margin: 0 0 18px; }
.page-heading h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.25; letter-spacing: -.04em; }
.page-heading p { margin-top: 7px; font-size: .86rem; color: var(--muted); }
.desk {
  display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(210px, 270px);
  height: clamp(460px, calc(100dvh - 174px), 740px); min-width: 0; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 32px #3821160a;
}
.queue, .replies { overflow: auto; padding: 18px 12px; min-width: 0; }
.queue { border-right: 1px solid var(--line); }
.replies { border-left: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin: 0 4px 14px; }
.section-heading h2, .thread-header h2 { font-size: 1rem; }
#unread, .thread-header small { font-size: .8rem; color: var(--muted); }
.customer {
  width: 100%; text-align: left; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px;
  background: #fff; color: inherit; padding: 10px 7px; margin-bottom: 4px;
}
.customer:hover, .phrase:hover { background: #fdf8f6; }
.customer[aria-pressed="true"] { background: var(--tint); border-color: #f1d8ce; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--tint); color: var(--accent); font-weight: 700; }
.customer strong, .customer small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer strong { font-size: .88rem; }
.customer small { padding-top: 3px; font-size: .76rem; color: var(--muted); }
.badge { background: var(--accent); color: #fff; min-width: 19px; padding: 1px 5px; border-radius: 10px; text-align: center; font-size: .72rem; }
.thread { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.thread-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.back, .mobile-replies { display: none; }
.messages { overflow: auto; padding: 16px; background: #fcfaf8; }
.message { margin-bottom: 14px; max-width: 84%; }
.message small { color: var(--muted); font-size: .76rem; }
.message p { margin-top: 4px; border: 1px solid var(--line); padding: 8px 10px; border-radius: 0 9px 9px; background: white; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.message img { display: block; max-width: 100%; max-height: 220px; margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; }
.outgoing { margin-left: auto; width: fit-content; }
.outgoing small { display: block; text-align: right; }
.outgoing p { background: var(--tint); border-color: var(--tint); border-radius: 9px 0 9px 9px; }
.composer { padding: 12px 15px; border-top: 1px solid var(--line); }
textarea, select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; }
textarea { display: block; resize: vertical; }
.composer textarea { resize: none; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.composer-footer .primary { margin-left: auto; }
.attachment:not([hidden]) { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.attachment img { max-width: 90px; max-height: 52px; border-radius: 5px; }
.image-error { margin-top: 7px; font-size: .8rem; color: var(--accent); }
.primary, .plain, .back, .mobile-replies { border: 0; border-radius: 7px; padding: 8px 11px; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #812819; }
.plain, .back, .mobile-replies { background: var(--tint); color: var(--accent); font-size: .82rem; }
.phrase { width: 100%; margin-bottom: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; text-align: left; }
.phrase strong, .phrase small { display: block; }
.phrase strong { font-size: .88rem; }
.phrase small { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; font-size: .8rem; }
dialog { width: min(430px, calc(100% - 28px)); max-height: calc(100dvh - 30px); border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: inherit; }
dialog::backdrop { background: #281c1a60; }
dialog label { display: block; margin: 10px 0 4px; font-size: .88rem; }
.dialog-actions { margin-top: 12px; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 840px) {
  .desk { grid-template-columns: 172px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .queue { grid-row: span 2; }
  .replies { display: none; border-left: 0; border-top: 1px solid var(--line); max-height: min(180px, 32dvh); padding: 10px; }
  .show-replies .replies, .mobile-replies { display: block; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  main { width: calc(100% - 20px); margin: 13px auto; }
  .page-heading { margin-bottom: 12px; }
  .desk { grid-template-columns: minmax(0, 1fr); height: max(360px, calc(100dvh - 160px)); }
  .queue { grid-row: auto; border: 0; }
  .thread, .show-replies .replies { display: none; }
  .show-thread .queue { display: none; }
  .show-thread .thread { display: grid; }
  .show-thread.show-replies .replies, .back { display: block; }
}
