:root {
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --bg-elevated: #ffffff;
  --paper-back: #f7f7f9;
  --text: #000000;
  --text-2: rgba(60, 60, 67, 0.6);
  --text-3: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --accent: #e5a000;
  --accent-fill: #ffb800;
  --accent-soft: rgba(255, 184, 0, 0.16);
  --on-accent: #ffffff;
  --danger: #ff3b30;

  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --thumb-bg: rgba(120, 120, 128, 0.14);
  --shadow-rgb: 0, 0, 0;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --flip-ms: 760ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-top: calc(var(--safe-top) + 8px);
  --bar-h: 44px;
  --composer-h: 50px;
  --composer-bottom: max(12px, calc(var(--safe-bottom) + 4px));
  --gutter: 20px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg .fill {
  fill: currentColor;
  stroke: none;
}

:focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
}

/* ---------- Liquid Glass ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 0.5px 0 var(--glass-edge);
}

.app {
  /* --app-h 由 JS 按 visualViewport 设置，iOS 弹出键盘时输入栏才不会被挡住 */
  height: var(--app-h, 100dvh);
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

/* ---------- 顶栏：悬浮玻璃控件 ---------- */
.topbar {
  position: absolute;
  z-index: 10;
  top: var(--bar-top);
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

/* 内容滚到顶栏下方时的渐隐边缘 */
.app::before {
  content: "";
  position: absolute;
  z-index: 9;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--bar-top) + var(--bar-h) + 18px);
  background: linear-gradient(to bottom, var(--bg) 45%, transparent);
  pointer-events: none;
}

.app.has-lists::before {
  height: calc(var(--bar-top) + var(--bar-h) + 62px);
}

.nav-group {
  display: flex;
  align-items: center;
  height: var(--bar-h);
  border-radius: 22px;
  padding: 0 2px;
}

.glass-btn {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 22px;
  transition: opacity 0.2s, transform 0.25s var(--spring);
}

.glass-btn svg {
  stroke-width: 2.3;
}

.glass-btn:active:not(:disabled) {
  transform: scale(0.86);
}

.glass-btn:disabled {
  opacity: 0.25;
}

.nav-divider {
  width: 0.5px;
  height: 20px;
  background: var(--separator);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.glass-circle {
  width: var(--bar-h);
  height: var(--bar-h);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 22px;
  transition: transform 0.25s var(--spring), background-color 0.2s;
}

.glass-circle:active {
  transform: scale(0.88);
}

.glass-circle.tinted {
  color: var(--accent);
}

/* ---------- 分段控件 ---------- */
.segmented {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 228px;
  height: var(--bar-h);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: 22px;
}

.segmented button {
  position: relative;
  z-index: 1;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.25s;
}

.segmented button[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}

.segmented-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 18px;
  background: var(--thumb-bg);
  transition: transform 0.45s var(--spring);
}

/* ---------- 自定义清单条 ---------- */
.list-bar {
  position: absolute;
  z-index: 10;
  top: calc(var(--bar-top) + var(--bar-h) + 10px);
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 4px;
  scrollbar-width: none;
}

.list-bar[hidden] {
  display: none;
}

.list-bar::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  height: 34px;
  padding: 0 15px;
  border-radius: 17px;
  background: var(--fill);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s, transform 0.25s var(--spring);
}

.chip:active {
  transform: scale(0.94);
}

.chip[aria-current="true"] {
  background: var(--text);
  color: var(--bg);
}

.chip.add {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 页面（满屏，像备忘录） ---------- */
.book {
  position: absolute;
  inset: 0;
  perspective: 2400px;
  perspective-origin: 20% 50%;
  /* 横向手势留给翻页，否则浏览器会抢走并触发 pointercancel */
  touch-action: pan-y;
}

.paper {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg);
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: calc(var(--bar-top) + var(--bar-h) + 22px) var(--gutter)
    calc(var(--composer-bottom) + var(--composer-h) + 32px);
}

.app.has-lists .paper {
  padding-top: calc(var(--bar-top) + var(--bar-h) + 66px);
}

.page-head {
  margin-bottom: 14px;
}

.page-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.page-sub {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.page-sub b {
  font-weight: 600;
  color: var(--accent);
}

.day-group + .day-group {
  margin-top: 22px;
}

.day-label {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
}

/* 分隔线从文字处开始，和 iOS 列表一致 */
.item::after {
  content: "";
  position: absolute;
  left: 36px;
  right: 0;
  bottom: 0;
  height: 0.5px;
  background: var(--separator);
}

.item:last-child::after {
  display: none;
}

.check {
  position: relative;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  display: grid;
  place-items: center;
  transition: background-color 0.25s, border-color 0.25s;
}

.check svg {
  width: 14px;
  height: 14px;
  stroke: var(--on-accent);
  stroke-width: 3;
}

.check path {
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
}

.item.done .check {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
}

.item.done .check path {
  stroke-dashoffset: 0;
}

.item.animate.done .check {
  animation: pop 0.5s var(--spring);
}

.item.animate .check path {
  transition: stroke-dashoffset 0.3s 0.1s ease-out;
}

@keyframes pop {
  0% { transform: scale(0.8); }
  100% { transform: scale(1); }
}

.item-text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.strike {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 56%;
  background-size: 0% 1.2px;
  -webkit-box-decoration-break: slice;
  box-decoration-break: slice;
}

.item.done .strike {
  color: var(--text-2);
  background-size: 100% 1.2px;
}

.item.animate .strike {
  transition: background-size 0.5s 0.15s ease-in-out, color 0.4s 0.3s;
}

.item.typing .strike::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  border-radius: 1px;
  background: var(--accent-fill);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

/* 时间和删除默认隐藏，点一下条目才出现 */
.item-time {
  display: none;
  flex-shrink: 0;
  padding-top: 3px;
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.item-del {
  display: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -2px -2px 0 0;
  border-radius: 50%;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
}

.item-del svg {
  stroke-width: 2.6;
}

.item.reveal .item-time {
  display: block;
}

.item.reveal .item-del {
  display: grid;
  animation: popIn 0.35s var(--spring);
}

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
}

.item.removing {
  animation: removeItem 0.3s var(--ease) forwards;
}

@keyframes removeItem {
  to {
    opacity: 0;
    transform: translateX(-16px);
  }
}

.empty {
  padding-top: 26vh;
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1.7;
}

.empty .pill-btn {
  margin-top: 18px;
}

.page-foot {
  margin-top: 40px;
  text-align: center;
}

.link-danger {
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
  color: var(--danger);
}

/* ---------- 翻页动画 ---------- */
.flip-sheet {
  position: absolute;
  inset: 0;
  z-index: 5;
  transform-style: preserve-3d;
  transform-origin: left center;
  pointer-events: none;
  will-change: transform;
}

/* 滚动容器会让 Chrome 的 backface-visibility 失效，翻页纸必须是 overflow: hidden */
.flip-sheet .face {
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 0 40px rgba(var(--shadow-rgb), 0.12);
}

.flip-sheet .face.back {
  transform: rotateY(180deg);
  background: var(--paper-back);
}

.flip-sheet .shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.flip-sheet .front .shade {
  background: linear-gradient(90deg, rgba(var(--shadow-rgb), 0.02), rgba(var(--shadow-rgb), 0.16));
}

.flip-sheet .back .shade {
  background: linear-gradient(270deg, rgba(var(--shadow-rgb), 0.02), rgba(var(--shadow-rgb), 0.12));
}

.flip-sheet.next {
  animation: flipNext var(--flip-ms) cubic-bezier(0.45, 0.05, 0.25, 1) forwards;
}

.flip-sheet.prev {
  animation: flipPrev var(--flip-ms) cubic-bezier(0.45, 0.05, 0.25, 1) forwards;
}

.flip-sheet.next .shade,
.flip-sheet.prev .shade {
  animation: shade var(--flip-ms) ease-in-out forwards;
}

/* 透明度不能放在 .flip-sheet 上：opacity < 1 会把 preserve-3d 拍平，背面就透出来了 */
.flip-sheet.next .face {
  animation: faceOut var(--flip-ms) linear forwards;
}

.flip-sheet.prev .face {
  animation: faceIn var(--flip-ms) linear forwards;
}

@keyframes flipNext {
  0% { transform: rotateY(0deg); }
  12% { transform: rotateY(-12deg) translateZ(4px); }
  100% { transform: rotateY(-180deg); }
}

@keyframes flipPrev {
  0% { transform: rotateY(-180deg); }
  88% { transform: rotateY(-12deg) translateZ(4px); }
  100% { transform: rotateY(0deg); }
}

@keyframes faceOut {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes faceIn {
  0% { opacity: 0; }
  20%, 100% { opacity: 1; }
}

@keyframes shade {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.book.flipping .page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--shadow-rgb), 0.1), rgba(var(--shadow-rgb), 0) 70%);
  animation: shade var(--flip-ms) ease-in-out forwards;
}

/* ---------- 底部输入：悬浮玻璃胶囊 ---------- */
.composer {
  position: absolute;
  z-index: 10;
  left: 16px;
  right: 16px;
  bottom: var(--composer-bottom);
  height: var(--composer-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 5px 0 20px;
  border-radius: 25px;
  transition: box-shadow 0.25s;
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.composer input::placeholder {
  color: var(--text-3);
}

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 22px;
  transition: transform 0.35s var(--spring), opacity 0.2s;
}

.send-btn svg {
  stroke-width: 2.6;
}

.send-btn:disabled {
  transform: scale(0.4);
  opacity: 0;
  pointer-events: none;
}

.send-btn:active:not(:disabled) {
  transform: scale(0.88);
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(var(--composer-bottom) + var(--composer-h) + 14px);
  max-width: calc(100% - 48px);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.4s var(--spring);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- 弹层：iOS 26 悬浮圆角 sheet ---------- */
.sheet-dialog {
  width: calc(100% - 16px);
  max-width: 520px;
  max-height: calc(100dvh - var(--safe-top) - 40px);
  margin: auto auto max(8px, var(--safe-bottom));
  padding: 14px 16px 24px;
  border: 0;
  border-radius: 34px;
  background: var(--bg-grouped);
  color: var(--text);
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.sheet-dialog[open] {
  animation: sheetUp 0.5s var(--ease);
}

.sheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.22);
  animation: fadeIn 0.3s ease;
}

@media (min-width: 640px) {
  .sheet-dialog {
    margin: auto;
  }
}

@keyframes sheetUp {
  from { transform: translateY(60px); opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.sheet-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-head h2 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--text);
  font-size: 20px;
  transition: transform 0.25s var(--spring);
}

.circle-btn svg {
  stroke-width: 2.3;
}

.circle-btn:active {
  transform: scale(0.88);
}

.circle-btn.primary {
  background: var(--accent-fill);
  color: var(--on-accent);
}

.section-label {
  margin: 22px 16px 7px;
  font-size: 13px;
  color: var(--text-2);
}

.field-group {
  background: var(--bg-elevated);
  border-radius: 26px;
  overflow: hidden;
}

.field-group.spaced {
  margin-top: 22px;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 20px;
  font-size: 17px;
}

.field + .field::before,
.row-btn + .row-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.field span {
  width: 72px;
  flex-shrink: 0;
}

.field input {
  flex: 1;
  min-width: 0;
  height: 50px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  text-align: right;
  color: var(--text-2);
}

.field input:focus {
  color: var(--text);
}

.field input::placeholder {
  color: var(--text-3);
}

.field-hint {
  margin: 8px 20px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}

.row-btn {
  position: relative;
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  text-align: left;
  font-size: 17px;
  color: var(--text);
  transition: background-color 0.15s;
}

.row-btn:active {
  background: var(--fill);
}

.row-btn.danger {
  color: var(--danger);
}

.account-line {
  display: flex;
  align-items: center;
  min-height: 52px;
  margin: 0;
  padding: 0 20px;
  font-size: 17px;
}

.account-line + .row-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 4px 0;
}

.preset-row .chip {
  background: var(--bg-elevated);
}

.pill-btn {
  height: 48px;
  padding: 0 26px;
  border-radius: 24px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.25s var(--spring), opacity 0.2s;
}

.pill-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.pill-btn:disabled {
  opacity: 0.35;
}

.praise-scope {
  margin: -6px 0 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

.praise-body {
  min-height: 140px;
  padding: 20px 22px;
  border-radius: 26px;
  background: var(--bg-elevated);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}

.praise-body.typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: -0.2em;
  border-radius: 1px;
  background: var(--accent-fill);
  animation: caret 1s steps(1) infinite;
}

.praise-body.error {
  color: var(--danger);
  font-size: 15px;
}

.thinking {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-2);
  font-size: 15px;
}

.thinking i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-fill);
  animation: bounce 1.1s infinite ease-in-out;
}

.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.sheet-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.sheet-spacer {
  width: 44px;
}

/* ---------- 有鼠标的设备 ---------- */
@media (hover: hover) {
  .glass-btn:hover:not(:disabled),
  .glass-circle:hover {
    background-color: var(--fill);
  }
  .chip:hover:not([aria-current="true"]) {
    background: var(--fill-2);
  }
  .circle-btn:hover {
    filter: brightness(0.96);
  }
  .row-btn:hover {
    background: var(--fill);
  }
  .item:hover .item-time {
    display: block;
  }
  .item:hover .item-del {
    display: grid;
  }
}

/* ---------- 尺寸适配 ---------- */
@media (max-width: 360px) {
  :root {
    --gutter: 16px;
  }
  .topbar {
    left: 12px;
    right: 12px;
    gap: 6px;
  }
  .glass-btn {
    width: 36px;
  }
  .segmented button {
    font-size: 14px;
  }
}

@media (min-width: 640px) {
  :root {
    --gutter: 28px;
  }
}

@media (max-height: 500px) {
  :root {
    --bar-top: calc(var(--safe-top) + 6px);
  }
  .page-title {
    font-size: 28px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .glass {
    background: var(--bg-elevated);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

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