/* Notatnik — styl "zeszyt w linie + zakreślacz" */

@font-face { font-family: "Atkinson"; font-weight: 400; font-display: swap;
  src: url(../fonts/atkinson-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson"; font-weight: 400; font-display: swap;
  src: url(../fonts/atkinson-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson"; font-weight: 700; font-display: swap;
  src: url(../fonts/atkinson-latin-700.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson"; font-weight: 700; font-display: swap;
  src: url(../fonts/atkinson-ext-700.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --paper: #F5F7F6;
  --sheet: #FFFFFF;
  --ink: #17212B;
  --graphite: #5B6670;
  --rule: #D9E1DE;
  --marker: #F4CF3A;
  --marker-soft: #FBEBA6;
  --line: 1.75rem;           /* wysokość linii w zeszycie */
  --gutter: 16px;
  font-family: "Atkinson", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); font-size: 1.0625rem; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

#app { max-width: 42rem; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Lista ---------- */
.list-head { padding: 28px var(--gutter) 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.list-head h1 { margin: 0; font-size: 2rem; line-height: 1.1; letter-spacing: -0.01em; }
.list-head .count { color: var(--graphite); font-size: 0.9375rem; }

.notes { list-style: none; margin: 0; padding: 0 0 120px; border-top: 1px solid var(--rule); }
.notes li { border-bottom: 1px solid var(--rule); }
.notes a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px var(--gutter); text-decoration: none; color: inherit; }
.notes a:active { background: var(--marker-soft); }
.notes .title { font-weight: 700; font-size: 1.125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes .title.untitled { color: var(--graphite); font-weight: 400; font-style: italic; }
.notes .date { color: var(--graphite); font-size: 0.875rem; align-self: center; }
.notes .excerpt { grid-column: 1 / -1; color: var(--graphite); font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 48px var(--gutter); color: var(--graphite); max-width: 28ch; }
.empty strong { display: block; color: var(--ink); font-size: 1.25rem; margin-bottom: 4px; }

.new-note {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom));
  border: 2px solid var(--ink); background: var(--marker); color: var(--ink);
  font-weight: 700; font-size: 1.0625rem; padding: 14px 28px; border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.new-note:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 0 0 var(--ink); }

/* ---------- Notatka ---------- */
.bar { position: sticky; top: 0; z-index: 1; background: var(--paper); display: flex; align-items: center; justify-content: space-between; padding: 8px calc(var(--gutter) - 8px); border-bottom: 1px solid var(--rule); }
.back { background: none; border: 0; padding: 10px 8px; font-weight: 700; cursor: pointer; }
.status { color: var(--graphite); font-size: 0.875rem; padding: 0 8px; }

.sheet { flex: 1; background: var(--sheet); display: flex; flex-direction: column; padding: 20px var(--gutter) 40px; }
.title-input { border: 0; background: none; font-size: 1.625rem; font-weight: 700; line-height: 1.2; padding: 0 0 12px; width: 100%; }
.title-input::placeholder, .body-input::placeholder { color: #9AA5A1; }
.title-input:focus, .body-input:focus { outline: none; }

/* Treść na papierze w linie: linie wyrównane do wysokości wiersza */
.body-input {
  flex: 1; min-height: 60vh; width: 100%; border: 0; resize: none; padding: 0;
  line-height: var(--line); font-size: 1.0625rem;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px), var(--rule) var(--line));
  background-attachment: local;
}

/* Pasek: przyciski */
.bar .status { flex: 1; text-align: right; }
.bar .delete, .bar .mode { border: 0; background: none; padding: 10px 8px; cursor: pointer; font-weight: 700; }
.bar .delete { color: var(--graphite); font-weight: 400; }
.bar .delete.armed { color: #A3271B; font-weight: 700; }
.bar .mode { border: 2px solid var(--ink); border-radius: 999px; padding: 6px 16px; margin-left: 4px; }
.bar .mode.primary { background: var(--marker); }

/* Narzędzia edycji */
.tools { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.tools button { flex: none; border: 1px solid var(--rule); background: var(--paper); border-radius: 8px; padding: 8px 10px; font-size: 0.9375rem; cursor: pointer; }
.tools button:active { background: var(--marker-soft); border-color: var(--ink); }

/* Podgląd */
.note-title { font-size: 1.625rem; line-height: 1.2; margin: 0 0 16px; }
.note-title.untitled { color: var(--graphite); font-weight: 400; font-style: italic; }
.md-empty { color: var(--graphite); }
.md { line-height: var(--line); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3 { line-height: 1.25; margin: 1.4em 0 0.4em; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.25rem; } .md h3 { font-size: 1.0625rem; }
.md p { margin: 0 0 0.75em; }
.md ul, .md ol { margin: 0 0 0.75em; padding-left: 1.5em; }
.md strong { background: linear-gradient(transparent 58%, var(--marker-soft) 58%); }
.md a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.md code { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; font-size: 0.9em; }
.md pre { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; overflow-x: auto; line-height: 1.5; }
.md pre code { border: 0; padding: 0; }
.md blockquote { margin: 0 0 0.75em; padding-left: 12px; border-left: 3px solid var(--marker); color: var(--graphite); }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5em 0; }

/* Zadania z checkboxem: duże pole do kliknięcia, zrobione = przekreślone */
.md li.task { list-style: none; margin-left: -1.5em; padding: 6px 0 6px 2.25em; position: relative; cursor: pointer; line-height: 1.5; }
.md li.task > input[type=checkbox] {
  appearance: none; position: absolute; left: 0; top: 4px; width: 1.5rem; height: 1.5rem; margin: 0;
  border: 2px solid var(--ink); border-radius: 6px; background: var(--sheet); cursor: pointer;
}
.md li.task > input[type=checkbox]:checked { background: var(--marker); }
.md li.task > input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 6px; top: 1px; width: 6px; height: 12px;
  border: solid var(--ink); border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.md li.task:has(> input:checked) { color: var(--graphite); text-decoration: line-through; text-decoration-color: var(--graphite); }

/* Kopia: link w nagłówku + przypomnienie */
.list-head .count { margin-left: auto; }
.backup-link { color: var(--ink); font-weight: 700; text-decoration: none; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 14px; font-size: 0.9375rem; align-self: center; }
.backup-link:active { background: var(--marker-soft); }
.reminder { margin: 0 var(--gutter) 14px; padding: 12px 14px; background: var(--marker-soft); border-left: 4px solid var(--marker); border-radius: 0 10px 10px 0; }
.reminder p { margin: 0 0 8px; }
.reminder-actions { display: flex; gap: 16px; align-items: center; }
.reminder-go { font-weight: 700; color: var(--ink); }
.reminder-later { border: 0; background: none; padding: 4px 0; color: var(--graphite); cursor: pointer; text-decoration: underline; }

/* Ekran kopii */
.backup { padding: 20px var(--gutter) 48px; background: var(--sheet); flex: 1; }
.backup h1 { font-size: 1.625rem; margin: 0 0 8px; }
.backup-state { margin: 0 0 8px; color: var(--graphite); }
.backup-state strong { color: var(--ink); }
.backup section { border-top: 1px solid var(--rule); margin-top: 20px; padding-top: 16px; }
.backup h2 { font-size: 1.125rem; margin: 0 0 6px; }
.backup p { margin: 0 0 12px; max-width: 60ch; }
.backup .hint { color: var(--graphite); font-size: 0.9375rem; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.btn { display: inline-block; border: 2px solid var(--ink); background: var(--sheet); color: var(--ink); border-radius: 999px; padding: 11px 20px; font-weight: 700; cursor: pointer; text-align: center; }
.btn.primary { background: var(--marker); box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(2px); }
.file-btn { position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-btn:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.backup-msg { margin: 12px 0 0; font-weight: 700; }
.backup-msg:empty { display: none; }
.backup-msg.bad { color: #A3271B; }

/* Wyszukiwanie */
.search { padding: 0 var(--gutter) 14px; }
.search-input {
  width: 100%; border: 2px solid var(--ink); border-radius: 12px; background: var(--sheet);
  padding: 11px 14px 11px 40px; font-size: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%235B6670' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='7.5' cy='7.5' r='5.5'/%3E%3Cpath d='m12 12 4.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center;
}
.search-input:focus { outline: none; box-shadow: 0 0 0 3px var(--marker); }
.found { margin: 0; padding: 0 var(--gutter) 8px; color: var(--graphite); font-size: 0.875rem; }
.found ~ .notes .excerpt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: var(--marker-soft); color: inherit; border-radius: 2px; box-shadow: 0 0 0 1px var(--marker-soft); }
.no-results { padding: 20px var(--gutter); color: var(--graphite); }
.no-results p { margin: 0 0 12px; }
.create-from-search { border: 2px solid var(--ink); background: var(--sheet); border-radius: 999px; padding: 10px 18px; font-weight: 700; cursor: pointer; }
.create-from-search:active { background: var(--marker-soft); }

/* Linki [[...]] */
.md a.wikilink { color: var(--ink); font-weight: 700; text-decoration: none; background: var(--marker-soft); border-radius: 4px; padding: 0 3px; }
.md a.wikilink:active { background: var(--marker); }
.md a.wikilink.missing { font-weight: 400; background: none; padding: 0; color: var(--graphite); text-decoration: underline dashed; text-underline-offset: 3px; }

/* Wybór notatki do linku */
.picker { border: 2px solid var(--ink); border-radius: 12px; padding: 10px; margin: 0 0 14px; background: var(--sheet); }
.picker-input { width: 100%; border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; background: var(--paper); }
.picker-list { list-style: none; margin: 6px 0; padding: 0; }
.picker-list button { width: 100%; text-align: left; border: 0; background: none; padding: 10px 4px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.picker-list li:last-child button { border-bottom: 0; }
.picker-list button.new { font-weight: 700; }
.picker-list button:active { background: var(--marker-soft); }
.picker-list .hint { color: var(--graphite); padding: 8px 4px; font-size: 0.9375rem; }
.picker-cancel { border: 0; background: none; color: var(--graphite); padding: 6px 4px; cursor: pointer; }

/* Linkują tutaj */
.backlinks { margin-top: 40px; border-top: 2px solid var(--ink); padding-top: 12px; }
.backlinks h2 { font-size: 1rem; margin: 0 0 4px; }
.backlinks ul { list-style: none; margin: 0; padding: 0; }
.backlinks li { border-bottom: 1px solid var(--rule); }
.backlinks a { display: block; padding: 10px 0; text-decoration: none; color: inherit; }
.backlinks a:active { background: var(--marker-soft); }
.bl-title { display: block; font-weight: 700; }
.bl-line { display: block; color: var(--graphite); font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-empty { color: var(--graphite); font-size: 0.9375rem; margin: 4px 0 0; }
.bl-empty code { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
