.wd-editor, .wd-render {
  --wd-surface: var(--c-surface, #ffffff);
  --wd-surface-2: var(--c-surface-2, #f4f5f7);
  --wd-line: var(--c-line, #e2e5ea);
  --wd-ink: var(--c-ink, #1c2430);
  --wd-ink-faint: var(--c-ink-faint, #74808f);
  --wd-accent: var(--c-primary, #ff7a1a);
  --wd-radius: var(--r-md, 12px);
  --wd-gap: var(--sp-3, 12px);
  color: var(--wd-ink);
}

.wd-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  margin-bottom: var(--wd-gap);
  background: var(--wd-surface);
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
}
.wd-tb-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--wd-line);
  border-radius: 10px;
  background: var(--wd-surface-2);
  color: var(--wd-ink);
  cursor: pointer;
  font-size: 15px;
}
.wd-tb-btn:hover { background: var(--wd-line); }
.wd-tb-comment { margin-inline-start: auto; }
.wd-tb-hl { position: relative; display: inline-flex; }
.wd-hl-menu {
  display: none;
  position: absolute;
  top: 44px;
  left: 0;
  gap: 6px;
  padding: 8px;
  background: var(--wd-surface);
  border: 1px solid var(--wd-line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.wd-tb-hl:hover .wd-hl-menu, .wd-tb-hl:focus-within .wd-hl-menu { display: flex; }
.wd-hl-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--wd-line); cursor: pointer; }

.wd-hl-yellow { background: rgba(255, 214, 0, 0.4); }
.wd-hl-green { background: rgba(46, 204, 113, 0.35); }
.wd-hl-pink { background: rgba(255, 105, 160, 0.35); }
.wd-hl-blue { background: rgba(52, 152, 219, 0.32); }
.wd-hl-purple { background: rgba(155, 89, 182, 0.32); }

.wd-cards { display: flex; flex-direction: column; }

.wd-divider { display: flex; justify-content: center; padding: 4px 0; }
.wd-add {
  border: 1px dashed var(--wd-line);
  background: transparent;
  color: var(--wd-ink-faint);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.wd-add:hover { color: var(--wd-accent); border-color: var(--wd-accent); }

.wd-card {
  border: 1px solid var(--wd-line);
  border-left: 4px solid var(--wd-line);
  border-radius: var(--wd-radius);
  background: var(--wd-surface);
  padding: var(--wd-gap);
}
.wd-card[data-accent="intro"], .wd-card-ro[data-accent="intro"] { border-left-color: #3498db; }
.wd-card[data-accent="segment"] { border-left-color: var(--wd-accent); }
.wd-card[data-accent="outro"] { border-left-color: #9b59b6; }
.wd-card[data-accent="note"] { border-left-color: #f1c40f; }

.wd-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.wd-role-wrap { position: relative; }
.wd-role {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--wd-line); background: var(--wd-surface-2);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--wd-ink);
}
.wd-role-menu {
  display: none; position: absolute; top: 34px; left: 0; z-index: 20;
  flex-direction: column; min-width: 150px;
  background: var(--wd-surface); border: 1px solid var(--wd-line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); overflow: hidden;
}
.wd-role-menu.open { display: flex; }
.wd-role-opt { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--wd-ink); }
.wd-role-opt:hover { background: var(--wd-surface-2); }

.wd-headline { flex: 1 1 140px; min-width: 120px; border: 0; border-bottom: 1px solid transparent; background: transparent; font-size: 16px; font-weight: 600; color: var(--wd-ink); padding: 4px 2px; }
.wd-headline:focus { outline: none; border-bottom-color: var(--wd-accent); }

.wd-card-tools { display: inline-flex; gap: 2px; align-items: center; }
.wd-tool, .wd-badge {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--wd-ink-faint); cursor: pointer; font-size: 14px;
}
.wd-tool:hover, .wd-badge:hover { background: var(--wd-surface-2); color: var(--wd-ink); }
.wd-tool-del.armed { width: auto; padding: 0 10px; color: #fff; background: #e74c3c; border-color: #e74c3c; font-size: 12px; }
.wd-badge.has { color: var(--wd-accent); }
.wd-badge span { font-size: 12px; }

.wd-body {
  min-height: 60px; padding: 8px 10px; border: 1px solid var(--wd-line); border-radius: 10px;
  background: var(--wd-surface); line-height: 1.6; font-size: 16px; outline: none; word-break: break-word;
}
.wd-body:focus { border-color: var(--wd-accent); }
.wd-body:empty::before { content: attr(data-ph); color: var(--wd-ink-faint); }
.wd-body a { color: var(--wd-accent); }
.wd-body .wd-hl { border-radius: 3px; padding: 0 1px; }
.wd-hl[data-color="yellow"] { background: rgba(255, 214, 0, 0.4); }
.wd-hl[data-color="green"] { background: rgba(46, 204, 113, 0.35); }
.wd-hl[data-color="pink"] { background: rgba(255, 105, 160, 0.35); }
.wd-hl[data-color="blue"] { background: rgba(52, 152, 219, 0.32); }
.wd-hl[data-color="purple"] { background: rgba(155, 89, 182, 0.32); }
.wd-comment { border-bottom: 2px solid var(--wd-accent); cursor: help; }

.wd-ref {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 0 8px; border-radius: 999px; font-size: 0.88em; font-weight: 600; cursor: pointer;
  background: var(--wd-surface-2); border: 1px solid var(--wd-line); color: var(--wd-accent); user-select: none;
}
.wd-ref[data-ref-kind="asset"] { color: #2e8b57; }

.wd-source { width: 100%; margin-top: 8px; border: 1px solid var(--wd-line); border-radius: 8px; padding: 6px 8px; font-size: 13px; background: var(--wd-surface); color: var(--wd-ink); }

.wd-extras { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wd-extras:empty { display: none; }

.wd-empty { text-align: center; color: var(--wd-ink-faint); padding: 24px; }
.wd-empty i { font-size: 28px; display: block; margin-bottom: 8px; }

.wd-refmenu, .wd-pop {
  z-index: 200; min-width: 220px; max-width: 300px;
  background: var(--wd-surface, #fff); border: 1px solid var(--wd-line, #e2e5ea); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); overflow: hidden;
}
.wd-refmenu-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 14px; }
.wd-refmenu-row:hover { background: var(--wd-surface-2, #f4f5f7); }
.wd-refmenu-row img { width: 26px; height: 26px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.wd-refmenu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-refmenu-type { font-size: 11px; color: var(--wd-ink-faint); text-transform: capitalize; }
.wd-refmenu-loading, .wd-refmenu-empty, .wd-pop-loading, .wd-pop-empty { padding: 12px; color: var(--wd-ink-faint); font-size: 13px; }

.wd-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--wd-line); }
.wd-pop-x { border: 0; background: transparent; cursor: pointer; color: var(--wd-ink-faint); font-size: 15px; }
.wd-pop-body { padding: 10px; }
.wd-pop-img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.wd-pop-type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--wd-ink-faint); }
.wd-pop-name { font-size: 15px; font-weight: 700; }
.wd-pop-sub { font-size: 13px; color: var(--wd-ink-faint); margin-top: 2px; }
.wd-pop-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--wd-accent); text-decoration: none; }

.wd-ro-title { font-size: 22px; font-weight: 800; margin: 0 0 12px; }
.wd-card-ro { margin-bottom: 12px; }
.wd-ro-role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--wd-ink-faint); margin-bottom: 4px; }
.wd-ro-headline { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.wd-body-ro { border: 0; padding: 0; background: transparent; min-height: 0; }
.wd-ro-source { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--wd-ink-faint); margin-top: 8px; text-decoration: none; }
.wd-ro-assets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.wd-ro-thumb img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; }
.wd-ro-clip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--wd-line); border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--wd-ink); }
.wd-ro-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--wd-line); }
.wd-ro-ccount { font-size: 13px; color: var(--wd-ink-faint); }
.wd-ro-ccount.has { color: var(--wd-accent); }
.wd-ro-comment { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--wd-line); background: var(--wd-surface-2); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--wd-ink); }

.wd-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: flex-start; }
.wd-media-item { position: relative; display: flex; flex-direction: column; align-items: center; width: 92px; }
.wd-media-item img { width: 92px; height: 68px; object-fit: cover; border-radius: 8px; border: 1px solid var(--wd-line); background: var(--wd-surface-2); }
.wd-media-item.wd-media-broken img { display: none; }
.wd-media-item.wd-media-broken::before { content: ""; display: block; width: 92px; height: 68px; border-radius: 8px; border: 1px dashed var(--wd-line); background: var(--wd-surface-2); }
.wd-media-clip { display: flex; align-items: center; justify-content: center; width: 92px; height: 68px; border-radius: 8px; border: 1px solid var(--wd-line); background: var(--wd-surface-2); color: var(--wd-accent); font-size: 20px; }
.wd-media-cap { font-size: 11px; color: var(--wd-ink-faint); margin-top: 3px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-media-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--wd-line); background: var(--wd-surface); color: #e74c3c; cursor: pointer; font-size: 11px; line-height: 1; }
.wd-media-add { display: inline-flex; align-items: center; gap: 6px; height: 68px; padding: 0 14px; border: 1px dashed var(--wd-line); border-radius: 8px; background: transparent; color: var(--wd-ink-faint); cursor: pointer; font-size: 13px; }
.wd-media-add:hover { color: var(--wd-accent); border-color: var(--wd-accent); }

.wd-asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 44vh; overflow-y: auto; margin-top: 8px; }
.wd-asset-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid var(--wd-line); border-radius: 8px; background: var(--wd-surface); cursor: pointer; }
.wd-asset-tile:hover { border-color: var(--wd-accent); }
.wd-asset-tile img { width: 100%; height: 60px; object-fit: cover; border-radius: 6px; }
.wd-asset-tile > span:first-child { font-size: 22px; color: var(--wd-accent); }
.wd-asset-tile-label { font-size: 11px; color: var(--wd-ink-faint); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wd-cardrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-items: start; }
.wd-comments { display: none; }
@media (min-width: 760px) {
  .wd-editor .wd-cardrow.has-comments { grid-template-columns: minmax(0, 1fr) 270px; }
  .wd-comments { display: flex; flex-direction: column; gap: 8px; }
}
.wd-cmt {
  background: var(--wd-surface);
  border: 1px solid var(--wd-line);
  border-left: 3px solid var(--wd-accent);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.wd-cmt-reply { margin-inline-start: 16px; border-left-color: var(--wd-line); }
.wd-cmt-resolved { opacity: .6; border-left-color: var(--wd-line); }
.wd-cmt-head { display: flex; align-items: baseline; gap: 8px; }
.wd-cmt-author { font-weight: 700; }
.wd-cmt-when { font-size: 11px; color: var(--wd-ink-faint); margin-inline-start: auto; white-space: nowrap; }
.wd-cmt-quote { font-style: italic; color: var(--wd-ink-faint); font-size: 12px; margin: 3px 0; border-left: 2px solid var(--wd-line); padding-inline-start: 6px; }
.wd-cmt-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.wd-cmt-actions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.wd-cmt-act {
  border: 1px solid var(--wd-line); background: var(--wd-surface-2); color: var(--wd-ink-faint);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.wd-cmt-act:hover { color: var(--wd-ink); border-color: var(--wd-accent); }
.wd-cmt-del { margin-inline-start: auto; }
.wd-cmt-replybox { display: flex; gap: 6px; margin-top: 6px; align-items: flex-end; }
.wd-cmt-ta { flex: 1; border: 1px solid var(--wd-line); border-radius: 8px; padding: 6px 8px; font-size: 13px; font-family: inherit; resize: vertical; background: var(--wd-surface); color: var(--wd-ink); }
.wd-cmt-post { border: 0; background: var(--wd-accent); color: #fff; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; flex-shrink: 0; }
.wd-cmt-resolved-box .wd-cmt-resolved-list { display: none; margin-top: 6px; }
.wd-cmt-resolved-box.open .wd-cmt-resolved-list { display: flex; flex-direction: column; gap: 8px; }

.wd-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 400;
  background: var(--wd-surface, #fff);
  border-top: 1px solid var(--wd-line, #e2e5ea);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 32px rgba(0, 0, 0, .22);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  max-height: 55vh; display: flex; flex-direction: column;
}
@media (min-width: 760px) {
  .wd-panel { left: auto; right: 24px; bottom: 24px; width: 380px; border-radius: 14px; border: 1px solid var(--wd-line, #e2e5ea); }
}
.wd-panel-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--wd-line, #e2e5ea); }
.wd-panel-viewall { border: 0; background: transparent; color: var(--wd-accent, #ff7a1a); font-weight: 700; font-size: 13px; cursor: pointer; padding: 6px 4px; }
.wd-panel-nav { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.wd-panel-navbtn { border: 0; background: transparent; color: var(--wd-ink, #1c2430); cursor: pointer; padding: 6px 8px; font-size: 13px; }
.wd-panel-navbtn:disabled { opacity: .3; cursor: default; }
.wd-panel-pos { font-size: 12px; color: var(--wd-ink-faint, #74808f); white-space: nowrap; }
.wd-panel-x { border: 0; background: transparent; color: var(--wd-ink-faint, #74808f); cursor: pointer; padding: 6px 8px; font-size: 15px; }
.wd-panel-thread { overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.wd-panel-thread .wd-cmt { border: 0; border-left: 3px solid var(--wd-accent, #ff7a1a); background: var(--wd-surface-2, #f4f5f7); }
.wd-panel-thread .wd-cmt-reply { border-left-color: var(--wd-line, #e2e5ea); }
.wd-panel-foot { display: flex; gap: 6px; align-items: flex-end; padding-top: 6px; border-top: 1px solid var(--wd-line, #e2e5ea); }
.wd-panel-resolve { border: 1px solid var(--wd-line, #e2e5ea); background: var(--wd-surface-2, #f4f5f7); color: #2e8b57; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; flex-shrink: 0; }
.wd-panel-list { overflow-y: auto; display: flex; flex-direction: column; padding: 6px 0; }
.wd-panel-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 0; background: transparent; text-align: left; padding: 8px 6px; cursor: pointer; border-bottom: 1px solid var(--wd-line, #e2e5ea); }
.wd-panel-item:hover { background: var(--wd-surface-2, #f4f5f7); }
.wd-panel-item-label { font-size: 11px; font-weight: 700; color: var(--wd-accent, #ff7a1a); text-transform: uppercase; letter-spacing: .04em; }
.wd-panel-item-body { font-size: 13px; color: var(--wd-ink, #1c2430); }

.wd-selpill {
  position: absolute; z-index: 390;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--wd-line, #e2e5ea); background: var(--wd-surface, #fff); color: var(--wd-accent, #ff7a1a);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}

@media (max-width: 480px) {
  .wd-headline { flex-basis: 100%; order: 3; }
  .wd-card-tools { margin-inline-start: auto; }
  .wd-tb-btn { min-width: 38px; height: 38px; padding: 0 8px; }
}

/* --- Review commenting (renderer) --- */
.wd-render { position: relative; }
.wd-ro-ccount.has { cursor: pointer; font-weight: 600; }
.wd-card-hascomments { box-shadow: inset 3px 0 0 var(--wd-accent); }
@keyframes wd-flash { 0% { box-shadow: inset 0 0 0 2px var(--wd-accent); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
.wd-card-flash, .wd-flash { animation: wd-flash 1.2s ease-out; }
.wd-sel-comment {
  position: absolute; z-index: 60; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: #fff; background: var(--wd-accent);
  border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
}

/* --- Document page variant --- */
.wd-render--page { position: relative; }
.wd-sheet {
  background: #ffffff; color: #202733; border-radius: 14px;
  padding: 46px 54px 58px; box-shadow: 0 2px 16px rgba(24,30,40,.16);
}
.wd-sheet-title { font-size: 27px; font-weight: 800; line-height: 1.25; margin: 0 0 22px; color: #141a23; }
.wd-sec { margin: 0 0 24px; scroll-margin-top: 90px; border-radius: 8px; }
.wd-sec-headline { font-size: 18px; font-weight: 800; margin: 26px 0 8px; color: #141a23; }
.wd-sec:first-of-type .wd-sec-headline { margin-top: 0; }
.wd-sec-body { border: 0; padding: 0; background: transparent; min-height: 0; font-size: 15.5px; line-height: 1.75; }
.wd-sec-body p { margin: 0 0 10px; }
.wd-sec-body a { color: var(--wd-accent); }
.wd-sec-source { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #8a94a3; text-decoration: none; margin-top: 4px; }
.wd-sec-source:hover { color: var(--wd-accent); }
.wd-sec .wd-ro-assets { margin-top: 10px; }
.wd-render--page ::selection { background: rgba(255, 153, 0, .35); }
::highlight(wd-anchor) { background-color: rgba(255, 153, 0, .28); }
::highlight(wd-anchor-active) { background-color: rgba(255, 153, 0, .6); }
@media (max-width: 640px) {
  .wd-sheet { padding: 24px 18px 32px; border-radius: 10px; }
  .wd-sheet-title { font-size: 22px; }
}
