:root {
  --bg: #f4efe6;
  --surface: #fffdf8;
  --surface-soft: #fbf6ed;
  --ink: #292821;
  --muted: #756f63;
  --line: #e5dccb;
  --sage: #7d997c;
  --sage-dark: #4d6e57;
  --night: #253045;
  --night-soft: #52677f;
  --blue: #5d7890;
  --amber: #c99a5a;
  --rose: #bc776f;
  --cream: #fff3d6;
  --shadow: 0 20px 50px rgba(65, 53, 36, 0.12);
  --soft-shadow: 0 12px 28px rgba(65, 53, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14px 16px, rgba(255, 255, 255, 0.75) 0 1px, transparent 1.5px),
    linear-gradient(180deg, #eef2f1 0%, #f4efe6 38%, #f9f2e6 100%);
  background-size: 72px 72px, auto;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.side-nav {
  background:
    linear-gradient(180deg, rgba(37, 48, 69, 0.98), rgba(54, 70, 82, 0.98)),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.04) 18px 19px);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 12px 0 34px rgba(37, 48, 69, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #fff0c6, #d9bd7d);
  color: #263246;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 22px rgba(0, 0, 0, 0.18);
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: 8px;
  object-fit: contain;
  background: #fffdf8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 22px rgba(0, 0, 0, 0.18);
}

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

.brand > div:last-of-type {
  padding-right: 128px;
}

.brand span {
  margin-top: 3px;
  color: #d8ded2;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.quick-band button,
.quick-band a {
  border: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item {
  height: 46px;
  border-radius: 8px;
  padding: 0 14px;
  color: #e4e8df;
  background: transparent;
  text-align: left;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 246, 218, 0.14);
  color: #fff;
}

.nav-item svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.main {
  padding: 28px;
  overflow: hidden;
}

.topbar,
.form-head,
.section-head,
.archive-head,
.doctor-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.topbar {
  margin-bottom: 24px;
  padding: 22px 24px;
  border: 1px solid rgba(229, 220, 203, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.94), rgba(247, 238, 221, 0.88)),
    linear-gradient(90deg, rgba(125, 153, 124, 0.12), rgba(201, 154, 90, 0.12));
  box-shadow: var(--soft-shadow);
}

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

.auth-status {
  min-height: 46px;
}

.nav-auth-status {
  position: absolute;
  top: 0;
  right: 0;
  min-height: 32px;
  height: 32px;
  width: auto;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0 10px;
  font-size: 13px;
  color: #fffdf8;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.nav-auth-status svg {
  width: 15px;
  height: 15px;
}

.nav-auth-status:hover {
  background: rgba(255, 255, 255, 0.14);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(37, 48, 69, 0.42);
}

.auth-card {
  position: relative;
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

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

.code-row .ghost-button {
  min-height: 44px;
  white-space: nowrap;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--sage-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.14;
}

h2 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 12px;
}

h3 {
  font-size: 20px;
  line-height: 1.35;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.checkin-notice {
  margin: 18px 0 6px;
  padding: 12px 14px;
  border: 1px solid rgba(125, 153, 124, 0.32);
  border-radius: 8px;
  background: rgba(245, 250, 239, 0.78);
}

.checkin-notice.is-recorded {
  color: #3f674c;
  border-color: rgba(104, 151, 111, 0.42);
  background: rgba(235, 248, 230, 0.92);
}

.date-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.9fr);
  gap: 14px;
  margin-top: 16px;
  align-items: stretch;
}

.duration-card {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(125, 153, 124, 0.32);
  border-radius: 8px;
  background: #fffdf8;
}

.duration-card span {
  color: var(--muted);
  font-size: 13px;
}

.duration-card strong {
  color: var(--night);
  font-size: 18px;
}

.primary-action,
.solid-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--sage-dark), #637d5f);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.ghost-button {
  color: var(--ink);
  background: #fbf7ee;
  border: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 16px;
}

.home-checkin {
  margin-top: 16px;
  scroll-margin-top: 120px;
}

.hero-panel,
.score-panel,
.advice-panel,
.tree-panel,
.work-panel,
.summary-panel,
.checkin-form,
.chart-panel,
.timeline-panel,
.doctor-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  min-height: 330px;
  padding: 26px;
  display: grid;
  align-content: space-between;
  position: relative;
  overflow: hidden;
  color: #fffdf8;
  background:
    linear-gradient(140deg, rgba(37, 48, 69, 0.96), rgba(76, 94, 105, 0.88) 58%, rgba(157, 127, 88, 0.75)),
    radial-gradient(circle at 82% 20%, rgba(255, 239, 190, 0.35), transparent 28%);
  border-color: rgba(255, 246, 218, 0.28);
}

.night-visual {
  position: absolute;
  right: 28px;
  top: 28px;
  width: 180px;
  height: 150px;
  opacity: 0.96;
}

.moon {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: #ffe7a8;
  box-shadow: -20px 6px 0 #fff8dc inset, 0 0 34px rgba(255, 232, 172, 0.36);
  margin-left: auto;
}

.sleep-line {
  height: 14px;
  border-radius: 99px;
  background: rgba(255, 253, 248, 0.42);
  margin: 14px 0 0 auto;
}

.sleep-line.short {
  width: 92px;
  background: rgba(255, 224, 157, 0.55);
}

.hero-panel .eyebrow {
  color: #ffe7a8;
}

.hero-panel .muted {
  color: rgba(255, 253, 248, 0.78);
}

.home-record-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.home-record-summary span,
.home-record-summary strong {
  padding: 7px 10px;
  border-radius: 8px;
  color: #fffdf8;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 13px;
}

.home-record-summary strong {
  color: #ffe8ae;
}

.hero-panel .solid-button {
  color: var(--night);
  background: linear-gradient(135deg, #ffe8ae, #d8bd7b);
}

.score-panel,
.advice-panel,
.tree-panel,
.summary-panel,
.timeline-panel {
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(251, 246, 237, 0.96));
}

.score-row {
  display: flex;
  align-items: end;
  gap: 14px;
}

.score-row strong {
  font-size: 64px;
  line-height: 1;
  color: var(--night);
}

.score-row span {
  color: var(--sage-dark);
  padding-bottom: 9px;
}

.score-meter {
  height: 10px;
  background: #ede5d6;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 18px;
}

.score-meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--rose), var(--amber), var(--sage), var(--night-soft));
}

.score-meaning {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.score-meaning strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

.score-factors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.score-factors span {
  padding: 7px 9px;
  border-radius: 8px;
  background: #f7efe2;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.tree-panel {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tree-art {
  width: 110px;
  height: 130px;
  position: relative;
  flex: 0 0 auto;
}

.soil,
.stem,
.leaf {
  position: absolute;
}

.soil {
  width: 92px;
  height: 16px;
  border-radius: 50%;
  background: #a77f58;
  bottom: 8px;
  left: 8px;
}

.stem {
  width: 10px;
  height: 70px;
  background: #6f936a;
  bottom: 20px;
  left: 50px;
  border-radius: 99px;
}

.leaf {
  width: 50px;
  height: 32px;
  background: #7fa279;
  border-radius: 80% 20% 80% 20%;
  top: 32px;
}

.leaf.left {
  left: 8px;
  transform: rotate(-22deg);
}

.leaf.right {
  right: 8px;
  transform: scaleX(-1) rotate(-22deg);
}

.quick-band {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.quick-band button,
.quick-band a {
  min-height: 58px;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid var(--line);
  color: var(--ink);
  justify-content: center;
  box-shadow: var(--soft-shadow);
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.quick-band button:hover,
.quick-band a:hover {
  transform: translateY(-1px);
  border-color: rgba(77, 110, 87, 0.35);
  background: #fffaf0;
}

.split-layout,
.archive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.work-panel,
.checkin-form,
.chart-panel,
.doctor-band {
  padding: 24px;
}

.chat-window {
  height: 430px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(247, 242, 232, 0.92), rgba(250, 246, 239, 0.98)),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(229, 220, 203, 0.32) 38px 39px);
  border: 1px solid var(--line);
  border-radius: 8px;
}

#assessmentChat {
  height: auto;
  min-height: 96px;
  max-height: none;
  overflow: visible;
}

.bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-line;
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(65, 53, 36, 0.06);
}

.bubble.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, var(--night-soft), #667f74);
  border-color: transparent;
}

.option-grid,
.tag-list,
.factor-list,
.next-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.answer-area {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.assessment-question-card {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid rgba(229, 220, 203, 0.94);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(250, 246, 239, 0.96));
  box-shadow: 0 10px 24px rgba(65, 53, 36, 0.07);
}

.assessment-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.assessment-progress-row span:last-child {
  color: var(--sage-dark);
  font-weight: 700;
}

.assessment-progress-bar {
  height: 7px;
  margin: 12px 0 20px;
  overflow: hidden;
  border-radius: 99px;
  background: #ede5d6;
}

.assessment-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage-dark), var(--amber));
  transition: width 220ms ease;
}

.assessment-question-card .muted {
  margin: 0 0 8px;
  color: var(--sage-dark);
  font-weight: 700;
}

.assessment-question-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.35;
}

.assessment-question-card .option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.assessment-question-card .option-grid button {
  min-height: 52px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
  line-height: 1.35;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.assessment-question-card .option-grid button:not(.option-back):hover {
  transform: translateY(-1px);
  border-color: rgba(77, 110, 87, 0.42);
  background: #fffaf0;
}

.assessment-question-card .option-grid .option-back {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 36px;
  padding: 6px 2px;
  border: 0;
  color: var(--sage-dark);
  background: transparent;
  box-shadow: none;
}

#assessment .section-head {
  align-items: center;
}

#restartAssessment {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

.option-grid button,
.tag-list span,
.factor-list span,
.next-steps button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px 12px;
}

.next-steps {
  display: grid;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.next-steps button {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--ink);
}

.next-steps button:first-of-type {
  color: #fff;
  background: var(--sage-dark);
  border-color: var(--sage-dark);
}

.assessment-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.assessment-metrics div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.assessment-metrics span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.assessment-metrics strong {
  color: var(--night);
  font-size: 22px;
  line-height: 1.2;
}

.assessment-report-block {
  margin-top: 18px;
}

.dimension-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.dimension-item {
  display: grid;
  gap: 7px;
}

.dimension-item div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.dimension-item strong {
  color: var(--night);
}

.dimension-item i {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #ede5d6;
}

.dimension-item em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--night-soft));
}

.report-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.65;
}

.option-grid button:hover {
  border-color: var(--sage);
  background: #fff7e9;
}

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

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.auth-profile-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fffdf8;
}

input:focus,
select:focus {
  outline: 2px solid rgba(125, 153, 124, 0.25);
  border-color: var(--sage);
}

.toggle-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
}

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

.external-grid label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.external-grid input {
  width: 18px;
  height: 18px;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.archive-head span {
  color: var(--muted);
}

.chart-panel canvas {
  width: 100%;
  height: auto;
  display: block;
}

.trend-insight {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.trend-insight h3 {
  margin-bottom: 6px;
}

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

.timeline-item {
  border-left: 3px solid var(--sage);
  padding-left: 12px;
  background: linear-gradient(90deg, rgba(125, 153, 124, 0.08), transparent);
  border-radius: 0 8px 8px 0;
  padding-top: 8px;
  padding-bottom: 8px;
}

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

.chat-input {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 10px;
  margin-top: 12px;
}

.coach-profile-form {
  display: grid;
  gap: 0;
}

.empty-chat {
  display: grid;
  place-items: center;
}

.empty-state {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

.profile-summary {
  display: grid;
  gap: 12px;
}

.summary-line {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-line span {
  color: var(--muted);
}

.analysis-label {
  margin-top: 24px;
}

.icon-button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sage-dark), var(--night-soft));
  color: #fff;
  display: grid;
  place-items: center;
}

.doctor-contact {
  display: grid;
  gap: 16px;
}

.doctor-hero,
.doctor-image-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.doctor-hero {
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(246, 237, 223, 0.94));
}

.contact-list {
  display: grid;
  gap: 12px;
}

.contact-list a,
.contact-list div {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbf6ed;
  text-decoration: none;
  line-height: 1.5;
}

.contact-list svg {
  width: 20px;
  height: 20px;
  color: var(--sage-dark);
  flex: 0 0 auto;
}

.doctor-image-card {
  padding: 14px;
  background: #fffdf8;
}

.doctor-image-card img {
  width: 100%;
  display: block;
  border-radius: 8px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
    box-shadow: 0 12px 28px rgba(37, 48, 69, 0.18);
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    width: 100%;
    max-width: calc(100vw - 28px);
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .dashboard-grid,
  .split-layout,
  .archive-grid,
  .quick-band,
  .date-picker-row,
  .assessment-metrics,
  .form-grid,
  .doctor-hero {
    grid-template-columns: 1fr;
  }

  .topbar,
  .form-head,
  .section-head,
  .archive-head,
  .doctor-band {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 18px;
  }

  .brand span,
  .nav-item span {
    font-size: 12px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 24px;
  }

  .night-visual {
    opacity: 0.35;
  }

  .topbar {
    padding: 18px;
  }

  .top-actions,
  .top-actions button,
  .code-row {
    width: 100%;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

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

  .bubble {
    max-width: 92%;
  }
}

/* Mobile polish */
.option-grid .option-back {
  color: var(--sage-dark);
  background: #f5eee3;
  border-color: rgba(77, 110, 87, 0.22);
}

.option-grid .option-back::before {
  content: "‹";
  margin-right: 4px;
  font-size: 18px;
  line-height: 0;
}

@media (max-width: 980px) {
  body {
    background:
      radial-gradient(circle at 18px 18px, rgba(255, 255, 255, 0.86) 0 1px, transparent 1.6px),
      linear-gradient(180deg, #eef3f0 0%, #f6efe3 42%, #fbf5ea 100%);
    background-size: 82px 82px, auto;
  }

  .side-nav {
    gap: 14px;
    padding: 12px 12px 10px;
    border-bottom: 1px solid rgba(255, 246, 218, 0.1);
  }

  .brand {
    min-height: 46px;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .brand strong {
    font-size: 18px;
    line-height: 1.15;
  }

  .brand span {
    margin-top: 2px;
    font-size: 12px;
  }

  .brand > div:last-of-type {
    min-width: 0;
    padding-right: 116px;
  }

  .nav-auth-status {
    top: 5px;
    right: 0;
    min-height: 30px;
    height: 30px;
    max-width: 108px;
    padding: 0 8px;
    overflow: hidden;
    color: rgba(255, 253, 248, 0.92);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
  }

  .nav-auth-status span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .nav-list {
    gap: 8px;
    max-width: calc(100vw - 24px);
  }

  .nav-item {
    height: 40px;
    min-width: max-content;
    padding: 0 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
  }

  .nav-item.active {
    background: rgba(255, 246, 218, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .main {
    padding: 14px;
  }

  .topbar {
    margin-bottom: 14px;
    padding: 18px;
  }

  .topbar h1 {
    max-width: 11em;
    font-size: 30px;
    line-height: 1.18;
  }

  .dashboard-grid,
  .split-layout,
  .archive-grid {
    gap: 14px;
  }

  .hero-panel {
    min-height: 250px;
    padding: 22px;
  }

  .hero-panel h2 {
    max-width: 9em;
    line-height: 1.18;
  }

  .score-panel,
  .advice-panel,
  .tree-panel,
  .summary-panel,
  .timeline-panel,
  .work-panel,
  .checkin-form,
  .chart-panel,
  .doctor-band {
    padding: 18px;
    box-shadow: 0 10px 24px rgba(65, 53, 36, 0.08);
  }

  #assessment .section-head {
    align-items: center;
    flex-direction: row;
  }

  .assessment-question-card {
    margin-top: 14px;
    padding: 18px;
  }

  .assessment-question-card h3 {
    font-size: 24px;
  }

  .chat-window {
    height: 360px;
    padding: 14px;
    gap: 10px;
  }

  #assessmentChat {
    min-height: 128px;
  }

  .bubble {
    max-width: 88%;
    padding: 11px 13px;
    font-size: 15px;
  }

  .option-grid button {
    min-height: 42px;
    padding: 9px 12px;
  }
}

@media (max-width: 560px) {
  body {
    color: #17213e;
    background:
      linear-gradient(180deg, #e9edff 0%, #f7f8ff 34%, #fffaf3 100%);
    background-size: auto;
  }

  .side-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    z-index: 20;
    padding: 8px 10px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(147, 157, 221, 0.32);
    box-shadow: 0 14px 32px rgba(45, 57, 127, 0.2);
    backdrop-filter: blur(14px);
  }

  .brand {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    max-width: none;
    padding: 0;
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
    height: 54px;
    padding: 5px 2px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    color: #707894;
    background: transparent;
    border-radius: 18px;
    font-size: 11px;
    line-height: 1;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .nav-item span {
    max-width: 4em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .nav-item.active,
  .nav-item:hover {
    color: #5264dc;
    background: rgba(92, 111, 230, 0.1);
    box-shadow: none;
  }

  .main {
    padding: 12px 12px 92px;
  }

  .topbar {
    display: none;
  }

  .topbar .top-actions {
    display: none;
  }

  .topbar h1 {
    font-size: 25px;
  }

  .dashboard-grid {
    gap: 12px;
  }

  .hero-panel {
    min-height: 210px;
    padding: 22px;
    border: 0;
    border-radius: 26px;
    box-shadow: 0 22px 42px rgba(33, 48, 116, 0.2);
    background:
      radial-gradient(circle at 84% 24%, rgba(255, 237, 150, 0.95) 0 30px, transparent 32px),
      radial-gradient(circle at 76% 34%, rgba(255, 255, 255, 0.22) 0 2px, transparent 3px),
      radial-gradient(circle at 58% 18%, rgba(255, 255, 255, 0.28) 0 1px, transparent 2px),
      linear-gradient(155deg, #101a54 0%, #213b8f 58%, #7787e9 100%);
  }

  .hero-panel h2 {
    max-width: 8.5em;
    font-size: 27px;
    line-height: 1.16;
  }

  .hero-panel .muted {
    max-width: 16em;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.82);
  }

  .hero-panel .solid-button {
    min-height: 42px;
    width: fit-content;
    border-radius: 999px;
    color: #18225a;
    background: linear-gradient(135deg, #fff5b8, #ffd66b);
  }

  .night-visual {
    right: 18px;
    top: 18px;
    width: 128px;
    height: 120px;
    opacity: 0.72;
  }

  .moon {
    width: 62px;
    height: 62px;
  }

  .score-row strong {
    font-size: 66px;
    color: #13245d;
  }

  .score-panel,
  .advice-panel,
  .tree-panel,
  .checkin-form,
  .work-panel,
  .summary-panel,
  .timeline-panel,
  .chart-panel,
  .doctor-band {
    border: 0;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 30px rgba(74, 83, 142, 0.11);
  }

  .score-panel {
    padding: 20px;
  }

  .score-row {
    align-items: center;
  }

  .score-row span {
    padding: 6px 10px;
    border-radius: 999px;
    color: #5264dc;
    background: rgba(92, 111, 230, 0.12);
    font-weight: 700;
  }

  .score-meter {
    height: 8px;
    background: #e8ebfb;
  }

  .score-meter span {
    background: linear-gradient(90deg, #7d8cff, #ffd66b);
  }

  .score-meaning {
    margin-top: 14px;
    padding-top: 12px;
  }

  .score-factors span,
  .tag-list span,
  .factor-list span {
    border: 0;
    border-radius: 999px;
    color: #596070;
    background: #f1f3ff;
  }

  .tree-panel {
    align-items: flex-start;
  }

  .tree-art {
    width: 82px;
    height: 110px;
    transform: scale(0.82);
    transform-origin: left top;
  }

  .work-panel,
  .checkin-form,
  .chart-panel,
  .timeline-panel,
  .summary-panel,
  .score-panel,
  .advice-panel,
  .tree-panel,
  .doctor-band {
    padding: 16px;
  }

  .quick-band {
    display: none;
  }

  .home-checkin {
    margin-top: 12px;
    scroll-margin-top: 12px;
  }

  .form-head {
    gap: 8px;
  }

  .form-head h2,
  .section-head h2 {
    font-size: 22px;
  }

  .date-picker-row,
  .form-grid {
    gap: 10px;
  }

  .duration-card,
  .checkin-notice {
    border: 0;
    border-radius: 18px;
    background: #f4f6ff;
  }

  .checkin-form input,
  .checkin-form select,
  .checkin-form textarea {
    min-height: 46px;
    border-radius: 16px;
    border-color: #e3e6f5;
    background: #fbfcff;
  }

  .form-actions {
    position: sticky;
    bottom: 10px;
    z-index: 1;
    margin: 16px -4px -4px;
    padding: 10px 4px 4px;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0), var(--surface) 42%);
  }

  .form-actions .primary-action,
  .form-actions .solid-button {
    min-height: 46px;
    width: 100%;
    border-radius: 18px;
    background: linear-gradient(135deg, #5367df, #7f8df1);
  }

  .chat-window {
    height: min(58vh, 390px);
  }

  #assessmentChat {
    min-height: 120px;
  }

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

  .assessment-question-card .option-grid {
    gap: 10px;
  }

  .assessment-question-card .option-grid button {
    min-height: 50px;
    padding: 10px 8px;
    font-size: 15px;
  }

  .option-grid button {
    width: 100%;
    white-space: normal;
    line-height: 1.35;
  }

  .option-grid .option-back {
    grid-column: 1 / -1;
  }

  .timeline-item {
    padding-left: 14px;
  }
}
