:root {
  --bg: #06101c;
  --panel: rgba(10, 24, 40, .72);
  --line: rgba(149, 215, 255, .13);
  --text: #f4f8ff;
  --muted: #8fa6bb;
  --cyan: #4df7ff;
  --blue: #5d6bff;
  --pink: #ff70d6;
  --success: #43f6a3;
  --danger: #ff6d7a;
  --shadow: 0 30px 90px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 20%, rgba(38, 97, 140, .18), transparent 32%),
    radial-gradient(circle at 80% 24%, rgba(80, 55, 175, .16), transparent 28%),
    linear-gradient(135deg, #040a12 0%, #071524 45%, #050b13 100%);
  font-family: Inter, system-ui, sans-serif;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .25;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 86%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
input, textarea { color-scheme: dark; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .13;
  pointer-events: none;
}
.ambient-one { top: -170px; left: -120px; background: var(--cyan); }
.ambient-two { right: -180px; bottom: -180px; background: var(--blue); }
.glass {
  background: linear-gradient(145deg, rgba(14, 31, 51, .82), rgba(7, 19, 32, .72));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-brand { position: fixed; top: 24px; left: 28px; }
.auth-card {
  width: min(470px, 100%);
  border-radius: 28px;
  padding: 34px;
}
.auth-card h1 {
  margin: 12px 0 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 34px;
}
.auth-card p { color: var(--muted); line-height: 1.6; }
.auth-form { display: grid; gap: 12px; margin-top: 14px; }
.primary-link {
  width: 100%;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  border-radius: 15px;
  color: #06101c;
  background: linear-gradient(135deg, var(--cyan), #7d73ff);
  font-weight: 900;
  text-decoration: none;
}

.topbar {
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(77,247,255,.35);
  border-radius: 15px;
  background: rgba(77,247,255,.07);
  color: var(--cyan);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 900;
  box-shadow: inset 0 0 24px rgba(77,247,255,.08), 0 0 24px rgba(77,247,255,.08);
}
.brand strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: .18em;
  font-size: 18px;
}
.brand small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .38em;
}
.top-actions { display: flex; align-items: center; gap: 12px; }
.status-pill, .ghost-button {
  border: 1px solid var(--line);
  background: rgba(10, 24, 40, .58);
  color: var(--muted);
  border-radius: 999px;
  padding: 11px 15px;
  font-size: 12px;
}
.ghost-button.full { width: 100%; margin-top: 12px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffbd4a;
  box-shadow: 0 0 14px #ffbd4a;
}
.status-pill.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 14px var(--success);
}

.dashboard {
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr);
  gap: 22px;
  height: calc(100vh - 126px);
  min-height: 640px;
}
.profile-panel, .chat-panel {
  min-height: 0;
  height: 100%;
  border-radius: 30px;
  overflow: hidden;
  position: relative;
}
.profile-panel {
  padding: 30px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(77,247,255,.3) transparent;
}
.chat-panel { display: flex; flex-direction: column; min-width: 0; }
.profile-head, .chat-head, .diary-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.profile-head h2, .chat-head h2, .diary-head h3 {
  margin: 6px 0 0;
  font-family: "Space Grotesk", sans-serif;
}
.profile-head h2, .chat-head h2 { font-size: clamp(24px, 2.2vw, 34px); }
.diary-head h3 { font-size: 20px; }
.eyebrow {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .24em;
}
.bmi-badge {
  min-width: 96px;
  text-align: center;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(77,247,255,.25);
  background: rgba(77,247,255,.06);
  color: var(--cyan);
  font-weight: 800;
}

.figure-zone {
  min-height: 470px;
  display: grid;
  grid-template-columns: 138px minmax(260px, 1fr) 138px;
  align-items: center;
  gap: 12px;
  position: relative;
}
.metric-stack { display: grid; gap: 16px; z-index: 3; }
.metric-card {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 22, 38, .55);
}
.metric-card span, .metric-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.metric-card strong {
  display: block;
  margin: 10px 0 2px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 30px;
}
.human-figure-wrap {
  min-height: 455px;
  display: grid;
  place-items: center;
  position: relative;
}
#figureCanvas {
  width: 100%;
  height: 450px;
  display: block;
  position: relative;
  z-index: 2;
  filter: saturate(.86) brightness(.86) contrast(.98);
}
.figure-fallback {
  position: absolute;
  z-index: 4;
  color: var(--muted);
  font-size: 12px;
}
.figure-platform {
  position: absolute;
  bottom: 10px;
  width: 62%;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(77,247,255,.25);
  background: radial-gradient(ellipse, rgba(77,247,255,.2), transparent 70%);
  box-shadow: 0 0 40px rgba(77,247,255,.12);
}
.scan-line {
  position: absolute;
  z-index: 4;
  left: 12%;
  right: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(77,247,255,.65), transparent);
  box-shadow: 0 0 18px rgba(77,247,255,.5);
  animation: scan 4.8s ease-in-out infinite;
  opacity: .6;
}
@keyframes scan {
  0%, 100% { top: 25%; opacity: .12; }
  50% { top: 76%; opacity: .7; }
}

.goal-strip {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}
.goal-strip > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.goal-strip span, .goal-strip small { color: var(--muted); font-size: 12px; }
.goal-strip strong { font-family: "Space Grotesk"; font-size: 21px; }
.progress-track {
  margin: 14px 0 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  box-shadow: 0 0 18px rgba(77,247,255,.45);
  transition: width .8s ease;
}

.diary-panel {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}
.diary-days {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.day-card, .entry-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 22, 38, .5);
}
.day-card { padding: 14px; }
.day-card span, .entry-card span { color: var(--muted); font-size: 11px; }
.day-card strong {
  display: block;
  margin-top: 6px;
  font-family: "Space Grotesk";
  font-size: 22px;
}
.diary-entries {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}
.entry-card { padding: 13px 14px; }
.entry-card strong { display: block; margin: 4px 0; }
.entry-card p { margin: 0; color: #dbe7f4; font-size: 12px; line-height: 1.5; }

.chat-head { padding: 28px 28px 18px; }
.chat-clock {
  display: inline-flex;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(77,247,255,.16);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(77,247,255,.045);
  font-size: 11px;
  line-height: 1;
}
.api-warning {
  margin: 0 28px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255,189,74,.2);
  border-radius: 8px;
  background: rgba(255,189,74,.06);
}
.warning-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffbd4a;
  background: rgba(255,189,74,.12);
  font-weight: 900;
}
.api-warning strong { font-size: 13px; }
.api-warning p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(77,247,255,.3) transparent;
}
.profile-panel::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 8px;
}
.profile-panel::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.profile-panel::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(77, 247, 255, .26);
  background-clip: padding-box;
}
.profile-panel::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(77, 247, 255, .42);
  background-clip: padding-box;
}
.message { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-end; }
.avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(77,247,255,.2), rgba(93,107,255,.2));
  border: 1px solid rgba(77,247,255,.22);
  color: var(--cyan);
  font-size: 9px;
  font-weight: 800;
}
.bubble {
  max-width: min(76%, 560px);
  padding: 10px 12px;
  border-radius: 5px 8px 8px 8px;
  background: rgba(14, 32, 51, .78);
  border: 1px solid var(--line);
}
.bubble strong { font-size: 12px; }
.bubble p { margin: 5px 0 7px; color: #dbe7f4; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.bubble span { color: var(--muted); font-size: 9px; }
.user-message { justify-content: flex-end; }
.user-message .avatar { order: 2; color: #fff; border-color: rgba(255,112,214,.25); }
.user-message .bubble {
  border-radius: 8px 5px 8px 8px;
  background: linear-gradient(135deg, rgba(93,107,255,.2), rgba(255,112,214,.13));
}
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 7px;
}
.message-image-thumb {
  width: 96px;
  height: 72px;
  padding: 0;
  border: 1px solid rgba(77,247,255,.22);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(4, 13, 23, .55);
}
.message-image-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.message-image-chip {
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid rgba(77,247,255,.18);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(4, 13, 23, .45);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-prompts {
  padding: 0 28px 12px;
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.quick-prompts button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 10px;
}
.chat-input-row {
  padding: 16px 22px 10px;
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--line);
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 52px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(4, 13, 23, .65);
  color: var(--text);
}
.chat-input-row button, .file-button {
  flex: 0 0 52px;
  height: 52px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #06101c;
  font-weight: 900;
}
.file-button {
  flex-basis: auto;
  padding: 0 14px;
  font-size: 12px;
}
.file-button input { display: none; }
.chat-input-row button:disabled, .file-button.disabled {
  filter: grayscale(1);
  opacity: .35;
  cursor: not-allowed;
}
.chat-input-row svg { width: 22px; fill: none; stroke: #06101c; stroke-width: 2; }
.file-preview {
  min-height: 30px;
  padding: 0 24px 12px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pending-file {
  max-width: 220px;
  border: 1px solid rgba(77,247,255,.18);
  border-radius: 999px;
  padding: 6px 10px;
  color: #cfe8f8;
  background: rgba(255,255,255,.04);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pending-file::after {
  content: " ×";
  color: var(--pink);
  font-weight: 900;
}
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 7, 13, .82);
  backdrop-filter: blur(12px);
}
.image-modal-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  position: relative;
  display: grid;
  gap: 10px;
}
.image-modal-card img {
  max-width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(77,247,255,.2);
  background: rgba(4,13,23,.74);
}
.image-modal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.image-modal-close {
  position: absolute;
  right: -12px;
  top: -12px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  color: var(--text);
  background: rgba(8, 22, 38, .95);
  font-size: 22px;
  line-height: 1;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 7, 13, .72);
  backdrop-filter: blur(14px);
}
.onboarding-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 28px;
  border: 1px solid rgba(77,247,255,.18);
  background: linear-gradient(145deg, rgba(12, 29, 48, .97), rgba(6, 16, 28, .98));
  box-shadow: 0 40px 120px rgba(0,0,0,.65), inset 0 0 60px rgba(77,247,255,.03);
}
.onboarding-card h1 {
  margin: 12px 0 10px;
  font-family: "Space Grotesk";
  font-size: clamp(28px, 4vw, 44px);
}
.modal-badge {
  display: inline-flex;
  padding: 8px 12px;
  border: 1px solid rgba(77,247,255,.22);
  border-radius: 999px;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .24em;
}
.modal-subtitle { color: var(--muted); line-height: 1.7; font-size: 13px; }
.gender-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 26px 0;
}
.gender-card {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
  transition: .25s ease;
}
.gender-card.active {
  color: var(--text);
  border-color: rgba(77,247,255,.45);
  background: linear-gradient(145deg, rgba(77,247,255,.09), rgba(93,107,255,.08));
}
.gender-symbol {
  display: block;
  font-size: 52px;
  line-height: 1;
  text-shadow: 0 0 18px currentColor;
}
.gender-card span:last-child { display: block; font-weight: 700; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.field-wide { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; }
.field > span { color: #c8d8e8; font-size: 11px; font-weight: 700; }
.field input {
  width: 100%;
  height: 49px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  padding: 0 14px;
  background: rgba(2, 10, 18, .55);
  color: var(--text);
}
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 48px; }
.input-with-unit small {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.privacy-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 10px;
}
.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}
.primary-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: #06101c;
  background: linear-gradient(135deg, var(--cyan), #7d73ff);
  font-weight: 900;
  box-shadow: 0 18px 45px rgba(77,247,255,.18);
}
.error { min-height: 20px; color: #ff8b9b; margin: 8px 0 0; }

@media (max-width: 1120px) {
  .dashboard { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .profile-panel, .chat-panel { min-height: auto; }
  .profile-panel { overflow: hidden; }
  .chat-panel { height: min(760px, calc(100vh - 96px)); min-height: 620px; }
}
@media (max-width: 720px) {
  .topbar, .dashboard { width: min(100% - 24px, 1540px); }
  .topbar { height: 76px; }
  .status-pill { display: none; }
  .profile-panel { padding: 20px; }
  .figure-zone {
    grid-template-columns: 1fr 1fr;
    min-height: auto;
  }
  .human-figure-wrap {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 500px;
  }
  #figureCanvas { height: 470px; }
  .metric-left, .metric-right { grid-row: 2; }
  .diary-days { grid-template-columns: 1fr; }
  .chat-input-row { display: grid; grid-template-columns: auto 1fr auto; padding: 12px; }
}
@media (max-width: 520px) {
  .brand small { display: none; }
  .ghost-button { padding: 9px 11px; font-size: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .figure-zone { grid-template-columns: 1fr; }
  .metric-left, .metric-right {
    grid-row: auto;
    grid-template-columns: 1fr 1fr;
  }
  .human-figure-wrap { grid-column: 1; }
}
