:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f4f7f5;
  --surface: #fbfcfb;
  --surface-strong: #e9efec;
  --ink: #14201b;
  --muted: #5d6b65;
  --line: #d8e0dc;
  --accent: #176f5b;
  --accent-dark: #0d4e40;
  --accent-soft: #d7ebe4;
  --danger: #a23e35;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(37, 62, 52, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 92% 5%, rgba(23, 111, 91, 0.1), transparent 24rem),
    var(--bg);
  color: var(--ink);
}

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

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23, 111, 91, 0.28);
  outline-offset: 3px;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: max(56px, env(safe-area-inset-bottom));
}

.topbar {
  min-height: calc(72px + env(safe-area-inset-top));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.install-tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(23, 111, 91, 0.18);
  border-radius: 16px;
  background: rgba(215, 235, 228, 0.92);
}

.install-tip[hidden] {
  display: none;
}

.install-tip p {
  display: grid;
  gap: 2px;
  margin: 0;
  line-height: 1.45;
}

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

.install-tip button {
  min-width: 68px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent-dark);
  font-weight: 750;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link,
.mobile-nav a {
  color: var(--muted);
  text-decoration: none;
}

.nav-link {
  padding: 9px 15px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--surface-strong);
  color: var(--ink);
}

.text-button {
  justify-self: end;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent);
}

main {
  padding-top: clamp(28px, 5vw, 66px);
}

.empty-state {
  min-height: calc(100dvh - 170px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: clamp(40px, 8vw, 100px);
  padding-bottom: 48px;
}

.empty-copy h1 {
  max-width: 740px;
  margin: 14px 0 20px;
  font-size: clamp(46px, 7vw, 86px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.empty-copy p:not(.kicker) {
  max-width: 560px;
  margin: 0 0 32px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.7;
}

.kicker {
  margin: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.empty-note {
  position: relative;
  padding: 34px;
  border: 1px solid rgba(23, 111, 91, 0.18);
  border-radius: var(--radius);
  background: rgba(251, 252, 251, 0.78);
  box-shadow: var(--shadow);
}

.empty-note::before {
  content: "";
  position: absolute;
  top: -18px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-soft);
  z-index: -1;
}

.empty-note strong {
  display: block;
  margin-bottom: 18px;
  font-size: 20px;
}

.empty-note ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 2;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:active,
.icon-button:active,
.task-check:active {
  transform: scale(0.97);
}

.button.primary {
  background: var(--accent-dark);
  color: #f7faf8;
  box-shadow: 0 12px 24px rgba(13, 78, 64, 0.18);
}

.button.primary:hover {
  background: #093f34;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #aebdb6;
  background: #f2f6f4;
}

.dashboard {
  display: grid;
  gap: 42px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(270px, 0.65fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: end;
}

.date-line {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.hero-grid h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.03;
  letter-spacing: -0.05em;
}

.coach-card {
  padding: 24px 26px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
}

.coach-card span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.coach-card p {
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.55;
}

.today-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 251, 0.86);
  box-shadow: var(--shadow);
}

.task-panel {
  padding: clamp(24px, 4vw, 42px);
}

.panel-heading,
.section-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading {
  margin-bottom: 30px;
}

.panel-heading h2,
.section-heading h2,
.dialog-heading h2 {
  margin: 5px 0 0;
  letter-spacing: -0.035em;
}

.panel-heading h2,
.section-heading h2 {
  font-size: clamp(26px, 3vw, 36px);
}

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

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.task-item:last-child {
  border-bottom: 0;
}

.task-check {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #9baba4;
  border-radius: 9px;
  background: transparent;
  color: transparent;
  cursor: pointer;
}

.task-check:hover {
  border-color: var(--accent);
}

.task-item.is-done .task-check {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #f7faf8;
}

.task-copy strong {
  display: block;
  margin-bottom: 5px;
  font-size: 17px;
}

.task-copy span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.task-item.is-done .task-copy {
  opacity: 0.58;
}

.task-item.is-done .task-copy strong {
  text-decoration: line-through;
}

.task-time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.checkin {
  display: grid;
  gap: 14px;
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.checkin label {
  font-weight: 700;
}

.checkin textarea {
  min-height: 88px;
  resize: vertical;
}

.stats-panel {
  display: grid;
  align-content: start;
  gap: 26px;
  padding: 28px;
}

.progress-ring {
  --progress: 0deg;
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  margin: 6px auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), var(--surface-strong) 0);
}

.progress-ring::before {
  content: "";
  grid-area: 1 / 1;
  width: 118px;
  height: 118px;
  border-radius: inherit;
  background: var(--surface);
}

.progress-ring strong {
  position: relative;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.stat-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.stat strong {
  display: block;
  font-size: 24px;
}

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

.stats-panel .button {
  width: 100%;
}

.section-block {
  scroll-margin-top: 24px;
  padding-top: 24px;
}

.section-heading {
  align-items: end;
  margin-bottom: 20px;
}

.section-heading p {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.plan-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 251, 0.72);
}

.plan-row {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

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

.plan-row.is-today {
  background: var(--accent-soft);
}

.plan-row.is-done {
  color: var(--muted);
}

.plan-date {
  font-size: 13px;
  font-weight: 700;
}

.plan-task strong {
  display: block;
  margin-bottom: 3px;
}

.plan-task span,
.status-label {
  color: var(--muted);
  font-size: 13px;
}

.status-label {
  min-width: 48px;
  text-align: right;
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.review-note {
  min-height: 150px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.review-note time {
  color: var(--muted);
  font-size: 13px;
}

.review-note p {
  margin: 16px 0 0;
  line-height: 1.7;
}

.review-empty {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px dashed #acbbb4;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.mobile-nav {
  display: none;
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }
}

dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(20, 32, 27, 0.24);
}

dialog::backdrop {
  background: rgba(20, 32, 27, 0.45);
  backdrop-filter: blur(5px);
}

#goal-form {
  padding: clamp(24px, 5vw, 44px);
}

.dialog-heading {
  margin-bottom: 32px;
}

.dialog-heading h2 {
  font-size: 32px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 25px;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.field > span {
  font-size: 14px;
  font-weight: 750;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #acbbb4;
  border-radius: 12px;
  background: #fdfefd;
  color: var(--ink);
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

textarea {
  padding: 13px 14px;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #6f7b76;
}

.form-error {
  min-height: 21px;
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (prefers-reduced-transparency: reduce) {
  .panel,
  .empty-note {
    background: var(--surface);
  }

  dialog::backdrop {
    backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .empty-copy,
  .empty-note,
  .dashboard > * {
    animation: enter 560ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .empty-note,
  .dashboard > *:nth-child(2) {
    animation-delay: 90ms;
  }

  .dashboard > *:nth-child(3) {
    animation-delay: 150ms;
  }

  @keyframes enter {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 28px, 680px);
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .desktop-nav {
    display: none;
  }

  .empty-state,
  .hero-grid,
  .today-layout,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .empty-state {
    min-height: auto;
    padding-top: 24px;
  }

  .empty-copy h1 {
    font-size: clamp(44px, 13vw, 68px);
  }

  .hero-grid {
    align-items: start;
  }

  .today-layout {
    gap: 16px;
  }

  .stats-panel {
    grid-template-columns: 180px 1fr;
    align-items: center;
  }

  .stats-panel .button {
    grid-column: 1 / -1;
  }

  .section-heading {
    display: grid;
    gap: 10px;
  }

  .mobile-nav {
    position: fixed;
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 14px;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    max-width: 460px;
    margin: 0 auto;
    padding: 8px;
    border: 1px solid rgba(216, 224, 220, 0.9);
    border-radius: 16px;
    background: rgba(251, 252, 251, 0.94);
    box-shadow: 0 18px 45px rgba(20, 32, 27, 0.16);
    backdrop-filter: blur(16px);
  }

  .mobile-nav a {
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
  }

  .mobile-nav a:active {
    background: var(--surface-strong);
  }
}

@media (max-width: 560px) {
  .shell {
    width: calc(100% - 24px);
  }

  main {
    padding-top: 30px;
  }

  .topbar {
    min-height: calc(64px + env(safe-area-inset-top));
  }

  .install-tip {
    align-items: flex-start;
  }

  .empty-note,
  .task-panel,
  .stats-panel {
    padding: 22px;
  }

  .hero-grid h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .stats-panel {
    grid-template-columns: 1fr;
  }

  .progress-ring {
    width: 138px;
    height: 138px;
  }

  .progress-ring::before {
    width: 108px;
    height: 108px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .plan-row {
    grid-template-columns: 82px 1fr;
    gap: 14px;
    padding: 16px;
  }

  .status-label {
    grid-column: 2;
    text-align: left;
  }

  .task-item {
    grid-template-columns: auto 1fr;
  }

  .task-time {
    grid-column: 2;
  }

  .dialog-actions .button {
    flex: 1;
    padding-inline: 12px;
  }
}
