/* Cloud Chabura -- Editorial Blue.
 *
 * Every rule is scoped under .cloud-chabura so loading this file cannot
 * reskin the player, the Interactive Daf, or anything else. The tokens are
 * redeclared on that scope rather than on :root for the same reason.
 *
 * Worth knowing before editing: /chaburah/ already rendered LIGHT before this
 * redesign, because watch-theme.css loads after styles.css and overrides the
 * palette. So this is a re-accent (warm gold -> editorial blue) plus a
 * restructure, not a dark-to-light inversion. This file is loaded INSTEAD of
 * styles.css/watch-theme.css on the new page, which is why it also carries the
 * handful of base rules the page needs.
 */

.cloud-chabura {
  --cc-bg: #f4f7fb;
  --cc-surface: #ffffff;
  --cc-surface-subtle: #eef3f9;
  --cc-text: #132238;
  --cc-muted: #65748a;
  --cc-border: #d9e1eb;
  --cc-primary: #2f6ea5;
  --cc-primary-hover: #255d8d;
  --cc-primary-soft: #e7f0f8;
  --cc-danger: #aa4238;
  --cc-success: #397358;
  --cc-warning: #946b27;
  --cc-focus: rgba(47, 110, 165, 0.32);
  --cc-radius-sm: 8px;
  --cc-radius-md: 14px;
  --cc-radius-lg: 18px;
  --cc-shadow: 0 18px 48px rgba(29, 57, 88, 0.12);

  /* Reserved for source/video cues only -- never general buttons. */
  --cc-source-accent: #b0872f;

  background: var(--cc-bg);
  color: var(--cc-text);
  font-family: "Assistant", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
}

.cloud-chabura *,
.cloud-chabura *::before,
.cloud-chabura *::after { box-sizing: border-box; }

.cloud-chabura :focus-visible {
  outline: 3px solid var(--cc-focus);
  outline-offset: 2px;
  border-radius: var(--cc-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  .cloud-chabura *, .cloud-chabura *::before, .cloud-chabura *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Layout: three zones on desktop, one column on mobile ---------------- */
.cc-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 64px;
  align-items: start;
}

/* The centre column stays readable on very wide screens. */
.cc-main { min-width: 0; max-width: 820px; }
.cc-rail { min-width: 0; position: sticky; top: 16px; }

@media (max-width: 1180px) {
  .cc-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .cc-rail-right { display: none; }
}
@media (max-width: 900px) {
  .cc-shell { grid-template-columns: minmax(0, 1fr); padding: 12px 14px 96px; gap: 16px; }
  .cc-rail-left { display: none; }
}

/* My Notes (/notes/) shares this shell but has no right rail, so the shared
   three-column template would leave a permanently empty 280px column. And on
   its Documents tab the LEFT rail is hidden too (its filters describe notes,
   which a document has none of) -- without .no-rail the main column would
   then fall into the rail's own 240px slot and the cards would render in a
   narrow strip with the page empty beside them. Declared after the shared
   breakpoints above, and repeating them, because these selectors are more
   specific and would otherwise win at every width. */
body[data-page="my-notes"] .cc-shell { grid-template-columns: 240px minmax(0, 1fr); }
body[data-page="my-notes"] .cc-shell.no-rail { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1100px) {
  body[data-page="my-notes"] .cc-shell { grid-template-columns: 220px minmax(0, 1fr); }
  body[data-page="my-notes"] .cc-shell.no-rail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  body[data-page="my-notes"] .cc-shell,
  body[data-page="my-notes"] .cc-shell.no-rail { grid-template-columns: minmax(0, 1fr); }
}

/* Kuntras Builder has no rail at all, at any width -- there is nothing here
   to filter (a kuntras has no daf, category or visibility to narrow by, the
   same reasoning /notes/'s own no-rail class rests on for its Documents
   tab). One column always, so .cc-main never falls into a rail slot no
   element is occupying. */
body[data-page="kuntras"] .cc-shell { grid-template-columns: minmax(0, 1fr); }

/* Same fix as #mnImportDialog's own .field-note override: styles.css's
   global .field-note is nowrap + ellipsis, sized for a short inline hint,
   and silently truncates a full sentence. The tree-editing hint under the
   builder title has to read in full. */
#knBuilder .field-note {
  white-space: normal; overflow: visible; text-overflow: clip;
  margin: 6px 0 14px; font-size: 13px; line-height: 1.5;
}
/* Same fix again for the library's own public-browse blurb and each
   Sharing-dialog option's description -- the recurring pattern by now:
   styles.css's global .field-note is nowrap + ellipsis, and every one of
   these is a full sentence. */
#knLibrary .field-note, .kn-share-option .field-note {
  white-space: normal; overflow: visible; text-overflow: clip;
}


/* --- Header -------------------------------------------------------------- */
.cc-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 24px 0;
}
.cc-header-titles { min-width: 0; }
.cc-header h1 { font-size: 26px; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
.cc-header .cc-tagline { margin: 2px 0 0; color: var(--cc-muted); font-size: 14px; }
.cc-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .cc-header { padding: 12px 14px 0; }
  .cc-header h1 { font-size: 21px; }
}

.cc-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cc-surface);
  border: 1px solid var(--cc-border);
  border-radius: 999px;
  padding: 0 14px;
  min-width: 260px;
}
.cc-search input {
  border: 0;
  background: transparent;
  padding: 10px 0;
  font: inherit;
  color: inherit;
  width: 100%;
  min-width: 0;
}
.cc-search input:focus { outline: none; }
.cc-search:focus-within { border-color: var(--cc-primary); box-shadow: 0 0 0 3px var(--cc-focus); }
/* flex-basis auto, not 100%: at 100% the search box claimed a whole row and
   forced "Start from a daf" onto another, costing ~120px of first screen before
   the page had shown a single discussion. */
@media (max-width: 900px) {
  /* flex-basis 120px, not auto: `auto` sizes from the input's own intrinsic
     width, which is wide enough that the button still wrapped to its own row. */
  .cc-search { min-width: 0; flex: 1 1 120px; }
  .cc-header-actions > .cc-btn { flex: 0 0 auto; white-space: nowrap; }
}

/* --- Cards and surfaces -------------------------------------------------- */
.cc-panel {
  background: var(--cc-surface);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md);
  padding: 16px 18px;
}
.cc-panel + .cc-panel { margin-top: 14px; }
.cc-panel h2 { font-size: 15px; margin: 0 0 10px; letter-spacing: 0.01em; }
.cc-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cc-muted); margin: 0 0 8px; }

/* --- Browse rail --------------------------------------------------------- */
.cc-rail-nav { display: flex; flex-direction: column; gap: 2px; }
.cc-rail-nav button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--cc-text);
  font: inherit; padding: 9px 11px; border-radius: var(--cc-radius-sm);
  cursor: pointer; transition: background 140ms ease, color 140ms ease;
}
.cc-rail-nav button:hover { background: var(--cc-surface-subtle); }
.cc-rail-nav button[aria-current="true"] {
  background: var(--cc-primary-soft);
  color: var(--cc-primary-hover);
  font-weight: 600;
}
.cc-rail-count { color: var(--cc-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.cc-filter-group { margin-top: 14px; }
.cc-filter-group label { display: block; font-size: 12px; color: var(--cc-muted); margin-bottom: 5px; }
.cc-select {
  width: 100%; font: inherit; color: inherit;
  padding: 8px 10px; border-radius: var(--cc-radius-sm);
  border: 1px solid var(--cc-border); background: var(--cc-surface);
}

/* --- Today's Daf --------------------------------------------------------- */
.cc-today {
  background: linear-gradient(180deg, var(--cc-primary-soft), var(--cc-surface) 70%);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.cc-today-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--cc-primary-hover); font-weight: 700; margin: 0 0 2px;
}
.cc-today h2 { font-size: 22px; margin: 0 0 6px; }
.cc-today-excerpt {
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-size: 17px; line-height: 1.75; color: var(--cc-text);
  margin: 0 0 10px; max-height: 3.6em; overflow: hidden;
}
.cc-today-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 12px; padding: 0; list-style: none; }
.cc-today-stats li { font-size: 13px; color: var(--cc-muted); }
.cc-today-stats strong { color: var(--cc-text); font-variant-numeric: tabular-nums; }
.cc-today-previews { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.cc-today-preview {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--cc-border); background: var(--cc-surface);
  border-radius: var(--cc-radius-sm); padding: 9px 11px;
  font: inherit; color: inherit; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: border-color 140ms ease;
}
.cc-today-preview:hover { border-color: var(--cc-primary); }
.cc-today-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 900px) {
  .cc-today { padding: 13px 14px; }
  .cc-today h2 { font-size: 19px; }
  .cc-today-excerpt { font-size: 16px; max-height: 3.5em; }
  /* Today's Daf is the page's anchor, but at full height on a phone the panel
     filled the entire first screen and pushed the tabs and every card below the
     fold -- exactly the failure it was meant to avoid. One preview keeps the
     "what are people actually discussing" signal; the rest are one tap away
     behind the same button that was already there. */
  .cc-today-stats { margin-bottom: 9px; }
  .cc-today-previews { gap: 5px; margin-bottom: 10px; }
  .cc-today-previews > :nth-child(n + 2) { display: none; }
  .cc-today-preview { padding: 8px 10px; font-size: 14px; }
  .cc-today-actions .cc-btn { flex: 1 1 auto; }
}

/* --- Buttons ------------------------------------------------------------- */
.cc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 9px 15px;
  border-radius: var(--cc-radius-sm); border: 1px solid var(--cc-border);
  background: var(--cc-surface); color: var(--cc-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.cc-btn:hover { border-color: var(--cc-primary); color: var(--cc-primary-hover); }
.cc-btn-primary { background: var(--cc-primary); border-color: var(--cc-primary); color: #fff; }
.cc-btn-primary:hover { background: var(--cc-primary-hover); border-color: var(--cc-primary-hover); color: #fff; }
.cc-btn-quiet { border-color: transparent; background: transparent; color: var(--cc-muted); font-weight: 500; }
.cc-btn-quiet:hover { background: var(--cc-surface-subtle); color: var(--cc-primary-hover); }
.cc-btn-sm { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.cc-btn-danger { color: var(--cc-danger); }
.cc-btn-danger:hover { background: rgba(220, 90, 90, .12); }
.cc-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.cc-btn[disabled]:hover { border-color: var(--cc-border); color: var(--cc-text); background: var(--cc-surface); }

/* Touch targets stay >=44px on mobile. */
@media (max-width: 900px) {
  .cc-btn { min-height: 44px; }
  .cc-btn-sm { min-height: 44px; }
}

/* --- Feed tabs ----------------------------------------------------------- */
.cc-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--cc-surface); border: 1px solid var(--cc-border);
  border-radius: 999px; margin-bottom: 12px;
  overflow-x: auto; scrollbar-width: thin;
}
.cc-tabs::-webkit-scrollbar { height: 4px; }
.cc-tab {
  flex: 0 0 auto;
  border: 0; background: transparent; color: var(--cc-muted);
  font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background 140ms ease, color 140ms ease;
}
.cc-tab:hover:not([disabled]) { color: var(--cc-text); background: var(--cc-surface-subtle); }
.cc-tab[aria-selected="true"] { background: var(--cc-primary); color: #fff; }
.cc-tab[disabled] { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 900px) { .cc-tab { min-height: 44px; } }

/* --- Thread cards -------------------------------------------------------- */
.cc-feed { display: flex; flex-direction: column; gap: 10px; }

.cc-card {
  position: relative;
  background: var(--cc-surface);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md);
  padding: 14px 16px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.cc-card:hover { border-color: #c3d2e2; box-shadow: 0 6px 18px rgba(29, 57, 88, 0.07); }
.cc-card:focus-within { border-color: var(--cc-primary); }
@media (max-width: 900px) { .cc-card { padding: 12px 13px; } }

.cc-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }

/* The whole card is a link, but nested buttons stay independently clickable:
 * the link is a stretched overlay behind them, not an ancestor of them. */
.cc-card-title { font-size: 16.5px; font-weight: 700; line-height: 1.4; margin: 0 0 4px; }
.cc-card-title a { color: var(--cc-text); text-decoration: none; }
.cc-card-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.cc-card-title a:hover { color: var(--cc-primary-hover); }

/* The note's own words are the most readable thing on the card. The old feed
 * rendered the body lighter than the author name, which inverted the
 * hierarchy the whole product is supposed to have (audit F-10). */
.cc-card-body {
  margin: 0 0 8px; color: var(--cc-text); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-card-source {
  font-family: "Frank Ruhl Libre", Georgia, serif;
  background: var(--cc-surface-subtle);
  border-inline-start: 3px solid var(--cc-source-accent);
  border-radius: 0 var(--cc-radius-sm) var(--cc-radius-sm) 0;
  padding: 7px 11px; margin: 0 0 8px;
  font-size: 15.5px; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.cc-card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px;
  color: var(--cc-muted); font-size: 12.5px;
}
.cc-card-meta strong { color: var(--cc-text); font-weight: 600; }
.cc-card-actions { position: relative; z-index: 1; display: flex; gap: 6px; margin-left: auto; }

/* --- Chips and pills ----------------------------------------------------- */
.cc-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 9px; border-radius: 999px;
  background: var(--cc-surface-subtle); color: var(--cc-muted);
  border: 1px solid transparent;
}
/* Category chips carry the Hebrew term AND the English one -- the old feed put
 * the English only in a title attribute, which is hover-only and invisible on
 * touch (audit F-11). */
.cc-chip-category { background: var(--cc-primary-soft); color: var(--cc-primary-hover); }
.cc-chip-category .cc-chip-he { font-family: "Frank Ruhl Libre", Georgia, serif; font-size: 13px; }
.cc-chip-category .cc-chip-en { opacity: 0.75; font-weight: 500; }
.cc-chip-daf { border-color: var(--cc-border); background: var(--cc-surface); color: var(--cc-text); }
.cc-chip-answered { background: rgba(57, 115, 88, 0.12); color: var(--cc-success); }
.cc-chip-unanswered { background: rgba(148, 107, 39, 0.13); color: var(--cc-warning); }
.cc-chip-locked, .cc-chip-deleted { background: rgba(170, 66, 56, 0.1); color: var(--cc-danger); }
.cc-chip-unread { background: var(--cc-primary); color: #fff; }
.cc-chip-demo { background: rgba(101, 116, 138, 0.14); color: var(--cc-muted); }
.cc-chip-video { background: rgba(176, 135, 47, 0.14); color: var(--cc-source-accent); }

/* My Notes (/notes/) only: every card there is the reader's own, so the one
   thing worth reading at a glance is whether a note is still private or has
   been shared. Deliberately quiet -- private is the default state and should
   not look like a warning. */
.cc-chip-private { background: var(--cc-surface-subtle); color: var(--cc-muted); border-color: var(--cc-border); }
.cc-chip-shared { background: var(--cc-primary-soft); color: var(--cc-primary-hover); }

/* A plain text link inside .cc-card-meta ("Open on the daf" / "Open
   discussion"), sitting alongside the timestamp rather than as a button row --
   the whole card title is already the primary link. */
.cc-card-action { color: var(--cc-primary); font-weight: 600; text-decoration: none; }
.cc-card-action:hover { text-decoration: underline; }

/* styles.css's global field rule covers input[type=text]/number/select but no
   textarea -- nothing on the site had one in a dialog until this. Without
   this the paste box renders as a raw browser default next to a styled title
   field, in the same dialog. Scoped to the import dialog rather than added to
   the global rule, so no other textarea on the site changes appearance. */
#mnImportDialog textarea {
  width: 100%; font: inherit; color: var(--text);
  background: rgba(4, 14, 27, .7); border: 1px solid var(--line-strong);
  border-radius: 11px; padding: 10px 12px; outline: none; resize: vertical;
}
#mnImportDialog textarea:focus {
  border-color: rgba(47, 110, 165, .8); box-shadow: 0 0 0 3px rgba(47, 110, 165, .1);
}

/* Import dialog: the running byte count, which turns red once the import is
   over the ceiling the database itself enforces. */
.cc-import-size { margin: 4px 0 0; font-size: 12.5px; color: var(--cc-muted); font-variant-numeric: tabular-nums; }
.cc-import-size.over { color: var(--cc-danger); font-weight: 600; }
/* styles.css's global .field-note is nowrap + ellipsis, which suits the short
   inline hints it was written for and silently truncates a sentence. The
   import dialog's explanation of what happens to a chosen file has to be
   readable in full, so it wraps here. */
#mnImportDialog .field-note {
  white-space: normal; overflow: visible; text-overflow: clip;
  margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--cc-muted);
}
/* On a phone the 10-row paste box is taller than the screen, which pushes
   Import below the fold on every import. The dialog does scroll, so this was
   reachable rather than broken -- but scrolling past a mostly empty box to
   reach the only button is a poor way to spend a small screen. The row count
   stays 10 in the markup, where it suits a desktop; this caps the rendered
   height instead, so the box still grows to fill what space there is. */
@media (max-height: 760px), (max-width: 620px) {
  #mnImportDialog textarea { max-height: 34vh; }
}

/* Document reader. The text is shown in a <pre> so an imported document keeps
   its own line breaks and indentation; pre-wrap rather than plain pre so long
   lines still wrap instead of forcing the dialog to scroll sideways. */
.cc-doc-actions { display: flex; gap: 8px; margin: 10px 0 14px; }
.cc-doc-text {
  margin: 0; max-height: 60vh; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font: inherit; line-height: 1.6;
  background: var(--cc-surface-subtle); border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-sm); padding: 14px;
}

/* "Quoted on": the dafs this document has been excerpted onto, from
   line_notes.source_document_id. Hidden entirely when there are none. */
.cc-doc-citations { margin-top: 16px; border-top: 1px solid var(--cc-border); padding-top: 14px; }
.cc-doc-citations-title { font-size: 13px; margin: 0 0 10px; }
.cc-doc-citations-list { display: flex; flex-direction: column; gap: 8px; max-height: 30vh; overflow: auto; }
.cc-doc-citation {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm);
  background: var(--cc-surface-subtle); padding: 9px 11px;
  color: inherit; text-decoration: none;
}
a.cc-doc-citation:hover { border-color: var(--cc-accent); }
.cc-doc-citation-daf { font-weight: 700; font-size: 13px; white-space: nowrap; }
/* The note's opening words. Takes the remaining width and truncates, so a
   long note cannot push the Shared chip onto its own line. */
.cc-doc-citation-body {
  flex: 1 1 140px; min-width: 0; font-size: 12.5px; color: var(--cc-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- Kuntras Builder --------------------------------------------------- */
/* Slice 1: the shell -- a library of kuntrasim, and a tree editor of
   sections and freeform entries. Reordering is up/down buttons (see
   .kn-move-buttons), not drag-and-drop -- the position column supports
   either, so drag-and-drop is a later addition, not a schema change. */

.kn-library-actions { margin-bottom: 14px; }

/* Slice 4: the public browse section sits below the reader's own library on
   the same screen (see kn-library-actions above it) -- a visible heading of
   its own is what actually separates the two, since both use .cc-feed. */
.kn-public-heading { margin: 28px 0 2px; font-size: 17px; }

.kn-builder-head { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.kn-builder-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; }

.kn-tree { margin-top: 14px; }
/* Nested .kn-level blocks are what actually draws the tree: each section's
   own body contains another .kn-level for its children, indented once. The
   border gives a nested group a visible spine without needing to draw
   connector lines by hand. */
.kn-level { display: flex; flex-direction: column; gap: 10px; }
.kn-level .kn-level { margin-top: 10px; margin-left: 22px; padding-left: 14px; border-left: 2px solid var(--cc-border); }

.kn-section {
  border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm);
  background: var(--cc-surface); padding: 12px 14px;
}
.kn-section-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kn-section-title { margin: 0; font-size: 15px; flex: 1 1 auto; min-width: 0; }
.kn-section-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.kn-section-body { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }

.kn-entry {
  border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm);
  background: var(--cc-surface-subtle); padding: 10px 12px;
}
.kn-entry-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kn-entry-title { margin: 0; font-size: 14px; flex: 1 1 auto; min-width: 0; }
.kn-entry-actions { display: flex; gap: 4px; margin-left: auto; }
.kn-entry-body { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }

.kn-move-buttons { display: flex; gap: 2px; }
.kn-icon-button {
  border: 1px solid var(--cc-border); background: var(--cc-surface); color: var(--cc-text);
  border-radius: 7px; width: 26px; height: 26px; line-height: 1; cursor: pointer; font-size: 13px;
}
.kn-icon-button:hover:not(:disabled) { border-color: var(--cc-primary); color: var(--cc-primary); }
.kn-icon-button:disabled { opacity: .35; cursor: default; }

.kn-root-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* Sharing dialog (slice 4). One .kn-share-option per radio, styled as a
   clickable card rather than a bare input+label pair -- the same "the whole
   row is the hit target" pattern .note-cite-doc already uses elsewhere on
   this page. */
.kn-share-options { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.kn-share-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm);
  background: var(--cc-surface); cursor: pointer;
}
.kn-share-option:has(input:checked) { border-color: var(--cc-primary); background: var(--cc-primary-soft); }
.kn-share-option input { margin-top: 3px; }
.kn-share-option .field-note { display: block; margin-top: 2px; }

#knShareLinkInput {
  width: 100%; border: 1px solid var(--cc-border); color: var(--cc-text); background: var(--cc-surface-subtle);
  border-radius: 11px; padding: 10px 12px; font-family: inherit; font-size: 13px;
}

#knEntryDialog textarea {
  width: 100%; resize: vertical; font: inherit; font-size: 14px;
  border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm);
  background: var(--cc-surface-subtle); color: var(--cc-text); padding: 10px 12px;
}
#knEntryDialog textarea:focus { border-color: var(--cc-primary); outline: none; }

/* The quote picker reuses styles.css's .note-cite-* classes (title, meta,
   preview, layout, hover state) rather than duplicating that CSS -- a note
   card and a document card are the identical visual pattern. Two of its
   rules are the exception: .note-cite-doc's own base background
   (rgba(255,255,255,.03), a near-invisible tint meant to sit on that page's
   dark navy canvas) and .note-cite-text's (rgba(4,14,27,.7), a dark overlay
   that would put this page's dark text on a near-black box). Neither is a
   var(), so neither adapts through watch-theme.css's light overrides the
   way every OTHER color in those rules already does -- scoped here to swap
   just those two for this page's own cc-* surface tokens. */
#knQuoteDialog .note-cite-doc { background: var(--cc-surface); border-color: var(--cc-border); }
#knQuoteDialog .note-cite-text { background: var(--cc-surface-subtle); border-color: var(--cc-border); }

/* Same truncation risk .field-note already caused twice elsewhere on this
   page (the import dialog's own explanation, the builder's tree-editing
   hint) -- guarded here too before a long selection-size message hits it. */
#knQuoteDialog .field-note {
  white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.5;
}

.kn-quote-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--cc-border); margin: 4px 0 14px; }
.kn-quote-tab {
  border: 0; background: transparent; color: var(--cc-muted); font: inherit; font-weight: 600;
  padding: 9px 4px; margin-bottom: -1px; border-bottom: 2px solid transparent; cursor: pointer;
}
.kn-quote-tab:hover { color: var(--cc-text); }
.kn-quote-tab.active { color: var(--cc-primary); border-bottom-color: var(--cc-primary); }

/* input[type="search"] is not covered by any generic field rule on this
   page either -- same reason #noteCiteSearch and #mnImportDialog's own
   fields each carry their own. */
#knQuoteNotesSearch, #knQuoteDocSearch, #knQuoteChaburahSearch, #knPublicSearch {
  width: 100%; border: 1px solid var(--cc-border); color: var(--cc-text); background: var(--cc-surface-subtle);
  border-radius: 11px; padding: 10px 12px; font-family: inherit; font-size: 14px; outline: none;
}
#knQuoteNotesSearch:focus, #knQuoteDocSearch:focus, #knQuoteChaburahSearch:focus, #knPublicSearch:focus {
  border-color: var(--cc-primary); box-shadow: 0 0 0 3px var(--cc-focus);
}

/* --- States -------------------------------------------------------------- */
.cc-empty, .cc-error {
  background: var(--cc-surface); border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md); padding: 26px 20px; text-align: center;
}
.cc-empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--cc-text); text-transform: none; letter-spacing: 0; }
.cc-empty p, .cc-error p { margin: 0 0 12px; color: var(--cc-muted); font-size: 14px; }
.cc-error { border-color: rgba(170, 66, 56, 0.35); }
.cc-error h3 { color: var(--cc-danger); margin: 0 0 6px; font-size: 16px; }

.cc-skeleton {
  background: var(--cc-surface); border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md); padding: 14px 16px;
}
.cc-skeleton-line {
  height: 11px; border-radius: 6px; margin-bottom: 9px;
  background: linear-gradient(90deg, #e9eff6 25%, #f4f8fc 37%, #e9eff6 63%);
  background-size: 400% 100%;
  animation: cc-shimmer 1.3s ease-in-out infinite;
}
.cc-skeleton-line:last-child { margin-bottom: 0; }
@keyframes cc-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.cc-feed-footer { display: flex; justify-content: center; margin-top: 14px; }
.cc-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Mobile filter sheet ------------------------------------------------- */
.cc-mobile-filter-bar { display: none; gap: 8px; margin-bottom: 10px; }
@media (max-width: 900px) { .cc-mobile-filter-bar { display: flex; } }

.cc-sheet { border: 0; padding: 0; background: transparent; }
.cc-sheet::backdrop { background: rgba(19, 34, 56, 0.45); }
.cc-sheet-panel {
  background: var(--cc-surface);
  border-radius: var(--cc-radius-lg) var(--cc-radius-lg) 0 0;
  padding: 18px 18px 26px;
  width: 100vw; max-width: 100vw;
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: 80vh; overflow-y: auto;
}
.cc-sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--cc-border); margin: 0 auto 14px; }

/* Hebrew source text is RTL inside an otherwise LTR interface. */
.cloud-chabura [lang="he"] { direction: rtl; text-align: right; }

/* --- Notifications ------------------------------------------------------- */
.cc-notify { position: relative; }
.cc-notify-button {
  position: relative; display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--cc-border); background: var(--cc-surface);
  cursor: pointer; font-size: 15px; line-height: 1;
}
.cc-notify-button:hover { border-color: var(--cc-primary); }
.cc-notify-badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 999px; background: var(--cc-primary); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
}
.cc-notify-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 300;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--cc-surface); border: 1px solid var(--cc-border);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(16, 32, 55, .16);
}
.cc-notify-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px 8px; position: sticky; top: 0; background: var(--cc-surface);
  border-bottom: 1px solid var(--cc-border);
}
.cc-notify-head h2 { margin: 0; font-size: 14px; }
.cc-notify-empty { margin: 0; padding: 18px 16px; color: var(--cc-muted); font-size: 13.5px; line-height: 1.6; }
.cc-notify-list { list-style: none; margin: 0; padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.cc-notify-item { position: relative; display: flex; align-items: flex-start; }
.cc-notify-link {
  flex: 1; display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--cc-text); min-width: 0;
}
.cc-notify-link:hover { background: var(--cc-primary-soft); }
.cc-notify-item.is-unread .cc-notify-link { background: var(--cc-primary-soft); }
.cc-notify-summary { font-size: 13.5px; font-weight: 600; }
.cc-notify-where { font-size: 11.5px; color: var(--cc-primary); font-weight: 600; }
.cc-notify-preview {
  font-size: 12.5px; color: var(--cc-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-notify-time { font-size: 11.5px; color: var(--cc-muted); }
.cc-notify-dot {
  position: absolute; right: 8px; top: 12px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--cc-primary);
}
@media (max-width: 900px) {
  .cc-notify-button { width: 40px; height: 40px; }
  .cc-notify-panel { position: fixed; top: auto; bottom: 64px; right: 12px; left: 12px; width: auto; }
}

/* ===========================================================================
   /profile/ -- avatar preview, the crop dialog, and the "how this appears"
   preview card. New classes only; nothing above this point is touched.
   ========================================================================= */

.pf-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.pf-avatar-preview {
  flex: none; width: 84px; height: 84px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--cc-primary-soft); color: var(--cc-primary);
  font-size: 26px; font-weight: 700;
}
.pf-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.pf-avatar-preview-sm { width: 36px; height: 36px; font-size: 13px; }
.pf-avatar-controls .field-note { margin-top: 6px; }

.pf-preview-card {
  margin-top: 24px; padding: 16px; border: 1px solid var(--cc-border);
  border-radius: 14px; background: var(--cc-surface);
}
.pf-viewing {
  margin-top: 24px; padding: 16px; border: 1px solid var(--cc-border);
  border-radius: 14px; background: var(--cc-surface);
}
.pf-viewing .sync-field { margin-top: 8px; }
.pf-viewing select { width: 100%; max-width: 420px; }
.pf-preview-post { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pf-preview-post strong { font-size: 14px; }
.pf-preview-post .field-note { display: block; margin-top: 2px; }

.pf-crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 12px 0; }
#pfCropCanvas {
  width: 100%; max-width: 320px; aspect-ratio: 1 / 1; border-radius: 50%;
  background: var(--cc-primary-soft); cursor: grab; touch-action: none;
}
#pfCropCanvas:active { cursor: grabbing; }
.pf-crop-wrap .sync-field { width: 100%; max-width: 320px; }
