:root {
  color-scheme: dark;
  --bg: #050607;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.11);
  --text: #f6f7f7;
  --muted: #8d969b;
  --green: #35e58f;
  --cyan: #5fd8ff;
  --amber: #ffcc66;
  --coral: #ff6b6b;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.34);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 22% 0%, rgba(53, 229, 143, 0.14), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(95, 216, 255, 0.1), transparent 25%),
    linear-gradient(180deg, #080b0c 0%, var(--bg) 42%, #07090a 100%);
  color: var(--text);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px 48px;
}

.hero,
.section-title,
.status-card,
.tabs,
.mini-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero {
  padding: 16px 4px 20px;
}

.eyebrow,
.muted,
small {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

h2 {
  font-size: 22px;
  letter-spacing: 0;
}

.icon-button,
.primary-button,
.ghost-button,
.tab {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel);
  backdrop-filter: blur(24px);
}

.ghost-button {
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 23px;
}

.icon-button span {
  display: inline-block;
}

.icon-button.loading span {
  animation: rotate 0.8s linear infinite;
}

.status-card,
.panel,
.recovery-card,
.metric-card {
  border: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.04)),
    rgba(8, 11, 12, 0.44);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
}

.status-card {
  padding: 18px;
  border-radius: 24px;
  margin-bottom: 16px;
}

.status-card p {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.status-pills span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.055);
  color: #dce4e6;
  font-size: 13px;
  font-weight: 700;
}

.status-pills i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-pills .ok i {
  background: var(--green);
}

.status-pills .warn {
  color: #c7ced2;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  height: 48px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}

.primary-button.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.today-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(2, 1fr);
  gap: 12px;
}

.recovery-card {
  grid-row: span 2;
  min-height: 286px;
  padding: 22px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.recovery-card p {
  color: var(--muted);
  line-height: 1.55;
  margin-top: 8px;
}

.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

.ring {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 13;
}

.ring-track {
  stroke: rgba(255, 255, 255, 0.09);
}

.ring-value {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  filter: drop-shadow(0 0 16px rgba(53, 229, 143, 0.45));
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-center span {
  font-size: 42px;
  font-weight: 800;
}

.metric-card {
  min-height: 128px;
  padding: 18px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  animation: floatIn 0.7s both;
}

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

.metric-card strong {
  font-size: 31px;
  letter-spacing: 0;
}

.accent-cyan {
  border-color: rgba(95, 216, 255, 0.22);
}

.accent-amber {
  border-color: rgba(255, 204, 102, 0.22);
}

.accent-green {
  border-color: rgba(53, 229, 143, 0.22);
}

.accent-coral {
  border-color: rgba(255, 107, 107, 0.24);
}

.panel {
  padding: 22px;
  border-radius: 24px;
  min-height: 218px;
  margin-top: 14px;
  animation: panelIn 0.35s both;
}

#overview {
  margin-top: 20px;
}

.section-title {
  margin-bottom: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 14px;
}

.recommendation {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  color: #d9eeee;
  line-height: 1.65;
}

.pulse {
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(53, 229, 143, 0.42);
  animation: pulse 2.2s infinite;
}

.ai-insight {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(95, 216, 255, 0.16);
  background: rgba(95, 216, 255, 0.07);
}

.ai-insight p {
  margin-top: 8px;
  white-space: pre-wrap;
  color: #dceff6;
  line-height: 1.65;
}

.compact-button {
  min-width: 104px;
  height: 42px;
  border-radius: 14px;
}

.mini-grid {
  margin-top: 24px;
}

.mini-grid > div {
  flex: 1;
  min-height: 84px;
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid var(--border);
}

.note-box,
.chat-box {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.tag-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tag-grid button {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font-weight: 700;
}

.tag-grid button.selected {
  color: #06100b;
  background: var(--green);
  border-color: transparent;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
  font: inherit;
  line-height: 1.5;
}

.form-button {
  border: 0;
  width: fit-content;
}

.coach-answer {
  white-space: pre-wrap;
  line-height: 1.65;
  padding: 16px;
  border-radius: 18px;
  background: rgba(53, 229, 143, 0.08);
  border: 1px solid rgba(53, 229, 143, 0.18);
  color: #dff8ea;
}

.wide-button {
  width: 100%;
  margin-top: 14px;
}

.mini-grid strong {
  display: block;
  margin-top: 8px;
}

.sleep-timeline {
  display: flex;
  height: 44px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.sleep-timeline span {
  display: block;
  animation: grow 1s both;
}

.awake {
  background: #f5f6f6;
}

.light {
  background: var(--cyan);
}

.deep {
  background: #35e58f;
}

.rem {
  background: var(--amber);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
}

.gauge {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  margin: 20px 0;
}

.gauge-fill {
  width: 58%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--coral));
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.chart {
  width: 100%;
  height: 190px;
}

.grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  animation: drawLine 1.2s 0.2s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

.line.green {
  stroke: var(--green);
}

.line.cyan {
  stroke: var(--cyan);
}

.line.amber {
  stroke: var(--amber);
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 14px rgba(53, 229, 143, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(53, 229, 143, 0);
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes grow {
  from {
    transform: scaleX(0.2);
    transform-origin: left;
  }
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: max(18px, env(safe-area-inset-top)) 14px 36px;
  }

  .status-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-insight {
    grid-template-columns: 1fr;
  }

  .today-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 520px) {
  .hero {
    align-items: flex-start;
  }

  .hero-actions {
    padding-top: 6px;
  }

  .ghost-button {
    display: none;
  }

  h1 {
    font-size: 40px;
  }

  .today-grid,
  .mini-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-card,
  .recovery-card,
  .metric-card,
  .panel {
    border-radius: 24px;
  }

  .status-card {
    padding: 16px;
  }

  .recovery-card {
    min-height: 0;
    gap: 22px;
  }

  .metric-card {
    min-height: 118px;
  }

  .ring-wrap,
  .ring {
    width: 164px;
    height: 164px;
  }
}
