:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffefa;
  --ink: #23272a;
  --muted: #687076;
  --line: #ddd8ce;
  --accent: #1f7a8c;
  --accent-strong: #145363;
  --warm: #c86b4a;
  --soft: #eef6f5;
  --shadow: 0 18px 45px rgba(27, 34, 41, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.66;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 100vh;
}

.group-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--warm);
  font-size: 22px;
  font-weight: 800;
}

.brand h1,
.brand p,
.message-header h2,
.message-header p,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
}

.brand p,
.eyebrow,
.group-meta,
.message-time,
.empty-state p {
  color: var(--muted);
}

.group-form {
  display: grid;
  gap: 10px;
}

.group-form label {
  color: var(--muted);
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 13px 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.14);
}

.group-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.group-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.group-item:hover,
.group-item.active {
  border-color: var(--line);
  background: var(--soft);
}

.group-title {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  margin-top: 3px;
  font-size: 13px;
}

.message-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
  padding: 34px clamp(20px, 4vw, 56px);
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 13px;
  letter-spacing: 0;
}

.message-header h2 {
  font-size: clamp(24px, 3vw, 36px);
}

.count-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--soft);
  font-weight: 700;
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  min-height: 360px;
  text-align: center;
}

.empty-state h3 {
  font-size: 22px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 22px 0;
  overflow-y: auto;
}

.message-card {
  max-width: min(760px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
}

.message-image {
  display: block;
  max-width: min(520px, 100%);
  max-height: 440px;
  margin-top: 12px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.message-time {
  margin-top: 12px;
  font-size: 13px;
}

.composer {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.file-button {
  display: inline-grid;
  min-height: 42px;
  padding: 0 14px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #ffffff;
  cursor: pointer;
}

#messageImage {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-preview {
  width: 150px;
  height: 110px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #252a2e;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .group-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .group-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 72vw);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .message-panel {
    min-height: calc(100vh - 260px);
    padding: 24px 16px;
  }

  .message-header {
    align-items: flex-start;
  }

  .composer-actions {
    align-items: stretch;
  }

  .composer-actions button,
  .file-button {
    flex: 1 1 0;
  }
}
