:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  background: #eef2f7;
  color: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 32%),
    radial-gradient(circle at 88% 0%, rgba(99, 102, 241, 0.13), transparent 34%),
    linear-gradient(135deg, #f8fafc 0%, #edf2f7 48%, #e7eef7 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.panel,
.chat {
  width: min(980px, 100%);
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
}

.panel {
  display: grid;
  gap: 24px;
  max-width: 520px;
  padding: 34px;
  border-radius: 18px;
}

.auth-panel h1,
.chooser h1 {
  margin: 0;
  font-size: clamp(38px, 8vw, 68px);
  letter-spacing: 0;
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 8px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
.status-line {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 14px;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.login-form input,
.composer textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
}

.login-form input {
  min-height: 48px;
  padding: 0 14px;
}

.login-form input:focus,
.composer textarea:focus {
  border-color: #14b8a6;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.login-form button,
.identity-button,
.pill.active,
.composer > button {
  background: #0f172a;
  color: #ffffff;
}

.login-form button,
.identity-button,
.ghost-button,
.pill,
.composer > button,
.tool-button,
.image-preview button,
.reaction-button,
.reaction-trigger,
.reaction-popover-button {
  border-radius: 12px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.login-form button,
.composer > button {
  min-width: 90px;
  padding: 0 18px;
  font-weight: 800;
}

.identity-actions,
.identity-switch,
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.identity-button {
  min-width: 140px;
  padding: 16px 24px;
  font-size: 22px;
  font-weight: 900;
}

.chat {
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto auto;
  height: min(860px, calc(100vh - 36px));
  overflow: hidden;
  border-radius: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.72);
}

.pill,
.ghost-button {
  padding: 9px 12px;
  border: 1px solid #d8e0ea;
  background: #ffffff;
  color: #0f172a;
  font-weight: 800;
}

.notify-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
}

.notify-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.ghost-button.secondary {
  background: #e6fffb;
  border-color: #99f6e4;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 8px 18px;
  color: #64748b;
  font-size: 13px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.72);
}

#typingIndicator {
  color: #0f766e;
  font-weight: 700;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 18px;
  background: rgba(248, 250, 252, 0.72);
}

.empty {
  margin: auto;
  color: #64748b;
}

.message {
  max-width: min(74%, 610px);
  align-self: flex-start;
}

.message.mine {
  align-self: flex-end;
}

.bubble {
  position: relative;
  overflow: visible;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  word-break: break-word;
}

.message.mine .bubble {
  border-color: #a7f3d0;
  background: #dcfce7;
}

.message-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  color: #64748b;
  font-size: 12px;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.message-image {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  margin-top: 8px;
  border-radius: 12px;
  object-fit: contain;
  background: #0f172a;
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.reaction-button {
  min-height: 30px;
  border: 1px solid #dbe4ef;
  background: rgba(255, 255, 255, 0.82);
  color: #0f172a;
  padding: 4px 8px;
  font-size: 13px;
}

.reaction-button.active {
  border-color: #14b8a6;
  background: #ccfbf1;
}

.reaction-trigger-wrap {
  position: absolute;
  right: -11px;
  bottom: -11px;
  z-index: 4;
}

.reaction-trigger {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
  color: #0f172a;
  font-size: 16px;
  line-height: 1;
}

.reaction-popover {
  position: fixed;
  z-index: 30;
  display: flex;
  gap: 4px;
  max-width: min(320px, calc(100vw - 42px));
  padding: 6px;
  border: 1px solid rgba(203, 213, 225, 0.92);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  overflow-x: auto;
}

.reaction-popover-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 21px;
  line-height: 1;
}

.reaction-popover-button:hover,
.reaction-popover-button.active {
  border-color: #99f6e4;
  background: #ecfeff;
  transform: translateY(-2px) scale(1.06);
}

.image-preview {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
}

.image-preview img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
}

.image-preview strong,
.image-preview span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview span {
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
}

.image-preview button {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  padding: 9px 11px;
  font-weight: 800;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
}

.tools {
  display: flex;
  gap: 8px;
}

.tool-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #dbe4ef;
  background: #f8fafc;
  color: #0f172a;
  font-size: 20px;
  font-weight: 900;
}

.tool-button input {
  display: none;
}

.input-wrap {
  position: relative;
}

.composer textarea {
  min-height: 44px;
  max-height: 150px;
  resize: none;
  padding: 11px 13px;
}

.composer > button {
  height: 44px;
}

.composer > button:disabled,
.login-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.emoji-panel {
  position: absolute;
  left: 0;
  bottom: 54px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, 38px);
  max-height: 238px;
  overflow-y: auto;
  gap: 6px;
  padding: 10px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.14);
}

.emoji-panel button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 20px;
}

.hidden {
  display: none !important;
}

button:active,
.tool-button:active {
  transform: translateY(1px);
}

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

  .panel {
    width: calc(100% - 28px);
  }

  .chat {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .chat {
    grid-template-rows: auto auto minmax(280px, 1fr) auto auto;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 8px 10px;
  }

  .compact-label {
    display: none;
  }

  .identity-switch {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .pill {
    padding: 8px 10px;
    font-size: 14px;
  }

  .top-actions {
    flex: 0 0 auto;
  }

  .notify-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
  }

  .notify-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .statusbar {
    align-items: center;
    flex-direction: row;
    min-height: 30px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  .composer > button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .login-form {
    grid-template-columns: 1fr;
  }

  .emoji-panel {
    left: -52px;
    grid-template-columns: repeat(5, 36px);
    max-height: 210px;
  }
}
