:root {
  color-scheme: light;
  --bg: #101200;
  --paper: #f5f2e9;
  --paper-soft: #fbfaf5;
  --ink: #111316;
  --muted: #74746a;
  --line: rgba(17, 19, 22, 0.12);
  --line-strong: rgba(17, 19, 22, 0.2);
  --accent: #f2c744;
  --accent-strong: #d8aa13;
  --danger: #b84e4e;
  --shadow: 0 28px 80px rgba(16, 18, 0, 0.2);
  --radius: 8px;
  font-family:
    Inter, "Arial Narrow", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

:root.dark {
  color-scheme: dark;
  --bg: #080a00;
  --paper: #171812;
  --paper-soft: #202119;
  --ink: #f5f2e9;
  --muted: #aaa99d;
  --line: rgba(245, 242, 233, 0.14);
  --line-strong: rgba(245, 242, 233, 0.24);
  --accent: #f2c744;
  --accent-strong: #ffd95b;
  --danger: #ee7777;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

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

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1080px, calc(100% - 48px));
  margin: 0 auto;
  padding: 56px 0;
}

.topbar {
  height: 54px;
  position: sticky;
  top: 18px;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: rgba(245, 242, 233, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(18px);
}

.brand-mark,
.side-brand,
.site-footer strong {
  font-weight: 950;
  letter-spacing: -0.03em;
}

.top-links {
  display: flex;
  gap: 20px;
  color: rgba(17, 19, 22, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.top-actions,
.hero-actions,
.history-actions,
.form-actions,
.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button,
.pill-button,
.subtle-button,
.primary-button,
.danger-button,
.import-button,
.item-actions button,
select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
}

.icon-button,
.pill-button {
  min-width: 38px;
  height: 34px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.primary-button,
.subtle-button,
.danger-button,
.import-button,
.item-actions button,
.ghost-on-dark {
  min-height: 42px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
}

.primary-button {
  border-color: transparent;
  background: var(--accent);
  color: #141300;
}

.ghost-on-dark {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.danger-button {
  border-color: rgba(184, 78, 78, 0.36);
  color: var(--danger);
}

.hero-section {
  position: relative;
  min-height: 650px;
  margin-top: -54px;
  overflow: hidden;
  background: #161616;
  box-shadow: var(--shadow);
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.hero-section::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.68), rgba(0, 0, 0, 0.18) 56%, rgba(0, 0, 0, 0.26)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.62), transparent 42%);
}

.hero-overlay {
  position: relative;
  z-index: 1;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 120px 48px 132px;
  color: white;
}

.hero-rating {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 720px;
  font-size: clamp(54px, 9vw, 116px);
  line-height: 0.82;
  font-weight: 1000;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.9;
  font-weight: 1000;
  text-transform: uppercase;
}

.hero-actions {
  margin-top: 28px;
}

.hero-stat-strip {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 26px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(18px);
}

.hero-stat-strip div {
  min-height: 118px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(10, 10, 8, 0.36);
  color: white;
}

.hero-stat-strip span,
.hero-stat-strip small,
.section-head p,
.intro-copy p,
.coach-card p,
.history-item p,
.site-footer p {
  color: var(--muted);
}

.hero-stat-strip span,
.section-index,
label,
fieldset {
  font-size: 12px;
  font-weight: 900;
}

.hero-stat-strip small {
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.35;
}

.hero-stat-strip strong {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.section-band,
.app-workspace,
.site-footer {
  background: var(--paper);
}

.intro-section {
  min-height: 360px;
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 54px;
  padding: 88px 48px;
  border-bottom: 1px solid var(--line);
}

.section-index {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  text-transform: uppercase;
}

.section-index span {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #151400;
  font-size: 11px;
}

.intro-copy {
  max-width: 700px;
}

.intro-copy p,
.section-head p {
  max-width: 560px;
  line-height: 1.6;
}

.coach-card {
  margin-top: 30px;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}

.coach-title {
  margin: 0 0 6px;
  color: var(--ink);
  font-weight: 1000;
  text-transform: uppercase;
}

#coachText {
  margin: 0;
  line-height: 1.6;
}

.app-workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.side-panel {
  min-height: 720px;
  padding: 48px 28px;
  border-right: 1px solid var(--line);
}

.side-brand {
  margin-bottom: 48px;
  font-size: 28px;
}

.tabs {
  display: grid;
  gap: 10px;
  position: sticky;
  top: 92px;
}

.tab {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}

.tab.is-active {
  border-color: var(--line-strong);
  background: var(--paper-soft);
  color: var(--ink);
}

.content-panel {
  min-height: 720px;
  padding: 48px;
}

.view {
  display: none;
}

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

.entry-form,
.settings-form {
  display: grid;
  gap: 24px;
}

.section-head {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 28px;
  align-items: start;
  margin-bottom: 28px;
}

.section-head p {
  margin: 12px 0 0;
}

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

label,
fieldset {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 0;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-strong);
}

.habit-row,
.medicine-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.habit-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.habit-row legend,
.medicine-panel legend {
  padding: 0 8px;
  color: var(--ink);
}

.habit-row label,
.medicine-check {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
}

.habit-row input,
.medicine-check input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--accent);
}

.medicine-panel {
  display: grid;
  gap: 12px;
}

.medicine-check {
  width: fit-content;
}

.note-label {
  display: block;
}

.chart-wrap {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  overflow: hidden;
}

#weightChart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: var(--ink);
}

.chart-label {
  fill: var(--muted);
  font-size: 14px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 18px;
  background: var(--line);
  border: 1px solid var(--line);
}

.insight {
  min-height: 118px;
  padding: 18px;
  background: var(--paper-soft);
}

.insight span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.insight strong {
  display: block;
  margin-top: 18px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.04em;
}

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

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.history-item time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.history-item strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.history-item p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.item-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.empty-state {
  padding: 48px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.site-footer {
  min-height: 300px;
  padding: 70px 48px 52px;
}

.site-footer h2 {
  font-size: clamp(48px, 8vw, 94px);
  text-align: center;
}

.site-footer > div {
  margin-top: 56px;
  display: grid;
  grid-template-columns: 0.7fr 1fr;
  gap: 40px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.site-footer p {
  max-width: 380px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 1080px);
    padding: 28px 0;
  }

  .topbar {
    top: 10px;
  }

  .hero-stat-strip,
  .intro-section,
  .app-workspace,
  .section-head {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-brand {
    margin-bottom: 18px;
  }

  .tabs {
    grid-template-columns: repeat(4, 1fr);
    position: static;
  }

  .tab {
    text-align: center;
  }

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

@media (max-width: 640px) {
  html {
    scroll-padding-top: 80px;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 58px;
    margin: 0;
    border: 0;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  }

  .top-links {
    display: none;
  }

  .top-actions {
    gap: 8px;
  }

  .icon-button,
  .pill-button {
    min-width: 42px;
    height: 40px;
  }

  .hero-section {
    margin-top: 0;
    min-height: 650px;
    box-shadow: none;
  }

  .hero-section::after {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.16) 72%),
      linear-gradient(0deg, rgba(0, 0, 0, 0.78), transparent 52%);
  }

  .hero-overlay {
    min-height: 0;
    padding: 58px 18px 330px;
  }

  .hero-rating {
    margin-bottom: 10px;
    font-size: 12px;
  }

  h1 {
    max-width: 340px;
    font-size: 42px;
    line-height: 0.9;
  }

  h2 {
    font-size: 30px;
    line-height: 1;
  }

  .hero-actions {
    width: 100%;
    margin-top: 22px;
  }

  .hero-actions > * {
    flex: 1;
  }

  .hero-stat-strip {
    left: 16px;
    right: 16px;
    bottom: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-stat-strip div {
    min-height: 94px;
    padding: 12px;
  }

  .hero-stat-strip strong {
    font-size: 27px;
  }

  .hero-stat-strip small {
    font-size: 11px;
  }

  .intro-section,
  .content-panel,
  .side-panel,
  .site-footer {
    padding: 34px 22px;
  }

  .intro-section {
    min-height: auto;
    gap: 22px;
  }

  .intro-copy p,
  .section-head p,
  #coachText {
    line-height: 1.55;
  }

  .side-panel {
    padding-top: 20px;
    padding-bottom: 18px;
  }

  .side-brand {
    display: none;
  }

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

  .tab {
    min-height: 42px;
    padding: 0 8px;
    text-align: center;
    font-size: 12px;
  }

  .content-panel {
    padding-top: 28px;
  }

  .form-grid,
  .medicine-grid,
  .insight-grid,
  .site-footer > div {
    grid-template-columns: 1fr;
  }

  .section-head {
    gap: 14px;
    margin-bottom: 22px;
  }

  .section-head,
  .history-item {
    align-items: stretch;
  }

  input,
  select,
  textarea {
    min-height: 52px;
    font-size: 16px;
  }

  .habit-row,
  .medicine-panel {
    padding: 14px;
  }

  .habit-row label,
  .medicine-check {
    min-height: 42px;
  }

  .chart-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #weightChart {
    min-width: 680px;
    min-height: 270px;
  }

  .history-item {
    flex-direction: column;
  }

  .history-actions,
  .form-actions,
  .item-actions {
    width: 100%;
  }

  .history-actions > *,
  .form-actions > *,
  .item-actions > * {
    flex: 1;
  }

  .site-footer h2 {
    text-align: left;
  }
}
