/* Notes — the notes pane (/notes/, /m/<pk>/notes/) and the Ask / Interact /
 * Draft drawer. Markup: templates/notes/_notes_pane.html,
 * templates/partials/_notes_drawer.html; behaviour: static/js/notes.js.
 * The editor itself reuses .mira-editor / .md-toolbar / .answer-md. */

[data-notes-only][hidden] { display: none !important; }

/* ---- pane ---------------------------------------------------------------- */
.notes-pane {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.notes-pane--page { height: calc(100vh - 13rem); min-height: 460px; }

.notes-pane__side {
  display: flex; flex-direction: column; gap: .55rem;
  min-height: 0; padding: .85rem .75rem;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
}
.notes-pane__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.notes-pane__h { font-size: 1rem; font-weight: 700; margin: 0; }
.notes-pane__scope {
  font-size: .76rem; color: var(--text-subtle);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem;
}
.notes-pane__search { flex: 0 0 auto; }
.notes-pane__hint { margin: 0; }

.notes-pane__pickbar {
  display: flex; flex-direction: column; gap: .4rem;
  padding: .6rem .65rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border));
}
.notes-pane__pickbar[hidden] { display: none; }
.notes-pane__pickbar-text { font-size: .84rem; font-weight: 600; }
.notes-pane__pickbar-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.notes-pane.is-picking .notes-row { cursor: copy; }
.notes-pane.is-picking .notes-row:hover { outline: 1px dashed var(--brand); }

.notes-pane__list {
  list-style: none; margin: 0; padding: 0;
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.notes-row {
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
}
.notes-row:hover { background: var(--surface); border-color: var(--border-soft); }
.notes-row.is-active { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.notes-row:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.notes-row__title {
  font-weight: 600; font-size: .88rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-row__title.is-untitled { color: var(--text-muted); font-style: italic; }
.notes-row__preview {
  font-size: .78rem; color: var(--text-muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notes-row__meta { font-size: .7rem; color: var(--text-faint); margin-top: .15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-pane__empty { padding: 1rem .4rem; text-align: center; color: var(--text-muted); }
.notes-pane__empty p { margin: 0 0 .25rem; }

.notes-pane__main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.notes-pane__placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; color: var(--text-subtle); padding: 2rem;
}
.notes-pane__placeholder .icon { width: 36px; height: 36px; opacity: .6; }
.notes-pane__placeholder[hidden], .notes-pane__doc[hidden] { display: none; }
.notes-pane__doc { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.notes-pane__docbar {
  display: flex; align-items: center; gap: .35rem;
  padding: .45rem .75rem; border-bottom: 1px solid var(--border-soft);
}
.notes-pane__spacer { flex: 1; }
.notes-pane__back { display: none; }
.notes-pane__chip {
  font-size: .72rem; color: var(--text-muted); background: var(--bg-elev);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: .1rem .55rem;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-pane__chip[hidden] { display: none; }
.notes-pane__title {
  border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: 1.35rem; font-weight: 700; padding: .8rem 1rem .2rem; width: 100%;
}
.notes-pane__title::placeholder { color: var(--text-faint); }
.notes-pane__editor { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .5rem .75rem; }
.notes-pane__editor .mira-editor { display: flex; flex-direction: column; min-height: 100%; }
.notes-pane__editor .md-toolbar { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.notes-pane__editor .answer-md--editing { flex: 1; min-height: 12rem; padding: .5rem .5rem 2rem; outline: 0; }

/* ---- drawer (single column: list, then the note) ------------------------- */
.notes-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1150;
  width: min(520px, 94vw);
  display: flex; flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border-strong);
  box-shadow: -24px 0 60px -28px rgba(15,18,32,.4);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .26s cubic-bezier(.16,1,.3,1), visibility 0s linear .26s;
}
.notes-drawer.is-open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.notes-drawer__close {
  position: absolute; top: .7rem; right: .7rem; z-index: 3;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.notes-drawer__close:hover { color: var(--text); }
.notes-drawer__scrim {
  position: fixed; inset: 0; z-index: 1149;
  background: rgba(15,18,32,.28);
}
.notes-drawer__scrim[hidden] { display: none; }
.notes-drawer .notes-pane {
  flex: 1; display: flex; flex-direction: column;
  border: 0; border-radius: 0; background: var(--bg);
}
.notes-drawer .notes-pane__side { flex: 1; border-right: 0; padding-top: 1rem; padding-right: 3rem; background: var(--bg); }
.notes-drawer .notes-pane__head { padding-right: 0; }
.notes-drawer .notes-pane__main { display: none; flex: 1; }
.notes-drawer .notes-pane.is-editing .notes-pane__side { display: none; }
.notes-drawer .notes-pane.is-editing .notes-pane__main { display: flex; }
.notes-drawer .notes-pane__back { display: inline-flex; }
.notes-drawer .notes-pane__docbar { padding-right: 3rem; }

/* Floating Notes button (every app page; Profile.show_notes_button) and its
 * menu: New note / Open notes / the 3 latest notes / All notes / Hide. Sits
 * above the status bar, under the drawer, and steps aside while it is open. */
.notes-fab {
  position: fixed; right: 18px; bottom: calc(var(--statusbar-h, 30px) + 18px); z-index: 1040;
  display: flex; flex-direction: column; align-items: flex-end; gap: .5rem;
}
body.notes-drawer-open .notes-fab { display: none; }
.notes-fab__btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  box-shadow: 0 6px 18px -6px rgba(15,18,32,.35);
  cursor: pointer; transition: color .15s, transform .15s, box-shadow .15s;
}
.notes-fab__btn .icon { width: 20px; height: 20px; }
.notes-fab__btn:hover,
.notes-fab.is-open .notes-fab__btn { color: var(--warn); transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(15,18,32,.4); }
.notes-fab__btn:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.notes-fab__menu {
  width: 260px; max-height: min(70vh, 420px); overflow-y: auto;
  padding: .35rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: 0 18px 44px -16px rgba(15,18,32,.45);
}
.notes-fab__menu[hidden] { display: none; }
.notes-fab__item {
  width: 100%; display: flex; align-items: center; gap: .6rem;
  padding: .45rem .55rem; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text); text-align: left; text-decoration: none;
  font-size: .85rem; cursor: pointer;
}
.notes-fab__item:hover, .notes-fab__item:focus-visible { background: var(--bg); color: var(--text); outline: 0; }
.notes-fab__item--muted { color: var(--text-muted); }
.notes-fab__glyph {
  flex: none; width: 22px; height: 22px; display: inline-grid; place-items: center;
  color: var(--text-muted); font-size: 1rem; line-height: 1;
}
.notes-fab__glyph .icon { width: 16px; height: 16px; }
.notes-fab__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.notes-fab__text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-fab__text small { font-size: .72rem; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-fab__kbd { font-size: .68rem; padding: .05rem .35rem; }
.notes-fab__item--note { padding-left: calc(.55rem + 22px + .6rem); }
.notes-fab__label {
  padding: .45rem .55rem .15rem; font-size: .75rem; font-weight: 600;
  letter-spacing: .01em; text-transform: none; color: var(--text-subtle);
}
.notes-fab__recent[hidden] { display: none; }
.notes-fab__sep { height: 1px; margin: .3rem .2rem; background: var(--border); }
@media (max-width: 720px) {
  .notes-fab { right: 12px; bottom: calc(var(--statusbar-h, 30px) + 12px); }
  .notes-fab__btn { width: 40px; height: 40px; }
}
@media print { .notes-fab { display: none; } }

.notes-add-pill { z-index: 1160; }

@media (max-width: 720px) {
  .notes-pane--page { grid-template-columns: 1fr; height: auto; }
  .notes-pane--page .notes-pane__side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .notes-pane--page .notes-pane__main { min-height: 60vh; }
}

/* ---- sketches (pen / touch ink) ---------------------------------------------
 * The "Draw" button on the notes editor toolbar and the pad it opens
 * (static/js/notes-ink.js). A sketch sits in the note as a white "paper"
 * image the full width of the text; clicking it reopens it in the pad. */
.notes-draw-btn { display: inline-flex; align-items: center; gap: .3rem; }
.notes-pane__editor .answer-md img[src*="/ink/"] {
  display: block; width: 100%; max-width: 100%; height: auto;
  margin: .35rem 0; background: #fff; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.notes-pane__editor .answer-md img[src*="/ink/"]:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }

body.ink-pad-open { overflow: hidden; }
.ink-pad {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; flex-direction: column;
  background: var(--bg-elev, var(--bg));
  outline: 0;
}
.ink-pad__bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem;
  padding: .5rem .75rem; padding-top: max(.5rem, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.ink-pad__group { display: flex; align-items: center; gap: .2rem; }
.ink-pad__group + .ink-pad__group:not(.ink-pad__done) { padding-left: .6rem; border-left: 1px solid var(--border-soft); }
.ink-pad__spacer { flex: 1; }
/* 40px targets: fingers and pens, not only mice. */
.ink-btn:not(.ink-btn--text) {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  touch-action: manipulation;
}
.ink-btn:not(.ink-btn--text):hover { background: var(--bg); color: var(--text); }
.ink-btn[aria-pressed="true"] { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.ink-btn:disabled { opacity: .35; cursor: default; }
.ink-btn[hidden] { display: none; }
.ink-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.ink-btn--text { min-height: 36px; touch-action: manipulation; }
.ink-swatch span { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.ink-swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }
.ink-size span { display: block; border-radius: 50%; background: currentColor; }

.ink-pad__scroll {
  position: relative; flex: 1; min-height: 0; overflow: auto;
  padding: 18px; padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.ink-pad__sheet {
  position: relative; margin: 0 auto;
  background: #fff; border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(15,18,32,.12), 0 8px 28px -12px rgba(15,18,32,.3);
}
.ink-pad__canvas { position: absolute; inset: 0; display: block; }
/* The live layer takes every pointer; no browser pan / zoom / callout on it. */
.ink-pad__canvas--live {
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ink-pad__hint {
  position: absolute; top: 40px; left: 0; right: 0; text-align: center;
  color: #8a8f98; font-size: .9rem; pointer-events: none;
}
@media (max-width: 720px) {
  .ink-pad__bar { gap: .25rem .35rem; padding: .4rem .5rem; }
  .ink-pad__group + .ink-pad__group:not(.ink-pad__done) { padding-left: .35rem; }
  .ink-pad__spacer { display: none; }
  .ink-pad__done { width: 100%; justify-content: flex-end; }
  .ink-pad__scroll { padding: 10px; }
}
@media print { .ink-pad { display: none; } }
