/* MDView live editor (public tools + in-app editor) */
.ed { position: relative; display: flex; flex-direction: column; background: var(--elev); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); overflow: hidden; min-height: 560px; height: min(78vh, 900px); }
.ed-bar, .ed-bar2 { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.ed-bar { border-bottom: 1px solid var(--line); background: var(--elev); }
.ed-bar2 { border-bottom: 1px solid var(--line); background: var(--surface); padding: 8px 14px; }
.ed-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 320px; }
.ed-name { font: 600 16px/1.3 var(--font-ui); color: var(--text); border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 6px 8px; min-width: 120px; max-width: 320px; width: 100%; }
.ed-name:hover { border-color: var(--line); } .ed-name:focus { outline: none; border-color: var(--primary); background: var(--bg); box-shadow: 0 0 0 3px var(--primary-100); }
.ed-stats { white-space: nowrap; }
.ed-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ed-actions .btn.on { color: var(--primary); border-color: var(--primary-100); background: var(--primary-50); }
.ed-docs-btn .badge { margin-left: 4px; }
.ed-seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.ed-seg button.on { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .ed-seg button.on { color: #0B1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ed-seg button.on { color: #0B1220; } }
.ed-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.ed-tool { min-width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px; cursor: pointer;
  font: 600 13px/1 var(--font-ui); display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; transition: background .15s var(--ease); }
.ed-tool:hover { background: var(--surface-2); color: var(--text); } .ed-tool:focus-visible { outline: 2px solid var(--primary); }
.ed-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 6px; }
.ed-status { white-space: nowrap; }
.ed-drop { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 14px 0; padding: 14px; border: 1.5px dashed var(--line-2);
  border-radius: 12px; color: var(--muted); font-size: 13px; position: relative; background: var(--surface); }
.ed-drop[hidden] { display: none; }
.ed-drop-x { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.ed-drop-x:hover { background: var(--surface-2); color: var(--text); }
.ed-panes { --split: 50%; flex: 1; min-height: 0; display: grid; grid-template-columns: var(--split) 8px minmax(0, 1fr); margin-top: 10px; border-top: 1px solid var(--line); }
.ed-panes[data-mode="editor"] { grid-template-columns: 1fr; } .ed-panes[data-mode="editor"] .ed-split, .ed-panes[data-mode="editor"] .ed-prev { display: none; }
.ed-panes[data-mode="preview"] { grid-template-columns: 1fr; } .ed-panes[data-mode="preview"] .ed-split, .ed-panes[data-mode="preview"] .ed-src { display: none; }
.ed-src { position: relative; min-width: 0; min-height: 0; }
.ed-ta { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; outline: none; padding: 18px 20px 40vh;
  font: 14px/1.7 var(--font-mono); color: var(--text); background: var(--bg); tab-size: 2; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.ed-panes[data-mode="split"] .ed-src { box-shadow: inset -1px 0 0 var(--line); }
.ed-ta:focus { box-shadow: inset 0 0 0 2px var(--primary-100); }
.ed-mirror { position: absolute; left: 0; top: 0; visibility: hidden; pointer-events: none; overflow: hidden; height: 0; }
.ed-split { cursor: col-resize; background: var(--surface); position: relative; touch-action: none; }
.ed-split::after { content: ""; position: absolute; left: 3px; top: 50%; width: 2px; height: 36px; margin-top: -18px; border-radius: 2px; background: var(--line-2); }
.ed-split:hover::after, .ed-split:focus-visible::after { background: var(--primary); }
.ed-prev { overflow: auto; min-width: 0; min-height: 0; padding: 26px 30px 40vh; background: var(--bg); }
.ed-prev .md-body { max-width: 860px; font-size: 16px; }
.ed-dropmask { display: none; position: absolute; inset: 0; z-index: 5; background: color-mix(in srgb, var(--primary) 12%, transparent); border: 2px dashed var(--primary);
  border-radius: var(--r-lg); align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--primary); font-size: 16px; backdrop-filter: blur(2px); }
.ed.ed-dragging .ed-dropmask { display: flex; }
.ed.ed-full { position: fixed; inset: 0; z-index: 90; border-radius: 0; height: 100vh; border: 0; }
body.ed-noscroll { overflow: hidden; }

/* preview theme override (independent of the site theme) */
.ed-prev.pv-dark { --bg: #0B1220; --surface: #111A2E; --surface-2: #172033; --text: #E2E8F0; --text-2: #CBD5E1; --muted: #94A3B8; --line: #283548;
  --code-bg: #0F172A; --primary: #60A5FA; --accent: #A78BFA; color-scheme: dark; background: var(--bg); color: var(--text); }
.ed-prev.pv-light { --bg: #FFFFFF; --surface: #F8FAFC; --surface-2: #F1F5F9; --text: #0F172A; --text-2: #334155; --muted: #64748B; --line: #E2E8F0;
  --code-bg: #F1F5F9; --primary: #2563EB; --accent: #7C3AED; color-scheme: light; background: var(--bg); color: var(--text); }
.pv-dark .hljs-keyword, .pv-dark .hljs-selector-tag, .pv-dark .hljs-type, .pv-dark .hljs-doctag { color: #ff7b72; }
.pv-dark .hljs-string, .pv-dark .hljs-regexp, .pv-dark .hljs-addition { color: #a5d6ff; }
.pv-dark .hljs-number, .pv-dark .hljs-literal, .pv-dark .hljs-variable, .pv-dark .hljs-attr, .pv-dark .hljs-attribute { color: #79c0ff; }
.pv-dark .hljs-title, .pv-dark .hljs-title.function_, .pv-dark .hljs-section { color: #d2a8ff; }
.pv-dark .hljs-built_in, .pv-dark .hljs-name, .pv-dark .hljs-tag { color: #7ee787; }
.pv-light .hljs-keyword, .pv-light .hljs-selector-tag, .pv-light .hljs-type, .pv-light .hljs-doctag { color: #cf222e; }
.pv-light .hljs-string, .pv-light .hljs-regexp, .pv-light .hljs-addition { color: #0a3069; }
.pv-light .hljs-number, .pv-light .hljs-literal, .pv-light .hljs-variable, .pv-light .hljs-attr, .pv-light .hljs-attribute { color: #0550ae; }
.pv-light .hljs-title, .pv-light .hljs-title.function_, .pv-light .hljs-section { color: #8250df; }
.pv-light .hljs-built_in, .pv-light .hljs-name, .pv-light .hljs-tag { color: #116329; }

/* local documents list (guest, max 20) */
.ed-doclist { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; }
.ed-doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--elev); }
.ed-doc.on { border-color: var(--primary); background: var(--primary-50); }
.ed-doc b { display: block; cursor: pointer; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* public tool pages */
.tool-hero { padding: 40px 0 22px; }
.tool-hero h1 { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.03em; margin: 0 0 10px; }
.tool-hero p { color: var(--muted); max-width: 720px; margin: 0; font-size: 16px; }
.tool-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; }
.tool-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); font-weight: 600; font-size: 14px; background: var(--elev); }
.tool-tabs a.on, .tool-tabs a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 40px 0; }
.tool-cards .card { padding: 22px; }
.tool-cards h3 { margin: 10px 0 6px; font-size: 17px; }
.tool-cards p { margin: 0; color: var(--muted); font-size: 14px; }
.tool-steps { counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0; list-style: none; }
.tool-steps li { counter-increment: s; padding: 18px 18px 18px 58px; position: relative; border: 1px solid var(--line); border-radius: 14px; background: var(--elev); }
.tool-steps li::before { content: counter(s); position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.tool-faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.tool-faq summary { cursor: pointer; font-weight: 600; }
.tool-faq p { color: var(--text-2); margin: 10px 0 0; }
@media (max-width: 767px) {
  .ed { height: 80vh; border-radius: 12px; }
  .ed-tools { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .ed-prev { padding: 18px 16px 40vh; }
  .ed-ta { padding: 14px 14px 40vh; }
  .ed-actions .btn span:not(.badge) { display: none; }
  .ed-actions .btn[data-act="save"] span, .ed-actions .btn[data-act="export"] span:first-of-type { display: inline; }
}

/* PDF export = print only the preview */
@media print {
  body.ed-printing * { visibility: hidden !important; }
  body.ed-printing .ed-article, body.ed-printing .ed-article * { visibility: visible !important; }
  body.ed-printing .ed-article { position: absolute; left: 0; top: 0; width: 100%; max-width: none; margin: 0; }
  body.ed-printing .ed, body.ed-printing .ed-panes, body.ed-printing .ed-prev { overflow: visible !important; height: auto !important; display: block !important; border: 0 !important; box-shadow: none !important; }
  body.ed-printing .code-btn { display: none !important; }
}

/* shared read-only page (/s/{token}) */
.shared-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 26px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--elev); box-shadow: var(--shadow-card); position: sticky; top: calc(var(--header-h) + 8px); z-index: 20; }
.shared-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 36px; }
.shared-cta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 48px; padding: 18px 20px; }
@media (max-width: 900px) { .shared-grid { grid-template-columns: 1fr; } .shared-bar { position: static; } }
@media print {
  body:not(.ed-printing) .site-hdr, body:not(.ed-printing) .site-foot, .shared-bar .btn, .shared-grid aside, .shared-cta, #banners { display: none !important; }
  .shared-bar { position: static; box-shadow: none; border: 0; padding: 0; }
  .shared-grid { display: block; }
}

/* home page editor section */
.home-editor { padding: 72px 0 24px; }
.home-editor .sec-head { text-align: center; max-width: 760px; margin: 0 auto 26px; }
.home-editor .sec-head h2 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -.025em; margin: 0 0 10px; }
.home-editor .sec-head p { color: var(--muted); margin: 0; font-size: 16px; }
.home-editor .pills { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.home-editor .pills span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }