/* The notes room (/account/notes/): the extension's notes page (its
   notes.css), inside the app shell. The list and the note sit side by side
   and fill the window under the 60px topbar, each scrolling on its own, so a
   long note never carries the list away. The editor itself is
   note-editor.css, the extension's. */

.page.notes-page { padding-bottom: clamp(1rem, 2vw, 1.5rem); }

.notes-app {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  /* The window, less the topbar and the page's own top and bottom padding. */
  height: calc(100dvh - 60px - clamp(1.25rem, 3vw, 2.25rem) - clamp(1rem, 2vw, 1.5rem));
  min-height: 440px;
}
.notes-app .panel { margin: 0; }

.notes-side { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 14px; gap: 10px; }
.notes-head { display: flex; align-items: center; gap: 8px; }
.notes-head h1 { font-size: 1.25rem; margin: 0; flex: 1 0 auto; }
/* "Notes" is the top banner's title; said twice it read as a duplicate. The
   heading stays for screen readers and as the spacer that keeps trash, sync
   and New note at the row's end, but takes no room and shows nothing. */
.notes-head h1.notes-head-title {
  flex: 1 0 0; min-width: 0; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.notes-head .notes-sync-times {
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto;
}
.notes-head #notesNew { flex: none; }
/* Two lines: back, title, trash, sync and New note on the first; the sign-in
   nudge or the last-sync time (never both) on a small line under the title,
   so a long translation cannot push the buttons out of the panel. */
.notes-head { flex-wrap: wrap; row-gap: 2px; }
.notes-head #notesSyncNudge, .notes-head .notes-sync-times {
  order: 10; flex: 1 0 100%; min-width: 0; margin: 0; padding-inline-start: 0; box-sizing: border-box;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* New note keeps its words while they fit; when they do not (a narrow list,
   a long translation) it is a round +, its name kept in the title and
   aria-label. notes-page.js / notes-web.js fitHead() sets .compact. */
.notes-head.compact #notesNew {
  font-size: 0; width: 34px; height: 34px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.notes-head.compact #notesNew::before { content: '+'; font-size: 22px; font-weight: 600; line-height: 1; }
#notesSyncBtn { white-space: nowrap; font-size: 16px; line-height: 1; padding: 6px 8px; flex: none; }
#notesSyncBtn:disabled { color: var(--text-3); cursor: default; background: transparent; }
.notes-search {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
}
.notes-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.notes-sub { color: var(--text-2); font-size: 12px; margin: 0; }
#notesStatus:empty { display: none; }
.notes-list { overflow-y: auto; min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.notes-group { color: var(--text-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin: 6px 4px 0; }

.note-row {
  text-align: left; width: 100%; padding: 10px 12px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--text); display: block;
  font: inherit; cursor: pointer;
}
.note-row:hover { background: var(--surface-2); }
.note-row.selected { background: var(--accent-soft); border-color: var(--accent); }
.note-row-title { font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.note-row-title span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-pinned { color: var(--accent); display: inline-flex; align-items: center; flex: none; }
.note-pinned svg { width: 15px; height: 15px; display: block; }
/* Another device's edit of this note clashed with one here (note-merge.js). */
.note-conflict-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.note-conflict {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0 0 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-soft); font-size: 13px;
}
.note-conflict[hidden] { display: none; }
.note-conflict span { flex: 1 1 auto; min-width: 0; }
.note-row-preview { color: var(--text-2); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-row-meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; color: var(--text-2); font-size: 11.5px; flex-wrap: wrap; }
.note-chip { background: var(--surface-2); color: var(--text-2); border-radius: 6px; padding: 2px 7px; font-size: 11.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-chip.running, .note-chip.done-all { background: var(--green-soft); color: var(--green); }
.note-chip.shelf { background: var(--accent-soft); color: var(--accent); }
.note-chip.paused { background: var(--amber-soft); color: var(--amber); }

.notes-main { display: flex; flex-direction: column; min-height: 0; padding: 10px 18px 18px; }
.note-tools { display: flex; align-items: center; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.note-tools-gap { flex: 1; }
/* The extension's ghost buttons: accent text, a soft wash on hover. */
.note-tool {
  font: inherit; font-size: 13px; cursor: pointer; border-radius: 8px; padding: 6px 10px;
  border: 1px solid transparent; background: transparent; color: var(--accent);
}
.note-tool:hover { background: var(--accent-soft); }
.note-arrow { font-size: 17px; padding: 2px 8px; line-height: 1; }
.note-arrow:disabled { color: var(--text-3); cursor: default; background: transparent; }
.note-back { display: none; font-size: 14px; font-weight: 600; padding: 8px 12px; }
.note-body { flex: 1; overflow-y: auto; padding: 14px 4px; font-size: 15px; position: relative; }
.notes-empty { color: var(--text-2); padding: 18px 6px; }
.notes-empty p { margin: 6px 0 0; font-size: 13px; }
.note-none { text-align: center; padding-top: 22vh; }
.notes-main.no-note .note-tools, .notes-main.no-note .note-body { display: none; }
.notes-main:not(.no-note) .note-none { display: none; }

/* The note's ⋯ menu, under its button. */
.note-more { position: relative; }
.note-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 20;
  min-width: 170px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.note-menu[hidden] { display: none; }
/* A note held or right-clicked in the list: the same menu at the pointer. */
.note-row-menu { position: fixed; right: auto; top: 0; left: 0; z-index: 60; }
.note-menu [role="menuitem"] {
  text-align: left; width: 100%; border: 0; background: transparent; color: var(--text);
  padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.note-menu [role="menuitem"].danger { color: var(--red); }
.note-menu [role="menuitem"]:hover, .note-menu [role="menuitem"]:focus-visible { background: var(--surface-2); }
.note-menu [role="menuitem"].danger:hover { background: var(--red-soft); }

/* The delete question, centred, as in the extension. */
.notes-dialog {
  color: var(--text); background: var(--surface-card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px 22px; width: min(380px, 92vw); margin: auto;
}
.notes-dialog::backdrop { background: rgba(10, 12, 16, 0.45); backdrop-filter: blur(2px); }
.notes-dialog h2 { margin: 0 0 6px; font-size: 17px; }
.notes-dialog .notes-sub { font-size: 13.5px; }
.notes-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.notes-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13px;
}
.notes-toast button {
  font: inherit; font-weight: 600; margin-left: 6px; border: 0; background: transparent;
  color: var(--accent-soft); cursor: pointer; padding: 0 4px;
}

/* One pane at a time on a narrow window: the list, or the note. */
@media (max-width: 860px) {
  .notes-app { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .notes-app.viewing .notes-side { display: none; }
  .notes-app:not(.viewing) .notes-main { display: none; }
  .note-back { display: inline-block; }
}

/* A quiet panel control in the editor toolbar, shown only while a note is open. */
.notes-list-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; margin-inline-end: 8px;
  border: 1px solid var(--border); border-radius: 8px; color: var(--text-2);
}
.notes-list-toggle:hover { color: var(--text); }
.notes-list-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notes-list-toggle[aria-expanded="false"] .notes-panel-arrow { transform: rotate(180deg); transform-origin: 15px 12px; }
:dir(rtl) .notes-list-toggle svg { transform: scaleX(-1); }
.notes-main.no-note .note-tools { display: flex; }
.notes-main.no-note .note-tools > :not(.notes-list-toggle) { display: none; }
@media (min-width: 861px) {
  .notes-app.viewing.notes-list-collapsed,
  html.notes-embedded .notes-app.viewing.notes-list-collapsed { grid-template-columns:minmax(0,1fr); }
  .notes-app.viewing.notes-list-collapsed .notes-side { display:none; }
}
@media (max-width: 860px) { .notes-list-toggle { display:none; } }

/* Keep the list available until a note is selected, including after deletion. */
.notes-app:not(.viewing) .notes-list-toggle { display: none; }

/* Version history (notes.html #noteHistoryDialog). */
.note-history-dialog { width: min(460px, 94vw); }
.note-history-list { display: flex; flex-direction: column; gap: 2px; max-height: 34vh; overflow-y: auto; margin: 10px 0 8px; }
.note-history-list button {
  display: flex; gap: 8px; align-items: baseline; text-align: left; width: 100%; border: 0; background: transparent;
  color: var(--text); padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.note-history-list button:hover, .note-history-list button:focus-visible { background: var(--surface-2); }
.note-history-list button[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.note-history-list button[aria-selected="false"]:not(:hover):not(:focus-visible) { background: transparent; }
.note-history-when { color: var(--text-2, var(--text)); opacity: 0.75; white-space: nowrap; font-size: 12.5px; }
.note-history-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.note-history-tag { font-size: 11.5px; color: var(--red); white-space: nowrap; }
.note-history-preview {
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 26vh; overflow-y: auto; font-size: 13.5px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
}
.note-history-keep { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.note-history-keep select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; color-scheme: light dark;
}
/* Trash in the list's header: only while notes deleted lately are kept. */
.notes-trash { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.notes-trash[hidden] { display: none; }
.notes-trash-count {
  position: absolute; top: -4px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 16px; text-align: center;
}
.note-history-empty-trash { margin-inline-end: auto; }
.note-history-empty-trash[hidden] { display: none; }

/* The open note's own sync state; a click sends it now (notes-web.js). */
.note-sync-state { font-size: 12px; color: var(--text-2); white-space: nowrap; padding: 4px 8px; flex: none; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
#notesSyncTimes.sync-line-press { cursor: pointer; }
.note-sync-state:disabled { color: var(--text-3); cursor: default; background: transparent; }

/* The sync line on the web: on the button row, at its start, where the
   heading would be (the heading is hidden here: the top banner says Notes).
   On its own line under an empty row it read as stray text. */
.notes-head .notes-sync-times {
  order: 0; flex: 1 1 0; min-width: 0; padding: 0; margin: 0;
  font-size: 12px; color: var(--text-2);
}
.notes-head:has(.notes-sync-times:not([hidden])) h1.notes-head-title { flex: 0 0 0; }
