:root {
  color-scheme: light;
  --app-bg: #d8d4c5;
  --panel: #f7f5ef;
  --panel-strong: #ffffff;
  --header: #075e54;
  --header-muted: #128c7e;
  --text: #17211f;
  --muted: #66736f;
  --border: #d9ddd8;
  --sent: #dcf8c6;
  --received: #ffffff;
  --focus: #25d366;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(rgba(216, 212, 197, 0.88), rgba(216, 212, 197, 0.88)),
    repeating-linear-gradient(45deg, #c8c2ad 0 1px, transparent 1px 18px);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 780px);
  width: min(1100px, 100%);
  height: min(760px, calc(100vh - 48px));
  min-height: 520px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
  background: var(--panel-strong);
}

.panel-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 16px 20px;
  color: #ffffff;
  background: var(--header);
}

.panel-header h1,
.chat-header h2,
.login-card h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 3px;
  color: currentColor;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.74;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--focus);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.2);
}

.icon-action {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--header);
  font-weight: 800;
  background: #ffffff;
}

.chat-list {
  overflow: auto;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.chat-list-item:hover,
.chat-list-item.active {
  background: #e8f4ee;
}

.player-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.player-meta strong,
.player-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta small {
  color: var(--muted);
  font-size: 0.8rem;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 800;
  background: var(--header-muted);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0;
  background:
    linear-gradient(rgba(239, 232, 213, 0.9), rgba(239, 232, 213, 0.9)),
    repeating-linear-gradient(135deg, #d7cfb8 0 1px, transparent 1px 20px);
}

.presets {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 10px 12px;
  background: rgba(238, 240, 237, 0.95);
  border-top: 1px solid var(--border);
}

.preset-group {
  display: grid;
  gap: 6px;
  min-width: min(560px, 86vw);
}

.role-templates {
  min-width: 100%;
}

.preset-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.preset-chip {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 11px;
  border: 1px solid #cfd8d2;
  border-radius: 999px;
  color: var(--text);
  background: #ffffff;
}

.preset-chip:hover {
  background: #e8f4ee;
  border-color: #9fcbbb;
}

.role-summary {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.3;
}

.empty-presets {
  color: var(--muted);
  font-size: 0.9rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.bubble {
  width: fit-content;
  max-width: min(620px, 78%);
  padding: 8px 10px 6px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.bubble time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
}

.bubble.sent {
  align-self: flex-end;
  background: var(--sent);
}

.bubble.received {
  align-self: flex-start;
  background: var(--received);
}

.composer,
.login-form {
  display: flex;
  gap: 10px;
}

.composer {
  padding: 12px;
  background: #eef0ed;
  border-top: 1px solid var(--border);
}

.composer input,
.login-form input {
  min-width: 0;
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  background: #ffffff;
}

.composer input:focus,
.login-form input:focus {
  border-color: var(--focus);
}

.composer button,
.login-form button {
  min-width: 96px;
  height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
  background: var(--header-muted);
}

.player-page {
  display: grid;
  width: min(520px, 100%);
  height: min(760px, calc(100vh - 48px));
  min-height: 520px;
}

.login-card {
  align-self: center;
  padding: 28px;
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.login-card .eyebrow {
  color: var(--header-muted);
}

.login-form {
  flex-direction: column;
  margin-top: 24px;
}

.login-form label {
  color: var(--muted);
  font-weight: 700;
}

.player-chat {
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.error-text {
  min-height: 1.2em;
  margin: 0;
  color: #b00020;
}

.hidden {
  display: none;
}

@media (max-width: 760px) {
  .app-body {
    padding: 0;
  }

  .shell {
    grid-template-columns: 1fr;
    width: 100%;
    height: 100vh;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    min-height: 230px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .chat-panel {
    min-height: 0;
  }

  .player-page {
    width: 100%;
    height: 100vh;
    min-height: 0;
  }

  .login-card,
  .player-chat {
    height: 100%;
    border-radius: 0;
  }

  .bubble {
    max-width: 86%;
  }
}
