:root {
  color-scheme: light dark;
  --bg: #f7f4f4;
  --panel: #fffdfd;
  --panel-muted: #f2ecee;
  --text: #2b2326;
  --muted: #776a6f;
  --border: #e3d9dc;
  --accent: #b34f67;
  --accent-hover: #963e54;
  --accent-soft: #f6e4e9;
  --incoming: #ffffff;
  --outgoing: #b34f67;
  --outgoing-text: #fffafa;
  --shadow: 0 18px 55px rgb(69 32 43 / 13%);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171315;
    --panel: #211b1e;
    --panel-muted: #2b2327;
    --text: #f3ebed;
    --muted: #bdaeb3;
    --border: #3c3136;
    --accent: #d4748b;
    --accent-hover: #e18aa0;
    --accent-soft: #3d252d;
    --incoming: #272025;
    --outgoing: #b95e75;
    --outgoing-text: #fffafb;
    --shadow: 0 20px 60px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  min-width: 0;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body { min-height: 100dvh; }
button,
textarea,
input { font: inherit; }

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 2px;
}

button:disabled { cursor: not-allowed; opacity: .58; }

.cloud-shell {
  width: min(920px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.cloud-header,
.section-heading,
.brand,
.composer-actions,
.login-mark {
  display: flex;
  align-items: center;
}

.cloud-header {
  justify-content: space-between;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 22px 16px;
  border-bottom: 1px solid var(--border);
}

.brand,
.login-mark { gap: 12px; }
.brand img,
.login-mark img { border-radius: 15px; }
h1,
h2,
p { margin: 0; }
.brand h1 { font-size: 1.25rem; }
.brand p,
.section-heading p,
.privacy-note { color: var(--muted); font-size: .82rem; }

.status-pill {
  flex: none;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: .78rem;
  font-weight: 700;
}

.status-pill.offline { color: var(--muted); background: var(--panel-muted); }

.timeline-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  background: color-mix(in srgb, var(--bg) 72%, var(--panel));
}

.section-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading h2 { margin-bottom: 5px; font-size: 1.05rem; }

.timeline {
  display: grid;
  gap: 14px;
}

.message {
  width: min(78%, 660px);
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 5px;
  background: var(--incoming);
  box-shadow: 0 7px 24px rgb(50 28 35 / 7%);
}

.message.reply {
  justify-self: end;
  border-color: transparent;
  border-radius: 18px 18px 5px;
  background: var(--outgoing);
  color: var(--outgoing-text);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .74rem;
}

.message.reply .message-meta { color: color-mix(in srgb, var(--outgoing-text) 76%, transparent); }

.message-content {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.56;
}

.empty-state {
  min-height: 44vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

.empty-state img { border-radius: 22px; opacity: .78; }

.composer-panel {
  padding: 15px 22px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.composer { display: grid; gap: 9px; }
.composer label,
.pairing-form label { font-size: .84rem; font-weight: 700; }

textarea,
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-muted);
  color: var(--text);
}

textarea {
  min-height: 78px;
  max-height: 220px;
  resize: vertical;
  padding: 12px 14px;
}

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

.composer-actions { justify-content: space-between; gap: 12px; }
.composer-actions span { color: var(--muted); font-size: .78rem; }

.primary-button,
.quiet-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 17px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button { background: var(--accent); color: #fffafa; }
.primary-button:hover { background: var(--accent-hover); }
.quiet-button { background: var(--panel-muted); color: var(--text); }

.privacy-note { margin-top: 8px; line-height: 1.45; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-copy { margin: 22px 0; color: var(--muted); line-height: 1.65; }
.pairing-form { display: grid; gap: 10px; }
.pairing-form .primary-button { margin-top: 5px; }
.form-status { min-height: 1.5em; margin-top: 14px; color: var(--muted); }

@media (max-width: 620px) {
  .cloud-shell { box-shadow: none; }
  .cloud-header,
  .timeline-panel,
  .composer-panel { padding-left: 14px; padding-right: 14px; }
  .brand p { display: none; }
  .message { width: 91%; }
  .section-heading { align-items: flex-start; }
  .login-page { padding: 14px; }
  .login-card { padding: 22px 18px; border-radius: 20px; }
}

