:root {
  --ink: #17283b;
  --muted: #647486;
  --paper: #f6f9fb;
  --card: #ffffff;
  --line: #dbe5ec;
  --night: #18324d;
  --coral: #ef765f;
  --coral-dark: #d95843;
  --mint: #3f9b79;
  --shadow: 0 20px 55px rgba(24, 50, 77, 0.1);
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 0%, rgba(239, 118, 95, 0.13), transparent 31rem),
    linear-gradient(180deg, #eef5f8 0, var(--paper) 22rem);
}

button, textarea, input { font: inherit; }

button:focus-visible, textarea:focus-visible, input:focus-visible + label {
  outline: 3px solid rgba(239, 118, 95, 0.38);
  outline-offset: 3px;
}

.room-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel[hidden], .room-shell[hidden] { display: none; }

.login-card {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-card h1 { font-size: clamp(2rem, 10vw, 3.2rem); }
.login-card > p:not(.eyebrow) { color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfe;
}

#login-status { min-height: 1.2em; margin: 0; color: var(--coral-dark); font-size: 0.82rem; }

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--coral-dark);
  font: 700 0.75rem/1.2 Consolas, "SFMono-Regular", monospace;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-family: "Microsoft YaHei UI", "Segoe UI Variable", sans-serif;
  font-size: clamp(2.15rem, 7vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.065em;
}

.room-note, .transcript-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.86rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b2bec8;
}

.connection.is-online .connection-dot { background: var(--mint); }
.connection.is-offline .connection-dot { background: var(--coral); }

.table-card, .conversation-card, .composer {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.table-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-radius: 26px 26px 10px 10px;
}

.table-card::after {
  content: "";
  position: absolute;
  right: -54px;
  top: -76px;
  width: 190px;
  height: 190px;
  border: 24px solid rgba(239, 118, 95, 0.09);
  border-radius: 50%;
  pointer-events: none;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.section-heading > span { color: var(--muted); font-size: 0.86rem; }

.seat-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.seat {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.seat-top { display: flex; align-items: center; gap: 9px; }
.seat-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--night);
  color: white;
  font-weight: 700;
}

.seat[data-seat="human"] .seat-mark { background: var(--coral); }
.seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.91rem; }
.seat p { margin: 8px 0 0 39px; color: var(--muted); font-size: 0.76rem; }
.seat .online { color: var(--mint); }

.conversation-card {
  min-height: 330px;
  margin-top: 14px;
  padding: 24px;
  border-radius: 10px;
}

.transcript-heading { align-items: flex-end; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.transcript-heading h2 { margin-bottom: 4px; }
.transcript-heading p { font-size: 0.86rem; }

.quiet-button {
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--coral-dark);
  cursor: pointer;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 245px;
  color: var(--muted);
}

.empty-state span { color: var(--coral); font-size: 1.5rem; }
.empty-state p { margin: 0; }
.empty-state[hidden] { display: none; }

.transcript { list-style: none; margin: 0; padding: 8px 0 0; }
.message { display: grid; grid-template-columns: 46px 1fr; gap: 12px; padding: 15px 0; border-bottom: 1px solid #edf2f5; }
.message:last-child { border-bottom: 0; }
.message-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #e5edf2; color: var(--night); font-weight: 700; }
.message[data-sender="human"] .message-avatar { background: #ffe3dc; color: var(--coral-dark); }
.message-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.message-head span, .message-head time { color: var(--muted); font-size: 0.76rem; }
.message-body { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }

.composer {
  position: sticky;
  bottom: 14px;
  margin-top: 14px;
  padding: 19px 20px 17px;
  border-radius: 10px 10px 26px 26px;
}

fieldset { min-width: 0; margin: 0 0 14px; padding: 0; border: 0; }
legend, .message-label { margin-bottom: 9px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.message-label { display: block; }
.recipient-list { display: flex; flex-wrap: wrap; gap: 7px; }
.recipient-option input { position: absolute; opacity: 0; pointer-events: none; }
.recipient-option label { display: block; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 0.82rem; }
.recipient-option input:checked + label { border-color: var(--night); background: var(--night); color: white; }

textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 86px;
  max-height: 280px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfe;
  color: var(--ink);
  line-height: 1.55;
}

.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 12px; }
#send-status { min-height: 1.2em; margin: 0; color: var(--muted); font-size: 0.82rem; }
#send-status.is-error { color: var(--coral-dark); }
.send-button { border: 0; border-radius: 999px; padding: 11px 18px; background: var(--coral); color: white; font-weight: 700; cursor: pointer; box-shadow: 0 7px 18px rgba(239, 118, 95, 0.25); }
.send-button:hover { background: var(--coral-dark); }
.send-button:disabled { opacity: 0.55; cursor: wait; }

@media (max-width: 760px) {
  .room-shell { width: min(100% - 20px, 620px); padding-top: 24px; }
  .room-header { display: block; }
  .connection { width: max-content; margin-top: 18px; }
  .seat-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seat:first-child { grid-column: 1 / -1; }
  .table-card, .conversation-card { padding: 18px; }
  .composer { bottom: 8px; padding: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .message { animation: arrive 220ms ease-out both; }
  @keyframes arrive { from { opacity: 0; transform: translateY(5px); } }
}
