:root {
  --bg: #eef3f0;
  --surface: #fffdf9;
  --surface-soft: #f8fbf8;
  --ink: #1f282b;
  --muted: #687579;
  --line: #dbe5df;
  --teal: #0f766e;
  --teal-dark: #0a5e58;
  --teal-soft: #e2f4f0;
  --coral: #d36b55;
  --coral-soft: #fae8e2;
  --indigo: #5058b8;
  --indigo-soft: #e8e9fb;
  --amber: #b27820;
  --shadow: 0 22px 70px rgba(28, 41, 38, 0.12);
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(211, 107, 85, 0.12), transparent 32%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 18px;
  gap: 16px;
}

.app-bar,
.main-window,
.chat-window,
.settings-shell,
.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--shadow);
}

.app-bar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.brand,
.app-actions,
.peer,
.composer,
.settings-header,
.privacy-note,
.switch,
.source,
.room-header,
.room-actions {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--teal);
  color: white;
}

.brand h1,
.brand p,
.peer strong,
.peer p,
.settings-header h2,
.settings-header p,
.settings-card h3,
.match-stage h2,
.match-stage p {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  line-height: 1.1;
}

.brand p,
.peer p,
.settings-header p,
.match-stage p,
.message-time,
.source small,
.privacy-note p {
  color: var(--muted);
}

.brand p,
.peer p,
.settings-header p,
.message-time,
.source small {
  font-size: 12px;
}

.app-actions {
  gap: 8px;
}

.top-button,
.icon-button,
.send-button,
.save-button,
.mini-button,
.source {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.top-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  background: white;
  font-weight: 800;
}

.top-button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.top-button:hover,
.source:hover,
.icon-button:hover {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
}

.main-window {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.chat-window {
  width: min(100%, 860px);
  height: min(760px, calc(100vh - 128px));
  min-height: 560px;
  overflow: hidden;
  display: grid;
  background: var(--surface);
}

.match-stage {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 30px;
  text-align: center;
}

.match-stage h2 {
  font-size: clamp(28px, 6vw, 54px);
  letter-spacing: 0;
}

.match-stage p {
  max-width: 420px;
  line-height: 1.7;
  font-size: 15px;
}

.match-orbit {
  width: min(70vw, 360px);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
    radial-gradient(circle, #ffffff 0 34%, transparent 35%),
    conic-gradient(from 180deg, rgba(15, 118, 110, 0.14), rgba(211, 107, 85, 0.18), rgba(80, 88, 184, 0.14), rgba(15, 118, 110, 0.14));
}

.orbit-person,
.orbit-bridge,
.peer-avatar {
  display: grid;
  place-items: center;
  font-weight: 900;
}

.orbit-person {
  position: absolute;
  width: 76px;
  height: 76px;
  border-radius: var(--radius);
  color: white;
  box-shadow: 0 14px 35px rgba(31, 40, 43, 0.16);
}

.orbit-person.me {
  left: 13%;
  top: 18%;
  background: var(--coral);
}

.orbit-person.stranger {
  right: 13%;
  bottom: 18%;
  background: var(--indigo);
}

.orbit-bridge {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: var(--teal);
  color: white;
  box-shadow: 0 16px 45px rgba(15, 118, 110, 0.28);
}

.orbit-bridge svg {
  width: 38px;
  height: 38px;
}

.chat-room {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.room-header {
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 251, 248, 0.92);
}

.room-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.peer {
  min-width: 0;
  gap: 10px;
}

.peer-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: var(--radius);
  background: var(--indigo);
  color: white;
}

.peer strong {
  display: block;
  font-size: 17px;
}

.live-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mini-button.danger {
  border-color: color-mix(in srgb, var(--coral) 55%, var(--line));
  color: #9a3f2d;
}

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(rgba(255, 253, 249, 0.9), rgba(255, 253, 249, 0.9)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(15, 118, 110, 0.06) 32px);
}

.message {
  width: min(80%, 580px);
  display: grid;
  gap: 5px;
}

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

.message.peer {
  align-self: flex-start;
}

.message.host {
  align-self: center;
  width: min(92%, 680px);
}

.message-meta {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.message.me .message-meta {
  justify-content: flex-end;
}

.message-name {
  color: var(--ink);
  font-weight: 900;
}

.bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 10px 24px rgba(31, 40, 43, 0.06);
  line-height: 1.65;
  font-size: 14px;
}

.message-warning {
  padding: 7px 9px;
  border-radius: 6px;
  background: #fff4e5;
  color: #8a520e;
  font-size: 12px;
  font-weight: 800;
}

.message.me .bubble {
  border-color: color-mix(in srgb, var(--coral) 45%, var(--line));
  background: var(--coral-soft);
}

.message.peer .bubble {
  border-color: color-mix(in srgb, var(--indigo) 42%, var(--line));
  background: var(--indigo-soft);
}

.message.host .bubble {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  background: var(--teal-soft);
}

.composer {
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: none;
  line-height: 1.55;
}

#messageInput {
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--teal);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.send-button,
.icon-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: white;
}

.send-button {
  width: 44px;
  height: 44px;
  background: var(--teal);
  color: white;
}

.send-button:hover,
.save-button:hover,
.top-button.primary:hover {
  background: var(--teal-dark);
}

.settings-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: auto;
  padding: 18px;
  background: rgba(238, 243, 240, 0.96);
}

.settings-shell {
  width: min(100%, 1040px);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  padding: 16px;
}

.settings-header {
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  font-size: 26px;
}

.icon-button {
  width: 42px;
  height: 42px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.08fr) minmax(280px, 0.92fr);
  gap: 14px;
  margin-top: 14px;
}

.settings-card {
  padding: 16px;
  box-shadow: none;
}

.auth-card {
  grid-column: 1 / -1;
}

.settings-card h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.source-editor h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.settings-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-card input,
.settings-card textarea {
  padding: 11px 12px;
  color: var(--ink);
  font-weight: 500;
}

.source-list {
  display: grid;
  gap: 9px;
}

.source {
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px 1fr 26px;
  gap: 10px;
  padding: 9px 10px;
  background: white;
  text-align: left;
}

.source.active {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  background: #f2fbf8;
}

.source.selected {
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.source strong,
.source small {
  display: block;
}

.source strong {
  font-size: 14px;
}

.source i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 999px;
  background: #e8eeeb;
  color: transparent;
  font-style: normal;
}

.source.active i {
  background: var(--teal);
  color: white;
}

.source i svg {
  width: 15px;
  height: 15px;
}

.source-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.source-editor {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.split-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.account-line {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.account-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.account-line strong {
  overflow-wrap: anywhere;
}

.wechat {
  background: #1d9d5a;
}

.alipay {
  background: #1677ff;
}

.linkedin {
  background: #0a66c2;
}

.facebook {
  background: #1877f2;
}

.x {
  background: #111111;
}

.instagram {
  background: #c13584;
}

.privacy-card {
  grid-column: 2;
}

.safety-card {
  grid-column: 1 / -1;
}

.switch {
  grid-template-columns: auto 1fr;
  color: var(--ink);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 38px;
  height: 22px;
  position: relative;
  display: inline-block;
  border-radius: 999px;
  background: #d4ddd8;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: white;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(16px);
}

.privacy-note {
  align-items: flex-start;
  gap: 9px;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.privacy-note svg {
  flex: 0 0 auto;
  color: var(--teal);
}

.privacy-note p {
  margin: 0;
  line-height: 1.6;
  font-size: 13px;
}

.save-button {
  width: 100%;
  min-height: 44px;
  background: var(--teal);
  color: white;
  font-weight: 900;
  margin-top: 10px;
}

.save-button.secondary {
  background: white;
  color: var(--teal-dark);
}

.save-button.danger {
  background: #b54837;
  color: white;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.legal-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: white;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.legal-links a:hover {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  background: var(--teal-soft);
}

.hidden {
  display: none !important;
}

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

  .app-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .top-button {
    justify-content: center;
  }

  .main-window {
    padding: 0;
  }

  .chat-window {
    width: 100%;
    height: calc(100vh - 142px);
    min-height: 520px;
    border-radius: 0;
  }

  .match-stage {
    padding: 20px;
  }

  .match-orbit {
    width: min(82vw, 300px);
  }

  .orbit-person {
    width: 64px;
    height: 64px;
  }

  .message,
  .message.host {
    width: 100%;
  }

  .settings-view {
    padding: 10px;
  }

  .settings-shell {
    min-height: calc(100vh - 20px);
    padding: 12px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .privacy-card {
    grid-column: auto;
  }

  .safety-card {
    grid-column: auto;
  }

  .auth-card {
    grid-column: auto;
  }

  .split-actions {
    grid-template-columns: 1fr;
  }

  .legal-links a {
    flex: 1 1 120px;
    justify-content: center;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .room-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-pill {
    align-self: flex-start;
  }

  .messages,
  .composer {
    padding-left: 12px;
    padding-right: 12px;
  }
}
