:root {
  color-scheme: light;
  --bg: #e8ecef;
  --panel: #f7f8f9;
  --panel-strong: #ffffff;
  --text: #17202a;
  --muted: #707b86;
  --line: #d8dee4;
  --brand: #21a35b;
  --brand-dark: #168044;
  --bubble: #ffffff;
  --mine: #95ec69;
  --danger: #c83737;
  --shadow: 0 18px 60px rgba(24, 39, 54, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(33, 163, 91, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(54, 112, 172, 0.12), transparent 36%),
    var(--bg);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

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

.login-view {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 36px;
  align-items: center;
}

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

.brand-mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-size: 38px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.login-brand h1 {
  margin: 0;
  font-size: 44px;
  letter-spacing: 0;
}

.login-brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.login-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #edf1f3;
  border-radius: 8px;
}

.tab-button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
}

.tab-button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.12);
}

.qr-login-pane, .account-login-pane {
  margin-top: 24px;
}

.qr-card {
  width: 256px;
  margin: 0 auto;
  padding: 18px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.qr-grid {
  height: 220px;
  display: grid;
  grid-template-columns: repeat(17, 1fr);
  grid-template-rows: repeat(17, 1fr);
  gap: 3px;
  padding: 8px;
  background: #fff;
}

.qr-dot {
  border-radius: 2px;
  background: transparent;
}

.qr-dot.on { background: #111820; }

.qr-status {
  margin-top: 12px;
  padding: 8px;
  text-align: center;
  color: var(--brand-dark);
  background: #e9f8ef;
  border-radius: 6px;
  font-size: 14px;
}

.login-hint, .form-error {
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.form-error {
  min-height: 22px;
  color: var(--danger);
}

.account-login-pane label {
  display: block;
  margin-bottom: 14px;
}

.account-login-pane span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.account-login-pane input, .search-box input, .composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: white;
}

.account-login-pane input {
  height: 42px;
  padding: 0 12px;
}

.primary-button, .send-button {
  border: 0;
  color: white;
  background: var(--brand);
  border-radius: 6px;
  padding: 10px 16px;
}

.secondary-button {
  width: 100%;
  height: 42px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: white;
}

.primary-button {
  width: 100%;
  height: 44px;
}

.chat-view {
  width: min(1380px, 100%);
  height: min(860px, calc(100vh - 32px));
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 280px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sidebar {
  min-width: 0;
  background: #2d353c;
  color: white;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: 72px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.current-user {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

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

.current-user span {
  margin-top: 3px;
  color: rgba(255,255,255,0.58);
  font-size: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #ccd7df;
  color: #17202a;
  font-weight: 700;
}

.icon-button, .ghost-button, .tool-button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-color: rgba(255,255,255,0.12);
  color: white;
  background: rgba(255,255,255,0.08);
}

.search-box {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.search-box input {
  height: 36px;
  padding: 0 12px;
  color: white;
  background: rgba(255,255,255,0.08);
  border-color: transparent;
}

.chat-list {
  overflow: auto;
}

.chat-item {
  width: 100%;
  border: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  text-align: left;
  color: white;
  background: transparent;
}

.chat-item.active, .chat-item:hover { background: rgba(255,255,255,0.1); }

.chat-meta, .chat-time {
  color: rgba(255,255,255,0.52);
  font-size: 12px;
}

.chat-name, .chat-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-preview {
  margin-top: 5px;
  color: rgba(255,255,255,0.62);
  font-size: 13px;
}

.unread {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: white;
  background: #fa5151;
  border-radius: 999px;
  font-size: 12px;
}

.conversation {
  min-width: 0;
  display: grid;
  grid-template-rows: 72px 1fr auto;
  background: #f2f3f5;
}

.conversation-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(247,248,249,0.92);
}

.conversation-header h2 {
  margin: 0;
  font-size: 18px;
}

.conversation-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.conversation-actions {
  display: flex;
  gap: 8px;
}

.ghost-button {
  padding: 7px 10px;
  color: var(--text);
  background: transparent;
}

.empty-state {
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin: 12px 0 6px;
  color: var(--text);
}

.empty-illustration {
  font-size: 58px;
}

.messages {
  overflow: auto;
  padding: 24px 28px;
}

.message-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.mine .message-bubble {
  background: var(--mine);
}

.message-bubble {
  max-width: min(620px, 74%);
  padding: 10px 12px;
  background: var(--bubble);
  border-radius: 7px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
  overflow-wrap: anywhere;
}

.message-sender {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-time {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.file-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 220px;
  color: inherit;
  text-decoration: none;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.08);
}

.composer {
  min-height: 86px;
  padding: 14px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: end;
  background: #f7f8f9;
  border-top: 1px solid var(--line);
}

.tool-button {
  width: 42px;
  height: 42px;
  font-size: 24px;
  color: var(--muted);
}

.composer textarea {
  min-height: 42px;
  max-height: 136px;
  resize: none;
  padding: 10px 12px;
  line-height: 1.45;
}

.send-button {
  height: 42px;
}

.details-panel {
  min-width: 0;
  padding: 20px;
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
}

.details-panel h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.details-content {
  color: var(--muted);
  line-height: 1.6;
}

.member-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px 8px 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

@media (max-width: 1020px) {
  .login-view { grid-template-columns: 1fr; }
  .chat-view { grid-template-columns: 300px minmax(0, 1fr); }
  .details-panel { display: none; }
}

@media (max-width: 720px) {
  .app-shell { padding: 0; }
  .login-view { padding: 24px; }
  .login-brand h1 { font-size: 32px; }
  .chat-view {
    height: 100vh;
    border-radius: 0;
    grid-template-columns: 1fr;
  }
  .sidebar { display: none; }
  .message-bubble { max-width: 86%; }
}
