:root {
  color-scheme: light;
  --paper: #f5efe3;
  --paper-deep: #eee3d3;
  --ink: #171411;
  --ink-soft: #655d53;
  --line: #cdbfaa;
  --line-dark: #8d8171;
  --orange: #e8521b;
  --orange-dark: #a93610;
  --yellow: #efc72f;
  --white: #fffaf0;
  --danger: #9d2d19;
  --success: #236441;
  --shadow: rgba(58, 42, 23, 0.16);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: #ddd1bf;
  color: var(--ink);
}

body::before,
.paper-grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  opacity: 0.075;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.paper-grain {
  position: absolute;
  z-index: 1;
  border-radius: inherit;
  opacity: 0.09;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--white);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  position: relative;
  width: min(100%, 460px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
}

.topbar {
  position: relative;
  z-index: 2;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 10px;
}

.brand {
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.1em;
}

.top-action {
  min-height: 42px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  font-size: 0.95rem;
  cursor: pointer;
}

.top-action:hover {
  color: var(--orange-dark);
}

.app-message {
  position: absolute;
  top: 70px;
  right: 20px;
  left: 20px;
  z-index: 15;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-message.is-visible {
  min-height: 42px;
  padding: 11px 14px;
  border: 1px solid var(--line-dark);
  background: var(--white);
  opacity: 1;
  transform: translateY(0);
}

.app-message.is-error {
  border-color: var(--danger);
  color: var(--danger);
}

.stage {
  position: relative;
  z-index: 2;
  padding: 16px 26px max(34px, env(safe-area-inset-bottom));
}

.view {
  animation: view-in 230ms ease-out both;
}

.view-copy h1,
.focus-view h1,
.done-history h2,
.sheet-header h2 {
  margin: 0;
}

.view-copy h1 {
  max-width: 390px;
  font-size: clamp(2.08rem, 9vw, 2.7rem);
  line-height: 1.18;
  letter-spacing: -0.055em;
}

.view-copy > p {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.75;
}

.ink-underline {
  position: relative;
  display: inline-block;
  z-index: 0;
}

.ink-underline::after {
  position: absolute;
  right: 3%;
  bottom: -3px;
  left: 16%;
  z-index: -1;
  content: "";
  border-bottom: 4px solid var(--orange);
  transform: rotate(-1.5deg);
}

.state-options {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

.state-option {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px 13px 15px 12px;
  background: rgba(255, 250, 240, 0.24);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.state-option:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.state-option[aria-checked="true"] {
  border: 2px solid var(--orange);
  padding: 12.5px 15.5px;
  background: rgba(232, 82, 27, 0.035);
  transform: rotate(-0.12deg);
}

.choice-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-dark);
  border-radius: 50%;
  color: transparent;
  font-size: 0.98rem;
  font-weight: 900;
}

.state-option[aria-checked="true"] .choice-mark {
  border-color: var(--orange);
  background: var(--orange);
  color: var(--white);
}

.choice-name {
  font-size: 1.22rem;
  font-weight: 850;
  letter-spacing: -0.025em;
}

.choice-note {
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: right;
}

.task-preview {
  margin-top: 28px;
  animation: view-in 220ms ease-out both;
}

.sketch-rule {
  position: relative;
  height: 12px;
  margin-bottom: 21px;
  border-top: 3px solid var(--ink);
  transform: rotate(0.3deg);
}

.sketch-rule::after {
  position: absolute;
  top: 3px;
  right: 4%;
  left: 1%;
  content: "";
  border-top: 1px solid rgba(23, 20, 17, 0.38);
  transform: rotate(-0.5deg);
}

.section-kicker {
  position: relative;
  width: max-content;
  margin: 0 auto 9px;
  font-size: 0.94rem;
  letter-spacing: 0.04em;
}

.section-kicker::after {
  position: absolute;
  right: -3px;
  bottom: -7px;
  left: 20%;
  content: "";
  border-bottom: 4px solid var(--yellow);
  transform: rotate(-1.4deg);
}

.task-preview h2 {
  margin: 23px 0 4px;
  font-size: clamp(2.45rem, 12vw, 3.55rem);
  line-height: 1.05;
  letter-spacing: -0.065em;
  text-align: center;
}

.task-preview h2 em {
  color: var(--orange);
  font-style: normal;
}

.task-meta {
  margin: 13px 0 0;
  color: var(--ink);
  font-size: 1rem;
  text-align: center;
}

.task-meta strong {
  color: var(--orange);
  font-weight: 850;
}

.task-meta i {
  margin: 0 7px;
  color: var(--line-dark);
  font-style: normal;
}

.task-reason {
  max-width: 340px;
  margin: 13px auto 20px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.65;
  text-align: center;
}

.primary-button,
.secondary-button,
.outline-button {
  min-height: 58px;
  border-radius: 13px 12px 14px 11px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.primary-button {
  width: 100%;
  padding: 0 20px;
  border: 1px solid var(--orange-dark);
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 3px 0 var(--orange-dark);
  font-size: 1.1rem;
}

.primary-button:hover {
  background: #dc4613;
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--orange-dark);
}

.primary-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--orange-dark);
}

.primary-button:disabled {
  border-color: var(--line-dark);
  background: var(--line);
  color: var(--ink-soft);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.primary-button.is-compact {
  width: auto;
  min-width: 88px;
  min-height: 52px;
  font-size: 1rem;
}

.local-caption {
  margin: 20px 0 0;
  color: #81776a;
  font-size: 0.76rem;
  text-align: center;
}

.focus-view {
  min-height: calc(100dvh - 126px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 22px;
  text-align: center;
}

.focus-view h1 {
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.75rem, 7.4vw, 2.2rem);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.timer-orbit {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 1;
  margin: clamp(20px, 5vh, 40px) auto 6px;
}

.timer-orbit::after {
  position: absolute;
  inset: 8.5%;
  content: "";
  border: 1px solid rgba(23, 20, 17, 0.15);
  border-radius: 49% 51% 47% 53%;
  transform: rotate(3deg);
}

.timer-orbit svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-92deg);
}

.timer-sketch,
.timer-progress {
  fill: none;
}

.timer-sketch {
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 620 18 130 22;
}

.timer-progress {
  stroke: var(--orange);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 829.38;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 350ms linear;
}

.timer-readout {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.75rem, 18vw, 5.5rem);
  line-height: 1;
  letter-spacing: -0.065em;
  font-variant-numeric: tabular-nums;
}

.focus-task {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2rem);
  font-weight: 850;
}

.focus-task strong {
  color: var(--orange);
}

.focus-meta {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.focus-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 0.9fr 1.2fr;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
}

.secondary-button,
.outline-button {
  padding: 0 18px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.secondary-button:hover,
.outline-button:hover {
  background: rgba(23, 20, 17, 0.05);
  transform: translateY(-1px);
}

.reassurance {
  min-height: 1.6em;
  margin: 17px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.6;
}

.review-view {
  min-height: calc(100dvh - 126px);
  padding-top: 24px;
}

.review-copy h1,
.done-copy h1 {
  font-size: clamp(2.35rem, 10vw, 3rem);
}

.review-form {
  display: grid;
  margin-top: 34px;
}

.review-form > label {
  margin-bottom: 10px;
  font-size: 1rem;
  font-weight: 800;
}

textarea,
input {
  width: 100%;
  border: 1.5px solid var(--line-dark);
  border-radius: 13px 12px 14px 11px;
  background: rgba(255, 250, 240, 0.32);
  color: var(--ink);
}

textarea {
  min-height: 152px;
  padding: 15px 16px;
  resize: vertical;
  font-size: 1rem;
  line-height: 1.65;
}

textarea::placeholder,
input::placeholder {
  color: #918779;
}

.field-message {
  min-height: 1.45em;
  margin: 8px 2px 0;
  color: var(--danger);
  font-size: 0.78rem;
}

.review-details {
  margin: 7px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.review-details summary {
  position: relative;
  padding: 17px 34px 17px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
}

.review-details summary::-webkit-details-marker {
  display: none;
}

.review-details summary::after {
  position: absolute;
  top: 19px;
  right: 7px;
  width: 9px;
  height: 9px;
  content: "";
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.review-details[open] summary::after {
  top: 24px;
  transform: rotate(225deg);
}

.review-details textarea {
  min-height: 100px;
  margin-bottom: 16px;
}

.done-view {
  min-height: calc(100dvh - 126px);
  padding-top: 17px;
  text-align: center;
}

.done-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  border: 2px solid var(--orange-dark);
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.9rem;
  font-weight: 900;
  transform: rotate(-4deg);
}

.done-copy > p {
  margin-top: 12px;
}

.done-task {
  display: grid;
  gap: 8px;
  margin-top: 32px;
  padding: 20px 4px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.done-task span {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.done-task strong {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.done-history {
  margin-top: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.done-history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.done-history h2 {
  font-size: 1.08rem;
}

.done-history-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.history-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.history-day {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.day-name {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.day-dot {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.history-day.complete .day-dot {
  background: var(--ink);
  color: var(--white);
}

.history-day.return .day-dot {
  border-color: var(--orange-dark);
  background: var(--orange);
  color: var(--white);
}

.day-status {
  min-height: 1.2em;
  color: var(--orange-dark);
  font-size: 0.63rem;
  line-height: 1.2;
  white-space: nowrap;
}

.outline-button {
  width: 100%;
  margin-top: 24px;
}

.bottom-sheet {
  position: fixed;
  top: auto;
  right: auto;
  bottom: 0;
  left: 50%;
  z-index: 50;
  width: min(100%, 460px);
  max-height: min(78dvh, 680px);
  margin: 0;
  padding: 10px 24px max(26px, env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid var(--line-dark);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 -18px 50px rgba(44, 31, 17, 0.18);
  transform: translateX(-50%);
}

.bottom-sheet[open] {
  animation: sheet-in 210ms ease-out both;
}

.bottom-sheet::backdrop {
  background: rgba(23, 20, 17, 0.48);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 1px auto 15px;
  border-radius: 4px;
  background: var(--line-dark);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.sheet-header h2 {
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.sheet-header p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 1.65rem;
  line-height: 1;
}

.bottom-sheet .history-strip {
  margin-top: 28px;
}

.history-strip.is-large .day-dot {
  width: 32px;
  height: 32px;
}

.sheet-note {
  margin: 24px 0 0;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.65;
}

.parking-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 25px;
}

.parking-form input {
  min-width: 0;
  min-height: 52px;
  padding: 0 14px;
  font-size: 0.95rem;
}

.idea-list {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.idea-list li {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.idea-list li::before {
  align-self: start;
  width: 6px;
  height: 6px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--orange);
  content: "";
}

.idea-list .empty-ideas {
  display: block;
  color: #8b8174;
  text-align: center;
}

.idea-list .empty-ideas::before {
  display: none;
}

.completion-toast {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 60;
  width: min(330px, calc(100vw - 40px));
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  opacity: 0;
  transform: translateY(15px) rotate(0.4deg);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.completion-toast.is-visible {
  opacity: 1;
  transform: translateY(0) rotate(0.4deg);
}

.completion-toast strong {
  font-size: 0.98rem;
}

.completion-toast span {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translate(-50%, 24px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (min-width: 600px) {
  .app-shell {
    min-height: calc(100dvh - 48px);
    margin: 24px auto;
    border: 1px solid #cbbca5;
    border-radius: 30px 27px 32px 28px;
    box-shadow: 0 22px 55px var(--shadow);
  }

  .focus-view,
  .review-view,
  .done-view {
    min-height: calc(100dvh - 174px);
  }

  .bottom-sheet {
    bottom: 24px;
    border-bottom: 1px solid var(--line-dark);
    border-radius: 24px;
  }

  .completion-toast {
    right: calc(50% - 210px);
  }
}

@media (max-width: 370px) {
  .topbar,
  .stage {
    padding-right: 19px;
    padding-left: 19px;
  }

  .choice-note {
    font-size: 0.8rem;
  }

  .timer-orbit {
    width: 76vw;
  }
}

@media (max-height: 730px) {
  .topbar {
    min-height: 66px;
    padding-top: 14px;
  }

  .stage {
    padding-top: 8px;
  }

  .state-options {
    gap: 8px;
    margin-top: 20px;
  }

  .state-option {
    min-height: 66px;
  }

  .task-preview {
    margin-top: 18px;
  }

  .task-preview h2 {
    margin-top: 15px;
    font-size: 2.5rem;
  }

  .task-reason {
    margin-bottom: 14px;
  }

  .timer-orbit {
    width: min(62vh, 280px);
    margin-top: 12px;
  }
}

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