:root {
  --ink: #16252d;
  --muted: #5e6d73;
  --line: #dce5e3;
  --paper: #f7faf8;
  --white: #ffffff;
  --teal: #167f7a;
  --teal-dark: #0f5f5b;
  --brand-soft: #dff3ec;
  --mint: #dff3ec;
  --coral: #d86f58;
  --amber: #d99b2b;
  --green: #4d8b57;
  --danger: #b63f3f;
  --blue: #3a7290;
  --shadow: 0 18px 44px rgba(22, 37, 45, 0.12);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(520px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(220, 229, 227, 0.95);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 176px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: var(--white);
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.32), transparent 38%),
    linear-gradient(135deg, #24a39a 0%, #0f5f5b 100%);
  box-shadow: 0 10px 24px rgba(22, 127, 122, 0.18);
  overflow: hidden;
}

.brand-mark img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  object-position: center 46%;
  border-radius: 10px;
  filter: drop-shadow(0 5px 8px rgba(12, 61, 57, 0.24));
}

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

.brand strong {
  font-size: 1.02rem;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.top-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
}

.nav-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  color: #31434b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-btn:hover,
.nav-btn.active {
  color: var(--teal-dark);
  background: var(--mint);
  border-color: #c4e5dc;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 370px;
}

#userBadge {
  max-width: 120px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: #6a4d14;
  background: #fff4d8;
  border: 1px solid #ecd19c;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.plan-badge.free {
  color: #51636a;
  background: #f3f7f6;
  border-color: var(--line);
}

.plan-badge.plus {
  color: #0f5f5b;
  background: #dff3ec;
  border-color: #a8d9cf;
  box-shadow: 0 8px 20px rgba(22, 127, 122, 0.12);
}

.plan-badge.pro {
  color: #143f6b;
  background: #e3f0f7;
  border-color: #a9c9dd;
  box-shadow: 0 8px 20px rgba(38, 99, 139, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.primary-btn {
  color: var(--white);
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(22, 127, 122, 0.18);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.module-card:hover,
.hospital-card:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.secondary-btn {
  color: var(--teal-dark);
  background: var(--mint);
  border-color: #b9ded4;
}

.ghost-btn {
  color: var(--teal-dark);
  background: var(--white);
  border-color: var(--line);
}

.compact {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.full-width {
  width: 100%;
}

.app-view {
  display: none;
  min-height: calc(100svh - 72px);
}

.app-view.active {
  display: block;
}

.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: min(720px, calc(100svh - 72px));
  overflow: hidden;
  isolation: isolate;
}

.hero-image,
.hero-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-image {
  object-fit: cover;
  object-position: center;
  z-index: -2;
}

.hero-shade {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(247, 250, 248, 0.97) 0%, rgba(247, 250, 248, 0.84) 39%, rgba(247, 250, 248, 0.18) 78%),
    linear-gradient(0deg, rgba(22, 37, 45, 0.14), rgba(22, 37, 45, 0.02));
}

.hero-content {
  width: min(700px, calc(100% - 36px));
  margin-left: clamp(18px, 6vw, 84px);
  padding: 72px 0 96px;
}

.hero-brand-lockup {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 32px);
  margin-bottom: 22px;
}

.hero-app-icon {
  display: grid;
  place-items: center;
  width: clamp(92px, 10vw, 150px);
  aspect-ratio: 1;
  padding: clamp(6px, 0.8vw, 10px);
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.32), transparent 38%),
    linear-gradient(135deg, #26a99f 0%, #0e625e 100%);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: clamp(22px, 2.5vw, 34px);
  box-shadow: 0 24px 52px rgba(22, 127, 122, 0.22);
  overflow: hidden;
}

.hero-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 48%;
  border-radius: clamp(16px, 1.8vw, 26px);
  filter: drop-shadow(0 12px 20px rgba(12, 61, 57, 0.22));
}

.hero-brand-lockup h1 {
  margin-bottom: 4px;
}

.hero-brand-lockup p {
  margin: 0;
  color: #526268;
  font-size: clamp(1.3rem, 2.8vw, 2.4rem);
  font-weight: 800;
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 20px;
  font-size: clamp(2.35rem, 5vw, 5rem);
  line-height: 1.03;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.12;
}

h3 {
  margin-bottom: 14px;
  font-size: 1.08rem;
  line-height: 1.3;
}

.hero-copy {
  max-width: 620px;
  color: #43545a;
  font-size: clamp(1rem, 1.5vw, 1.18rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.page-band {
  padding: clamp(42px, 6vw, 76px) clamp(18px, 5vw, 72px);
}

.compact-band {
  padding-top: 0;
}

.section-head {
  width: min(860px, 100%);
  margin-bottom: 26px;
}

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

.module-card {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 22px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(22, 37, 45, 0.06);
  text-align: left;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.module-card:hover {
  border-color: #b7dcd3;
  box-shadow: var(--shadow);
}

.module-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--teal-dark);
  background: var(--mint);
  border-radius: 8px;
}

.module-icon svg {
  width: 25px;
  height: 25px;
}

.module-card strong {
  font-size: 1.14rem;
}

.module-card span:last-child {
  color: var(--muted);
  font-size: 0.94rem;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow div {
  min-height: 168px;
  padding: 24px;
  background: var(--white);
}

.workflow span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 16px;
  color: var(--white);
  background: var(--teal);
  border-radius: 8px;
  font-weight: 800;
}

.workflow strong {
  display: block;
  margin-bottom: 8px;
}

.workflow p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.subpage-head {
  padding: 42px clamp(18px, 5vw, 72px) 26px;
}

.subpage-head p:last-child {
  max-width: 850px;
  margin-bottom: 0;
  color: var(--muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 18px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.two-column,
.chat-layout,
.checkin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(340px, 0.72fr);
  gap: 18px;
  padding: 0 clamp(18px, 5vw, 72px) 46px;
}

.checkin-grid {
  grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1.22fr);
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(22, 37, 45, 0.06);
}

form.panel,
.result-panel,
.side-tools,
.dashboard-panel,
.history-panel,
.source-note,
.referral-panel {
  padding: 24px;
}

.plus-layout {
  display: grid;
  gap: 18px;
  padding: 0 clamp(18px, 5vw, 72px) 56px;
}

.plus-hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: clamp(22px, 4vw, 34px);
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.74), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #e7f7f2 60%, #d5eee7 100%);
  border-color: #a8d9cf;
}

.plus-price {
  display: grid;
  gap: 6px;
}

.plus-price span,
.plus-price small {
  color: var(--muted);
  font-weight: 800;
}

.plus-price strong {
  color: var(--teal-dark);
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 1;
}

.plus-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.payment-feedback {
  grid-column: 1 / -1;
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.plan-compare {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.plan-card {
  padding: 24px;
}

.plan-card.plus {
  border-color: #a8d9cf;
  box-shadow: 0 18px 42px rgba(22, 127, 122, 0.1);
}

.plan-card.featured {
  border-width: 2px;
}

.plan-card.pro {
  border-color: #a9c9dd;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9fb 100%);
  box-shadow: 0 18px 42px rgba(38, 99, 139, 0.1);
}

.plan-label {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 9px;
  color: var(--teal-dark);
  background: var(--mint);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 900;
}

.plan-card ul {
  display: grid;
  gap: 9px;
  padding-left: 20px;
  margin: 0;
  color: var(--muted);
}

.plan-detail-panel {
  margin-top: 16px;
  padding: 22px;
}

.plan-detail-panel .mini-head span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.plan-feature-table {
  display: grid;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plan-feature-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr));
  min-width: 760px;
  border-bottom: 1px solid var(--line);
}

.plan-feature-row:last-child {
  border-bottom: 0;
}

.plan-feature-row span {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.plan-feature-row span:last-child {
  border-right: 0;
}

.plan-feature-row.header span {
  color: var(--ink);
  background: #f3f8f7;
  font-weight: 900;
}

.admin-panel {
  margin: 0 clamp(18px, 5vw, 72px) 56px;
  padding: 24px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.admin-stat {
  min-height: 92px;
  padding: 16px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.admin-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
  line-height: 1;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: var(--white);
}

.admin-table th,
.admin-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: #33464f;
  background: #f3f7f6;
  font-size: 0.82rem;
}

.admin-table td {
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-plus-btn {
  white-space: nowrap;
}

.admin-plan-tools {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.admin-plan-select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
}

.admin-plus-btn:disabled {
  cursor: wait;
  opacity: 0.62;
}

.form-section {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  border-bottom: 0;
}

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

label,
fieldset {
  display: grid;
  gap: 7px;
  color: #33464f;
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfdfc;
  border: 1px solid #ccd9d6;
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 127, 122, 0.12);
}

.result-panel {
  position: sticky;
  top: 92px;
  align-self: start;
}

.result-panel p {
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--teal-dark);
  background: var(--mint);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag.danger {
  color: var(--danger);
  background: #f7e5e2;
}

.tag.amber {
  color: #87601d;
  background: #fbefd6;
}

.plan-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.plan-item {
  padding: 14px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plan-item strong {
  display: block;
  margin-bottom: 4px;
}

.plan-item span {
  color: var(--muted);
  font-size: 0.92rem;
}

.chat-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.chat-panel {
  display: grid;
  min-height: 650px;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  overflow: hidden;
}

.assistant-strip {
  position: relative;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  width: 100%;
  min-height: 276px;
  padding: 30px 34px;
  color: var(--ink);
  background:
    radial-gradient(circle at 122px 50%, rgba(22, 127, 122, 0.16), transparent 34%),
    linear-gradient(90deg, #ffffff 0%, #edf8f4 100%);
  border: 0;
  border-bottom: 1px solid var(--line);
  appearance: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  overflow: hidden;
}

.assistant-strip::before {
  content: "";
  position: absolute;
  inset: 20px auto 20px 24px;
  width: 232px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(225, 245, 239, 0.8)),
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.95), transparent 46%);
  border: 1px solid rgba(122, 191, 176, 0.45);
  border-radius: 26px;
  box-shadow: 0 26px 48px rgba(22, 127, 122, 0.15);
}

.assistant-strip::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: 18px;
  width: 9px;
  height: 9px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 16px 0 0 rgba(22, 127, 122, 0.45), 32px 0 0 rgba(22, 127, 122, 0.22);
  opacity: 0.42;
}

.assistant-strip:hover {
  background: linear-gradient(90deg, #ffffff 0%, #e8f7f3 100%);
}

.assistant-strip:hover .agent-stage {
  transform: translateY(-4px) rotateX(3deg) rotateY(-4deg);
  box-shadow: 0 28px 54px rgba(22, 127, 122, 0.2);
}

.assistant-strip:active .agent-stage {
  transform: translateY(1px) scale(0.985);
}

.assistant-strip:focus-visible {
  outline: 3px solid rgba(22, 127, 122, 0.28);
  outline-offset: -4px;
}

.agent-stage {
  position: relative;
  z-index: 1;
  display: block;
  width: 216px;
  aspect-ratio: 1;
  border: 1px solid rgba(116, 185, 171, 0.54);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.9), transparent 40%),
    linear-gradient(150deg, #fafdff 0%, #dff2ec 56%, #b8e1d6 100%);
  box-shadow: 0 22px 44px rgba(22, 127, 122, 0.16);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.agent-stage::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(22, 127, 122, 0.16);
  border-radius: 22px;
  transform: rotate(7deg);
}

.agent-stage::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 22px;
  width: 10px;
  height: 10px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(22, 127, 122, 0.1);
}

.agent-canvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
}

.agent-shadow {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 1;
  width: 92px;
  height: 18px;
  background: rgba(27, 76, 74, 0.18);
  border-radius: 50%;
  filter: blur(8px);
  transform: translateX(-50%);
}

.assistant-strip > div {
  position: relative;
  z-index: 1;
}

.assistant-strip strong,
.assistant-strip span {
  display: block;
}

.assistant-strip strong {
  margin-bottom: 8px;
  font-size: 1.56rem;
}

.assistant-strip span {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.72;
}

.assistant-strip .agent-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.assistant-strip .agent-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--teal-dark);
  background: #e9f7f3;
  border: 1px solid #c7e8df;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.assistant-strip .agent-signal {
  display: inline-flex;
  align-items: end;
  gap: 4px;
  height: 20px;
}

.agent-signal i {
  display: block;
  width: 4px;
  height: 8px;
  background: rgba(22, 127, 122, 0.42);
  border-radius: 999px;
}

.agent-signal i:nth-child(2) {
  height: 14px;
}

.agent-signal i:nth-child(3) {
  height: 18px;
}

.assistant-strip.is-interacting .agent-stage {
  animation: agent-wave 840ms cubic-bezier(0.22, 1, 0.36, 1);
}

.assistant-strip.is-interacting::before {
  animation: agent-halo 840ms ease;
}

.assistant-strip.is-thinking .agent-stage {
  animation: agent-think 1080ms ease-in-out infinite;
}

.assistant-strip.is-thinking::after {
  animation: typing-dots 900ms ease-in-out infinite;
  opacity: 0.75;
}

.assistant-strip.is-thinking .agent-signal i {
  animation: signal-bars 880ms ease-in-out infinite;
}

.assistant-strip.is-thinking .agent-signal i:nth-child(2) {
  animation-delay: 120ms;
}

.assistant-strip.is-thinking .agent-signal i:nth-child(3) {
  animation-delay: 240ms;
}

.assistant-strip.is-speaking .agent-stage {
  animation: agent-speaking 520ms ease-in-out infinite;
  box-shadow: 0 18px 36px rgba(22, 127, 122, 0.18);
}

.assistant-strip.is-speaking::after {
  opacity: 1;
  animation: typing-dots 620ms ease-in-out infinite;
}

.assistant-strip.is-speaking .agent-status-pill {
  color: #0f5f5a;
  background: #dff5ef;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbf9 100%);
}

.message {
  width: min(720px, 86%);
  padding: 14px 16px;
  border-radius: 8px;
  white-space: pre-line;
}

.message.user {
  align-self: flex-end;
  color: var(--white);
  background: var(--teal);
}

.message.bot {
  align-self: flex-start;
  color: #23343b;
  background: var(--white);
  border: 1px solid var(--line);
}

.message.thinking-message {
  border-color: #b9ded4;
  background: #f2fbf8;
}

.message small {
  display: block;
  margin-bottom: 6px;
  color: inherit;
  opacity: 0.72;
  font-weight: 800;
}

.message-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  color: var(--ink);
  background: #f3faf8;
  border: 1px solid #cae9e2;
  border-radius: 8px;
}

.message-action span {
  color: #315057;
  font-size: 0.86rem;
  font-weight: 800;
}

.chat-form {
  padding: 16px;
  background: var(--white);
  border-top: 1px solid var(--line);
}

.chat-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.side-tools p {
  color: var(--muted);
  font-size: 0.92rem;
}

.side-tools > .primary-btn {
  margin-top: 10px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 118px;
  margin: 14px 0;
  padding: 18px;
  color: var(--teal-dark);
  background: #f6fbf9;
  border: 1px dashed #91c8bd;
  border-radius: 8px;
  text-align: center;
}

.upload-box input {
  display: none;
}

.upload-box span {
  font-weight: 800;
}

.upload-box small {
  color: var(--muted);
  font-weight: 600;
}

.photo-preview-wrap {
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.photo-preview-wrap img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.choice-group {
  gap: 10px;
  padding: 0;
  margin: 14px 0;
  border: 0;
}

.choice-group legend {
  margin-bottom: 8px;
  font-weight: 800;
}

.choice-group label,
.inline-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.choice-group input,
.inline-checks input {
  width: 18px;
  min-height: 18px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.quick-prompts button {
  min-height: 34px;
  padding: 0 10px;
  color: #33464f;
  background: #f3f7f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 800;
}

@keyframes agent-wave {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  30% {
    transform: translateY(-10px) rotate(-6deg) scale(1.06);
  }
  65% {
    transform: translateY(-2px) rotate(5deg) scale(1.04);
  }
}

@keyframes agent-halo {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.035);
    box-shadow: 0 24px 48px rgba(22, 127, 122, 0.2);
  }
}

@keyframes agent-think {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-9px) scale(1.035);
  }
}

@keyframes agent-speaking {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-3px) scale(1.055);
  }
}

@keyframes typing-dots {
  0%,
  100% {
    transform: translateY(0);
    filter: opacity(0.45);
  }
  50% {
    transform: translateY(-4px);
    filter: opacity(1);
  }
}

@keyframes signal-bars {
  0%,
  100% {
    transform: scaleY(0.65);
    opacity: 0.45;
  }
  50% {
    transform: scaleY(1.18);
    opacity: 1;
  }
}

.slider-row {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--teal);
  border: 0;
}

.inline-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 98px;
  padding: 16px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.38rem;
  line-height: 1.1;
}

.chart-card,
.weekly-report {
  padding: 18px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.mini-head h3 {
  margin: 0;
}

.mini-head span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.pain-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(24px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 180px;
  padding: 12px 4px 0;
}

.bar-wrap {
  display: grid;
  align-items: end;
  gap: 8px;
  min-height: 160px;
  text-align: center;
}

.bar {
  width: 100%;
  min-height: 6px;
  background: linear-gradient(180deg, var(--coral), var(--teal));
  border-radius: 8px 8px 0 0;
}

.bar-label,
.bar-value {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.weekly-report {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

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

.report-item {
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.doctor-summary {
  padding: 14px;
  color: #31434b;
  background: #eef7f4;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  white-space: pre-line;
}

.history-panel {
  margin: 0 clamp(18px, 5vw, 72px) 56px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 14px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-item strong {
  display: block;
}

.history-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.triage-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 clamp(18px, 5vw, 72px) 18px;
}

.triage-strip div {
  min-height: 112px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.triage-strip strong,
.triage-strip span {
  display: block;
}

.triage-strip span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hospital-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 clamp(18px, 5vw, 72px) 30px;
}

.referral-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  margin: 0 clamp(18px, 5vw, 72px) 18px;
}

.referral-copy h3 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.referral-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.referral-control {
  display: grid;
  gap: 12px;
  align-content: center;
}

.smart-doctor-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 clamp(18px, 5vw, 72px) 24px;
}

.doctor-match-overview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.4fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.78), transparent 30%),
    linear-gradient(135deg, #f8fffc 0%, #e1f5ef 54%, #d2eee6 100%);
  border: 1px solid #a8d9cf;
  border-radius: 8px;
  box-shadow: 0 20px 46px rgba(22, 127, 122, 0.13);
}

.doctor-match-overview h3 {
  margin-bottom: 4px;
  font-size: 1.42rem;
}

.doctor-match-overview p {
  margin-bottom: 0;
  color: var(--muted);
}

.match-reason {
  display: grid;
  gap: 8px;
}

.match-reason strong {
  color: var(--teal-dark);
}

.match-reason span {
  display: block;
  color: #3a5056;
  font-size: 0.92rem;
}

.smart-doctor-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(22, 37, 45, 0.06);
}

.smart-doctor-card.recommended {
  border-color: #9bd3c7;
  box-shadow: 0 18px 42px rgba(22, 127, 122, 0.12);
}

.doctor-rank {
  justify-self: start;
  min-height: 28px;
  padding: 4px 9px;
  color: var(--teal-dark);
  background: var(--mint);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.smart-doctor-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.smart-doctor-card h3 {
  margin-bottom: 4px;
  font-size: 1.18rem;
}

.smart-doctor-card p {
  margin-bottom: 0;
}

.doctor-meta,
.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doctor-meta span,
.reason-list span {
  min-height: 28px;
  padding: 4px 9px;
  color: #33464f;
  background: #f3f7f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.doctor-expertise {
  color: var(--muted);
}

.route-box {
  padding: 14px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.route-box strong {
  display: block;
  margin-bottom: 8px;
}

.route-box ol {
  padding-left: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.route-box li + li {
  margin-top: 4px;
}

.hospital-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(22, 37, 45, 0.06);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.hospital-card:hover {
  box-shadow: var(--shadow);
}

.hospital-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.hospital-card h3 {
  margin-bottom: 5px;
}

.hospital-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.hospital-level {
  flex: 0 0 auto;
  align-self: start;
  padding: 5px 8px;
  color: var(--teal-dark);
  background: var(--mint);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.doctor-list {
  display: grid;
  gap: 10px;
}

.doctor-card {
  padding: 13px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.doctor-card strong {
  display: block;
  margin-bottom: 4px;
}

.doctor-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.hospital-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-note {
  margin: 0 clamp(18px, 5vw, 72px) 56px;
}

.source-note p {
  margin-bottom: 0;
  color: var(--muted);
}

.safety-modal,
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(18, 33, 39, 0.58);
}

.safety-modal.active,
.auth-modal.active {
  display: grid;
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  padding: 28px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-card p {
  color: var(--muted);
}

.consent-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0;
  color: #31434b;
}

.consent-line input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: #eef6f4;
  border-radius: 8px;
}

.tab-btn {
  min-height: 34px;
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.tab-btn.active {
  color: var(--teal-dark);
  background: var(--white);
}

#authForm {
  display: grid;
  gap: 14px;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.code-row input {
  min-width: 0;
}

.code-row .secondary-btn {
  white-space: nowrap;
}

.code-row .secondary-btn:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-feedback {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .brand,
  .top-nav,
  .account-bar {
    justify-content: center;
  }

  .top-nav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .module-grid,
  .metric-grid,
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .chat-layout,
  .checkin-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: auto;
    padding: 10px 12px;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .account-bar {
    min-width: 0;
    flex-wrap: wrap;
  }

  .hero {
    min-height: 620px;
  }

  .hero-content {
    margin-left: 18px;
    padding: 54px 0 70px;
  }

  .hero-brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .hero-app-icon {
    width: 104px;
    border-radius: 24px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .module-grid,
  .workflow,
  .form-grid,
  .inline-checks,
  .metric-grid,
  .admin-stats,
  .plan-compare,
  .plus-hero-panel,
  .report-grid,
  .triage-strip,
  .hospital-grid,
  .referral-panel,
  .smart-doctor-list,
  .doctor-match-overview {
    grid-template-columns: 1fr;
  }

  .two-column,
  .chat-layout,
  .checkin-grid {
    padding-left: 14px;
    padding-right: 14px;
  }

  .subpage-head {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message {
    width: 94%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-panel,
  .source-note,
  .referral-panel,
  .admin-panel {
    margin-left: 14px;
    margin-right: 14px;
  }

  .plus-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .plus-actions {
    justify-content: flex-start;
  }

  .assistant-strip {
    grid-template-columns: 124px minmax(0, 1fr);
    gap: 16px;
    min-height: 168px;
    padding: 18px 16px;
  }

  .assistant-strip::before {
    inset: 16px auto 16px 12px;
    width: 126px;
    border-radius: 18px;
  }

  .agent-stage {
    width: 116px;
    border-radius: 18px;
  }

  .assistant-strip strong {
    font-size: 1.12rem;
  }

  .assistant-strip span {
    font-size: 0.9rem;
    line-height: 1.56;
  }

  .assistant-strip .agent-status-row {
    flex-wrap: wrap;
    margin-top: 10px;
  }
}
