/* ---------- Docs editor ---------- */
.doc-page { display: flex; flex-direction: column; height: 100%; min-height: 0; flex: 1; background: #fff; }
.doc-tb { display: flex; align-items: center; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex: none; height: 52px; }
.doc-tb .btn { height: 32px; }
.doc-tb .tbtn { height: 32px; }
.doc-tb .tbtn .badge { background: var(--primary); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 6px; line-height: 18px; }
.dsep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; flex: none; }
.doc-main { flex: 1; min-height: 0; display: flex; position: relative; }
.doc-scroll { flex: 1; overflow: auto; position: relative; }
.doc-side { width: 0; flex: none; border-left: 1px solid transparent; overflow: auto; background: #fff; transition: width .15s; }
.doc-page.has-side .doc-side { width: 430px; border-left-color: var(--border); }
.dside-h { display: flex; align-items: center; gap: 8px; padding: 20px 16px 12px; position: sticky; top: 0; background: #fff; z-index: 2; }
.dside-h h3 { font-size: 20px; font-weight: 500; }
.dside-b { padding: 0 16px 24px; }

/* cover */
.doc-cover { height: 270px; background-size: cover; background-color: #e7e9ef; position: relative; }
.doc-cover .cover-acts { position: absolute; right: 16px; bottom: 12px; display: none; gap: 6px; }
.doc-cover:hover .cover-acts { display: flex; }
.doc-cover .cover-acts .btn { height: 28px; padding: 2px 10px; font-size: 13px; background: rgba(255,255,255,.95); }

/* wrap + title */
.doc-wrap { max-width: 860px; margin: 0 auto; padding: 48px 72px 120px; position: relative; --dfs: 16px; font-size: var(--dfs); }
.doc-wrap.wide { max-width: 1260px; }
.doc-wrap.font-serif .doc-blocks { font-family: Georgia, 'Times New Roman', serif; }
.doc-wrap.font-mono .doc-blocks { font-family: Menlo, 'SF Mono', monospace; }
.doc-wrap.size-small { --dfs: 14px; } .doc-wrap.size-large { --dfs: 18px; }
.doc-toc-btn { position: absolute; left: -10px; top: 40px; color: var(--text2); }
.doc-toc-btn.on { color: var(--primary); background: var(--selected); }
.doc-title-row { display: flex; align-items: center; gap: 8px; position: relative; padding-top: 18px; }
.doc-title { font-family: var(--title); font-size: 34px; font-weight: 700; line-height: 46px; outline: 0; padding: 0; min-width: 40px; word-break: break-word; }
.doc-title:empty::before { content: 'Untitled'; color: var(--ui-border); }
.doc-star { color: var(--text2); } .doc-star.on { color: #ffcb00; }
.add-cover { position: absolute; top: -10px; left: -4px; visibility: hidden; font-size: 13px; color: var(--text2); }
.doc-title-row:hover .add-cover { visibility: visible; }
.doc-meta { display: flex; align-items: center; gap: 8px 18px; color: var(--text2); font-size: 14px; margin: 10px 0 28px; flex-wrap: wrap; }
.doc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.doc-meta b { font-weight: 600; color: var(--text); }
.doc-meta .av { margin-right: -10px; }

/* toc */
.doc-toc { position: absolute; left: 12px; top: 96px; width: 210px; display: none; z-index: 3; background: #fff; }
.doc-toc.open { display: block; }
.toc-h { font-size: 12px; color: var(--text2); padding: 4px 8px 8px; }
.toc-i { display: block; width: 100%; text-align: left; padding: 4px 8px; border-radius: 4px; font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-i:hover { background: var(--hover); color: var(--text); }
.toc-i.l-h2 { padding-left: 18px; } .toc-i.l-h3 { padding-left: 28px; }
@media (max-width: 1250px) { .doc-toc.open + .doc-side { } .doc-toc { box-shadow: var(--sh-s); border-radius: 8px; padding: 8px; } }

/* blocks */
.doc-blocks { counter-reset: none; }
.dblk { position: relative; padding: 2px 0; border-radius: 4px; }
.dblk.flash { background: var(--highlight); transition: background .3s; }
.dblk.dragging { opacity: .4; }
.dblk.drop-before { box-shadow: 0 -2px 0 var(--primary); } .dblk.drop-after { box-shadow: 0 2px 0 var(--primary); }
.dhandle { position: absolute; left: -54px; top: 3px; display: flex; gap: 2px; align-items: center; opacity: 0; transition: opacity .1s; height: 26px; }
.dblk:hover > .dhandle, .dblk:focus-within > .dhandle { opacity: 1; }
.dh-plus { width: 22px; height: 22px; border-radius: 4px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; }
.dh-plus:hover { background: var(--primary-hover); }
.dh-drag { width: 22px; height: 24px; color: var(--text2); display: flex; align-items: center; justify-content: center; cursor: grab; border-radius: 4px; }
.dh-drag:hover { background: var(--hover); }
.dbody { display: flex; align-items: flex-start; gap: 8px; min-height: 28px; }
.dtext { flex: 1; outline: 0; line-height: 1.6; min-height: 1.6em; word-break: break-word; white-space: pre-wrap; }
.dtext:empty::before, [data-ph]:empty::before { content: attr(data-ph); color: var(--ui-border); pointer-events: none; }
.doc-blocks.is-empty .dblk:first-child .dtext:empty::before { content: "Type '/' to start with a block, '{' to surface board data, or simply start writing"; color: #9699a6; }
.dtext a, .dtog-body a, td a { color: var(--link); }
.dtext code, td code { background: #f6f7fb; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-family: Menlo, monospace; font-size: .88em; color: #d83a52; }
.t-h1 .dtext { font-family: var(--title); font-size: calc(var(--dfs) * 2); font-weight: 600; line-height: 1.3; margin-top: 14px; }
.t-h2 .dtext { font-family: var(--title); font-size: calc(var(--dfs) * 1.5); font-weight: 600; line-height: 1.35; margin-top: 10px; }
.t-h3 .dtext { font-family: var(--title); font-size: calc(var(--dfs) * 1.2); font-weight: 600; line-height: 1.4; margin-top: 6px; }
.t-quote .dbody { border-left: 4px solid var(--text); padding-left: 14px; }
.t-quote .dtext { font-size: calc(var(--dfs) * 1.1); }
.t-code .dbody { background: #f6f7fb; border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; }
.t-code .dtext { font-family: Menlo, 'SF Mono', monospace; font-size: 14px; line-height: 1.55; }
.t-notice .dbody { background: #f0f7ff; border-radius: 6px; padding: 12px 16px; border-left: 4px solid var(--primary); }
.dnotice-ic { color: var(--primary); margin-top: 3px; }
.dbul, .dnum { width: 22px; flex: none; text-align: right; line-height: 1.6; color: var(--text); user-select: none; }
.dbul { font-size: 1.2em; line-height: 1.35; text-align: center; }
.dcheck { width: 18px; height: 18px; border: 1.5px solid var(--ui-border); border-radius: 4px; margin: 4px 2px 0; flex: none; cursor: pointer; display: flex; align-items: center; justify-content: center; background: #fff; }
.dcheck:hover { border-color: var(--primary); }
.dcheck.on { background: var(--primary); border-color: var(--primary); }
.dcheck.on::after { content: ''; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.dtext.done { text-decoration: line-through; color: var(--text2); }
.dtog { width: 22px; height: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); flex: none; transition: transform .1s; }
.dtog.open { transform: rotate(90deg); }
.dtog-body { margin-left: 30px; outline: 0; line-height: 1.6; padding: 2px 0 6px; min-height: 1.6em; white-space: pre-wrap; }
.ddiv { border: 0; border-top: 1px solid var(--border); margin: 12px 0; width: 100%; }
.dbreak { width: 100%; border-top: 2px dashed var(--ui-border); margin: 16px 0; position: relative; text-align: center; }
.dbreak span { position: relative; top: -10px; background: #fff; padding: 0 8px; color: var(--text2); font-size: 12px; }
.dplace { width: 100%; display: flex; align-items: center; gap: 8px; padding: 18px 16px; background: #f6f7fb; border-radius: 6px; color: var(--text2); flex-wrap: wrap; }
.dimg { margin: 6px 0; position: relative; max-width: 100%; }
.dimg img { width: 100%; border-radius: 6px; display: block; }
.dimg figcaption { color: var(--text2); font-size: 14px; text-align: center; padding: 6px; outline: 0; }
.dimg-rz { position: absolute; right: -5px; top: 50%; width: 8px; height: 46px; margin-top: -40px; border-radius: 4px; background: rgba(50,51,56,.55); cursor: ew-resize; opacity: 0; }
.dimg:hover .dimg-rz { opacity: 1; }
.dvid { width: 100%; aspect-ratio: 16 / 9; } .dvid iframe { width: 100%; height: 100%; border: 0; border-radius: 6px; }
.dvideo { width: 100%; border-radius: 6px; background: #000; }
.dfile { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; text-decoration: none; color: var(--text); }
.dfile:hover { background: var(--grey-bg); }
.dfile small { color: var(--text2); }
.dtable-wrap { width: 100%; overflow-x: auto; }
.dtable { border-collapse: collapse; width: 100%; margin: 4px 0; }
.dtable td { border: 1px solid var(--border); padding: 8px 10px; min-width: 90px; vertical-align: top; outline: 0; line-height: 1.5; }
.dtable td:focus { box-shadow: inset 0 0 0 2px var(--primary); }
.dtable tr:first-child td { background: #f6f7fb; }
.dtable-acts { display: none; gap: 4px; padding-top: 4px; }
.dblk:hover .dtable-acts, .dblk:focus-within .dtable-acts { display: flex; }
.dtable-acts .linkbtn { font-size: 13px; }
.dlayout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; }
.dlcol { outline: 0; line-height: 1.6; min-height: 60px; padding: 8px; border: 1px dashed transparent; border-radius: 4px; white-space: pre-wrap; }
.dblk:hover .dlcol { border-color: var(--border); }
.dblk-cmt { position: absolute; right: -52px; top: 4px; display: flex; align-items: center; gap: 3px; color: var(--primary); font-size: 12px; padding: 2px 6px; border-radius: 10px; background: var(--highlight); }
span.dcmt { background: #fff0cc; border-bottom: 2px solid #ffcb00; cursor: pointer; }
.mention { color: var(--primary); background: var(--highlight); border-radius: 4px; padding: 0 3px; white-space: nowrap; }
a.dref { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); background: var(--highlight); border-radius: 4px; padding: 0 5px; text-decoration: none; vertical-align: baseline; }
a.dref .ic { display: inline-block; }

/* board embed + widgets */
.dboard { width: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 4px 0; font-family: var(--font); font-size: 14px; }
.dboard-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fff; }
.dboard-h a { color: var(--text); font-weight: 600; text-decoration: none; }
.dboard-h a:hover { text-decoration: underline; }
.dboard-h select { border: 1px solid var(--ui-border); border-radius: 4px; height: 28px; padding: 0 6px; background: #fff; }
.dboard-g { border-left: 5px solid var(--gc); margin: 10px 12px 12px; border-radius: 4px 0 0 4px; }
.dboard-gt { font-family: var(--title); font-weight: 500; padding: 2px 10px 6px; font-size: 15px; }
.dboard-r { display: grid; grid-template-columns: 1fr 70px 130px 90px; align-items: center; border-top: 1px solid var(--border); border-right: 1px solid var(--border); height: 36px; cursor: pointer; }
.dboard-r:last-child { border-bottom: 1px solid var(--border); }
.dboard-r:hover { background: #f5f6f8; }
.dboard-r .n { padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dboard-r .p { display: flex; justify-content: center; }
.dboard-r .s { height: 100%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; overflow: hidden; white-space: nowrap; }
.dboard-r .d { text-align: center; color: var(--text2); font-size: 13px; }
.dwidget { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; font-family: var(--font); margin: 4px 0; }
.dwidget .dw-t { font-size: 15px; font-weight: 500; margin-bottom: 10px; } .dwidget .dw-t a { color: var(--link); text-decoration: none; }
.dwidget .dw-num { font-size: 48px; font-weight: 300; text-align: center; font-family: var(--title); }
.dwidget .dw-pct { font-size: 28px; font-family: var(--title); margin-bottom: 8px; }
.dw-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--text2); }
.dw-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

/* quick starts + tail */
.doc-quick { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.doc-quick button { display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 14px; border-radius: 4px; color: var(--text); text-align: left; width: 100%; font-size: 16px; }
.doc-quick button:hover { background: var(--hover); }
.doc-quick button .ic { color: var(--text2); }
.doc-tail { height: 120px; cursor: text; }

/* slash menu + floating toolbar */
.dslash { width: 290px; padding: 8px; }
.dslash-list { max-height: 360px; overflow: auto; margin-top: 6px; }
.dslash .menu-head { font-weight: 500; color: var(--text); font-size: 14px; padding: 10px 8px 4px; }
.dslash .menu-item .ic { color: var(--text2); }
.dsc { font-size: 11px; color: var(--text2); background: var(--ui-bg); border-radius: 3px; padding: 1px 5px; font-family: Menlo, monospace; }
.dfloat { position: fixed; z-index: 1100; display: flex; align-items: center; gap: 1px; background: #fff; border-radius: 6px; box-shadow: var(--sh-m); padding: 4px; }
.dfloat button { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.dfloat button:hover { background: var(--hover); }
.dfloat .fcmt { width: auto; padding: 0 8px; gap: 6px; font-size: 14px; }
.dfloat .fcolor { font-weight: 700; text-decoration: underline; text-decoration-color: #df2f4a; text-decoration-thickness: 3px; }
.dfloat .dsep { height: 18px; margin: 0 3px; }

/* comments */
.dc { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.dc.resolved { opacity: .6; }
.dc-q { border-left: 3px solid #ffcb00; padding: 2px 8px; color: var(--text2); font-size: 13px; margin-bottom: 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dc-h b { font-weight: 600; } .dc-h small { color: var(--text2); }
.dc-t { line-height: 1.5; margin: 0 0 8px 34px; white-space: pre-wrap; }
.dc-r { display: flex; gap: 8px; margin: 8px 0 8px 34px; font-size: 14px; line-height: 1.4; }
.dc .input.sm { margin-top: 4px; }

/* style drawer */
.dst-l { font-size: 15px; margin: 18px 0 8px; }
.dst-row { display: flex; border: 1px solid var(--ui-border); border-radius: 4px; overflow: hidden; }
.dst-o { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 4px; border-right: 1px solid var(--ui-border); min-height: 44px; }
.dst-o:last-child { border-right: 0; }
.dst-o:hover { background: var(--hover); }
.dst-o.on { background: var(--selected); box-shadow: inset 0 0 0 1px var(--primary); }
.dst-aa { font-size: 26px; font-weight: 700; line-height: 1; }
.dst-tog { display: flex; align-items: center; gap: 8px; padding: 10px 0; }

/* version history */
.dver { display: grid; grid-template-columns: 260px 1fr; height: 60vh; border-top: 1px solid var(--border); margin: 8px -32px -24px; }
.dver-l { border-right: 1px solid var(--border); overflow: auto; padding: 8px; }
.dver-l button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 10px 12px; border-radius: 4px; text-align: left; }
.dver-l button.on { background: var(--selected); }
.dver-l b { font-weight: 500; } .dver-l small { color: var(--text2); }
.dver-p { overflow: auto; padding: 20px 32px; }
.dver-acts { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.dver-b { line-height: 1.6; padding: 2px 0; }
.dver-b.t-h1 { font-size: 26px; font-weight: 600; } .dver-b.t-h2 { font-size: 21px; font-weight: 600; } .dver-b.t-h3 { font-size: 18px; font-weight: 600; }

/* present */
.dpresent { position: fixed; inset: 0; background: #fff; z-index: 5000; overflow: auto; }
.dpresent .dp-x { position: fixed; top: 16px; right: 16px; z-index: 2; }
.dpresent .dp-in { max-width: 980px; padding-top: 80px; }
.dpresent .doc-title { font-size: 44px; line-height: 56px; margin-bottom: 30px; }

/* embedded in a board view */
.doc-page.embedded { border-top: 1px solid var(--border); }
.doc-page.embedded .doc-wrap { padding-top: 24px; }

/* print */
@media print {
  body * { visibility: hidden; }
  .doc-page.printing, .doc-page.printing * { visibility: visible; }
  .doc-page.printing { position: absolute; inset: 0; }
  .doc-page.printing .doc-tb, .doc-page.printing .dhandle, .doc-page.printing .doc-side, .doc-page.printing .doc-toc, .doc-page.printing .doc-toc-btn, .doc-page.printing .dtable-acts, .doc-page.printing .doc-quick { display: none !important; }
  .dbreak { break-after: page; border: 0; } .dbreak span { display: none; }
  .doc-scroll { overflow: visible !important; }
}

/* ---------- Docs hub ---------- */
.dhub-tpl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.dhub-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; border: 1px solid var(--border); border-radius: 8px; padding: 16px; background: #fff; transition: box-shadow .15s; }
.dhub-card:hover { box-shadow: var(--sh-s); border-color: transparent; }
.dhub-card b { font-weight: 500; font-size: 15px; }
.dhub-card small { color: var(--text2); line-height: 1.35; }
.dhub-card-ic { width: 36px; height: 36px; border-radius: 6px; background: #fdeaec; color: #e2445c; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.dhub-bar { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dhub-tbl td { height: 56px; }
.dhub-n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dhub-p { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
