:root {
  --bg: #101722; --card: #1E2B3D; --card2: #253549; --accent: #88BFFF; --accent-soft: rgba(136,191,255,.18);
  --text: #fff; --muted: #8E9BAE; --divider: #2C3D54; --ok: #7FD6A4; --warn: #F2B866; --danger: #FF7A7A;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { display: flex; min-height: 100%; }
#nav { width: 200px; padding: 18px 12px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; margin: 0 6px 18px; }
.brand img { width: 32px; height: 32px; }
.nav-btn { background: none; border: 0; text-align: left; padding: 12px 14px; border-radius: 12px; color: var(--muted); font-size: 16px; }
.nav-btn:hover { background: var(--card); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sync-pill { margin-top: auto; font-size: 13px; color: var(--muted); padding: 8px 12px; display: flex; gap: 8px; align-items: center; }
.sync-pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-pill.ok::before { background: var(--ok); } .sync-pill.busy::before { background: var(--accent); }
.sync-pill.warn::before { background: var(--warn); } .sync-pill.err::before { background: var(--danger); }
main { flex: 1; padding: 22px 22px 90px; max-width: 1100px; outline: none; min-width: 0; }
h1 { font-weight: 300; font-size: 30px; margin: 0 0 16px; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--card2); border-radius: 12px; padding: 10px 14px; margin-bottom: 6px; min-height: 56px; }
.row.clickable { cursor: pointer; } .row.clickable:hover { filter: brightness(1.08); }
.row .grow { flex: 1; min-width: 0; }
.title { overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta.overdue { color: var(--warn); }
.done .title { text-decoration: line-through; opacity: .55; }
.check { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--muted); background: none; flex: none; position: relative; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after { content: ""; position: absolute; left: 10px; top: 5px; width: 8px; height: 15px; border: solid #0E1A2A; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.prio { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.p1 { background: var(--ok); } .p2 { background: var(--warn); } .p3 { background: var(--danger); } .p0 { background: transparent; }
.btn { background: var(--card2); border: 0; border-radius: 12px; padding: 11px 18px; min-height: 46px; }
.btn.accent { background: var(--accent); color: #0E1A2A; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.field { width: 100%; background: var(--card2); border: 1px solid var(--divider); border-radius: 12px; padding: 12px 14px; min-height: 48px; }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea.field { resize: vertical; }
.seg { display: inline-flex; background: var(--card2); border-radius: 14px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 9px 16px; border-radius: 11px; color: var(--text); }
.seg button.on { background: var(--accent); color: #0E1A2A; font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { flex: 1; min-width: 180px; }
.empty { color: var(--muted); padding: 18px 4px; }
.when { width: 74px; flex: none; color: var(--accent); font-weight: 600; }
.when small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.notes-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 14px; min-height: 70vh; }
.note-editor { display: flex; flex-direction: column; }
.note-editor .t { background: none; border: 0; font-size: 22px; font-weight: 600; padding: 4px 0; outline: none; }
.note-editor .b { flex: 1; background: none; border: 0; border-top: 1px solid var(--divider); padding: 12px 0; min-height: 50vh; outline: none; resize: none; line-height: 1.5; }
.note-row.sel .title { color: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .hd { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.cal .day { aspect-ratio: 1.1; border: 0; border-radius: 12px; background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; }
.cal .day.out { opacity: .4; } .cal .day.today { background: var(--accent); color: #0E1A2A; font-weight: 700; }
.cal .day.sel { outline: 2px solid var(--accent); }
.cal .dots { display: flex; gap: 3px; } .cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal .day.today .dots i { background: #0E1A2A; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: var(--card); border-radius: 20px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; }
.modal h3 { margin: 0 0 14px; font-size: 20px; }
.form { display: grid; gap: 10px; }
.form label { color: var(--muted); font-size: 13px; display: grid; gap: 6px; }
.form .inline { display: flex; gap: 10px; } .form .inline > * { flex: 1; }
.actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.actions .spacer { flex: 1; }
.msg { color: var(--muted); font-size: 14px; } .msg.err { color: var(--danger); } .msg.warn { color: var(--warn); }
.back-link { display: none; }
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #nav { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; width: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: #0B111A; border-top: 1px solid var(--divider); z-index: 5; gap: 0; }
  .brand { display: none; }
  .nav-btn { text-align: center; padding: 10px 6px; font-size: 13px; flex: 1; }
  .sync-pill { position: fixed; top: 8px; right: 10px; margin: 0; padding: 4px 10px; background: var(--card); border-radius: 20px; font-size: 12px; }
  main { padding: 44px 12px 100px; }
  h1 { font-size: 26px; margin-top: 4px; }
  .grid2 { grid-template-columns: 1fr; }
  .notes-wrap { grid-template-columns: 1fr; }
  .notes-wrap.editing .note-list { display: none; }
  .notes-wrap:not(.editing) .note-editor { display: none; }
  .back-link { display: inline-block; }
}
