/* ============================================================
   100件事 · bscjw.cn 实验室小工具
   暗色白橙基调 · 手机优先 · 桌面居中自适应
   ============================================================ */

:root {
  --bg: #050607;
  --card: #171d20;
  --card-2: #1a2124;
  --line: #232b2e;
  --text: #eef1f0;
  --text-2: #899292;
  --text-3: #5c6668;
  --brand: #f0dfad;
  --grid-off: #1f2426;
  --radius: 14px;
  --radius-s: 6px;
  --gap: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: fixed; left: -999px; top: 8px; z-index: 200;
  background: var(--brand); color: #171d20; padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { left: 8px; }

a { color: var(--brand); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 10px;
  background: rgba(5, 6, 7, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar__left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar__title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.02em; }
.topbar__badge {
  font-size: 12px; color: #171d20; background: var(--brand);
  padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.topbar__actions { display: flex; gap: 6px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------------- 页面容器 ---------------- */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 0;
}
.page-spacer { height: calc(60px + var(--safe-bottom)); }

/* ---------------- 进度卡 ---------------- */
.progress-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(150deg, #171d20 0%, #101416 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 8px 0 var(--gap);
}
.progress-card__numbers { display: flex; align-items: baseline; gap: 6px; }
.progress-card__count { font-size: 56px; line-height: 1; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.progress-card__total { font-size: 18px; color: var(--text-2); }
.progress-card__caption { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }

.progress-ring { position: relative; width: 108px; height: 108px; flex: 0 0 auto; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring__track { stroke: #20262a; }
.progress-ring__bar {
  stroke: var(--brand); transition: stroke-dashoffset 0.3s ease;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
}
.progress-ring__percent {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: var(--brand);
}

/* ---------------- Bento 统计区 ---------------- */
.bento {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  margin-bottom: var(--gap);
}
.bento__wall {
  grid-column: 1 / -1;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.bento__wall.is-in { opacity: 1; transform: none; }
.bento__wall-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.bento__wall-head span { font-size: 14px; font-weight: 600; }
.bento__wall-head small { font-size: 12px; color: var(--text-3); }

.wall-grid {
  display: grid; gap: 2px;
}
.wall-grid--100 { grid-template-columns: repeat(10, 1fr); }
.wall-grid--365 { grid-template-columns: repeat(20, 1fr); gap: 2px; }
.wall-grid--1000 { grid-template-columns: repeat(20, 1fr); gap: 2px; max-height: 380px; overflow-y: auto; }
.wall-cell {
  aspect-ratio: 1; border-radius: var(--radius-s);
  background: var(--grid-off); border: none; padding: 0; cursor: pointer;
  min-width: 0; position: relative;
  transition: transform 0.08s ease;
}
.wall-cell:active { transform: scale(0.9); }
.wall-cell.is-done { animation: pop 0.2s ease; }
.wall-cell.is-recent { box-shadow: 0 0 0 2px var(--brand); }
.wall-cell__light {
  position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: radial-gradient(circle, rgba(240, 223, 173, 0.55) 0%, transparent 70%);
  pointer-events: none;
}
.wall-cell.is-lighting .wall-cell__light { animation: glow 0.35s ease forwards; }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes glow { 0% { opacity: 0.9; } 100% { opacity: 0; } }

.wall-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 18px 0 6px; margin: 0; }

.bento__cell {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  min-width: 0;
}
.bento__cell.is-in { opacity: 1; transform: none; }
.bento__cell strong { display: block; font-size: 30px; line-height: 1.1; font-weight: 800; }
.bento__cell small { font-size: 12px; color: var(--text-2); }
.bento__cell--total { }
.mini-dots { display: flex; gap: 3px; margin-top: 8px; flex-wrap: wrap; }
.mini-dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--grid-off); }
.mini-dots i.on { background: var(--brand); }

.bento__cell--cats { grid-column: 1 / -1; }
.cat-bars { display: flex; flex-direction: column; gap: 7px; }
.cat-bar { display: grid; grid-template-columns: 72px 1fr 30px; align-items: center; gap: 8px; font-size: 12px; }
.cat-bar__name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar__track { height: 6px; border-radius: 3px; background: #20262a; overflow: hidden; }
.cat-bar__fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.cat-bar__num { color: var(--text-3); text-align: right; }
.cat-bars__more { margin-top: 8px; border: none; background: none; color: var(--text-2); font-size: 12px; cursor: pointer; }

.bento__cell--recent { grid-column: 1 / -1; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recent-list__empty { color: var(--text-3); font-size: 12px; margin: 0; }
.recent-item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; text-align: left; background: none; border: none; padding: 0; color: var(--text); cursor: pointer; }
.recent-item__date { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.recent-item__title { font-size: 14px; line-height: 1.4; }

/* ---------------- 筛选条 ---------------- */
.filterbar { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg__item {
  flex: 1; border: none; background: none; color: var(--text-2);
  padding: 8px 0; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.seg__item.is-active { background: var(--brand); color: #171d20; font-weight: 600; }
.seg--small { display: inline-flex; width: auto; }
.seg--small label { display: inline-flex; }
.seg--small label > span { display: inline-block; padding: 7px 14px; border-radius: 999px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.seg--small input:checked + span { background: var(--brand); color: #171d20; font-weight: 600; }

.filterbar__row { display: flex; gap: 8px; }
.searchbox { flex: 1; min-width: 0; }
.searchbox input {
  width: 100%; height: 44px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); padding: 0 14px; font-size: 14px; outline: none;
}
.searchbox input:focus { border-color: rgba(240, 223, 173, 0.5); }
.cat-select {
  width: 132px; flex: 0 0 auto; height: 44px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); padding: 0 10px; font-size: 14px; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23899292' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ---------------- 条目流 ---------------- */
.list__hint { color: var(--text-3); font-size: 12px; margin: 0 0 8px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: grid; grid-template-columns: 40px 1fr 48px; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 12px 12px 14px; cursor: pointer;
  transition: border-color 0.15s;
}
.item:active { border-color: #2c3538; }
.item__id { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; align-self: start; padding-top: 3px; }
.item__main { min-width: 0; }
.item__title { font-size: 16px; line-height: 1.6; margin: 0; }
.item__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.item__chip {
  font-size: 11px; line-height: 1; padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); color: var(--text-2);
}
.item.is-done .item__chip { opacity: 0.6; }
.item__date { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.item.is-done .item__title { opacity: 0.55; }

.check-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--text-3);
  background: transparent; color: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
  transition: transform 0.1s;
}
.check-btn:active { transform: scale(0.9); }
.check-btn.is-done {
  background: var(--brand); border-color: var(--brand); color: #171d20;
  animation: checkPop 0.25s ease;
}
@keyframes checkPop { 0% { transform: scale(0.7); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* 已完成区 */
.done-section { margin-top: 14px; }
.done-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-2); padding: 12px 14px; font-size: 14px; cursor: pointer;
}
.done-toggle__arrow { transition: transform 0.2s; }
.done-toggle[aria-expanded="true"] .done-toggle__arrow { transform: rotate(180deg); }
.done-items { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }

/* ---------------- 按钮 ---------------- */
.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #171d20; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--brand); font-size: 13px; cursor: pointer; padding: 4px; }

/* ---------------- 底部弹层 ---------------- */
.sheet {
  border: none; border-radius: 20px 20px 0 0; background: #12171a; color: var(--text);
  max-width: 560px; width: 100%; margin: auto auto 0; padding: 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  padding-bottom: var(--safe-bottom);
  animation: sheetUp 0.22s ease;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__handle {
  width: 40px; height: 4px; border-radius: 2px; background: #2c3538;
  margin: 10px auto 4px;
}
.sheet__body { padding: 8px 20px 24px; }
.sheet__meta { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.chip {
  display: inline-block; background: rgba(240, 223, 173, 0.12); color: var(--brand);
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
}
.sheet__id { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sheet__title { margin: 0 0 4px; font-size: 22px; line-height: 1.5; }
.sheet__sub { margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.sheet__done-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: rgba(240, 223, 173, 0.08); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.sheet__done-date { font-size: 13px; color: var(--brand); }
.note-field { display: block; margin: 4px 0 14px; }
.note-field span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.note-field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 14px; line-height: 1.5; resize: vertical;
  font-family: inherit; outline: none;
}
.note-field textarea:focus { border-color: rgba(240, 223, 173, 0.5); }
.sheet__actions { display: flex; flex-direction: column; gap: 8px; }
.sheet__actions .btn { width: 100%; }

/* 表单字段（设置 / 日历） */
.form-field { display: block; border: none; padding: 0; margin: 0 0 16px; }
.form-field legend { font-size: 13px; color: var(--text-2); margin-bottom: 8px; padding: 0; }
.form-field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-field input[type="date"], .form-field input[type="time"], .form-field input[type="text"] {
  width: 100%; height: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 0 12px; font-size: 15px; outline: none; font-family: inherit;
}
.form-field__pair { display: flex; align-items: center; gap: 8px; }
.form-field__pair input { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-3); margin: 6px 0 0; }

.level-switch { display: flex; flex-direction: column; gap: 8px; }
.level-switch button {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 12px 14px; font-size: 15px; cursor: pointer; min-height: 48px;
}
.level-switch button.is-active { border-color: var(--brand); color: var(--brand); }
.level-switch button:disabled { opacity: 0.4; cursor: not-allowed; }
.level-switch button span { font-size: 12px; color: var(--text-3); }
.level-switch button.is-active span { color: var(--brand); }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-switch button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 14px; font-size: 15px; line-height: 1.2; cursor: pointer; min-height: 56px;
}
.mode-switch button.is-active { border-color: var(--brand); color: var(--brand); }
.mode-switch button span { font-size: 12px; color: var(--text-3); }
.mode-switch button.is-active span { color: var(--brand); }

.custom-row { display: flex; gap: 8px; }
.custom-row input { flex: 1; min-width: 0; }
.custom-row select {
  width: 118px; height: 44px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 0 8px; font-size: 13px; outline: none;
}
.backup-row { display: flex; gap: 8px; }
.backup-row .btn { flex: 1; }
.settings-foot { text-align: center; color: var(--text-3); font-size: 12px; margin: 18px 0 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 300;
  transform: translateX(-50%) translateY(16px);
  background: rgba(18, 23, 26, 0.95); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 10px 18px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 48px); text-align: center;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 分享画布 ---------------- */
.share-canvas { position: fixed; left: -9999px; top: 0; }

/* ---------------- 桌面端适配 ---------------- */
@media (min-width: 640px) {
  .page { padding-top: 12px; }
  .progress-card { padding: 26px 30px; }
  .bento__wall, .bento__cell--cats, .bento__cell--recent { padding: 18px; }
}

/* ---------------- 减少动效 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
