:root {
  --bg: #f6f1e8;
  --bg-soft: rgba(255, 252, 245, 0.74);
  --surface: rgba(255, 251, 246, 0.88);
  --surface-strong: #fffdf8;
  --line: rgba(64, 88, 88, 0.12);
  --text: #243033;
  --muted: #657679;
  --brand: #275f61;
  --brand-soft: rgba(39, 95, 97, 0.1);
  --accent: #bf6c41;
  --accent-soft: rgba(191, 108, 65, 0.12);
  --morning: #6eae62;
  --morning-soft: rgba(110, 174, 98, 0.16);
  --afternoon: #d49a4d;
  --afternoon-soft: rgba(212, 154, 77, 0.18);
  --bedtime: #587589;
  --bedtime-soft: rgba(88, 117, 137, 0.16);
  --danger: #b54646;
  --danger-soft: rgba(181, 70, 70, 0.12);
  --shadow: 0 20px 45px rgba(31, 44, 54, 0.12);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(212, 154, 77, 0.16), transparent 28%),
    radial-gradient(circle at right 12% top 18%, rgba(39, 95, 97, 0.16), transparent 24%),
    linear-gradient(180deg, #f8f4ec 0%, #f2ece0 100%);
  font-family: var(--font-body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.16) 42%, transparent 62%),
    repeating-linear-gradient(
      0deg,
      rgba(45, 69, 70, 0.015) 0,
      rgba(45, 69, 70, 0.015) 1px,
      transparent 1px,
      transparent 9px
    );
}

.background-glow {
  position: fixed;
  width: 18rem;
  height: 18rem;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.35;
  pointer-events: none;
}

.background-glow--left {
  top: 14%;
  left: -8rem;
  background: rgba(212, 154, 77, 0.3);
}

.background-glow--right {
  right: -7rem;
  bottom: 12%;
  background: rgba(39, 95, 97, 0.28);
}

.page-shell {
  position: relative;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  padding: 24px 20px;
  background:
    radial-gradient(circle at top right, rgba(191, 108, 65, 0.16), transparent 32%),
    linear-gradient(135deg, rgba(39, 95, 97, 0.08), rgba(255, 255, 255, 0.72));
}

.hero__eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero__content {
  max-width: 860px;
}

.hero__label {
  margin: 0;
  color: var(--brand);
  font-size: 1rem;
  font-weight: 800;
}

.hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.1;
}

.hero__description,
.section-copy,
.history-footnote {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 0;
}

.form-card,
.history-card {
  padding: 22px 20px;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head--wrap {
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.notice,
.form-feedback {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.notice {
  margin-bottom: 18px;
  border: 1px solid rgba(39, 95, 97, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.notice.is-warning {
  border-color: rgba(181, 70, 70, 0.16);
  background: var(--danger-soft);
  color: #7e2d2d;
}

.notice.is-success {
  background: var(--brand-soft);
  color: var(--brand);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.95rem;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

.auto-slot {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 14px 15px;
  border: 1px solid rgba(39, 95, 97, 0.12);
  border-radius: var(--radius-md);
  background: rgba(39, 95, 97, 0.08);
  color: var(--brand);
  font-weight: 700;
}

.auto-slot.is-empty {
  background: rgba(181, 70, 70, 0.08);
  border-color: rgba(181, 70, 70, 0.16);
  color: #8b3535;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

input:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: rgba(39, 95, 97, 0.4);
  box-shadow: 0 0 0 4px rgba(39, 95, 97, 0.1);
}

input::placeholder {
  color: rgba(101, 118, 121, 0.8);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;
}

.button:hover,
.slot-button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.slot-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  background: linear-gradient(135deg, var(--brand) 0%, #2f7879 100%);
  color: white;
  box-shadow: 0 12px 26px rgba(39, 95, 97, 0.22);
}

.button--ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border: 1px solid rgba(39, 95, 97, 0.08);
}

.button--danger {
  background: rgba(181, 70, 70, 0.12);
  color: var(--danger);
}

.form-feedback {
  min-height: 50px;
  margin: 14px 0 0;
  color: var(--muted);
}

.form-feedback.is-error {
  background: var(--danger-soft);
  color: #7e2d2d;
}

.form-feedback.is-success {
  background: rgba(110, 174, 98, 0.14);
  color: #396235;
}

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

.slot-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 253, 249, 0.82);
  min-height: 176px;
}

.slot-card--morning {
  background: linear-gradient(180deg, rgba(110, 174, 98, 0.16), rgba(255, 253, 249, 0.96));
}

.slot-card--afternoon {
  background: linear-gradient(180deg, rgba(212, 154, 77, 0.16), rgba(255, 253, 249, 0.96));
}

.slot-card--bedtime {
  background: linear-gradient(180deg, rgba(88, 117, 137, 0.16), rgba(255, 253, 249, 0.96));
}

.slot-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.slot-card__eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.slot-card--morning .slot-card__eyebrow,
.slot-heading--morning {
  color: #3f7d36;
}

.slot-card--morning .slot-card__eyebrow::before {
  background: var(--morning);
}

.slot-card--afternoon .slot-card__eyebrow,
.slot-heading--afternoon {
  color: #9a6720;
}

.slot-card--afternoon .slot-card__eyebrow::before {
  background: var(--afternoon);
}

.slot-card--bedtime .slot-card__eyebrow,
.slot-heading--bedtime {
  color: #416075;
}

.slot-card--bedtime .slot-card__eyebrow::before {
  background: var(--bedtime);
}

.slot-card h3 {
  margin: 0;
  font-size: 1rem;
}

.slot-card__value {
  margin: 16px 0 6px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.slot-card__meta,
.slot-card__placeholder {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.slot-card__placeholder {
  margin-top: 16px;
}

.slot-card__action {
  margin-top: 14px;
}

.slot-button {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(39, 95, 97, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}

.history-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  margin-bottom: 16px;
}

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(39, 95, 97, 0.08);
  font-weight: 700;
}

.legend-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-chip--systolic {
  color: var(--accent);
}

.legend-chip--systolic::before {
  background: var(--accent);
}

.legend-chip--diastolic {
  color: var(--brand);
}

.legend-chip--diastolic::before {
  background: var(--brand);
}

.history-chart-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  text-align: right;
  font-size: 1rem;
}

.history-chart-scroll {
  margin-top: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
}

.history-chart {
  display: inline-block;
  min-width: 100%;
}

.history-svg {
  display: block;
  height: auto;
  max-width: none;
}

.history-editor-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid rgba(39, 95, 97, 0.08);
}

.history-editor-head {
  margin-bottom: 10px;
}

.history-editor-head h3 {
  margin: 0;
  font-size: 1.2rem;
}

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

.history-editor-pager {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.history-editor-page-button {
  padding: 9px 14px;
}

.history-editor-page-info {
  min-width: 52px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

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

.history-editor-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(39, 95, 97, 0.08);
  box-shadow: 0 8px 18px rgba(31, 44, 54, 0.04);
}

.history-editor-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-editor-card__top--compact {
  flex-direction: row;
  align-items: center;
}

.history-editor-card__date,
.history-editor-card__meta {
  margin: 0;
}

.history-editor-card__date {
  font-size: 0.96rem;
  font-weight: 800;
}

.history-editor-card__meta {
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.9rem;
  font-weight: 700;
}

.history-editor-compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}

.history-editor-inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.history-editor-inline-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.history-editor-inline-field input {
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.18rem;
  font-weight: 800;
}

.history-editor-inline-field:focus-within {
  border-color: rgba(39, 95, 97, 0.4);
  box-shadow: 0 0 0 4px rgba(39, 95, 97, 0.1);
}

.history-editor-save {
  min-width: 78px;
  padding: 10px 16px;
  align-self: stretch;
}

.history-axis-label {
  fill: rgba(101, 118, 121, 0.92);
  font-size: 16px;
  font-weight: 700;
}

.history-x-label {
  fill: rgba(101, 118, 121, 0.95);
  font-size: 15px;
  font-weight: 700;
}

.empty-state {
  padding: 22px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  line-height: 1.6;
}

.animate-rise {
  animation: rise-in 0.55s ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .slot-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 14px 12px 30px;
  }

  .hero,
  .form-card,
  .history-card {
    padding: 18px 16px;
    border-radius: 24px;
  }

  .field-grid,
  .field-grid--values,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-chart-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-chart-copy {
    text-align: left;
  }

  .history-editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-editor-card__top {
    flex-direction: column;
  }

  .history-editor-card__top--compact {
    flex-direction: row;
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .animate-rise,
  .button,
  .slot-button,
  input,
  select {
    animation: none !important;
    transition: none !important;
  }
}
