:root {
  --bg:#f6f7fb; --card:#fff; --ink:#111827; --mute:#6b7280; --line:#e5e7eb; --accent:#1d4ed8;
  --s10:#15803d; --s8:#22c55e; --s6:#a3e635; --s4:#e5e7eb; --s2:#fca5a5; --s0:#d1d5db;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1117; --card:#181b24; --ink:#e5e7eb; --mute:#9ca3af; --line:#2a2f3c; --s4:#2a2f3c; --s0:#3a3f4c; }
}
* { box-sizing:border-box; }
html, body { overscroll-behavior-y:none; margin:0; background:var(--bg); color:var(--ink); font:15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font:inherit; color:inherit; background:none; border:0; cursor:pointer; }

header { display:flex; align-items:center; gap:4px; padding:calc(8px + env(safe-area-inset-top)) 8px 6px; position:sticky; top:0; background:var(--bg); z-index:2; }
header h1 { flex:1; margin:0; font-size:16px; text-align:center; text-transform:capitalize; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
header button { width:36px; height:36px; border-radius:10px; font-size:22px; flex:none; }
header button:active { background:var(--line); }
#today { font-size:26px; color:var(--accent); }
#gear { font-size:18px; color:var(--mute); }
#filt { width:auto; padding:0 8px; font-size:12px; color:#fff; background:var(--accent); height:28px; border-radius:14px; }
#city { width:auto; padding:0 8px; font-size:12px; color:var(--mute); border:1px solid var(--line); height:28px; border-radius:14px; }

#dow { display:grid; grid-template-columns:repeat(7,1fr); padding:0 4px; font-size:11px; color:var(--mute); text-align:center; text-transform:uppercase; letter-spacing:.04em; }
#grid { display:grid; grid-template-columns:repeat(7,1fr); gap:3px; padding:4px; }
.day { transition:transform .08s; }
.day:active { transform:scale(.96); }
.day { background:var(--card); border-radius:8px; min-height:96px; padding:3px 3px 4px; display:flex; flex-direction:column; gap:2px; overflow:hidden; text-align:left; border:1px solid transparent; }
.day.other { opacity:.38; }
.day.today { border-color:var(--accent); }
.day .n { font-size:12px; color:var(--mute); padding-left:2px; }
.day.today .n { color:var(--accent); font-weight:700; }
.pill { font-size:10px; line-height:1.15; padding:2px 3px; border-radius:4px; background:var(--s4); overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; word-break:break-word; color:#0b1a0e; }
.pill.s10,.pill.s9 { background:var(--s10); color:#fff; font-weight:600; }
.pill.s8,.pill.s7 { background:var(--s8); }
.pill.s6 { background:var(--s6); }
.pill.un { background:var(--s0); color:var(--mute); }
.pill.fav { outline:1.5px solid var(--accent); outline-offset:-1.5px; }
@media (prefers-color-scheme: dark) { .pill { color:var(--ink); } .pill.s8,.pill.s7,.pill.s6 { color:#0b1a0e; } }
.more { font-size:10px; color:var(--mute); padding-left:3px; margin-top:auto; }
.empty { grid-column:1/-1; text-align:center; color:var(--mute); padding:40px 20px; }

#scrim { position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:3; animation:fade .2s; }
@keyframes fade { from { opacity:0 } }
@keyframes inl { from { transform:translateX(24px); opacity:0 } }
@keyframes inr { from { transform:translateX(-24px); opacity:0 } }
.slide-l { animation:inl .18s ease-out; } .slide-r { animation:inr .18s ease-out; }
.chips { display:flex; gap:6px; overflow-x:auto; padding:2px 0 10px; margin:0 -14px; padding-left:14px; scrollbar-width:none; }
.chips::-webkit-scrollbar { display:none; }
.chip { flex:none; font-size:12.5px; padding:5px 10px; border-radius:14px; border:1px solid var(--line); color:var(--mute); white-space:nowrap; }
.chip.on { background:var(--accent); border-color:var(--accent); color:#fff; }
.cat { text-transform:capitalize; }
.dayhead { display:flex; align-items:center; gap:4px; margin-bottom:6px; }
.dayhead h2 { flex:1; margin:0; text-align:center; }
.dnav { width:36px; height:36px; font-size:22px; border-radius:10px; color:var(--mute); }
.dnav:active { background:var(--line); }
.fb button.pop { animation:pop .25s; }
@keyframes pop { 50% { transform:scale(1.4) } }
#sheet, #settings { overscroll-behavior:contain; transition:transform .22s cubic-bezier(.2,.8,.2,1); will-change:transform; touch-action:pan-y; position:fixed; left:0; right:0; bottom:0; max-height:88vh; overflow:auto; background:var(--card); border-radius:18px 18px 0 0; z-index:4; padding:6px 14px calc(16px + env(safe-area-inset-bottom)); box-shadow:0 -6px 30px rgba(0,0,0,.18); }
@media (min-width:720px) { #sheet, #settings { left:50%; transform:translateX(-50%); width:640px; } #grid { max-width:980px; margin:0 auto; } .day { min-height:110px; } .pill { font-size:12px; } }
.handle { width:38px; height:4px; border-radius:2px; background:var(--line); margin:4px auto 10px; }
#sheet h2 { font-size:17px; text-transform:capitalize; }
#sheet h3.sub { font-size:12px; color:var(--mute); text-transform:uppercase; letter-spacing:.04em; margin:14px 0 2px; border-top:1px solid var(--line); padding-top:10px; }

.ev { padding:10px 0; border-top:1px solid var(--line); display:grid; grid-template-columns:44px 1fr; gap:10px; }
.ev.haspic { grid-template-columns:44px 1fr 84px; }
.ev .pic { width:84px; height:84px; border-radius:10px; overflow:hidden; background:var(--line); display:block; }
.ev .pic img { width:100%; height:100%; object-fit:cover; display:block; }
@media (min-width:720px) { .ev.haspic { grid-template-columns:44px 1fr 120px; } .ev .pic { width:120px; height:90px; } }
.ev:first-of-type { border-top:0; }
.ev .sc { width:44px; height:44px; border-radius:10px; display:grid; place-items:center; font-weight:700; font-size:18px; background:var(--s4); color:#0b1a0e; }
.ev .sc.s10,.ev .sc.s9 { background:var(--s10); color:#fff; } .ev .sc.s8,.ev .sc.s7 { background:var(--s8); } .ev .sc.s6 { background:var(--s6); }
.ev .sc.s3,.ev .sc.s2,.ev .sc.s1 { background:var(--s2); } .ev .sc.un { background:var(--s0); color:var(--mute); font-weight:400; }
@media (prefers-color-scheme: dark) { .ev .sc { color:var(--ink); } .ev .sc.s8,.ev .sc.s7,.ev .sc.s6,.ev .sc.s3,.ev .sc.s2,.ev .sc.s1 { color:#0b1a0e; } }
.ev .t { font-weight:600; }
.ev .t a { color:inherit; text-decoration:none; }
.ev .m { color:var(--mute); font-size:13px; margin-top:1px; }
.ev .d { font-size:13px; margin-top:4px; color:var(--ink); opacity:.85; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.ev .d.open { -webkit-line-clamp:unset; }
.more-link { display:inline-block; margin-top:6px; font-size:13px; color:var(--accent); text-decoration:none; font-weight:600; }
.more-link:active { opacity:.6; }
.places { margin:6px 0 0; padding:0 0 0 16px; font-size:13px; }
.places a { color:var(--accent); text-decoration:none; font-weight:600; }
.fb { display:flex; gap:2px; margin-top:6px; margin-left:-6px; }
.fb button { font-size:20px; width:38px; height:34px; border-radius:8px; opacity:.45; filter:grayscale(.6); transition:transform .1s; }
.fb button.on { opacity:1; filter:none; background:var(--line); transform:scale(1.12); }
.fb button:active { transform:scale(1.25); }
.toggle { width:100%; text-align:center; color:var(--mute); padding:12px; font-size:13px; border-top:1px solid var(--line); margin-top:6px; }
.src { font-size:11px; color:var(--mute); }

#settings h2 { font-size:17px; margin:4px 0 12px; }
#settings h3 { font-size:13px; color:var(--mute); text-transform:uppercase; letter-spacing:.04em; margin:16px 0 6px; }
#settings table { width:100%; border-collapse:collapse; font-size:13px; }
#settings td { padding:6px 4px; border-top:1px solid var(--line); vertical-align:top; }
#settings td:first-child { font-weight:600; }
#settings .err { color:#dc2626; font-size:12px; }
#settings label { display:flex; align-items:center; gap:6px; font-size:13px; }
#settings input[type=number] { width:64px; font:inherit; padding:4px 6px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:inherit; }
.btn { background:var(--accent); color:#fff; padding:9px 14px; border-radius:9px; font-weight:600; }
.btn:disabled { opacity:.5; }
pre.out { font-size:11.5px; background:var(--bg); padding:8px; border-radius:8px; white-space:pre-wrap; max-height:200px; overflow:auto; }

body.login { display:grid; place-items:center; min-height:100vh; }
body.login form { display:flex; flex-direction:column; gap:10px; width:min(320px, 90vw); }
body.login h1 { margin:0 0 6px; text-align:center; }
body.login input { font:inherit; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--card); color:inherit; }
body.login button { background:var(--accent); color:#fff; padding:12px; border-radius:10px; font-weight:600; }
body.login #msg { color:#dc2626; text-align:center; min-height:1.2em; margin:0; }

@media (prefers-reduced-motion: reduce) { *, #sheet, #settings { transition:none !important; animation:none !important; } }
