/* ==========================================================================
   פתקים חכמים — dark, warm-neutral, Hebrew-first.
   The one loud element is the card spine: a colour-coded edge that shimmers
   while the note is waiting to be sorted. Everything else stays quiet.
   ========================================================================== */

:root {
  --ink: #0e1013;
  --surface: #171a20;
  --raise: #1f242c;
  --line: #2a313b;
  --line-soft: #21262e;
  --text: #e9ecf1;
  --muted: #8d95a3;
  --brass: #d9a441;
  --brass-ink: #2a2113;
  --danger: #e4614f;

  --cat-idea: #d9a441;
  --cat-task: #56be92;
  --cat-link: #5e8cf0;
  --cat-info: #ac8bea;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --sans: "Assistant", "Segoe UI", system-ui, -apple-system, "Noto Sans Hebrew", Arial, sans-serif;
  --serif: "Frank Ruhl Libre", "Times New Roman", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  background: var(--ink);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
/* Numbers and number pairs read left-to-right even inside an RTL line. */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

a { color: var(--brass); text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.ico {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.ico.lg { width: 26px; height: 26px; }

/* ---------- wordmark ---------- */
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: .01em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wordmark i { display: block; width: 26px; height: 3px; background: var(--brass); border-radius: 2px; }
.wordmark.small { font-size: 21px; }
.wordmark.small i { width: 18px; height: 2px; }

/* ---------- buttons ---------- */
.btn-primary {
  font: inherit;
  font-weight: 700;
  min-height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: var(--r-md);
  background: var(--brass);
  color: var(--brass-ink);
  cursor: pointer;
  transition: filter .18s ease, transform .18s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.985); }
.btn-primary[disabled] { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  font: inherit;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease;
}
.btn-ghost:hover { border-color: var(--brass); }
.btn-ghost.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.icon-btn:hover { color: var(--text); background: var(--raise); }

/* ---------- login ---------- */
#login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px 24px 26px;
}
.login-card .wordmark { justify-content: center; margin-bottom: 6px; }
.login-card > .muted { text-align: center; font-size: 14px; margin: 0 0 22px; }
.login-card .btn-primary { width: 100%; margin-top: 16px; }

.field { display: block; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.field input:focus { border-color: var(--brass); outline: none; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
}
.search-wrap:focus-within { border-color: var(--brass); }
#search {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  width: 34vw;
  max-width: 190px;
  min-width: 90px;
  padding: 0;
}
#search:focus { outline: none; }
#search::-webkit-search-cancel-button { filter: invert(.6); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit;
  font-size: 14px;
  min-height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--brass);
  border-color: color-mix(in srgb, var(--brass) 55%, transparent);
  background: color-mix(in srgb, var(--brass) 12%, transparent);
  font-weight: 600;
}

.filter-bar { display: flex; gap: 8px; padding: 12px 16px 0; flex-wrap: wrap; }
.filter-chip {
  font: inherit;
  font-size: 13px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { color: var(--text); border-color: var(--brass); }
.filter-chip .n { font-family: var(--mono); font-size: 11px; opacity: .7; margin-inline-start: 6px; }

.quick-add {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  align-items: flex-end;
}
.quick-add textarea {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  min-height: 56px;
}
.quick-add textarea:focus { outline: none; border-color: var(--brass); }
.quick-add textarea::placeholder { color: var(--muted); }

.notes-grid {
  padding: 4px 16px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
  align-items: start;
}
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }

/* ---------- note card + the spine ---------- */
.note-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px 16px 14px 14px;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.note-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0; bottom: 0;
  width: 3px;
  background: var(--spine, var(--line));
}
.note-card[data-cat="idea"] { --spine: var(--cat-idea); }
.note-card[data-cat="task"] { --spine: var(--cat-task); }
.note-card[data-cat="link"] { --spine: var(--cat-link); }
.note-card[data-cat="info"] { --spine: var(--cat-info); }

/* waiting for the archivist */
.note-card.sorting::before {
  background: linear-gradient(to bottom,
    var(--line) 0%, var(--brass) 45%, var(--line) 90%);
  background-size: 100% 220%;
  animation: spine-sweep 2.4s ease-in-out infinite;
}
@keyframes spine-sweep {
  0%   { background-position: 0 -120%; }
  100% { background-position: 0 220%; }
}

.note-card.pinned { border-color: color-mix(in srgb, var(--brass) 45%, var(--line)); }

.note-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.35;
  margin: 0;
}
.note-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}
.note-summary {
  font-size: 13.5px;
  color: var(--muted);
  border-inline-start: 2px solid color-mix(in srgb, var(--brass) 60%, transparent);
  padding-inline-start: 10px;
}
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  background: var(--raise);
}
.badge.cat { color: var(--spine, var(--text)); border-color: color-mix(in srgb, var(--spine, var(--line)) 40%, transparent); background: transparent; }
.badge.tag { color: #9fd4ff; background: #1b2733; }
.badge.collection { color: #dcbcff; background: #262034; }
.badge.state { color: var(--brass); background: transparent; border-color: color-mix(in srgb, var(--brass) 35%, transparent); }
.badge.state.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.src { color: var(--muted); background: transparent; border-color: var(--line); }

.note-files { display: flex; flex-wrap: wrap; gap: 8px; }
.note-files img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--ink);
}
.note-files audio { width: 100%; }

.note-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.note-actions button {
  font: inherit;
  font-size: 12.5px;
  min-height: 36px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, background .18s ease;
}
.note-actions button:first-child { color: var(--text); }
.note-actions button:hover { color: var(--text); background: var(--raise); }
.note-actions button.danger:hover { color: var(--danger); }

.task-check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); cursor: pointer; }
.task-check input { width: 19px; height: 19px; accent-color: var(--cat-task); }

.checklist-steps { display: flex; flex-direction: column; gap: 7px; margin-top: 2px; }
.checklist-step { display: flex; align-items: flex-start; gap: 9px; min-height: 36px; padding: 4px 0; font-size: 14.5px; cursor: pointer; }
.checklist-step input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brass); flex: none; }
.checklist-step.done .checklist-step-text { text-decoration: line-through; color: var(--muted); }

/* ---------- modal / sheet ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 5, 7, .62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-in .2s cubic-bezier(.22,.8,.3,1);
}
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-header h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  margin: 0;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary { flex: 1; }

/* ---------- import sheet ---------- */
.howto {
  margin: 0 0 18px;
  padding-inline-start: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.howto b { color: var(--text); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 30px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease;
}
.dropzone b { color: var(--text); font-size: 15px; }
.dropzone span { font-size: 13px; }
.dropzone:hover, .dropzone.over { border-color: var(--brass); background: var(--surface); }

.file-line { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 16px; color: var(--text); }
.file-line .ico { width: 16px; height: 16px; color: var(--muted); }

.opt-group { border: none; padding: 0; margin: 0 0 18px; }
.opt-group legend {
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  font-size: 14.5px;
  cursor: pointer;
}
.switch input { width: 19px; height: 19px; accent-color: var(--brass); flex: none; }
.switch em { font-style: normal; color: var(--muted); font-size: 12.5px; margin-inline-start: 6px; }
.switch input:disabled + span { opacity: .45; }

.mode {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink);
  cursor: pointer;
  transition: border-color .18s ease;
}
.mode input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--brass); grid-row: span 2; }
.mode b { font-size: 14.5px; }
.mode span { font-size: 13px; color: var(--muted); line-height: 1.5; }
.mode:has(input:checked) { border-color: var(--brass); }
.mode.danger:has(input:checked) { border-color: var(--danger); }
.mode.danger:has(input:checked) b { color: var(--danger); }

.ledger {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.ledger-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 11px 14px;
  font-size: 14px;
  background: var(--ink);
}
.ledger-row + .ledger-row { border-top: 1px solid var(--line-soft); }
.ledger-row b { font-size: 19px; font-weight: 500; }
.ledger-row.remove b { color: var(--danger); }

.busy-line { font-size: 15px; margin: 0 0 14px; }
.done-title { font-family: var(--serif); font-size: 20px; margin: 0 0 14px; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--raise);
  overflow: hidden;
}
.bar i { display: block; height: 100%; width: 0; background: var(--brass); transition: width .3s ease; }
.bar.slim { height: 4px; flex: 1; }

/* ---------- sorting queue strip ---------- */
.queue-strip {
  position: fixed;
  inset-inline: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.queue-text { font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: baseline; }
.queue-text b { color: var(--brass); }
.queue-strip .icon-btn { width: 36px; height: 36px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  inset-inline: 0;
  margin-inline: auto;
  width: fit-content;
  max-width: 90vw;
  z-index: 50;
  background: var(--raise);
  border: 1px solid var(--line);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
}

/* ---------- wide screens ---------- */
@media (min-width: 700px) {
  .quick-add { max-width: 820px; margin-inline: auto; }
  .notes-grid { max-width: 980px; margin-inline: auto; }
  .tabs, .filter-bar { max-width: 820px; margin-inline: auto; }
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); max-height: 84dvh; }
  @keyframes sheet-in { from { transform: scale(.98); opacity: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .note-card.sorting::before { background: var(--brass); }
}

/* ---------- Google sign-in ---------- */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  margin-top: 4px;
  border-radius: var(--r-md);
  background: #fff;
  color: #1f1f1f;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  border: 1px solid #d5d8de;
  transition: filter .18s ease, transform .18s ease;
}
.btn-google:hover { filter: brightness(.96); }
.btn-google:active { transform: scale(.985); }
.g-logo { width: 20px; height: 20px; flex: none; }
.pw-fallback { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.pw-fallback summary { color: var(--muted); font-size: 13px; cursor: pointer; list-style: none; text-align: center; }
.pw-fallback summary::-webkit-details-marker { display: none; }
.pw-fallback summary:hover { color: var(--text); }
.pw-fallback form { margin-top: 12px; }
.pw-fallback .btn-ghost { width: 100%; margin-top: 10px; }

/* ---------- me + users ---------- */
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--raise);
  border: 1px solid var(--line);
  overflow: hidden;
  font-size: 14px; font-weight: 700; color: var(--brass);
  margin-inline: 4px;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; }
.invite-form { display: flex; gap: 8px; }
.invite-form input {
  flex: 1; min-height: 46px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--ink); color: var(--text); font: inherit; font-size: 16px;
}
.invite-form input:focus { outline: none; border-color: var(--brass); }
.users-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  background: var(--ink);
}
.user-row.off { opacity: .55; }
.user-text { flex: 1; display: flex; flex-direction: column; font-size: 14px; line-height: 1.35; min-width: 0; }
.user-text .mono { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.user-text > .muted:last-child { font-size: 12px; }
.btn-ghost.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- quick-add list toggle ---------- */
.quick-add-box { flex: 1; position: relative; display: flex; flex-direction: column; }
.quick-add-box textarea { width: 100%; padding-inline-end: 140px; }
.list-toggle {
  position: absolute; inset-inline-end: 8px; top: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12.5px;
  min-height: 30px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--raise); color: var(--muted);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.list-toggle .ico { width: 15px; height: 15px; }
.list-toggle:hover { color: var(--text); }
.list-toggle.on {
  color: var(--brass);
  border-color: color-mix(in srgb, var(--brass) 55%, transparent);
  background: color-mix(in srgb, var(--brass) 14%, transparent);
}

/* ---------- Keep-style checklist ---------- */
.checklist-step { position: relative; align-items: center; }
.checklist-step .checklist-step-text { flex: 1; }
.checklist-step.leaving { opacity: .35; transition: opacity .25s ease; }
.step-x {
  font: inherit; font-size: 18px; line-height: 1;
  width: 28px; height: 28px;
  border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--muted);
  cursor: pointer; opacity: 0; flex: none;
  transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.checklist-step:hover .step-x, .checklist-step:focus-within .step-x { opacity: 1; }
.step-x:hover { color: var(--danger); background: var(--raise); }
@media (hover: none) { .step-x { opacity: .55; } }
/* Same trick as the grips: keep the × small, make it hittable. Narrower than 44 so it
   stays clear of the card edge, full height because that is the axis a thumb misses on. */
.step-x { position: relative; }
.step-x::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 40px; height: 44px;
  transform: translate(-50%, -50%);
}
.step-x:focus-visible {
  outline: none; opacity: 1; color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 30%, transparent);
}

.add-item {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 2px 0;
  color: var(--muted);
}
.add-item .ico { width: 18px; height: 18px; margin-inline-start: 0; }
.add-item-input {
  flex: 1; min-width: 0;
  border: none; border-bottom: 1px solid transparent;
  background: transparent; color: var(--text);
  font: inherit; font-size: 16px; padding: 10px 0;   /* 16px: below that, iOS zooms the page */
}
.add-item-input::placeholder { color: var(--muted); }
.add-item-input:focus { outline: none; border-bottom-color: var(--brass); }
.add-item-go {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--brass);
  cursor: pointer; opacity: 0; transition: opacity .15s ease;
}
.add-item:focus-within .add-item-go { opacity: 1; }
.all-done { margin: 2px 0; font-size: 13.5px; }

.done-items { border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 6px; }
.done-items summary {
  display: flex; align-items: center; gap: 10px;
  list-style: none; cursor: pointer;
  font-size: 13px; color: var(--muted);
  min-height: 34px;
}
.done-items summary::-webkit-details-marker { display: none; }
.done-items summary::before {
  content: ""; width: 7px; height: 7px;
  border-inline-end: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease; margin-inline-start: 4px;
}
.done-items[open] summary::before { transform: rotate(45deg); }
.done-items summary:hover { color: var(--text); }
.clear-done {
  margin-inline-start: auto;
  font: inherit; font-size: 12px;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm); opacity: 0;
}
.done-items[open] .clear-done { opacity: 1; }
.clear-done:hover { color: var(--danger); background: var(--raise); }
.done-items .checklist-step { opacity: .7; }

/* ---------- finished tasks drawer ---------- */
.done-drawer { padding: 0 16px; }
#app { padding-bottom: 120px; }
.done-drawer summary {
  display: flex; align-items: center; gap: 10px;
  list-style: none; cursor: pointer;
  color: var(--muted); font-size: 14px;
  padding: 12px 0; border-top: 1px solid var(--line-soft);
}
.done-drawer summary::-webkit-details-marker { display: none; }
.done-drawer summary:hover { color: var(--text); }
.done-drawer .notes-grid { padding: 4px 0 0; opacity: .75; }
@media (min-width: 700px) { .done-drawer { max-width: 980px; margin-inline: auto; } }

/* ==========================================================================
   Smart notes — recipe card with a servings dial, link summary, suggestions.
   The dial is the one loud element: brass, tabular numbers, quantities
   flash when they rescale. Everything else keeps the card's quiet register.
   ========================================================================== */
:root { --cat-recipe: #e0865a; }
.note-card[data-cat="recipe"] { --spine: var(--cat-recipe); }
.badge.cat.recipe { color: var(--cat-recipe); border-color: color-mix(in srgb, var(--cat-recipe) 40%, transparent); }

@media (min-width: 700px) {
  .note-card.kind-recipe { grid-column: span 2; }
}

.cover {
  margin: -14px -16px 4px -14px;
  margin-inline-start: -18px;
  aspect-ratio: 16 / 8;
  overflow: hidden;
  background: var(--ink);
  border-bottom: 1px solid var(--line-soft);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.recipe-head { display: flex; flex-direction: column; gap: 6px; }
.kind-recipe .note-title, .kind-link .note-title { font-size: 20px; }
.recipe-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; color: var(--muted); }
.recipe-meta span { display: inline-flex; align-items: center; gap: 5px; }
.recipe-meta .ico { width: 15px; height: 15px; }
.source {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; color: var(--muted); text-decoration: none;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  direction: ltr; unicode-bidi: isolate;
}
.source:hover { color: var(--brass); border-color: var(--brass); }
.source .ico { width: 13px; height: 13px; }

/* ---- the servings dial ---- */
.dial {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 0 2px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--brass) 35%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brass) 7%, var(--ink));
  width: fit-content;
}
.dial > button {
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  background: var(--raise); color: var(--text);
  font: inherit; font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.dial > button:hover { background: var(--brass); color: var(--brass-ink); }
.dial > button:active { transform: scale(.94); }
.dial > button[disabled] { opacity: .35; cursor: not-allowed; }
.dial-num { display: flex; align-items: baseline; gap: 6px; padding: 0 10px; min-width: 84px; justify-content: center; }
.dial-num b { font-size: 24px; font-weight: 500; color: var(--brass); }
.dial-num span { font-size: 13px; color: var(--muted); }
.dial-reset {
  width: auto !important; height: 32px !important; border-radius: 999px !important;
  padding: 0 10px; font-size: 13px !important; color: var(--muted) !important; background: transparent !important;
  border: 1px solid var(--line) !important;
}
.dial-reset:hover { color: var(--text) !important; border-color: var(--brass) !important; }

.ings h4, .steps h4, .tips h4 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 8px 0 4px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted);
}
.ings ul, .tips ul { list-style: none; margin: 0; padding: 0; }
.ing {
  display: grid;
  grid-template-columns: 18px minmax(64px, auto) 1fr;
  align-items: baseline; gap: 10px;
  min-height: 34px; padding: 5px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 14.5px;
}
.ing:last-child { border-bottom: none; }
.ing input { width: 18px; height: 18px; accent-color: var(--cat-recipe); align-self: center; margin: 0; }
.ing .qty {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--brass); font-size: 14px;
  direction: ltr; unicode-bidi: isolate; text-align: end;
  white-space: nowrap;
}
.ing .qty small { font-family: var(--sans); font-size: 12.5px; color: var(--muted); }
.ing .ing-name em { font-style: normal; color: var(--muted); font-size: 13px; }
.ing.done .ing-name, .ing.done .qty { text-decoration: line-through; opacity: .5; }
.qty.pulse { animation: qty-pulse .5s ease-out; }
@keyframes qty-pulse {
  0% { color: #fff; text-shadow: 0 0 10px color-mix(in srgb, var(--brass) 70%, transparent); }
  100% { color: var(--brass); text-shadow: none; }
}

.steps ol { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; line-height: 1.55; }
.steps li::marker { color: var(--brass); font-family: var(--mono); font-size: 13px; }
.tips li { position: relative; padding-inline-start: 14px; font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.tips li::before { content: "—"; position: absolute; inset-inline-start: 0; color: var(--brass); }

.highlights { margin: 0; padding-inline-start: 18px; font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 4px; }
.highlights li::marker { color: var(--brass); }

/* ---- "make it smarter" strip ---- */
.suggest {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px dashed color-mix(in srgb, var(--brass) 45%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brass) 6%, transparent);
  font-size: 13.5px;
}
.suggest .ico { width: 16px; height: 16px; color: var(--brass); }
.suggest button {
  font: inherit; font-size: 13px; font-weight: 700;
  min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: none;
  background: var(--brass); color: var(--brass-ink); cursor: pointer;
  margin-inline-start: auto;
}
.suggest button.quiet, .quiet {
  background: transparent; color: var(--muted); font-weight: 400;
  border: none; font: inherit; font-size: 12.5px; cursor: pointer; padding: 0 6px; margin: 0; min-height: 28px;
}
.suggest button.quiet { font-size: 18px; margin-inline-start: 0; }
.quiet:hover { color: var(--text); }

/* ---- smart menu ---- */
details.menu { position: relative; }
details.menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; min-height: 36px; padding: 0 9px;
  border-radius: var(--r-sm); color: var(--brass); cursor: pointer;
  transition: background .18s ease;
}
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary:hover, details.menu[open] summary { background: var(--raise); }
details.menu summary .ico { width: 15px; height: 15px; }
.menu-pop {
  position: absolute; z-index: 15;
  bottom: calc(100% + 4px); inset-inline-start: 0;
  min-width: 200px;
  display: flex; flex-direction: column;
  padding: 6px;
  background: var(--raise); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  animation: sheet-in .15s ease-out;
}
.menu-pop button {
  text-align: start; font: inherit; font-size: 14px;
  min-height: 40px; padding: 0 12px;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--text); cursor: pointer;
}
.menu-pop button:hover { background: var(--surface); color: var(--brass); }

/* ---- images ---- */
.note-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.note-files:has(> :only-child) { grid-template-columns: 1fr; }
.note-img { position: relative; margin: 0; }
.note-img img { width: 100%; height: 100%; max-height: 240px; object-fit: cover; }
.img-x {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s ease;
}
.note-img:hover .img-x, .note-img:focus-within .img-x { opacity: 1; }
@media (hover: none) { .img-x { opacity: .8; } }

.qa-tools { position: absolute; inset-inline-end: 8px; top: 8px; display: flex; gap: 6px; }
.qa-tools .list-toggle { position: static; }
.staged-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.staged { position: relative; width: 56px; height: 56px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.staged img { width: 100%; height: 100%; object-fit: cover; }
.staged button {
  position: absolute; top: 2px; inset-inline-end: 2px; width: 20px; height: 20px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.65); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.note-card:has(details.menu[open]) { overflow: visible; }
.note-card:has(details.menu[open])::before { border-radius: var(--r-md) 0 0 var(--r-md); }

/* ==========================================================================
   Board order — sort control, pinned strip, drag handles, ten-row previews
   ========================================================================== */

.board { padding-bottom: 24px; }
.board .notes-grid { padding-bottom: 0; }
.board-section + .board-section { margin-top: 2px; }

.board-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 980px;
  margin-inline: auto;
  padding: 2px 16px 6px;
}
.sort-label { color: var(--muted); font-size: 13px; }
#sort-select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  min-height: 36px;
  cursor: pointer;
}
#sort-select:focus { outline: none; border-color: var(--brass); }

.section-head {
  max-width: 980px;
  margin: 14px auto 4px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
}
.drop-hint {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  font-size: 13px;
  text-align: center;
}

/* the little bar at the top of every card: grip · to-top · pin.
   The icons stay small so they don't shout over the note, but every one of them carries a
   44×44 hit area through ::after — the visual size and the tappable size are not the same
   thing, and on a phone it is the tappable one that matters. */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: -6px -6px -2px;
  min-height: 32px;
}
/* 10px keeps the two 44px hit areas from overlapping each other (36 + 10 > 44). */
.card-top-btns { display: flex; gap: 10px; }

.icon-mini, .drag-handle, .step-handle {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  transition: opacity .18s ease, color .18s ease, background .18s ease, transform .12s ease;
}
/* the invisible half of the target */
.icon-mini::after, .drag-handle::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;      /* only 4px past the button, so the card can't clip it */
  transform: translate(-50%, -50%);
}
/* Narrower, because a 44-wide area here would sit on top of the item's checkbox and
   swallow the taps that tick it off. Full height, which is the direction that matters. */
.step-handle::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 30px; height: 44px;
  transform: translate(-50%, -50%);
}
.icon-mini:active, .drag-handle:active, .step-handle:active { transform: scale(.92); }

.icon-mini { width: 36px; height: 36px; opacity: .6; }
.icon-mini .ico { width: 16px; height: 16px; }
.icon-mini:hover { color: var(--text); background: var(--raise); }
.pin-btn.on { color: var(--brass); opacity: 1; }
.pin-btn.on .ico { fill: color-mix(in srgb, var(--brass) 28%, transparent); }

.drag-handle, .step-handle { opacity: .5; cursor: grab; touch-action: none; }
.drag-handle { width: 36px; height: 36px; }
.drag-handle .ico { width: 17px; height: 17px; }
.step-handle { width: 24px; height: 32px; margin-inline-start: -6px; flex: none; }
.step-handle .ico { width: 15px; height: 15px; }
.note-card:hover .icon-mini,
.note-card:hover .drag-handle,
.checklist-step:hover .step-handle { opacity: .95; }

/* Focus is how the keyboard reorder is discovered at all, so it has to be loud. */
.icon-mini:focus-visible, .drag-handle:focus-visible, .step-handle:focus-visible, .more-btn:focus-visible {
  outline: none;
  opacity: 1;
  color: var(--text);
  border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 30%, transparent);
}
#sort-select:focus-visible {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 30%, transparent);
}

/* No hover on a touch screen, so nothing may depend on it to become visible. */
@media (hover: none) {
  .icon-mini, .drag-handle, .step-handle { opacity: .85; }
}
/* Hand ordering only makes sense while the board is in manual order. */
body:not([data-sort="manual"]) .drag-handle { visibility: hidden; }

.note-card.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 44px rgba(0, 0, 0, .55);
  border-color: color-mix(in srgb, var(--brass) 50%, var(--line));
  transform: rotate(-.5deg);
}
.checklist-step.dragging {
  background: var(--raise);
  border-radius: var(--r-sm);
  padding-inline: 6px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .5);
}
.note-placeholder {
  border: 1px dashed color-mix(in srgb, var(--brass) 55%, var(--line));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--brass) 7%, transparent);
}
.step-placeholder {
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brass) 10%, var(--raise));
}
body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* "עוד N פריטים" / "להציג הכל" under a clipped list or a clipped note */
.more-btn {
  align-self: flex-start;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--brass);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 10px;
  margin-inline-start: -10px;
  min-height: 44px;
  cursor: pointer;
}
.more-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.note-content.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Finished tasks in the drawer are not part of the hand-made order. */
#done-list .drag-handle, #done-list .icon-mini[data-action="to-top"] { display: none; }
