:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --text: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2a7ae2);
  --accent: var(--tg-theme-button-color, #2a7ae2);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d93a3a);
  --border: color-mix(in srgb, var(--text) 12%, transparent);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #1c1c1e; --bg-2: #000000; --text: #f2f2f2; --muted: #8e8e93;
    --link: #5aa2f5; --accent: #3d8bf0; --on-accent: #ffffff; --danger: #ff6b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: var(--text); }

header { position: sticky; top: 0; z-index: 2; background: var(--bg); display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 10px; border-bottom: 0.5px solid var(--border); }
.head-text { flex: 1; min-width: 0; }
#ttl { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sub { font-size: 12px; color: var(--muted); }
main { flex: 1; padding: 12px 16px 88px; max-width: 760px; width: 100%; margin: 0 auto; }

nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg); border-top: 0.5px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 2; }
nav button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button i { font-size: 22px; }
nav button.on { color: var(--accent); }
body.detail nav { display: none; }

.icon { border: 0; background: none; padding: 6px; color: var(--muted); font-size: 20px; line-height: 1; border-radius: 8px; }
.btn { border: 0.5px solid var(--border); background: color-mix(in srgb, var(--text) 6%, transparent); border-radius: 10px; padding: 8px 12px; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn i { font-size: 17px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 0.5px solid var(--border); background: transparent;
  white-space: nowrap; color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; display: inline-block; }

.thumb { position: relative; border-radius: 10px; overflow: hidden; background-size: cover; background-position: center;
  display: flex; align-items: flex-end; justify-content: space-between; padding: 6px 8px; font-size: 11px; font-weight: 600; }
.thumb .pf { font-size: 16px; }
.thumb.img { color: #fff; }
.thumb.img::after { content: ""; position: absolute; inset: 50% 0 0 0; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.thumb.img > * { position: relative; z-index: 1; }

.card { border: 0.5px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.row { display: flex; gap: 10px; }
.title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.note { font-size: 13px; color: var(--muted); margin-top: 3px; }
.small { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 6px; margin-top: 10px; }
.actions .btn:first-child { flex: 1; }

.search { position: relative; margin-bottom: 10px; }
.search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 17px; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 0; background: var(--bg-2); outline: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.grid .title { font-size: 13px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid > div { cursor: pointer; min-width: 0; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 0.5px solid var(--border); cursor: pointer; }
.cat-ico { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }

.empty { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty i { font-size: 30px; }
.box { background: var(--bg-2); border-radius: 10px; padding: 9px 11px; font-size: 14px; margin-bottom: 10px; }
.note-edit { width: 100%; min-height: 70px; border-radius: 10px; border: 0.5px solid var(--border); background: var(--bg-2);
  padding: 9px 11px; resize: vertical; font: inherit; color: var(--text); }
.pending { display: inline-flex; align-items: center; gap: 4px; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 5; max-width: 90vw; }
