:root {
  --bg: #f6f7fb; --panel: #fff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ee;
  --accent: #4f6bed; --accent-soft: #e8ecfd; --danger: #d64545; --ok: #2f9e6b; --warn: #d98b1c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171f; --panel: #1c2029; --text: #e6e9f0; --muted: #9098aa; --line: #2c313d; --accent: #7b91ff; --accent-soft: #262d48; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
a { color: var(--accent); cursor: pointer; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }

.top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { width: 28px; height: 28px; }
.icon-btn { border: none; background: none; font-size: 20px; padding: 6px 8px; color: var(--text); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-line { font-size: 12px; color: var(--muted); padding: 4px 14px; }

main { flex: 1; overflow: auto; padding: 8px 14px 90px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 11px; color: var(--muted); text-decoration: none; display: grid; gap: 1px; }
.tabs a span { font-size: 19px; line-height: 1.2; }
.tabs a.active { color: var(--accent); font-weight: 600; }

input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, select { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; min-height: 200px; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); padding: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list li .grow { flex: 1; min-width: 0; }
.list .sub { font-size: 13px; color: var(--muted); }
.list input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.done { text-decoration: line-through; color: var(--muted); }
.empty { color: var(--muted); padding: 6px 0; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.overdue { background: #fdf0dd; color: var(--warn); }
.fab { position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 28px;
  background: var(--accent); color: #fff; border: none; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.add-row { display: flex; gap: 8px; margin: 8px 0; }
.add-row input { flex: 1; }
.note-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.note-item .t { font-weight: 600; }
.note-item .b { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-head { margin: 16px 0 4px; font-weight: 600; }
.day-head.today { color: var(--accent); }

.sheet { position: fixed; inset: 0; background: rgba(10,15,30,.45); display: flex; align-items: flex-end; z-index: 10; }
.sheet-card { background: var(--panel); width: 100%; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.form label.check input { width: 20px; height: 20px; }

.md { line-height: 1.6; } .md h2 { text-transform: none; color: var(--text); font-size: 19px; } .md h3, .md h4 { margin: 10px 0 4px; }
.md code { background: var(--bg); border-radius: 4px; padding: 0 4px; } .md pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow: auto; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--accent); color: var(--muted); }
.md ul.checklist { list-style: none; padding-left: 2px; }
.md ul.checklist input[type=checkbox] { width: 20px; height: 20px; padding: 0; margin: 0 8px 0 0; vertical-align: -4px; accent-color: var(--accent); }
.atts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.atts img { height: 96px; border-radius: 8px; }
.atts audio { width: 100%; }
.att-wrap { position: relative; }

#toasts { position: fixed; left: 12px; right: 84px; bottom: calc(80px + env(safe-area-inset-bottom)); display: grid; gap: 8px; z-index: 20; }
.toast { background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.reminder { background: var(--panel); color: var(--text); border-left: 4px solid var(--warn); }
.login { max-width: 420px; margin: 40px auto; }
