:root {
  color-scheme: light;
  --background: #f4f6fb;
  --background-top: #fbfcff;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --line: rgba(61, 76, 108, 0.12);
  --line-strong: rgba(61, 76, 108, 0.18);
  --text: #202633;
  --muted: #737b8d;
  --muted-light: #a5acba;
  --accent: #556fad;
  --accent-pressed: #455f9e;
  --accent-soft: #e9edfa;
  --night: #535e8e;
  --night-deep: #48557f;
  --morning: #b68269;
  --shadow: 0 12px 30px rgba(54, 67, 97, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: linear-gradient(180deg, var(--background-top) 0, var(--background) 72%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled),
input:not(:disabled),
textarea:not(:disabled) {
  touch-action: manipulation;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(85, 111, 173, 0.28);
  outline-offset: 3px;
}

#app,
.app-shell {
  height: 100dvh;
  min-height: 0;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  margin: 0 auto;
  overflow: hidden;
}

.app-main {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(28px, env(safe-area-inset-top)) 20px 28px;
  -webkit-overflow-scrolling: touch;
}

.page {
  width: 100%;
}

.page-enter {
  animation: page-in 220ms ease-out both;
}

.app-name,
.focus-kicker,
.time-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.today-header,
.month-header {
  padding: 8px 2px 28px;
}

.today-header h1,
.month-header h1,
.flow-intro h1,
.detail-heading h1 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 34px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.16;
}

.today-prompt {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.focus-card {
  display: grid;
  gap: 16px;
  min-height: 276px;
  padding: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.focus-card--ready {
  align-content: center;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(239, 243, 255, 0.92));
}

.focus-card--night,
.focus-card--sleeping {
  background: linear-gradient(145deg, var(--night) 0, var(--night-deep) 100%);
  border-color: rgba(62, 73, 113, 0.36);
  color: #f8f9ff;
}

.focus-card--morning {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 240, 236, 0.98));
}

.focus-card--complete {
  align-content: start;
  background: var(--surface);
}

.focus-card--night .focus-kicker,
.focus-card--sleeping .focus-kicker {
  color: rgba(248, 249, 255, 0.74);
}

.focus-symbol {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: rgba(85, 111, 173, 0.1);
  color: var(--accent);
  font-size: 29px;
  line-height: 1;
}

.focus-card--night .focus-symbol,
.focus-card--sleeping .focus-symbol {
  background: rgba(255, 255, 255, 0.12);
  color: #f5f7ff;
}

.focus-card--morning .focus-symbol {
  background: rgba(182, 130, 105, 0.12);
  color: var(--morning);
}

.focus-copy {
  display: grid;
  gap: 5px;
}

.focus-copy h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.28;
}

.sleep-duration {
  display: block;
  color: inherit;
  font-size: 36px;
  font-weight: 730;
  letter-spacing: 0;
  line-height: 1.12;
}

.focus-card--complete .sleep-duration {
  color: var(--text);
}

.sleep-times {
  margin: -8px 0 2px;
  color: var(--muted);
  font-size: 16px;
}

.quick-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 249, 253, 0.9);
}

.quick-facts div {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 13px 14px;
}

.quick-facts div + div {
  border-left: 1px solid var(--line);
}

.quick-facts span {
  color: var(--muted);
  font-size: 12px;
}

.quick-facts strong {
  font-size: 18px;
  font-weight: 680;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 54px;
  transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.primary-button {
  width: 100%;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(73, 94, 152, 0.22);
  font-size: 17px;
  font-weight: 680;
}

.focus-card--night .primary-button,
.focus-card--sleeping .primary-button {
  background: #f6f7ff;
  color: var(--night-deep);
  box-shadow: none;
}

.primary-button:hover {
  background: var(--accent-pressed);
}

.focus-card--night .primary-button:hover,
.focus-card--sleeping .primary-button:hover {
  background: #fff;
}

.primary-button:active,
.secondary-button:active,
.text-button:active,
.nav-item:active,
.month-row--record:active,
.icon-button:active {
  transform: scale(0.985);
}

.secondary-button {
  width: 100%;
  margin-top: 14px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--accent-pressed);
  font-size: 16px;
  font-weight: 650;
}

.text-button {
  width: fit-content;
  min-height: 38px;
  padding: 0;
  background: transparent;
  color: var(--accent-pressed);
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}

.flow-page,
.detail-page {
  padding-bottom: 26px;
}

.flow-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 48px;
  margin: -7px 0 31px;
}

.flow-header strong {
  font-size: 16px;
  font-weight: 680;
  text-align: center;
}

.flow-header-spacer {
  width: 44px;
  height: 44px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  transition: transform 140ms ease, background-color 140ms ease;
}

.flow-back {
  font-size: 31px;
}

.flow-intro {
  margin-bottom: 28px;
}

.flow-intro h1 {
  margin-top: 8px;
}

.flow-intro > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.checkin-form {
  display: grid;
  gap: 12px;
}

.rating-control,
.note-field,
.time-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(54, 67, 97, 0.035);
}

.rating-control {
  padding: 17px 17px 15px;
}

.rating-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.rating-topline output {
  color: var(--accent-pressed);
  font-size: 14px;
  font-weight: 700;
}

.rating-slider {
  display: block;
  width: 100%;
  height: 48px;
  margin: 6px 0 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.rating-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--range-progress), #dde2ec var(--range-progress) 100%);
}

.rating-slider::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border: 5px solid #fff;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent);
  box-shadow: 0 3px 9px rgba(49, 65, 105, 0.23);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.rating-slider:active::-webkit-slider-thumb {
  transform: scale(1.12);
  box-shadow: 0 4px 13px rgba(49, 65, 105, 0.3);
}

.rating-slider::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: #dde2ec;
}

.rating-slider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.rating-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 3px 9px rgba(49, 65, 105, 0.23);
}

.rating-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 560;
}

.rating-caption {
  min-height: 21px;
  margin: 7px 0 0;
  color: var(--accent-pressed);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

.note-field {
  display: grid;
  gap: 11px;
  padding: 17px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.note-field textarea {
  width: 100%;
  min-height: 108px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(249, 250, 253, 0.96);
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
}

.note-field textarea::placeholder {
  color: var(--muted-light);
}

.note-field small {
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.month-header {
  padding-bottom: 20px;
}

.month-switcher {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.month-switcher strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 690;
  text-align: center;
}

.month-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(54, 67, 97, 0.035);
}

.month-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 20px;
  align-items: center;
  width: 100%;
  min-height: 75px;
  padding: 10px 15px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.month-row:last-child {
  border-bottom: 0;
}

.month-row--record {
  background: rgba(255, 255, 255, 0.36);
  transition: background-color 140ms ease, transform 140ms ease;
}

.month-row--record:hover {
  background: rgba(239, 243, 255, 0.78);
}

.month-row--empty {
  min-height: 46px;
  padding-top: 5px;
  padding-bottom: 5px;
  opacity: 0.53;
}

.date-cell {
  display: grid;
  gap: 3px;
}

.date-cell strong {
  font-size: 16px;
  font-weight: 680;
}

.date-cell span {
  color: var(--muted);
  font-size: 12px;
}

.month-summary {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.month-summary strong {
  font-size: 16px;
  font-weight: 680;
}

.month-summary span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-chevron {
  color: var(--muted-light);
  font-size: 27px;
  line-height: 1;
  text-align: right;
}

.detail-heading {
  padding: 4px 2px 25px;
}

.detail-heading h1 {
  margin-top: 8px;
}

.detail-heading > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.detail-list {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(54, 67, 97, 0.035);
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.9fr) minmax(0, 1.4fr);
  gap: 12px;
  min-height: 58px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row dt {
  color: var(--muted);
  font-size: 14px;
}

.detail-row dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 590;
  line-height: 1.5;
  text-align: right;
  overflow-wrap: anywhere;
}

.detail-row--note {
  align-items: start;
  min-height: 82px;
}

.detail-row--note dt,
.detail-row--note dd {
  padding-top: 2px;
}

.time-editor {
  display: grid;
  overflow: hidden;
}

.time-editor label {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 14px;
}

.time-editor label + label {
  border-top: 1px solid var(--line);
}

.time-editor input {
  min-width: 0;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: right;
}

.bottom-nav {
  z-index: 10;
  flex: 0 0 auto;
  width: auto;
  margin: 0 20px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  min-height: 58px;
  padding: 5px;
  border: 1px solid rgba(61, 76, 108, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(54, 67, 97, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-item {
  min-height: 46px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 620;
  transition: transform 140ms ease, color 140ms ease, background-color 140ms ease;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-pressed);
  font-weight: 700;
}

.toast-region {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: calc(89px + env(safe-area-inset-bottom));
  left: 20px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  max-width: min(100%, 390px);
  padding: 11px 15px;
  border-radius: 8px;
  background: rgba(32, 38, 51, 0.9);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

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

@media (min-width: 481px) {
  .app-shell {
    border-right: 1px solid rgba(61, 76, 108, 0.08);
    border-left: 1px solid rgba(61, 76, 108, 0.08);
  }
}

@media (max-width: 360px) {
  .app-main {
    padding-right: 16px;
    padding-left: 16px;
  }

  .focus-card {
    padding: 22px;
  }

  .today-header h1,
  .month-header h1,
  .flow-intro h1,
  .detail-heading h1 {
    font-size: 31px;
  }

  .month-summary span {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
