:root {
  color-scheme: light;
  --aqua-primary: #55D6F6;
  --aqua-primary-deep: #1FA9D6;
  --aqua-purple: #8F7CFF;
  --text-primary: #27364D;
  --text-secondary: #6A7892;
  --text-tertiary: #8B96AA;
  --aqua-page-gradient: linear-gradient(160deg, #EAFBFF 0%, #EEF6FF 52%, #F5F0FF 100%);
  --aqua-cta-gradient: linear-gradient(135deg, #55D6F6 0%, #8F7CFF 100%);
  --aqua-card-bg: rgba(255, 255, 255, 0.62);
  --aqua-card-soft-bg: rgba(255, 255, 255, 0.48);
  --aqua-card-border: rgba(255, 255, 255, 0.72);
  --aqua-card-border-soft: rgba(255, 255, 255, 0.6);
  --aqua-soft-blue: rgba(85, 214, 246, 0.14);
  --aqua-soft-purple: rgba(143, 124, 255, 0.12);
  --source-green: #52b788;
  --wuxing-wood: #52b788;
  --wuxing-fire: #ff6b6b;
  --wuxing-earth: #d4a373;
  --wuxing-metal: #ffd700;
  --wuxing-water: #4a90e2;
  --bg: #EAFBFF;
  --surface: var(--aqua-card-bg);
  --surface-strong: rgba(255, 255, 255, 0.5);
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--aqua-card-border);
  --accent: var(--aqua-primary-deep);
  --accent-soft: rgba(85, 214, 246, 0.13);
  --shadow: 0 18px 44px rgba(106, 150, 198, 0.2);
  --cta-shadow: 0 10px 20px rgba(92, 146, 216, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--aqua-page-gradient);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.phone-shell {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  width: min(100vw, 430px);
  height: min(100vh, 920px);
  min-height: 720px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(244, 250, 255, 0.42));
  border-left: 1px solid var(--aqua-card-border);
  border-right: 1px solid var(--aqua-card-border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-shell {
  width: min(100vw, 430px);
  margin: 0 auto;
}

.phone-shell::before {
  content: "";
  position: absolute;
  top: -88px;
  left: -48px;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  background: rgba(85, 214, 246, 0.2);
  filter: blur(18px);
  z-index: 0;
}

.phone-shell::after {
  content: "";
  position: absolute;
  top: -96px;
  right: -56px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: rgba(143, 124, 255, 0.18);
  filter: blur(20px);
  z-index: 0;
}

.phone-shell > * {
  position: relative;
  z-index: 1;
}

.topbar,
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sheet-subtitle {
  max-width: 260px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  font-weight: 750;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.send-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(106, 150, 198, 0.12);
}

.profile-pill,
.account-button,
.text-button,
.inline-action,
.primary-button {
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.account-button {
  min-width: 54px;
  max-width: 78px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--aqua-card-border);
  background: rgba(255, 255, 255, 0.54);
  color: var(--aqua-primary-deep);
  box-shadow: 0 8px 18px rgba(106, 150, 198, 0.12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-pill {
  min-width: 64px;
  height: 40px;
  padding: 0 14px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  box-shadow: var(--cta-shadow);
}

.profile-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.38);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.profile-strip-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--aqua-primary);
  box-shadow: 0 0 0 4px rgba(85, 214, 246, 0.16);
}

.profile-strip strong,
.profile-strip small {
  display: block;
}

.profile-strip small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-gate {
  position: relative;
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 16px 20px;
  overflow-y: auto;
  place-items: start center;
}

.login-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(85, 214, 246, 0.2), transparent 30%),
    radial-gradient(circle at 88% 10%, rgba(143, 124, 255, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.login-gate-card {
  position: relative;
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 390px;
  padding: 12px 0 0;
}

.login-hero {
  display: grid;
  gap: 8px;
  padding: 18px 8px 4px;
}

.login-hero h2 {
  color: var(--text-primary);
  font-size: 38px;
  line-height: 1.05;
}

.login-hero p:not(.eyebrow) {
  margin: 0;
  color: var(--text-primary);
  font-size: 23px;
  font-weight: 650;
  line-height: 1.35;
}

.login-showcase,
.login-trust-bar,
.login-question-grid article {
  border: 1px solid var(--aqua-card-border);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 16px 38px rgba(106, 150, 198, 0.16);
  backdrop-filter: blur(18px);
}

.login-showcase {
  display: grid;
  gap: 12px;
  border-radius: 24px;
  padding: 16px;
}

.login-showcase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.login-showcase-header strong {
  color: var(--ink);
  font-size: 16px;
}

.login-showcase-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-showcase-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, 0.88fr);
  gap: 12px;
  align-items: center;
}

.login-orbit-chart {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 28%, rgba(85, 214, 246, 0.1) 29% 42%, transparent 43%),
    conic-gradient(from 12deg, rgba(85, 214, 246, 0.08), rgba(143, 124, 255, 0.14), rgba(85, 214, 246, 0.08));
  border: 1px solid rgba(85, 214, 246, 0.22);
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.login-orbit-chart::before,
.login-orbit-chart::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 999px;
  border: 1px dashed rgba(143, 124, 255, 0.34);
}

.login-orbit-chart::after {
  inset: 33%;
  border-color: rgba(85, 214, 246, 0.32);
}

.login-orbit-chart span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--aqua-primary-deep);
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 5px 12px rgba(106, 150, 198, 0.12);
}

.login-orbit-chart span:nth-child(1) {
  top: 10%;
  left: 45%;
}

.login-orbit-chart span:nth-child(2) {
  top: 35%;
  right: 10%;
}

.login-orbit-chart span:nth-child(3) {
  right: 24%;
  bottom: 12%;
}

.login-orbit-chart span:nth-child(4) {
  bottom: 18%;
  left: 18%;
}

.login-orbit-chart span:nth-child(5) {
  top: 38%;
  left: 9%;
}

.login-orbit-chart span:nth-child(6) {
  top: 19%;
  right: 24%;
}

.login-orbit-chart i {
  position: absolute;
  width: 54%;
  height: 54%;
  border-radius: 38% 62% 48% 52%;
  background:
    linear-gradient(135deg, transparent 45%, rgba(85, 214, 246, 0.56) 46% 49%, transparent 50%),
    linear-gradient(32deg, transparent 39%, rgba(143, 124, 255, 0.45) 40% 43%, transparent 44%),
    linear-gradient(112deg, transparent 41%, rgba(82, 183, 136, 0.38) 42% 45%, transparent 46%);
  opacity: 0.9;
}

.login-reading-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid rgba(85, 214, 246, 0.2);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.login-reading-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.login-reading-card dl {
  display: grid;
  gap: 11px;
  margin: 0;
}

.login-reading-card div {
  display: grid;
  gap: 3px;
}

.login-reading-card dt {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.login-reading-card dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.login-questions {
  display: grid;
  gap: 12px;
}

.login-questions h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--text-primary);
  font-size: 17px;
  text-align: center;
}

.login-questions h3::before,
.login-questions h3::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(85, 214, 246, 0.38), transparent);
}

.login-question-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.login-question-grid article {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 7px;
  min-height: 132px;
  border-radius: 18px;
  padding: 13px 8px 11px;
  text-align: center;
}

.login-question-grid span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 16px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  font-size: 16px;
  font-weight: 850;
  box-shadow: var(--cta-shadow);
}

.login-question-grid strong {
  color: var(--ink);
  font-size: 13px;
}

.login-question-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.login-trust-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-radius: 20px;
  padding: 13px 12px;
}

.login-trust-bar div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.login-trust-bar strong {
  color: var(--ink);
  font-size: 12px;
}

.login-trust-bar span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.login-cta {
  width: 100%;
  min-height: 54px;
  margin-top: 0;
  border-radius: 999px;
  font-size: 17px;
}

.login-consent {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

body.auth-required .topbar {
  display: none;
}

body.auth-required .profile-strip,
body.auth-required .chat-window,
body.auth-required .quick-scenes,
body.auth-required .composer,
body.auth-required .desktop-profile-panel {
  display: none;
}

body.auth-required .login-gate {
  display: grid;
}

.text-button {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--aqua-card-border);
  background: rgba(255, 255, 255, 0.58);
  color: var(--aqua-primary-deep);
}

.chat-window {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 14px;
  min-height: 0;
  padding: 18px 14px 12px;
  overflow-y: auto;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.message.user .avatar {
  grid-column: 2;
  background: var(--aqua-cta-gradient);
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: var(--aqua-cta-gradient);
  color: #fff;
  box-shadow: var(--cta-shadow);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 12px 13px;
  border-radius: 8px;
  border: 1px solid var(--aqua-card-border-soft);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 22px rgba(106, 150, 198, 0.12);
  backdrop-filter: blur(12px);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.chart-bubble {
  width: 100%;
  padding: 0;
  background: transparent;
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 8px;
}

.answer-meta {
  color: var(--muted);
  font-size: 12px;
}

.inline-action {
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  box-shadow: var(--cta-shadow);
}

.evidence-card {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--aqua-card-bg);
  box-shadow: 0 10px 24px rgba(106, 150, 198, 0.13);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.evidence-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
  list-style: none;
  color: var(--aqua-primary-deep);
  font-weight: 800;
}

.evidence-card summary::-webkit-details-marker {
  display: none;
}

.evidence-content {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.evidence-content b {
  color: var(--ink);
}

.liunian-evidence {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.liunian-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.liunian-score span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.liunian-score strong {
  font-size: 14px;
}

.liunian-evidence dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.liunian-evidence .data-row {
  grid-template-columns: 72px minmax(0, 1fr);
  font-size: 12px;
}

.chat-chart-card {
  display: grid;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--aqua-card-border);
  border-radius: 24px;
  padding: 14px;
  background: var(--aqua-card-bg);
  box-shadow: 0 18px 34px rgba(106, 150, 198, 0.18);
  backdrop-filter: blur(16px);
}

.chart-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.chart-card-kicker,
.chart-card-meta,
.chart-card-source {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-card-source {
  font-weight: 600;
  line-height: 1.5;
}

.chart-card-header h3 {
  margin: 2px 0 0;
  font-size: 19px;
  line-height: 1.2;
}

.chart-card-action {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--aqua-card-border);
  background: rgba(255, 255, 255, 0.58);
  color: var(--aqua-primary-deep);
}

.chart-table-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--aqua-card-border);
  border-radius: 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 10px 24px rgba(106, 150, 198, 0.12);
}

.chart-table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chart-table-title strong {
  color: var(--ink);
  font-size: 15px;
}

.chart-table-title span {
  color: var(--aqua-primary-deep);
  font-size: 12px;
  font-weight: 800;
}

.chat-four-pillars-table {
  display: grid;
  min-width: 0;
  border: 1px solid rgba(85, 214, 246, 0.28);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.26);
}

.chat-four-pillars-row {
  display: grid;
  grid-template-columns: 52px repeat(4, minmax(0, 1fr));
  min-height: 42px;
  border-bottom: 1px solid rgba(85, 214, 246, 0.26);
}

.chat-four-pillars-row:last-child {
  border-bottom: 0;
}

.chat-four-pillars-row.header-row {
  min-height: 36px;
  background: rgba(85, 214, 246, 0.12);
}

.chat-four-pillars-row.compact-row {
  min-height: 34px;
  background: rgba(255, 255, 255, 0.2);
}

.chat-four-pillars-label,
.chat-four-pillars-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 6px 3px;
  text-align: center;
  overflow-wrap: anywhere;
}

.chat-four-pillars-label {
  justify-content: start;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chat-four-pillars-cell {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.ganzhi-stem,
.ganzhi-branch {
  display: block;
  line-height: 1;
  text-align: center;
}

.ganzhi-stem {
  font-size: 27px;
  font-weight: 850;
}

.ganzhi-branch {
  font-size: 23px;
  font-weight: 780;
}

.pillar-ganzhi {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.wuxing-wood {
  color: var(--wuxing-wood);
}

.wuxing-fire {
  color: var(--wuxing-fire);
}

.wuxing-earth {
  color: var(--wuxing-earth);
}

.wuxing-metal {
  color: #c9a92c;
}

.wuxing-water {
  color: var(--wuxing-water);
}

.wuxing-unknown {
  color: var(--text-tertiary);
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid rgba(85, 214, 246, 0.22);
  border-radius: 8px;
  overflow: hidden;
}

.pillar-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 74px;
  place-items: center;
  padding: 8px 4px;
  border-right: 1px solid rgba(85, 214, 246, 0.16);
  background: rgba(255, 255, 255, 0.42);
  text-align: center;
}

.pillar-cell:last-child {
  border-right: 0;
}

.pillar-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pillar-cell strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
}

.chart-brief-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.followups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.followups button,
.scene-chip {
  min-height: 34px;
  border: 1px solid var(--aqua-card-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.followups button {
  padding: 7px 9px;
}

.quick-scenes {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 56px;
  max-height: 72px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(18px);
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
}

.scene-chip {
  flex: 0 0 auto;
  height: 36px;
  align-self: center;
  padding: 0 12px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  padding: 10px 14px 16px;
  border-top: 1px solid var(--aqua-card-border);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(18px);
}

.composer input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  outline: none;
}

.composer input:focus {
  border-color: rgba(31, 169, 214, 0.56);
  box-shadow: 0 0 0 3px rgba(85, 214, 246, 0.16);
}

.send-button {
  width: 44px;
  height: 44px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  border-color: transparent;
  font-weight: 900;
  box-shadow: var(--cta-shadow);
}

.sheet,
.profile-center {
  position: fixed;
  inset: 0;
  display: none;
  align-items: end;
  justify-content: center;
  padding: 16px;
  background: rgba(39, 54, 77, 0.24);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.sheet.open,
.profile-center.open {
  display: flex;
}

.sheet-panel,
.profile-center-panel {
  width: min(100%, 430px);
  max-height: min(86vh, 780px);
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--aqua-card-border);
  background: var(--aqua-card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sheet-panel {
  padding: 18px;
}

.profile-center-panel {
  padding: 18px;
  max-height: min(92vh, 860px);
  background: var(--aqua-card-bg);
}

.profile-form,
.auth-form {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.profile-form label,
.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calendar-fieldset,
.auth-mode-fieldset {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.calendar-fieldset legend,
.auth-mode-fieldset legend {
  margin: 0 0 6px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.segmented-control label {
  display: block;
}

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

.segmented-control span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented-control input:checked + span {
  background: var(--aqua-cta-gradient);
  color: #fff;
  box-shadow: var(--cta-shadow);
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  min-height: 28px;
}

.checkbox-row input {
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  accent-color: var(--aqua-primary-deep);
}

.profile-form input,
.profile-form select,
.auth-form input,
.auth-form select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(92px, 0.78fr) minmax(0, 1.22fr);
  gap: 10px;
}

.auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 10px;
  align-items: stretch;
}

.password-auth-actions,
.username-auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 10px;
  align-items: stretch;
}

.auth-actions .text-button,
.auth-actions .primary-button,
.password-auth-actions .text-button,
.password-auth-actions .primary-button,
.username-auth-actions .text-button,
.username-auth-actions .primary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 0;
}

.auth-actions .text-button,
.password-auth-actions .text-button,
.username-auth-actions .text-button {
  padding: 0 10px;
}

.source-auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.source-auth-divider::before,
.source-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.source-social-logins {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.source-social-logins button {
  width: 56px;
  height: 56px;
  border: 1px solid rgba(123, 169, 207, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(48, 95, 130, 0.12);
}

.source-social-logins button:active {
  transform: translateY(1px);
}

.source-auth-note {
  text-align: center;
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 20px rgba(106, 150, 198, 0.1);
}

.account-panel div {
  min-width: 0;
}

.account-panel strong,
.account-panel small {
  display: block;
}

.account-panel strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.account-panel .text-button {
  min-width: 76px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 0.8fr));
  gap: 8px;
}

.primary-button {
  min-height: 44px;
  margin-top: 4px;
  background: var(--aqua-cta-gradient);
  color: #fff;
  box-shadow: var(--cta-shadow);
}

.form-note,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.profile-center-content {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.desktop-profile-panel {
  display: none;
  border: 1px solid var(--aqua-card-border);
  border-radius: 24px;
  background: var(--aqua-card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.desktop-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.26);
}

.desktop-profile-header h2 {
  font-size: 22px;
}

.desktop-profile-content {
  display: grid;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
}

.history-content {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.history-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 20px rgba(106, 150, 198, 0.1);
}

.history-item strong {
  font-size: 14px;
}

.history-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.profile-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.profile-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.data-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.data-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.data-row strong {
  color: var(--ink);
}

.loading {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 700px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .phone-shell {
    border-radius: 8px;
    border: 1px solid var(--aqua-card-border);
  }
}

@media (min-width: 960px) {
  body {
    align-items: stretch;
    padding: 28px;
  }

  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 560px) minmax(360px, 520px);
    grid-template-areas: "chat profile";
    gap: 18px;
    width: min(100%, 1120px);
    height: min(100vh - 56px, 920px);
    margin: auto;
  }

  body.auth-required .app-shell {
    grid-template-columns: minmax(0, 560px);
    grid-template-areas: "chat";
    width: min(100%, 560px);
  }

  .phone-shell {
    grid-area: chat;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 24px;
  }

  .desktop-profile-panel {
    grid-area: profile;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .chat-window {
    padding-inline: 18px;
  }

  .message {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .message.user {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .bubble {
    max-width: min(100%, 470px);
  }

  .chart-bubble {
    max-width: 100%;
  }
}

@media (max-width: 360px) {
  .login-gate {
    padding-inline: 12px;
  }

  .login-hero h2 {
    font-size: 34px;
  }

  .login-hero p:not(.eyebrow) {
    font-size: 20px;
  }

  .login-showcase-body,
  .login-trust-bar {
    grid-template-columns: 1fr;
  }

  .login-question-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-question-grid article {
    min-height: 118px;
  }

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

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

  .account-button {
    min-width: 48px;
    padding-inline: 9px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .composer,
  .quick-scenes,
  .chat-window {
    padding-inline: 12px;
  }
}
