:root {
  --paper: #f7f7f2;
  --panel: #ffffff;
  --ink: #20221e;
  --muted: #6d7168;
  --line: #dadfd1;
  --green: #2f6b4f;
  --green-soft: #e5f0e8;
  --clay: #b6593f;
  --blue: #315f82;
  --yellow: #e0b84d;
  --shadow: 0 18px 42px rgba(32, 34, 30, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(49, 95, 130, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(47, 107, 79, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

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

button {
  border: 0;
}

.app-shell {
  width: min(100%, 780px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 32px;
}

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

.topbar h1,
h2,
p {
  margin: 0;
}

.topbar h1 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--green);
  box-shadow: var(--shadow);
}

.hero-panel,
.transition-panel,
.tab-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  position: relative;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--clay), var(--yellow));
}

.hero-copy {
  padding-top: 4px;
}

.hero-copy h2 {
  margin-top: 6px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 1.65rem;
  line-height: 1.15;
}

.hero-copy p:last-child {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

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

.shift-option {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
  color: var(--ink);
  text-align: left;
}

.shift-option strong {
  font-size: 1rem;
}

.shift-option span {
  color: var(--muted);
  font-size: 0.78rem;
}

.shift-option.active {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}

.transition-panel {
  margin-top: 12px;
  padding: 16px;
  border-color: rgba(182, 89, 63, 0.35);
}

.transition-panel h2 {
  margin-top: 6px;
  font-size: 1.08rem;
}

.transition-panel ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.tab {
  min-height: 38px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-top: 5px;
  font-size: 1.22rem;
  line-height: 1.2;
}

.progress-pill,
.metric-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.progress-pill {
  padding: 8px 12px;
}

.metric-badge {
  display: grid;
  place-items: center;
  min-width: 72px;
  padding: 8px 12px;
}

.metric-badge span {
  font-size: 1.2rem;
  line-height: 1;
}

.metric-badge small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72rem;
}

.notify-box,
.notice-panel {
  border: 1px dashed rgba(49, 95, 130, 0.45);
  border-radius: var(--radius);
  background: rgba(49, 95, 130, 0.07);
}

.notify-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.notify-actions {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
}

.notify-box p,
.notice-panel {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.notify-diagnostics {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.notify-diagnostics summary {
  cursor: pointer;
  font-weight: 800;
}

.notify-diagnostics pre {
  overflow-x: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid rgba(49, 95, 130, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 800;
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--blue);
  background: #fff;
  color: var(--blue);
}

.muted-button {
  border-color: var(--line);
  color: var(--muted);
}

.primary-button {
  width: 100%;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
}

.timeline {
  display: grid;
  gap: 10px;
}

.task {
  display: grid;
  grid-template-columns: 54px 1fr 38px;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.task.done {
  background: #f4f7f0;
}

.task-time {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 900;
}

.task-body {
  min-width: 0;
}

.task-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-weight: 900;
}

.task-type {
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(224, 184, 77, 0.22);
  color: #6b5416;
  font-size: 0.72rem;
  font-weight: 900;
}

.task-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.check-button {
  align-self: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: transparent;
}

.task.done .check-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.form-grid,
.goal-form,
.review-form {
  display: grid;
  gap: 12px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

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

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

.range-value {
  color: var(--ink);
  font-size: 1rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.segmented input {
  width: auto;
  min-height: auto;
  margin-right: 8px;
}

.notice-panel {
  margin-top: 12px;
  padding: 12px;
}

.history-list,
.goal-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.history-item,
.goal-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.history-item strong,
.goal-item strong {
  color: var(--ink);
}

.history-item span,
.goal-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

.goal-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.goal-item.done {
  background: #f4f7f0;
}

.goal-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
  }

  .hero-panel {
    grid-template-columns: 1.1fr 1fr;
    align-items: center;
    padding: 22px;
  }

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

  .goal-form .wide,
  .goal-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .shift-control {
    grid-template-columns: 1fr;
  }

  .task {
    grid-template-columns: 48px 1fr 34px;
    gap: 8px;
    padding: 10px;
  }

  .tabs {
    gap: 4px;
  }

  .tab {
    font-size: 0.86rem;
  }

  .notify-box {
    align-items: stretch;
    flex-direction: column;
  }

  .notify-actions {
    grid-template-columns: 1fr 1fr;
  }
}
