:root {
  --bg: #f7f7f8; --surface: #ffffff; --surface2: #f0f0f3; --line: #e3e3e8;
  --text: #1c1c21; --muted: #6f6f7a; --accent: #3e63dd; --danger: #d93036; --warn: #c26a00; --ok: #2f8a44;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1011; --surface: #17181a; --surface2: #1f2023; --line: #2a2c30;
    --text: #ececef; --muted: #9a9ba3; --accent: #7b93f5; --danger: #ff6369; --warn: #f5a524; --ok: #4cc26a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif; word-break: keep-all; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  font-size: 16px; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
button { background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
[hidden] { display: none !important; }

#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#loginForm { width: min(320px, 100%); display: grid; gap: 10px; }
#loginForm h1 { font-size: 20px; margin: 0 0 6px; }
.err { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }
.meta { color: var(--muted); margin: 0; font-size: 12px; }

header {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line);
}
#tabs { display: flex; gap: 4px; }
#tabs button { background: none; border-color: transparent; color: var(--muted); padding: 6px 10px; }
#tabs button.on { color: var(--text); background: var(--surface2); border-color: var(--line); }

#filters { padding: 10px 16px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#laneChips { display: flex; gap: 6px; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap;
}
.chip.off { opacity: .4; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.toggle input { width: auto; }
#search { flex: 1; min-width: 120px; padding: 6px 10px; }

main { padding: 12px 16px 80px; max-width: 900px; margin: 0 auto; }
h3.group { font-size: 13px; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
h3.group.overdue { color: var(--danger); }

.ev {
  display: grid; grid-template-columns: auto 58px 1fr; gap: 10px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 6px;
}
.ev.done { opacity: .5; } .ev.done .title { text-decoration: line-through; }
.ev input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; }
.dd { font-weight: 700; font-size: 13px; text-align: center; border-radius: 6px; padding: 2px 0; background: var(--surface2); }
.dd.today { background: var(--danger); color: #fff; }
.dd.soon { color: var(--danger); }
.dd.past { color: var(--danger); background: none; border: 1px dashed var(--danger); }
.body { min-width: 0; cursor: pointer; }
.line1 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.title { font-weight: 600; margin-top: 2px; }
.note { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; }
.badge { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid currentColor; }
.badge.hard { color: var(--danger); }
.badge.event { color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.calhead { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.calhead strong { flex: 1; text-align: center; }
#calGrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cell {
  min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px; cursor: pointer; overflow: hidden;
}
.cell.other { opacity: .35; }
.cell.today { border-color: var(--danger); }
.cell.sel { outline: 2px solid var(--accent); }
.cell .n { font-size: 11px; color: var(--muted); }
.cell .items { display: flex; flex-direction: column; gap: 1px; }
.cell .it { font-size: 10.5px; line-height: 1.3; padding: 0 3px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.cell .more { font-size: 10px; color: var(--muted); }
@media (max-width: 560px) {
  .cell { min-height: 48px; }
  .cell .it { font-size: 0; height: 5px; padding: 0; }
}
#dayList { margin-top: 12px; }

.logrow { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.logrow .when { color: var(--muted); font-size: 12px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#evForm { display: grid; gap: 10px; padding: 16px; }
#evForm h2 { margin: 0; font-size: 17px; }
#evForm label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
#evForm label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
#evForm label.check input { width: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions span { flex: 1; }
