/* path: feature_flow/static/style.css — light "paper" theme (designed-to-scale vibe) */
:root {
  /* THEME "Thanh Trà Trong Gió" — 6 mã gốc, mỗi mã một vai trò */
  --cream: #dcdbc6; --bg: #6c8373; --sage: #4d6b51; --forest: #2a4323; --olive: #5c7136; --lime: #acb24f;
  --paper: #dee2d1; --paper2: #c2c8b0; --card: #dcdbc6; --card2: #eceddd;
  --ink: #2a4323; --ink-soft: #4d6b51; --line: #9fb089; --line-ink: #2a3b22;
  --green: #c9d29a; --green-d: #5c7136; --green-ink: #2a4323;
  --amber: #acb24f; --amber-ink: #565a1f; --red: #dcb0a6; --red-ink: #8a3a2a;
  --blue: #a6c0cf; --purple: #bdb6cf;
  --sans: "Nunito", system-ui, sans-serif; --mono: "Space Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
/* tree: kéo-thả + mục ẩn */
.flow-list li.is-hidden { opacity: .45; }
.flow-list li.dragging { opacity: .4; }
.flow-list li.folder.drop, .flow-list.drop { outline: 2px dashed var(--green-d); outline-offset: -2px;
  border-radius: 9px; background: rgba(141, 191, 104, .14); }
/* thanh cuộn hợp tông giấy */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px;
  border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 14px; }
b { font-weight: 800; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); } .sm { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 5px 14px; height: 44px;
  background: var(--paper); border-bottom: 2px solid var(--line); }
.topbar .btn, .topbar .switch { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; box-shadow: 1px 1px 0 rgba(43,40,36,.12); }
.brand { font-size: 15px; font-weight: 700; cursor: pointer; user-select: none; } .brand b { color: var(--green-d); }
.brand:hover { opacity: .8; }
/* trang HƯỚNG DẪN riêng */
.guide-only { display: none !important; }
body.guide-mode #btnGuideBack { display: block !important; }
body.guide-mode .side-head .guide-only { display: inline !important; }
body.guide-mode .only-normal { display: none; }
body.guide-mode #btnNewFlow, body.guide-mode #btnExportMd, body.guide-mode #btnImportMd,
body.guide-mode #btnGuide, body.guide-mode #mdFile, body.guide-mode .side-sep { display: none; }
.brand .logo { color: var(--green-d); }
.tabs .tab { font-weight: 700; border: 2px solid var(--line); background: var(--card2);
  padding: 7px 14px; border-radius: 10px; cursor: pointer; }
.tabs .tab.active { background: var(--green); border-color: var(--green-d); color: var(--green-ink); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600;
  border: 2px solid var(--line); background: var(--card2); padding: 6px 12px; border-radius: 10px; }

.btn { font-family: var(--sans); font-weight: 700; border: 2px solid var(--line-ink);
  background: var(--card2); color: var(--ink); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; box-shadow: 2px 2px 0 rgba(43,40,36,.12); }
.btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(43,40,36,.15); }
.btn:active { transform: translate(1px,1px); box-shadow: none; }
.btn.solid { background: var(--green); border-color: var(--green-d); color: var(--green-ink); }
.btn.ghost { border-color: var(--line); box-shadow: none; }
.btn.danger { background: var(--red); border-color: var(--red-ink); color: var(--red-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.full { width: 100%; } .btn.sm { padding: 5px 10px; font-size: 12px; }
.pill { font: 700 11px var(--mono); background: var(--paper2); color: var(--ink);
  border-radius: 20px; padding: 2px 8px; }

/* ---------- app grid ---------- */
.app { display: grid; grid-template-columns: 218px 1fr 290px; height: calc(100% - 44px - 28px); }
.footer { height: 28px; display: flex; align-items: center; gap: 14px; padding: 0 18px;
  font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); background: var(--paper); }
.footer .f-brand { font-weight: 700; color: var(--ink); }
.footer .f-mid { flex: 1; text-align: center; }
.footer .f-right { opacity: .8; }
@media (max-width: 1100px) { .footer .f-mid { display: none; } }

/* sidebar */
.sidebar { background: transparent; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 3px; overflow: auto; font-size: 11.5px; }
.side-head { font-weight: 800; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sidebar .btn { padding: 6px 10px; font-size: 11.5px; }
.fl-add { opacity: 0; border: none; background: transparent; box-shadow: none; cursor: pointer;
  color: var(--green-d); font-size: 15px; font-weight: 800; line-height: 1; padding: 0 5px; flex: none; }
.flow-list li.folder:hover .fl-add { opacity: 1; }
.fl-add:hover { color: var(--green-ink); transform: none; box-shadow: none; }
.flow-list { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.flow-list li { padding: 6px 9px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
  font-weight: 600; display: flex; align-items: center; gap: 6px; }
.flow-list li:hover { background: var(--paper2); }
.fl-name { flex: 1; min-width: 0; }
.flow-list li.folder { font-weight: 800; background: transparent; margin-top: 3px; gap: 6px; padding: 7px 8px; }
.flow-list li.folder:hover { background: var(--paper2); }
.flow-list li.folder .caret { display: block; box-sizing: border-box; width: 8px; height: 8px; flex: none; margin: 0 3px 0 2px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(-45deg); transition: transform .15s; }
.flow-list li.folder .caret.open { transform: rotate(45deg); }
.flow-list li.folder .pill { background: var(--line); color: var(--ink-soft); }
.folder-ico { width: 15px; height: 11px; border-radius: 2px 2px 3px 3px; flex: none; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); filter: saturate(.62) brightness(.99); }
.folder-ico::before { content: ""; position: absolute; top: -3px; left: 0; width: 6px; height: 3px;
  border-radius: 2px 2px 0 0; background: inherit; }
/* nhánh con + đường nối cây */
.flow-list li.branch { padding: 0; background: none !important; cursor: default; display: block; border: none; }
.subtree { list-style: none; margin: 2px 0 2px 16px; padding: 0;
  display: flex; flex-direction: column; gap: 3px; }
.subtree > li { position: relative; margin-left: 12px; }
/* đường dọc: mỗi mục vẽ 1 đoạn → nối liền; mục CUỐI chỉ tới chỗ nối rồi dừng */
.subtree > li::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.subtree > li:last-child::before { bottom: auto; height: 16px; }
/* gạch ngang nối vào mục */
.subtree > li::after { content: ""; position: absolute; left: -12px; top: 16px; width: 10px; height: 2px; background: var(--line); }
.subtree > li.active::after { background: var(--green-d); }
.fl-del { opacity: 0; border: none; background: transparent; box-shadow: none; cursor: pointer;
  color: var(--ink-soft); font-size: 13px; padding: 2px 5px; border-radius: 6px; flex: none; }
.flow-list li:hover .fl-del { opacity: 1; }
.fl-del:hover { color: var(--red-ink); background: var(--red); transform: none; box-shadow: none; }
.flow-list li.active { background: var(--green); border-color: var(--green-d); color: var(--green-ink); }
.side-sep { height: 2px; background: var(--line); margin: 8px 0; border-radius: 2px; }

/* center */
.center { display: flex; flex-direction: column; min-width: 0; padding: 12px 18px 14px; gap: 8px; overflow: auto;
  margin: 12px 6px; border: 2px solid var(--line); border-radius: 20px; background: var(--card); }
.lesson-head h1 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.2; }
.lesson-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.lh-left { min-width: 0; }
.chips { display: flex; gap: 6px; margin: 2px 0 0; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; max-width: 46%; }
@media (max-width: 1100px) { .lesson-head { flex-direction: column; gap: 4px; } .chips { justify-content: flex-start; max-width: none; margin-top: 5px; } }
.chip { font: 700 11px var(--mono); border: 2px solid var(--line); background: var(--card2);
  padding: 3px 9px; border-radius: 20px; display: inline-flex; gap: 5px; }
.chip.amber { background: var(--amber); border-color: var(--line); color: var(--amber-ink); }
.chip.green { background: var(--green); border-color: var(--green-d); color: var(--green-ink); }
.chip.purple { background: var(--paper2); border-color: var(--line); color: var(--ink); }

.canvas-wrap.maximized { position: fixed; inset: 0; z-index: 60; border-radius: 0; min-height: 0; }
.canvas-wrap { position: relative; flex: 1; min-height: 420px; border: 2px solid var(--line);
  border-radius: 18px; overflow: hidden; background:   /* lưới chấm nhạt theo sắc độ (thay lưới chéo rối mắt) */
    radial-gradient(color-mix(in srgb, var(--line) 70%, transparent) 1.1px, transparent 1.6px) 0 0 / 24px 24px, var(--paper); }
#cy { position: absolute; inset: 0; border-radius: 20px; overflow: hidden; }
.group-rubber { position: absolute; z-index: 7; pointer-events: none; border: 2px dashed #8a6fd0;
  background: rgba(138, 111, 208, 0.12); border-radius: 10px; }
.node-note-box { position: absolute; z-index: 9; display: flex; align-items: center; gap: 4px;
  background: var(--card2); border: 2px solid var(--line-ink); border-radius: 10px; padding: 4px 5px;
  box-shadow: 2px 2px 0 rgba(43, 40, 36, .15); }
.node-note-box input { width: 180px; border: none; outline: none; background: transparent;
  font-family: var(--sans); font-size: 13px; color: var(--ink); padding: 2px 4px; }
.node-note-box button { border: none; cursor: pointer; width: 24px; height: 24px; border-radius: 7px; font-weight: 800; font-size: 13px; line-height: 1; }
.node-note-box .nn-ok { background: var(--green); color: var(--green-ink); }
.node-note-box .nn-cancel { background: var(--red); color: var(--red-ink); }
.canvas-tools { position: absolute; top: 12px; right: 12px; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 70%; }
.chip-btn { background: var(--card2); }
.chip-btn.icon { padding: 6px 10px; font-weight: 800; }
/* cụm nút canvas: nhỏ gọn */
.canvas-tools .btn { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; box-shadow: 1px 1px 0 rgba(43,40,36,.12); }
.canvas-tools .chip-btn.icon { padding: 2px 7px; font-size: 12px; }
#btnDraw.on { background: var(--green); border-color: var(--green-d); color: var(--green-ink); }
/* edgehandles */
.eh-handle { background-color: #8dbf68 !important; border: 2px solid #2b2824; }
.eh-ghost-edge, .eh-preview { background-color: #8dbf68; line-color: #8dbf68; target-arrow-color: #8dbf68; }
/* thẻ mô tả nổi khi bấm khối (dùng được cả khi phóng to toàn màn) */
.node-pop { position: absolute; right: 16px; bottom: 16px; z-index: 8; width: min(400px, 44%);
  max-height: 60%; overflow: auto; background: var(--card2); border: 2px solid var(--line-ink);
  border-radius: 14px; padding: 14px 16px; box-shadow: 4px 4px 0 rgba(43,40,36,.18);
  animation: fadeUp .3s cubic-bezier(.22,.61,.36,1); }
.pop-close { position: absolute; top: 8px; right: 10px; border: none; background: transparent;
  font-size: 16px; cursor: pointer; color: var(--ink-soft); box-shadow: none; padding: 2px 6px; }
.pop-badge { font: 700 10px var(--mono); letter-spacing: .5px; color: var(--green-ink);
  background: var(--green); border: 1.5px solid var(--green-d); border-radius: 6px;
  padding: 1px 7px; display: inline-block; }
.pop-title { font-size: 17px; font-weight: 800; margin: 8px 0 6px; }
.pop-body { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: #3a362e; white-space: pre-wrap; }

.legend { position: absolute; left: 12px; bottom: 12px; z-index: 5; display: flex; gap: 14px;
  background: var(--card2); border: 2px solid var(--line); border-radius: 20px; padding: 5px 12px;
  font: 700 12px var(--mono); }
.legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px;
  border: 1.5px solid var(--line-ink); vertical-align: -1px; }
.sw.start { background: var(--green); } .sw.process { background: var(--card2); } .sw.decision { background: var(--amber); }   /* khớp màu khối trên canvas (01-core FILL) */

/* bottom tracker — nhỏ nhắn, thanh mảnh */
.tracker { border: 2px solid var(--line); border-radius: 14px; background: var(--card); padding: 7px 14px 8px; }
.tracker-head { font: 700 10px var(--mono); letter-spacing: 1px; color: var(--ink-soft); margin-bottom: 4px;
  display: flex; justify-content: space-between; }
.tracker-steps { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 2px 2px; }
.tstep { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  min-width: 56px; position: relative; }
.tstep .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cbc2ab;
  background: var(--card2); color: var(--ink-soft); display: grid; place-items: center;
  font: 700 11px var(--mono); position: relative; z-index: 1; transition: all .2s; }
.tstep .tlabel { font: 600 10px var(--sans); text-align: center; color: var(--ink-soft); max-width: 76px; line-height: 1.2; }
.tstep.done .dot { border-color: var(--green-d); color: var(--green-d); background: var(--tint); }
.tstep.active .dot { background: var(--green); border-color: var(--green-d); color: var(--green-ink);
  box-shadow: 0 0 0 4px rgba(141,191,104,.28); }
.tstep.active .tlabel { color: var(--ink); font-weight: 800; }
.tstep.picked .dot { background: #4f8cff; border-color: #2b2824; color: #fff; box-shadow: 0 0 0 4px rgba(79,140,255,.3); }
.tstep.picked .tlabel { color: var(--ink); font-weight: 800; }
.tstep:not(:last-child)::after { content: ""; position: absolute; top: 11px; left: 50%; width: 100%;
  height: 2px; background: var(--line); z-index: 0; }
.tstep.done:not(:last-child)::after { background: var(--green-d); opacity: .5; }

/* right panel */
.right { background: transparent; padding: 12px 12px; overflow: auto; font-size: 12.5px; }
/* panel phải = nền, bên trong là các THẺ rời (bước · bạn sẽ học) */
.r-card { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }

/* ----- tài liệu / blog (kind=doc) ----- */
#doc-wrap { flex: 1; display: flex; min-height: 0; }
.doc-view { flex: 1; overflow: auto; background: var(--paper); border: 2px solid var(--line); border-radius: 18px;
  padding: 24px 30px; line-height: 1.75; color: var(--ink); font-size: 15px; }
.doc-view > :first-child { margin-top: 0; }
.doc-view h1 { font-size: 26px; font-weight: 800; margin: .3em 0 .5em; }
.doc-view h2 { font-size: 20px; font-weight: 800; margin: 1.3em 0 .4em; }
.doc-view h3 { font-size: 16px; font-weight: 800; margin: 1.1em 0 .3em; }
.doc-view p { margin: .7em 0; }
.doc-view code { font-family: var(--mono); font-size: .9em; background: var(--paper2); padding: 1px 6px; border-radius: 5px; }
.doc-view pre { background: #2c2822; color: #e6e9ef; padding: 12px 14px; border-radius: 10px; overflow: auto; }
.doc-view pre code { background: none; color: inherit; padding: 0; }
.doc-view ul, .doc-view ol { padding-left: 1.4em; margin: .6em 0; }
.doc-view li { margin: .3em 0; }
.doc-view blockquote { border-left: 3px solid var(--green-d); padding: 2px 12px; color: var(--ink-soft); margin: .8em 0; background: var(--tint); border-radius: 0 8px 8px 0; }
.doc-view a { color: var(--green-d); }
.doc-view img { max-width: 100%; border-radius: 8px; }
.doc-view hr { border: none; border-top: 2px solid var(--line); margin: 1.2em 0; }
.doc-view table { border-collapse: collapse; margin: .8em auto; } .doc-view th, .doc-view td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
.doc-view th { background: var(--paper2); font-weight: 800; }
.doc-view caption, .doc-rich caption { caption-side: bottom; text-align: center; font-style: italic; font-weight: 600; font-size: 1em; padding: 8px 0 2px; color: var(--ink-soft); }
.doc-edit { flex: 1; width: 100%; min-height: 60vh; font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  border: 2px solid var(--line); border-radius: 18px; padding: 18px 20px; background: var(--paper); color: var(--ink); resize: none; }
/* trình soạn kiểu Word (contenteditable → markdown) */
.doc-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.doc-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 7px 9px;
  background: var(--card); border: 2px solid var(--line); border-bottom: none; border-radius: 14px 14px 0 0; }
.doc-toolbar button { font-family: var(--sans); font-size: 13px; font-weight: 700; color: var(--ink);
  background: #fbf7f1; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; cursor: pointer; line-height: 1; }
.doc-toolbar button:hover { background: var(--green); border-color: var(--green-d); }
.doc-toolbar .tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.doc-rich { flex: 1; overflow: auto; min-height: 55vh; background: var(--paper); color: var(--ink);
  border: 2px solid var(--line); border-radius: 0 0 18px 18px; padding: 18px 22px; outline: none; line-height: 1.6; }
.doc-rich:focus { border-color: var(--ink-soft); }
.doc-rich > :first-child { margin-top: 0; }
.doc-rich h1 { font-size: 26px; font-weight: 800; margin: .3em 0 .5em; }
.doc-rich h2 { font-size: 20px; font-weight: 800; margin: 1.3em 0 .4em; }
.doc-rich h3 { font-size: 16px; font-weight: 800; margin: 1.1em 0 .3em; }
.doc-rich p { margin: .7em 0; }
.doc-rich ul, .doc-rich ol { padding-left: 1.4em; margin: .6em 0; }
.doc-rich code { font-family: var(--mono); font-size: .9em; background: var(--paper2); padding: 1px 6px; border-radius: 5px; }
.doc-rich pre { background: #2c2822; color: #e6e9ef; font-family: var(--mono); font-size: 13px; line-height: 1.5;
  padding: 10px 14px; border-radius: 10px; overflow: auto; margin: .7em 0; min-height: 1.2em; white-space: pre-wrap; }
.doc-rich pre code { background: none; color: inherit; padding: 0; }
.doc-rich blockquote { border-left: 3px solid var(--green-d); padding: 2px 12px; color: var(--ink-soft); margin: .8em 0; background: var(--tint); border-radius: 0 8px 8px 0; }
.doc-rich a { color: var(--green-d); }
.doc-rich table { border-collapse: collapse; margin: .8em auto; }
.doc-rich th, .doc-rich td { border: 1px solid var(--line); padding: 6px 10px; min-width: 60px; text-align: center; }
.doc-rich th { background: var(--paper2); font-weight: 800; }
.doc-rich th:empty::before { content: "tiêu đề"; color: #b7ab8e; font-weight: 600; }
.doc-rich td:empty::after { content: "\00a0"; color: transparent; }   /* ô rỗng có chiều cao + bôi đen thấy được */
.doc-rich ::selection { background: var(--tint2); }
.doc-rich td::selection, .doc-rich th::selection { background: var(--tint2); }
.doc-rich td.cell-sel, .doc-rich th.cell-sel { background: var(--tint2); }   /* bôi nhiều ô/hàng/cột → tô xanh cả ô */
/* mục lục tài liệu (TOC) bên phải */
.doc-toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.doc-toc li { cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.doc-toc li:hover { background: var(--paper2); color: var(--ink); }
.doc-toc li.on { color: var(--green-ink); font-weight: 700; background: var(--tint); }
.doc-toc li.toc-h2 { padding-left: 18px; font-size: 12px; }
.doc-toc li.toc-h3 { padding-left: 30px; font-size: 11.5px; }
.step-top { display: flex; align-items: center; justify-content: space-between; }
.step-top .muted { font: 700 12px var(--mono); letter-spacing: .5px; }
.badge { font: 700 11px var(--mono); background: var(--red); color: var(--red-ink);
  border: 2px solid var(--red-ink); border-radius: 8px; padding: 2px 8px; }
#stepTitle { font-size: 18px; font-weight: 800; margin: 7px 0 10px; }
.prose { font-family: var(--mono); font-size: 12px; line-height: 1.65; white-space: pre-wrap; color: #3a362e; }
.callout { margin-top: 14px; border: 2px solid var(--green-d); background: var(--tint); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; }
.callout.warn { border-color: #d8b878; background: #fbf1dd; }
.nav { display: flex; gap: 8px; margin-top: 16px; }
.nav .btn { flex: 1; }
.kbd-hint { margin-top: 12px; color: var(--ink-soft); font-size: 11px; }
kbd { font: 700 11px var(--mono); border: 1.5px solid var(--line); border-bottom-width: 3px;
  border-radius: 5px; padding: 0 5px; background: var(--card2); margin: 0 1px; }
.learn { margin: 0; }
.learn-head { font: 700 12px var(--mono); color: var(--ink-soft); margin-bottom: 8px; }
.note-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.note-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.4;
  padding: 5px 6px; border-radius: 8px; }
.note-item:hover { background: var(--paper2); }
.note-box { color: var(--green-d); font-weight: 800; cursor: pointer; flex: none; user-select: none; }
.note-text { flex: 1; min-width: 0; outline: none; }
.note-text:empty::before { content: "ghi chú…"; color: #b7ab8e; }
.note-item.done .note-text { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--line); }
.note-del { flex: none; color: var(--ink-soft); cursor: pointer; opacity: 0; font-size: 12px; }
.note-item:hover .note-del { opacity: .7; }
.note-del:hover { opacity: 1; color: var(--red-ink); }
.note-add { width: 100%; }
.note-group { font: 700 11px var(--mono); color: var(--ink-soft); margin: 10px 0 2px; padding: 0 6px; }
.note-filter { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font: 700 12px var(--mono); color: var(--ink); background: var(--paper2); border-radius: 8px; padding: 5px 8px; margin-bottom: 4px; }
.note-filter .nf-clear { cursor: pointer; color: var(--ink-soft); font-weight: 600; font-size: 11px; }
.note-filter .nf-clear:hover { color: var(--red-ink); }
.note-empty { font-size: 12px; color: var(--ink-soft); padding: 4px 6px; }
.pop-notes { margin-top: 10px; }
.pop-notes-head { font: 700 11px var(--mono); color: var(--ink-soft); margin-bottom: 5px; }
.pop-note { font-size: 13px; line-height: 1.5; padding: 1px 0; }
.pop-note.done { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--line); }
.learn ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
/* edit panel */
.edit-section { border: 2px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--card2); }
.edit-title { font-weight: 800; margin-bottom: 8px; }
.edit-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.fld { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-bottom: 8px; }
.color-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.color-row input[type="color"] { width: 36px; height: 28px; border: 2px solid var(--line); border-radius: 7px; padding: 0; background: none; cursor: pointer; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-ink); cursor: pointer; padding: 0; box-shadow: none; }
.swatch:hover { transform: scale(1.18); }
.fld input, .fld textarea { width: 100%; margin-top: 3px; font-family: var(--mono); font-size: 13px;
  border: 2px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; color: var(--ink);
  resize: vertical; }

/* hiệu ứng panel đổi bước */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#panel-read.fade { animation: fadeUp .38s cubic-bezier(.22,.61,.36,1); }
.btn.solid.on { background: var(--red); border-color: var(--red-ink); color: var(--red-ink); }

/* context menu (chuột phải) */
.ctxmenu { position: fixed; z-index: 120; min-width: 180px; background: var(--card2);
  border: 2px solid var(--line-ink); border-radius: 10px; padding: 5px; box-shadow: 4px 4px 0 rgba(43,40,36,.18);
  animation: fadeUp .12s ease; }
.ctxmenu .ci { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px;
  cursor: pointer; font-weight: 600; font-size: 13px; }
.ctxmenu .ci .ci-ic { display: inline-block; width: 22px; text-align: center; flex: none; }
.ctxmenu .ci:hover { background: var(--green); color: var(--green-ink); }
.ctxmenu .ci.danger:hover { background: var(--red); color: var(--red-ink); }
.ctxmenu .sep { height: 2px; background: var(--line); margin: 4px 6px; border-radius: 2px; }

/* modal confirm/prompt */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(44,40,34,.38); animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: min(420px, 90vw); background: var(--card2); border: 2px solid var(--line-ink);
  border-radius: 16px; padding: 20px; box-shadow: 6px 6px 0 rgba(43,40,36,.2);
  animation: fadeUp .25s cubic-bezier(.22,.61,.36,1); }
.modal-msg { font-size: 15px; font-weight: 700; line-height: 1.5; margin-bottom: 14px; }
.modal-input { width: 100%; font-family: var(--mono); font-size: 14px; border: 2px solid var(--line-ink);
  border-radius: 9px; padding: 9px 11px; background: #fff; color: var(--ink); margin-bottom: 14px; }
.modal-fields { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.modal-fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.modal-fld input { font-family: var(--sans); font-size: 14px; font-weight: 400; color: var(--ink);
  border: 2px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; }
.modal-fld input:focus { border-color: var(--ink-soft); outline: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--green); border: 2px solid var(--green-d); color: var(--green-ink);
  font-weight: 700; padding: 9px 16px; border-radius: 10px; box-shadow: 3px 3px 0 rgba(43,40,36,.15); }
.toast.err { background: var(--red); border-color: var(--red-ink); color: var(--red-ink); }

@media (max-width: 1100px) {
  html, body { height: auto !important; min-height: 100%; overflow: visible; }
  body { overflow-y: visible !important; }   /* thắng rule body{overflow-y:hidden} do extension chèn inline */
  .app { display: block; height: auto; }                 /* bỏ grid viewport → block flow cuộn được */
  .sidebar, .center, .right { display: block; height: auto; max-height: none; overflow: visible; margin: 8px; }
  .canvas-wrap { height: 460px; min-height: 0; flex: none; }
  #cy { touch-action: pan-y; }                            /* vuốt dọc = cuộn trang, canvas không nuốt */
}

/* ===== THEME "Thanh Trà Trong Gió" (gộp 1 block, thay mọi đoạn vá trước) ===== */
:root{
  --cream:#dcdbc6; --bg:#6c8373; --sage:#4d6b51;
  --forest:#2a4323; --olive:#5c7136; --lime:#acb24f;
  --paper:#dee2d1;  --paper2:#d2d7c3;
  --card:#eceee0;   --card2:#f5f6ed;
  --ink:#203318;      --ink-soft:#3d5a41;
  --green-ink:#223a1b; --green-d:#4f6330; --green:#c3cf96;
  --line:#a9b88f;     --line-ink:#2a3b22;
  --amber:#acb24f;    --amber-ink:#2e3309;
  --chrome:#2a4323;   --chrome-ink:#e7ead9;     /* header/footer/sidebar */
  --tint:#eef6e4;     --tint2:#cfe3b8;          /* tô nhạt: callout, mục lục, bôi chọn */
}

/* ===== 7 SẮC ĐỘ KHÁC — chọn ở ô chọn trên header (lưu theo trình duyệt) =====
   Mã gốc mỗi bộ ghi ở comment; mã khác = pha đậm/nhạt từ mã gốc để chữ đủ tương phản (≥4.5:1).
   --chrome = header/footer/sidebar · --lime = màu nhấn trên nền tối · --green = nền dòng đang chọn. */
[data-theme="net-co-dong-duong"]{ /* NÉT CỔ ĐÔNG DƯƠNG (nâu sepia hoài cổ) — bảng cân màu */
  --chrome:#3B251A; --chrome-ink:#F9EAE1; --lime:#cdab90;
  --paper:#F7E5DB; --paper2:#F7DECF; --card:#F9EDE7; --card2:#FBF6F3;
  --ink:#452C1F; --ink-soft:#7D6050; --line:#F6D8C8; --line-ink:#3E281C;
  --green:#FCE4D7; --green-d:#7C675B; --green-ink:#452C1F;
  --amber:#FAD5C1; --amber-ink:#6D5A50; --tint:#fbeee5; --tint2:#f3d6c4; }
[data-theme="hoang-hon-mua-thu"]{ /* HOÀNG HÔN MÙA THU (cam ấm hoàng hôn) — bảng cân màu */
  --chrome:#351C16; --chrome-ink:#F6EADC; --lime:#faa608;
  --paper:#F2E5D6; --paper2:#F2DEC8; --card:#F6EDE3; --card2:#F9F5F1;
  --ink:#3E211A; --ink-soft:#805014; --line:#EFBD62; --line-ink:#381E17;
  --green:#FCCE77; --green-d:#905F05; --green-ink:#3E211A;
  --amber:#FBB32D; --amber-ink:#6A4703; --tint:#fcefe0; --tint2:#f5d5b3; }
[data-theme="phim-co-dien"]{ /* PHIM CỔ ĐIỂN (taupe/xám trầm, điểm tím nhạt) — bảng cân màu */
  --chrome:#474336; --chrome-ink:#F2EDE7; --lime:#d9d5e1;
  --paper:#EFE9E2; --paper2:#EBE3D9; --card:#F3F0EB; --card2:#F9F7F5;
  --ink:#4D493B; --ink-soft:#6B6659; --line:#E8DFD3; --line-ink:#454235;
  --green:#F1EAE0; --green-d:#6D675F; --green-ink:#4D493B;
  --amber:#E9DECF; --amber-ink:#645E57; --tint:#f1ece3; --tint2:#ddd3c2; }
[data-theme="cuoi-he-dau-thu"]{ /* CUỐI HÈ ĐẦU THU (xanh lá + mustard) — bảng cân màu */
  --chrome:#3C5214; --chrome-ink:#F5F3E0; --lime:#b7d553;
  --paper:#F2EFDA; --paper2:#F0ECCE; --card:#F5F4E6; --card2:#F9F9F2;
  --ink:#3E5414; --ink-soft:#656714; --line:#C4AF68; --line-ink:#384C12;
  --green:#D2BE7E; --green-d:#876A10; --green-ink:#3E5414;
  --amber:#BA9B37; --amber-ink:#3F3207; --tint:#f6f3dc; --tint2:#e5eab0; }
[data-theme="xanh-co-dien"]{ /* XANH CỔ ĐIỂN (xanh lam classic) — bảng cân màu */
  --chrome:#2F5574; --chrome-ink:#FDFDFD; --lime:#9abad3;
  --paper:#FDFDFD; --paper2:#FCFCFC; --card:#FDFDFD; --card2:#FEFEFE;
  --ink:#305877; --ink-soft:#4A7698; --line:#B1CDE2; --line-ink:#2B4F6B;
  --green:#B6D2E8; --green-d:#527590; --green-ink:#305877;
  --amber:#8EBADB; --amber-ink:#324858; --tint:#eaf2f9; --tint2:#c4daec; }
[data-theme="dao-pho-ngay-nang"]{ /* DẠO PHỐ NGÀY NẮNG (tan/olive/taupe) — bảng cân màu */
  --chrome:#413B2C; --chrome-ink:#DAD4C8; --lime:#d9a77a;
  --paper:#D1CABC; --paper2:#C6BCA8; --card:#DFDAD1; --card2:#EEEBE7;
  --ink:#3B3528; --ink-soft:#624C35; --line:#B7987D; --line-ink:#353024;
  --green:#D1B49D; --green-d:#7C5638; --green-ink:#3B3528;
  --amber:#B88B68; --amber-ink:#3A281A; --tint:#f4ece2; --tint2:#e3cfb7; }
[data-theme="pho-phap"]{ /* PHONG CÁCH ĐƯỜNG PHỐ PHÁP (caramel/nâu ấm) — bảng cân màu */
  --chrome:#62350F; --chrome-ink:#F9EBDC; --lime:#e9a462;
  --paper:#F7E7D5; --paper2:#F7E0C6; --card:#F8EEE3; --card2:#FBF6F1;
  --ink:#703C12; --ink-soft:#845D3A; --line:#F6DBBD; --line-ink:#653610;
  --green:#FCE7CF; --green-d:#776450; --green-ink:#703C12;
  --amber:#FBDAB5; --amber-ink:#6D5C4A; --tint:#fcf0e2; --tint2:#f6d6b2; }

[data-theme="fincon"]{ /* Fincon — 2 màu logo: navy 122C4E + xanh trời 25ADE0 */
  --chrome:#122c4e; --chrome-ink:#eaf4fb; --lime:#25ade0;
  --paper:#eef4f9; --paper2:#dde9f2; --card:#f6f9fc; --card2:#fbfdfe;
  --ink:#122c4e; --ink-soft:#3d5a7a; --line:#b9d3e6; --line-ink:#122c4e;
  --green:#cbe8f6; --green-d:#1a6f99; --green-ink:#122c4e;
  --amber:#9fd8f0; --amber-ink:#0d2340; --tint:#e7f4fb; --tint2:#bfe4f5; }

/* nút chọn sắc độ trên header */
.theme-pick { font: 600 12.5px var(--sans); color: var(--ink); background: var(--card2);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; cursor: pointer; max-width: 170px; }

/* header + footer + sidebar: nền tối làm neo, chữ sáng */
.topbar, .footer, .sidebar { background: var(--chrome); color: var(--chrome-ink); }
.topbar { border-bottom-color: rgba(0,0,0,.25); }
.footer { border-top-color: rgba(0,0,0,.25); }
.topbar .brand, .footer .f-brand { color: var(--chrome-ink); }
.topbar .brand b { color: var(--lime); }
.sidebar .flow-list li, .sidebar .side-head, .sidebar .fl-name { color: var(--chrome-ink); }
.sidebar .flow-list li:hover, .sidebar .flow-list li.folder:hover { background: rgba(255,255,255,.12); }
.sidebar .flow-list li.folder .caret { border-color: var(--chrome-ink); }
.sidebar .flow-list li.folder .pill, .sidebar .side-head .pill { background: rgba(255,255,255,.18); color: var(--chrome-ink); }
.sidebar .side-sep { background: rgba(255,255,255,.22); }
.sidebar .btn.ghost { background: var(--card2); color: var(--ink); }
/* dòng đang chọn nền sáng → chữ tối (fix chữ ẩn) */
.sidebar .flow-list li.active { background: var(--green); }
.sidebar .active, .sidebar .active .fl-name, .sidebar .active * { color: var(--green-ink); }
/* nút toggle "Chỉnh sửa" trên pill sáng */
.switch span { color: var(--green-ink); }
/* chip lime chữ tối */
.chip.amber { color: var(--amber-ink); }

/* chỉ có quyền XEM (app nhúng trả api/me can_edit=false) → ẩn mọi lối vào chỉnh sửa. Server vẫn chặn thật. */
.ff-readonly .switch, .ff-readonly #btnSave, .ff-readonly #btnShare, .ff-readonly #btnHistory, .ff-readonly #btnNewFlow,
.ff-readonly #btnImportMd, .ff-readonly #btnAddNote, .ff-readonly .note-del, .ff-readonly .fl-add,
.ff-readonly .fl-del { display: none !important; }
.ff-readonly .note-box { cursor: default; }

/* danh sách lựa chọn dài (vd 30 bản lịch sử) → xếp dọc + cuộn */
#modalChoices { flex-wrap: wrap; max-height: 60vh; overflow-y: auto; }

/* nền lưới isometric khi luồng vẽ kiểu 3D (flow.look = "iso") */
/* nền kem ấm + lưới mảnh (giống giấy vẽ isometric) — cố định, không theo sắc độ để khối màu nổi */
.canvas-wrap.iso { background:
  repeating-linear-gradient(30deg, transparent 0 27px, #e9dfcf 27px 28px),
  repeating-linear-gradient(150deg, transparent 0 27px, #e9dfcf 27px 28px),
  #f6f1e8; }

/* Font đều nét có đủ dấu tiếng Việt, đóng gói kèm (vendor/) — chữ khối/nhãn kiểu 3D. Phần tiếng Việt khai TRƯỚC
   Latin-ext (2 phần cùng chứa ư/ơ; khai sau thì trình duyệt lấy glyph lẫn 2 file → méo "ườ"). */
@font-face { font-family: "FFMono"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("vendor/jetbrains-mono-vietnamese-700-normal.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "FFMono"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("vendor/jetbrains-mono-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "FFMono"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("vendor/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
