:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f5f7fb);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17212b);
  --hint: var(--tg-theme-hint-color, #708499);
  --link: var(--tg-theme-link-color, #2678d9);
  --button: var(--tg-theme-button-color, #2678d9);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #d84d4d;
  --warning: #b96c08;
  --line: color-mix(in srgb, var(--hint) 24%, transparent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { touch-action: manipulation; }
#app { width: min(100%, 680px); min-height: 100vh; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.app-header h1 { margin: 0; font-size: 1.55rem; letter-spacing: .01em; }
.eyebrow { margin: 0 0 3px; color: var(--hint); font-size: .78rem; font-weight: 700; letter-spacing: .12em; }
.icon-button, .text-button, .tab, .action, .list-card { border: 0; border-radius: 14px; cursor: pointer; }
.icon-button { width: 44px; min-height: 44px; background: var(--card); color: var(--text); font-size: 1.55rem; }
.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--button) 12%, var(--card)); color: var(--text); line-height: 1.45; }
.notice.error { background: color-mix(in srgb, var(--danger) 13%, var(--card)); }
.content { display: grid; gap: 14px; }
.loading, .empty { margin: 32px 0; color: var(--hint); text-align: center; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.tab { min-height: 43px; padding: 8px 4px; background: var(--card); color: var(--hint); font-size: .87rem; font-weight: 650; }
.tab.active { background: var(--button); color: var(--button-text); }
.search-row, .archive-row { display: flex; gap: 8px; }
.search-row input, .archive-row input { min-width: 0; flex: 1; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); }
.text-button { min-height: 44px; padding: 9px 12px; background: transparent; color: var(--link); font-weight: 650; }
.scope { margin: -6px 2px 2px; color: var(--hint); font-size: .83rem; }
.group { display: grid; gap: 8px; }
.group h2 { margin: 7px 2px 1px; font-size: 1rem; }
.list-card { width: 100%; padding: 14px; text-align: left; background: var(--card); color: var(--text); box-shadow: 0 1px 1px rgb(0 0 0 / 3%); }
.list-card:active { transform: scale(.99); }
.card-top, .card-meta, .detail-meta, .actions, .pagination, .choice-actions { display: flex; gap: 8px; align-items: center; }
.card-top { justify-content: space-between; gap: 12px; }
.title { font-size: 1rem; font-weight: 720; line-height: 1.35; word-break: break-word; }
.badge { flex: 0 0 auto; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--button) 12%, var(--card)); color: var(--link); font-size: .78rem; font-weight: 700; }
.badge.overdue { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); }
.card-meta { flex-wrap: wrap; margin-top: 9px; color: var(--hint); font-size: .86rem; line-height: 1.35; }
.step-line { margin-top: 8px; color: var(--text); font-size: .9rem; line-height: 1.38; word-break: break-word; }
.calendar { margin-top: 8px; color: var(--hint); font-size: .82rem; }
.pagination { justify-content: center; }
.pagination .action { flex: 0 1 auto; }
.detail-head { display: grid; gap: 11px; }
.back { justify-self: start; margin-left: -8px; }
.detail-title { margin: 0; font-size: 1.35rem; line-height: 1.32; word-break: break-word; }
.detail-section { padding: 14px; border-radius: 14px; background: var(--card); }
.detail-section h2 { margin: 0 0 9px; font-size: .94rem; }
.detail-section p { margin: 0; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.detail-meta { flex-wrap: wrap; color: var(--hint); font-size: .9rem; }
.step-list { display: grid; gap: 9px; }
.step-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.step-item:last-child { border-bottom: 0; padding-bottom: 0; }
.step-item strong { display: block; line-height: 1.4; word-break: break-word; }
.step-item span { color: var(--hint); font-size: .84rem; }
.actions { display: grid; grid-template-columns: 1fr; }
.action { min-height: 49px; padding: 11px 14px; background: var(--button); color: var(--button-text); font-weight: 700; }
.action.secondary { background: var(--card); color: var(--link); border: 1px solid color-mix(in srgb, var(--link) 28%, transparent); }
.action.danger { background: var(--danger); }
.modal { padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); display: grid; gap: 10px; }
.modal h2 { margin: 0; font-size: 1.02rem; }
.modal label { color: var(--hint); font-size: .88rem; }
.modal input { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 9px; color: var(--text); background: var(--bg); }
.preview { padding: 10px; border-radius: 10px; background: color-mix(in srgb, var(--button) 8%, var(--bg)); line-height: 1.5; }
.choice-actions { flex-wrap: wrap; }
.choice-actions .action { flex: 1 1 145px; }
@media (max-width: 360px) { .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
