/* ── Desk ──────────────────────────────────────────────────────────────
   Built on the shared tokens (style.css + app-preferences.css: --stroke,
   --muted, --ui-*), the same radii (20 cards / 14 inner / 10 controls),
   Oswald headings and the same light-theme override pattern as the rest of
   the CRM. The only Desk-specific colours are the text/highlight palette,
   scoped to the editor. Every selector is prefixed .desk- (this file is
   also loaded on dashboard.html for the Desk handoff bar). */

.desk-container {
  max-width: min(1980px, 100%);
}

/* Class rules below set display:flex etc.; the [hidden] attribute must win. */
[class*="desk-"][hidden] { display: none !important; }

/* ── shared controls ────────────────────────────────────────────────── */
.desk-btn {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-soft);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.desk-btn:hover { background: color-mix(in srgb, var(--ui-text) 8%, transparent); }
.desk-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.desk-btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.desk-btn--primary:hover { background: var(--red-2); }
.desk-btn--icon { width: 36px; justify-content: center; padding: 8px 0; font-size: 18px; line-height: 1; }

.desk-empty {
  padding: 18px 4px;
  color: var(--muted);
  font-size: 13px;
}

.desk-empty--error { color: var(--ui-danger); }

.desk-empty--block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 42px 20px;
  border: 1px dashed var(--stroke);
  border-radius: 20px;
}

.desk-empty--block strong {
  color: var(--text);
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.desk-empty--block span { max-width: 52ch; line-height: 1.5; }

.desk-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
}

.desk-tag--muted { background: var(--ui-surface-soft); color: var(--muted); }

/* ── visibility chips ───────────────────────────────────────────────── */
.desk-vis {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--ui-surface-soft);
  color: var(--muted);
}

.desk-vis--team {
  background: var(--ui-info-soft);
  color: var(--ui-info);
}

.desk-vis-chip {
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
}

.desk-vis-chip:disabled { cursor: default; }
.desk-vis-chip:not(:disabled):hover .desk-vis { box-shadow: 0 0 0 1px var(--stroke) inset; }

/* ── list view ──────────────────────────────────────────────────────── */
.desk-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.desk-filter {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.desk-filter:hover { color: var(--text); background: var(--ui-surface-soft); }

.desk-filter.is-active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent);
  background: color-mix(in srgb, var(--ui-accent) 9%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 25%, transparent) inset;
}

.desk-filters__search { flex: 1 1 200px; min-width: 160px; margin-left: auto; }

.desk-filters__search input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
}

.desk-filters__search input::placeholder { color: var(--muted); }
.desk-filters__search input:focus-visible { outline: none; border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent); }

.desk-filters__dates {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.desk-filters__dates input {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  color-scheme: dark light;
}

.desk-filters__dates input:focus-visible { outline: none; border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent); }

.desk-filters__reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.desk-filters__reset:hover { color: var(--text); background: var(--ui-surface-soft); }

.desk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.desk-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-soft);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.desk-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--ui-accent) 40%, var(--stroke));
}

.desk-card.is-archived { opacity: 0.75; }

.desk-card__link {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}

.desk-card__link:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

.desk-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.desk-card__menu {
  position: relative;
  z-index: 2;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.desk-card__menu:hover { border-color: var(--stroke); color: var(--text); }

.desk-card__title {
  margin: 0;
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.desk-card__preview {
  margin: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.desk-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ── page view ──────────────────────────────────────────────────────── */
#deskPageView.is-loading .desk-editor-card { opacity: 0.5; pointer-events: none; }

.desk-page-head { align-items: flex-start; }

.desk-page-head__main {
  flex: 1;
  min-width: 0;
}

.desk-page-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.desk-page-head .crm-breadcrumb a { color: var(--muted); }
.desk-page-head .crm-breadcrumb a:hover { color: var(--text); }

.desk-title-input {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 2px 0 4px;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent !important;
  color: var(--text);
  font-family: 'Oswald', sans-serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.02em;
  outline: none;
  box-shadow: none;
}

/* Non-default themes force a background/border on every input
   (app-preferences.css, `html[data-ui-theme]… :is(input…) !important`, 0-4-2);
   the title is a heading, not a field — the id outranks that rule. */
#deskTitleInput {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

#deskTitleInput:focus { border-bottom-color: var(--stroke) !important; }
.desk-title-input::placeholder { color: var(--muted); }

.desk-page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.desk-save-state[data-state="saving"],
.desk-save-state[data-state="dirty"] { color: var(--muted); }
.desk-save-state[data-state="saved"] { color: color-mix(in srgb, var(--ui-success) 80%, var(--muted)); }
.desk-save-state[data-state="error"],
.desk-save-state[data-state="offline"] { color: var(--ui-danger); }

.desk-presence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.desk-presence__label { margin-right: 2px; }

.desk-presence__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
  font-size: 10.5px;
  font-weight: 700;
}

.desk-archived-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke-soft);
  background: var(--ui-warning-soft);
  color: var(--ui-warning);
  font-size: 13px;
}

.desk-editor-card {
  border-radius: 20px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-soft);
  min-height: 60vh;
}

/* ── editor ─────────────────────────────────────────────────────────── */
/* Popovers live in <body> (see desk-editor.js), so they get the palette too. */
.desk-editor,
.desk-popover {
  /* Content palette (text colour / highlight) — theme-aware, editor only. */
  --desk-c-gray: #a3a3a3;
  --desk-c-red: #ef7a71;
  --desk-c-orange: #f0a35a;
  --desk-c-yellow: #e6cb5c;
  --desk-c-green: #72cf8c;
  --desk-c-blue: #6db0f0;
  --desk-c-purple: #b896f2;
  --desk-bg-gray: rgba(255, 255, 255, 0.12);
  --desk-bg-red: rgba(239, 107, 98, 0.26);
  --desk-bg-orange: rgba(240, 160, 80, 0.26);
  --desk-bg-yellow: rgba(232, 204, 90, 0.3);
  --desk-bg-green: rgba(111, 207, 138, 0.22);
  --desk-bg-blue: rgba(106, 174, 240, 0.24);
  --desk-bg-purple: rgba(178, 140, 240, 0.26);
}

.desk-editor { position: relative; }

.desk-toolbar {
  position: sticky;
  top: var(--desk-sticky-top, 0px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--stroke-soft);
  border-radius: 20px 20px 0 0;
  background: color-mix(in srgb, var(--ui-page) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-x: auto;
  scrollbar-width: none;
}

.desk-toolbar::-webkit-scrollbar { display: none; }

.desk-toolbar__group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid var(--stroke-soft);
  flex-shrink: 0;
}

.desk-toolbar__group:last-child { border-right: none; }
.desk-toolbar__group--extra { margin-left: auto; padding-left: 6px; }

.desk-toolbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.desk-toolbar__btn:hover { background: var(--ui-surface-soft); }
.desk-toolbar__btn.is-active { background: var(--ui-accent-soft); color: var(--ui-accent-text); }
.desk-toolbar__btn:disabled { opacity: 0.4; cursor: default; }
.desk-toolbar__btn--icon { width: 32px; padding: 0; font-size: 14px; }
.desk-toolbar__btn--wide { min-width: 132px; justify-content: space-between; }
.desk-toolbar__label { overflow: hidden; text-overflow: ellipsis; }

.desk-toolbar__color-a {
  font-weight: 700;
  border-bottom: 3px solid var(--desk-c-red);
  line-height: 1.1;
}

.desk-toolbar__hl,
.desk-menu__hl {
  padding: 0 3px;
  border-radius: 3px;
  background: var(--desk-bg-yellow, rgba(232, 204, 90, 0.3));
  font-size: 12px;
}

.desk-toolbar.is-disabled { opacity: 0.55; }

/* Text formatting | structure — a quiet separator, then «+ Вставить». */
.desk-toolbar__divider {
  flex-shrink: 0;
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--stroke);
}

.desk-toolbar__btn--text { font-size: 12.5px; padding: 0 9px; }
.desk-toolbar__group--table { border-right: none; }

.desk-toolbar__dropdown { position: relative; }

.desk-popover {
  position: fixed;
  z-index: 520;
  display: none;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-2);
  box-shadow: var(--shadow);
}

.desk-popover.is-open { display: block; }

.desk-popover--menu {
  min-width: 230px;
  max-height: min(420px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.desk-popover__item.is-active { background: var(--ui-surface-soft); box-shadow: inset 2px 0 0 var(--ui-accent); }
.desk-popover__empty { padding: 10px; font-size: 13px; color: var(--muted); }

/* Callout icon / tone picker */
.desk-callout-pop { width: 288px; }
.desk-callout-pop__icons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.desk-callout-pop__icon {
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}

.desk-callout-pop__icon:hover,
.desk-callout-pop__icon.is-selected { background: var(--ui-surface-soft); border-color: var(--stroke); }
.desk-callout-pop__custom { margin: 8px 0; }
.desk-callout-pop__tones { display: flex; flex-wrap: wrap; gap: 6px; }

.desk-callout-pop__tone {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.desk-callout-pop__tone.is-selected { border-color: var(--ui-accent); }
.desk-callout-pop__tone--info { background: var(--ui-info-soft); }
.desk-callout-pop__tone--success { background: var(--ui-success-soft); }
.desk-callout-pop__tone--warning { background: var(--ui-warning-soft); }
.desk-callout-pop__tone--danger { background: var(--ui-danger-soft); }

.desk-popover__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.desk-popover__item:hover,
.desk-popover__item.is-selected { background: var(--ui-surface-soft); }

.desk-popover__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  border-radius: 6px;
  background: var(--ui-surface-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.desk-popover--colors {
  grid-template-columns: repeat(4, 34px);
  gap: 6px;
}

.desk-popover--colors.is-open { display: grid; }

.desk-popover__swatch {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.desk-popover__swatch:hover { box-shadow: 0 0 0 2px var(--ui-accent) inset; }

.desk-swatch--c-default { color: var(--ui-text); }
.desk-swatch--c-gray { color: var(--desk-c-gray); }
.desk-swatch--c-red { color: var(--desk-c-red); }
.desk-swatch--c-orange { color: var(--desk-c-orange); }
.desk-swatch--c-yellow { color: var(--desk-c-yellow); }
.desk-swatch--c-green { color: var(--desk-c-green); }
.desk-swatch--c-blue { color: var(--desk-c-blue); }
.desk-swatch--c-purple { color: var(--desk-c-purple); }
.desk-swatch--bg-none { background: linear-gradient(135deg, transparent 46%, var(--ui-danger) 47%, var(--ui-danger) 53%, transparent 54%); }
.desk-swatch--bg-gray { background: var(--desk-bg-gray); }
.desk-swatch--bg-red { background: var(--desk-bg-red); }
.desk-swatch--bg-orange { background: var(--desk-bg-orange); }
.desk-swatch--bg-yellow { background: var(--desk-bg-yellow); }
.desk-swatch--bg-green { background: var(--desk-bg-green); }
.desk-swatch--bg-blue { background: var(--desk-bg-blue); }
.desk-swatch--bg-purple { background: var(--desk-bg-purple); }

.desk-popover--link { width: min(320px, calc(100vw - 16px)); }

.desk-popover__input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--ui-input);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.desk-popover__input:focus { border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent); }

.desk-popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.desk-popover__btn {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.desk-popover__btn--primary { background: var(--red); border-color: var(--red); color: #fff; }

.desk-editor__body {
  position: relative;
  padding: 22px 0 60px;
}

/* Full card width: left gutter = drag handle, right gutter = entity badges. */
.desk-editor__surface {
  min-height: 50vh;
  padding: 0 176px 0 48px;
  outline: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  caret-color: var(--ui-accent);
  -webkit-user-select: text;
  user-select: text;
}

.desk-editor__surface { position: relative; }

.desk-editor.is-empty .desk-editor__surface::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  padding: inherit;
  color: var(--muted);
  pointer-events: none;
}

.desk-editor__surface > p,
.desk-editor__surface li {
  margin: 0;
  padding: 2px 0;
}

.desk-editor__surface > h1,
.desk-editor__surface > h2,
.desk-editor__surface > h3 {
  margin: 18px 0 4px;
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--text);
}

.desk-editor__surface > h1 { font-size: 26px; }
.desk-editor__surface > h2 { font-size: 21px; }
.desk-editor__surface > h3 { font-size: 17px; }
.desk-editor__surface > :first-child { margin-top: 0; }

.desk-editor__surface > ul,
.desk-editor__surface > ol {
  margin: 2px 0;
  padding-left: 24px;
}

.desk-editor__surface li::marker { color: var(--muted); }

.desk-editor__surface > p[data-type="todo"] {
  position: relative;
  padding-left: 30px;
}

.desk-editor__surface > p[data-type="todo"]::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.4em;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--muted);
  cursor: pointer;
  box-sizing: border-box;
}

.desk-editor__surface > p[data-type="todo"][data-checked="true"]::before {
  border-color: var(--ui-accent);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat,
    var(--ui-accent);
}

.desk-editor__surface > p[data-type="todo"][data-checked="true"] {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
}

/* ── structural blocks ──────────────────────────────────────────────── */

/* Toggle children: one indentation level; folding is per person. */
.desk-editor__surface [data-parent] { margin-left: 28px; }
.desk-editor__surface li[data-parent] { margin-left: 28px; }
.desk-editor__surface .dk-hidden { display: none !important; }

.desk-editor__surface > p[data-type="toggle"] {
  position: relative;
  padding-left: 28px;
  font-weight: 600;
}

.desk-editor__surface > p[data-type="toggle"]::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.2em;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 7l5 5-5 5z'/%3E%3C/svg%3E") center / 20px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 7l5 5-5 5z'/%3E%3C/svg%3E") center / 20px no-repeat;
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.desk-editor__surface > p[data-type="toggle"].is-collapsed::before { transform: none; }
.desk-editor__surface > p[data-type="toggle"]:hover::before { background-color: var(--text); }

.desk-editor__surface > p[data-type="quote"] {
  margin: 6px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid color-mix(in srgb, var(--ui-accent) 45%, var(--stroke));
  color: var(--text);
}

.desk-editor__surface > p[data-type="callout"] {
  position: relative;
  margin: 8px 0;
  padding: 10px 14px 10px 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke-soft);
  background: var(--ui-surface-soft);
}

.desk-editor__surface > p[data-type="callout"]::before {
  content: attr(data-icon);
  position: absolute;
  left: 10px;
  top: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.desk-editor__surface > p[data-type="callout"]:hover::before { background: var(--ui-surface-soft); }
.desk-editor__surface > p[data-type="callout"][data-tone="info"] { background: var(--ui-info-soft); border-color: color-mix(in srgb, var(--ui-info) 22%, transparent); }
.desk-editor__surface > p[data-type="callout"][data-tone="success"] { background: var(--ui-success-soft); border-color: color-mix(in srgb, var(--ui-success) 22%, transparent); }
.desk-editor__surface > p[data-type="callout"][data-tone="warning"] { background: var(--ui-warning-soft); border-color: color-mix(in srgb, var(--ui-warning) 24%, transparent); }
.desk-editor__surface > p[data-type="callout"][data-tone="danger"] { background: var(--ui-danger-soft); border-color: color-mix(in srgb, var(--ui-danger) 24%, transparent); }

/* Divider: a thin line inside a taller (clickable / draggable) strip. */
.desk-editor__surface > .dk-divider {
  position: relative;
  height: 17px;
  margin: 2px 0;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

.desk-editor__surface > .dk-divider::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: 1px;
  background: var(--stroke);
}

/* Simple table: one block, cells editable, scrolls sideways on phones. */
.desk-editor__surface > .dk-table { margin: 8px 0; }

.dk-table__scroll {
  overflow-x: auto;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.dk-table table {
  width: 100%;
  border-collapse: collapse;
  border-style: hidden;
  font-size: 14px;
}

.dk-table td {
  min-width: 120px;
  padding: 6px 10px;
  border: 1px solid var(--stroke-soft);
  vertical-align: top;
  line-height: 1.5;
  outline: none;
  overflow-wrap: anywhere;
}

.dk-table td:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ui-accent) 55%, transparent); }
.dk-table[data-header="true"] tr:first-child td { font-weight: 600; background: var(--ui-surface-soft); }
/* Freeform cell-range drag selection (a stand-in for native Selection, which
   can't span <td> editing hosts) — must read over the header row too. */
.dk-table td.dk-cell-range { background: color-mix(in srgb, var(--ui-accent) 22%, transparent) !important; }

.desk-editor__surface a {
  color: var(--ui-accent-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.desk-editor__surface .dk-c-default { color: var(--ui-text); }
.desk-editor__surface .dk-c-gray { color: var(--desk-c-gray); }
.desk-editor__surface .dk-c-red { color: var(--desk-c-red); }
.desk-editor__surface .dk-c-orange { color: var(--desk-c-orange); }
.desk-editor__surface .dk-c-yellow { color: var(--desk-c-yellow); }
.desk-editor__surface .dk-c-green { color: var(--desk-c-green); }
.desk-editor__surface .dk-c-blue { color: var(--desk-c-blue); }
.desk-editor__surface .dk-c-purple { color: var(--desk-c-purple); }
.desk-editor__surface .dk-bg-none { background: transparent; }
.desk-editor__surface [class*="dk-bg-"]:not(.dk-bg-none) { border-radius: 3px; padding: 0 1px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.desk-editor__surface .dk-bg-gray { background: var(--desk-bg-gray); }
.desk-editor__surface .dk-bg-red { background: var(--desk-bg-red); }
.desk-editor__surface .dk-bg-orange { background: var(--desk-bg-orange); }
.desk-editor__surface .dk-bg-yellow { background: var(--desk-bg-yellow); }
.desk-editor__surface .dk-bg-green { background: var(--desk-bg-green); }
.desk-editor__surface .dk-bg-blue { background: var(--desk-bg-blue); }
.desk-editor__surface .dk-bg-purple { background: var(--desk-bg-purple); }

.desk-editor__surface ::selection { background: color-mix(in srgb, var(--ui-accent) 32%, transparent); }

/* drag handle (one, follows the hovered / caret block) */
.desk-editor__handle {
  position: absolute;
  left: 12px;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  transition: opacity 0.12s ease, background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.desk-editor__handle.is-visible { opacity: 1; pointer-events: auto; }
.desk-editor__handle:hover { background: var(--ui-surface-soft); border-color: var(--stroke-soft); color: var(--text); }
.desk-editor.is-dragging .desk-editor__handle { cursor: grabbing; background: var(--ui-accent-soft); color: var(--ui-accent-text); }
.desk-editor.is-dragging .desk-editor__surface { -webkit-user-select: none; user-select: none; }
.desk-editor .is-drag-source { opacity: 0.4; }
.desk-editor.is-readonly .desk-editor__handle { display: none; }

.desk-editor__drop-indicator {
  position: absolute;
  left: 44px;
  right: 172px;
  height: 2px;
  border-radius: 2px;
  background: var(--ui-accent);
  opacity: 0;
  pointer-events: none;
}

.desk-editor__drop-indicator.is-visible { opacity: 1; }

/* entity badges in the right gutter */
.desk-editor__badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.desk-editor__badge-row {
  position: absolute;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 160px;
}

.desk-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.desk-badge:hover { border-color: color-mix(in srgb, var(--ui-accent) 50%, var(--stroke)); }

.desk-badge__dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.desk-badge__text { overflow: hidden; text-overflow: ellipsis; }
.desk-badge--lead .desk-badge__dot { background: var(--ui-info); }
.desk-badge--client .desk-badge__dot { background: var(--ui-success); }
.desk-badge--reminder .desk-badge__dot { background: var(--ui-warning); }

/* Page-level "this page is the workspace for this client_product" link —
   separate from the per-block .desk-badge row the editor renders. */
.desk-product-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.desk-product-link:hover { border-color: color-mix(in srgb, var(--ui-accent) 50%, var(--stroke)); }

.desk-editor.is-readonly .desk-editor__surface { cursor: default; }

/* ── context menu / bottom sheet ────────────────────────────────────── */
.desk-menu {
  position: fixed;
  z-index: 540;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-2);
  color: var(--text);
  box-shadow: var(--shadow);
}

.desk-menu__section {
  padding: 6px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.desk-menu__sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--stroke-soft);
}

.desk-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.desk-menu__item:hover:not(:disabled),
.desk-menu__item:focus-visible { background: var(--ui-surface-soft); outline: none; }
.desk-menu__item:disabled { opacity: 0.4; cursor: default; }

.desk-menu__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13px;
}

.desk-menu__item--accent .desk-menu__icon { color: var(--ui-accent-text); }
.desk-menu__item--danger { color: var(--ui-danger); }
.desk-menu__label { flex: 1; }
.desk-menu__hint { font-size: 11px; color: var(--muted); }

.desk-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 530;
  background: var(--ui-backdrop);
}

.desk-menu--sheet {
  left: 0;
  right: 0;
  bottom: 0;
  min-width: 0;
  max-width: none;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  border-bottom: none;
}

.desk-menu--sheet .desk-menu__item { min-height: 46px; font-size: 15px; }

/* touch selection pill */
.desk-selection-pill {
  position: fixed;
  z-index: 510;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ui-accent) 45%, transparent);
  background: var(--ui-surface-2);
  color: var(--ui-accent-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.desk-selection-pill.is-visible { display: inline-flex; }

/* ── history drawer ─────────────────────────────────────────────────── */
.desk-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 450;
  background: var(--ui-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.desk-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.desk-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 460;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  border-left: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 0.22s ease;
}

.desk-drawer.is-open { transform: none; }

.desk-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.desk-drawer__head h2 {
  margin: 0;
  font-family: 'Oswald', sans-serif;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.desk-drawer__close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.desk-drawer__tabs {
  display: flex;
  gap: 8px;
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--stroke-soft);
}

.desk-drawer__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
}

.desk-history-list {
  display: flex;
  flex-direction: column;
}

.desk-history-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--stroke-soft);
  text-align: left;
}

.desk-history-row__title { font-size: 13px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.desk-history-row__meta { font-size: 11.5px; color: var(--muted); }

.desk-history-row--button {
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 10px;
}

.desk-history-row--button:hover,
.desk-history-row--button.is-selected { background: var(--ui-surface-soft); }

.desk-revision-preview {
  margin-top: 14px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  overflow: hidden;
}

.desk-revision-preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke-soft);
  font-size: 12.5px;
  color: var(--muted);
}

.desk-revision-preview__body .desk-editor__body { padding: 14px 0 20px; }
.desk-revision-preview__body .desk-editor__surface { padding: 0 16px; min-height: 0; font-size: 14px; }

/* ── new page modal ─────────────────────────────────────────────────── */
.desk-new-modal { max-width: 560px; }
.desk-new-modal__grid { grid-template-columns: 1fr; }

.desk-visibility-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* #id beats the generic red `.modal button:not(…)` rule in style.css */
#deskNewPageModal .desk-visibility-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  text-align: left;
  font-weight: 400;
  cursor: pointer;
  transform: none;
}

#deskNewPageModal .desk-visibility-option:hover {
  transform: none;
  box-shadow: none;
  background: var(--ui-surface-soft);
}

#deskNewPageModal .desk-visibility-option.is-selected {
  border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent);
  background: color-mix(in srgb, var(--ui-accent) 9%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 25%, transparent) inset;
}

.desk-visibility-option__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--ui-surface-soft);
  color: var(--muted);
}

.desk-visibility-option.is-selected .desk-visibility-option__icon { color: var(--ui-accent-text); background: var(--ui-accent-soft); }

.desk-visibility-option__body { display: flex; flex-direction: column; gap: 3px; }
.desk-visibility-option__body strong { font-size: 14px; }
.desk-visibility-option__body small { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* ── handoff bar + suggestions (dashboard.html) ─────────────────────── */
.desk-return-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 100001;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 6px 6px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  transform: translateX(-50%);
}

.desk-return-bar.is-done { border-color: color-mix(in srgb, var(--ui-success) 50%, var(--ui-border)); }

.desk-return-bar__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
  font-weight: 600;
  text-decoration: none;
}

.desk-return-bar__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.desk-return-bar.is-done .desk-return-bar__text { color: var(--text); }

.desk-return-bar__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.desk-suggest {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke-soft);
  background: var(--ui-info-soft);
  font-size: 13px;
  line-height: 1.45;
}

.desk-suggest__head {
  font-weight: 700;
  color: var(--ui-info);
  margin-bottom: 4px;
}

.desk-suggest__text,
.desk-suggest__info { margin: 0; color: var(--muted); }
.desk-suggest__info { margin-top: 8px; font-size: 12px; }

.desk-suggest__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#leadModal .desk-suggest__chip,
#modal .desk-suggest__chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--ui-surface-2);
  box-shadow: none;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  transform: none;
}

#leadModal .desk-suggest__chip:hover,
#modal .desk-suggest__chip:hover { transform: none; box-shadow: none; border-color: var(--ui-info); }
#leadModal .desk-suggest__chip.is-applied,
#modal .desk-suggest__chip.is-applied { border-color: var(--ui-success); color: var(--ui-success); }
.desk-suggest__chip.is-applied::before { content: "✓ "; }

/* ── light themes (same override pattern as app-preferences.css) ────── */
html[data-ui-theme="light"] .desk-card,
html[data-ui-theme="light"] .desk-editor-card,
html[data-ui-theme="espanolitos"] .desk-card,
html[data-ui-theme="espanolitos"] .desk-editor-card {
  background: rgba(255,255,255,0.68);
  border-color: rgba(71,50,36,0.13);
}

html[data-ui-theme="light"] .desk-toolbar,
html[data-ui-theme="espanolitos"] .desk-toolbar {
  background: rgba(255,250,244,0.9);
}

html[data-ui-theme="light"] .desk-editor,
html[data-ui-theme="light"] .desk-popover,
html[data-ui-theme="espanolitos"] .desk-editor,
html[data-ui-theme="espanolitos"] .desk-popover {
  --desk-c-gray: #6b6b6b;
  --desk-c-red: #b3362c;
  --desk-c-orange: #b05e17;
  --desk-c-yellow: #8a6d00;
  --desk-c-green: #23743e;
  --desk-c-blue: #1f5f99;
  --desk-c-purple: #6d3fb0;
  --desk-bg-gray: rgba(35,38,42,0.1);
  --desk-bg-red: rgba(220,90,80,0.22);
  --desk-bg-orange: rgba(235,150,60,0.26);
  --desk-bg-yellow: rgba(240,205,60,0.42);
  --desk-bg-green: rgba(80,180,110,0.24);
  --desk-bg-blue: rgba(80,150,220,0.22);
  --desk-bg-purple: rgba(150,110,220,0.22);
}

/* ── tablet / mobile ────────────────────────────────────────────────── */
.desk-editor__body { cursor: text; }
.desk-editor.is-readonly .desk-editor__body { cursor: default; }

body[data-interaction-mode="tablet-touch"] .desk-editor__handle,
body[data-interaction-mode="mobile"] .desk-editor__handle {
  width: 32px;
  height: 32px;
  border-color: var(--stroke-soft);
  background: var(--ui-surface-2);
}

body[data-interaction-mode="tablet-touch"] .desk-toolbar__btn { min-width: 38px; height: 38px; }
body[data-interaction-mode="tablet-touch"] .desk-toolbar__btn--icon { width: 38px; }
body[data-interaction-mode="tablet-touch"] .desk-menu__item { min-height: 42px; font-size: 14.5px; }
body[data-interaction-mode="tablet-touch"] .desk-popover__item,
body[data-interaction-mode="mobile"] .desk-popover__item { min-height: 42px; font-size: 14.5px; }
body[data-interaction-mode="tablet-touch"] .desk-callout-pop__icon,
body[data-interaction-mode="mobile"] .desk-callout-pop__icon { height: 40px; }
body[data-interaction-mode="tablet-touch"] .dk-table td,
body[data-interaction-mode="mobile"] .dk-table td { padding: 9px 12px; }
body[data-interaction-mode="tablet-touch"] .desk-editor__surface > p[data-type="toggle"]::before,
body[data-interaction-mode="mobile"] .desk-editor__surface > p[data-type="toggle"]::before { width: 26px; height: 26px; left: 0; top: 0.05em; }

@media (max-width: 760px) {
  .desk-filters__search { flex-basis: 100%; margin-left: 0; }
  .desk-filters__dates { flex-basis: 100%; }
  .desk-page-head { flex-direction: column; gap: 10px; }
  .desk-page-head__actions { align-self: stretch; justify-content: flex-end; }
  .desk-title-input { font-size: 23px; }
  .desk-grid { grid-template-columns: 1fr; }
  .desk-editor-card { border-radius: 16px; }
  .desk-toolbar { border-radius: 16px 16px 0 0; padding: 6px; }
  .desk-editor__surface [data-parent] { margin-left: 18px; }
  .dk-table td { min-width: 110px; }
  .desk-editor__body { padding-top: 16px; }
  .desk-editor__surface { padding: 0 40px 0 38px; font-size: 16px; }
  .desk-editor__handle { left: 3px; }
  .desk-editor__drop-indicator { left: 36px; right: 36px; }
  .desk-editor__badge-row { right: 4px; max-width: 34px; }
  .desk-badge { padding: 4px; }
  .desk-badge__text { display: none; }
  .desk-badge__dot { width: 9px; height: 9px; }
  .desk-visibility-options { grid-template-columns: 1fr; }
  .desk-return-bar__text { display: none; }
}
