:root {
  --accent: #e0a800; --accent-soft: #fff3c4;
  --bg: #ffffff; --bg2: #f6f6f4; --bg3: #ececea; --line: #dddddb;
  --text: #1d1d1f; --muted: #86868b; --sel: #fde68a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --accent: #f5c518; --accent-soft: #3a3010; --bg: #1e1e1e; --bg2: #252525; --bg3: #2f2f2f;
    --line: #3a3a3a; --text: #f2f2f2; --muted: #9a9a9f; --sel: #5a4a10; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button, select, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; border-radius: 6px; padding: 4px 8px; }
button:hover { background: var(--bg3); }
.app { display: grid; grid-template-columns: 220px 300px 1fr; height: 100%; }
.pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.folders { background: var(--bg2); }
.list { background: var(--bg); }
.bar { display: flex; align-items: center; gap: 4px; padding: 10px 12px; min-height: 52px; }
.bar h1, .bar h2 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { font-size: 20px; color: var(--accent); }
.mobile-only { display: none; }
.spacer { flex: 1; }

#folder-list { flex: 1; overflow: auto; padding: 0 8px; }
.folder { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 7px 10px; }
.folder.active { background: var(--sel); }
.folder .count { color: var(--muted); font-size: 13px; }
.link { color: var(--accent); text-align: left; margin: 4px 8px; }
.sync { font-size: 12px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--line); }
.sync button { color: var(--accent); padding: 0; text-decoration: underline; }
.sync.error { color: #d33; }

.search { padding: 0 12px 8px; }
.search input { width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); }
#note-list { list-style: none; margin: 0; padding: 0 8px; overflow: auto; flex: 1; }
.group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.note { padding: 9px 12px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
.note.active { background: var(--sel); border-color: transparent; }
.note .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note .s time { color: var(--text); margin-right: 6px; }
.empty { color: var(--muted); text-align: center; }

.editor { border-right: 0; position: relative; }
.toolbar { border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar button { min-width: 32px; color: var(--muted); }
.toolbar #btn-back { color: var(--accent); font-size: 24px; }
.toolbar select { border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 3px; max-width: 140px; }
#btn-pin.on { background: var(--accent-soft); }
.meta { text-align: center; font-size: 12px; color: var(--muted); padding: 8px; }
#editor { flex: 1; overflow: auto; padding: 4px 32px 80px; outline: none; font-size: 16px; line-height: 1.5; word-wrap: break-word; }
#editor > div:first-child, #editor > h1:first-child { font-size: 26px; font-weight: 700; }
#editor h1 { font-size: 26px; margin: .4em 0; }
#editor h2 { font-size: 21px; margin: .4em 0; }
#editor a { color: var(--accent); }
ul.checklist { list-style: none; padding-left: 4px; }
ul.checklist > li { position: relative; padding-left: 28px; }
ul.checklist > li::before { content: ""; position: absolute; left: 0; top: .2em; width: 16px; height: 16px;
  border: 1.5px solid var(--muted); border-radius: 50%; cursor: pointer; }
ul.checklist > li.checked::before { background: var(--accent); border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg); }
ul.checklist > li.checked { color: var(--muted); text-decoration: line-through; }
.placeholder { position: absolute; inset: 52px 0 0; display: none; place-items: center; color: var(--muted); background: var(--bg); }
body.no-note .placeholder { display: grid; }
body.no-note .toolbar > *:not(#btn-back) { visibility: hidden; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); width: min(460px, 94vw); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin-top: 0; }
.hint { color: var(--muted); font-size: 14px; }
.opt { display: block; padding: 6px 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
fieldset label { display: block; font-size: 13px; margin: 6px 0; }
fieldset input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row button { border: 1px solid var(--line); padding: 6px 12px; }
.primary { background: var(--accent) !important; color: #000 !important; border-color: var(--accent) !important; }
.error { color: #d33; font-size: 14px; min-height: 1em; }
.plan-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px;
  background: var(--accent-soft); border-radius: 10px; font-size: 14px; font-weight: 600; }
button.small { padding: 4px 10px; font-size: 14px; border-radius: 999px; }
.perks { padding-left: 20px; line-height: 1.8; }
.buy { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.buy button { flex: 1; padding: 10px; border-radius: 10px; font-weight: 700; border: 0; }
.key { display: block; font-size: 13px; margin-top: 8px; }
.key input { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); font-family: Consolas, monospace; }

/* Phones: one pane at a time */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .pane { display: none; border: 0; }
  body.view-folders .folders, body.view-list .list, body.view-editor .editor { display: flex; }
  .mobile-only { display: inline-block; }
  #editor { padding: 4px 16px 80px; }
}
/* Tablets / small laptops: hide folders column */
@media (min-width: 761px) and (max-width: 1000px) {
  .app { grid-template-columns: 260px 1fr; }
  .folders { display: none; }
  body.view-folders .folders { display: flex; position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 5; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  #btn-folders { display: inline-block; }
}
