.leg {
  --navy: #1b2a4a;
  --green: #41a866;
  --ink: #1b2a4a;
  --muted: #5c6b80;
  --line: #e1e7ee;
  --paper: #fff;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}
.leg * { box-sizing: border-box; }
.leg-tools { padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-bottom: 0; }
.leg-search { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-width: 360px; background: #fff; }
.leg-search input { border: 0; padding: 8px 10px; width: 180px; font: inherit; color: var(--ink); }
.leg-search button { border: 0; border-left: 1px solid var(--line); background: #fff; width: 32px; height: 36px; cursor: pointer; }
#leg-count { margin-left: 8px; color: var(--muted); font-size: 13px; }
.leg-modes, .leg-scopes, .leg-pages { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.leg-modes button, .leg-scopes button, .leg-pages button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; font: 13px "Segoe UI", system-ui, sans-serif; color: var(--ink); cursor: pointer; }
.leg-modes button.on, .leg-scopes button.on, .leg-filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.leg-t[hidden], .leg-o[hidden] { display: none !important; }
.leg-untr { display: block; width: max-content; max-width: 100%; margin: 0 0 2px; padding: 0 4px; border-radius: 4px; background: #f7f8fa; color: var(--muted); font-size: 11px; line-height: 18px; }
.leg-tr-tools { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 8px 0 0; vertical-align: middle; }
.leg-sk, .leg-ai, .leg-ok { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font: 12px "Segoe UI", system-ui, sans-serif; line-height: 22px; background: #fff; color: var(--ink); }
.leg-sk { cursor: pointer; }
.leg-sk.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.leg-sk[data-section] { padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; line-height: 1.3; min-height: 32px; }
.leg-ai { background: #fff3bf; }
.leg-ok { background: #e7f6ee; color: var(--green); }
.leg-tr-banner { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7f8fa; font-size: 14px; }
.leg-tr-banner p { margin: 0 0 4px; }
.leg-tr-banner p:last-child { margin: 0; }
.leg-search-hint, .leg-search-msg, .leg-filter-count, .leg-ask { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.leg-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.leg-filters button, .leg-badge { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; font: 13px "Segoe UI", system-ui, sans-serif; color: var(--ink); cursor: pointer; }
.leg-badge { display: inline-block; margin: 6px 0 0; background: #fff3bf; }
.leg-badge.is-locked { background: #f7f8fa; color: var(--muted); }
.leg-node[hidden], .leg-card[hidden] { display: none !important; }
.leg-card { margin: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.leg-card strong, .leg-card small, .leg-card a, .leg-card p { display: block; }
.leg-card button.leg-card-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; width: 100%; max-width: 100%; text-align: left; border: 0; background: none; padding: 0; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.leg-read { margin-top: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; color: var(--ink); }
.leg-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.leg-card-actions .leg-read { margin-top: 0; }
.leg-card small, .leg-card a { color: var(--muted); font-size: 12px; }
.leg-card a { color: var(--green); text-decoration: none; margin-top: 4px; }
.leg-ask { margin: 8px; }
.leg-hit-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.leg-hit-list a { display: block; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); padding: 8px 4px; }
.leg-hit-list strong, .leg-hit-list small, .leg-snip { display: block; }
.leg-hit-list small, .leg-snip { color: var(--muted); font-size: 13px; font-weight: 400; }
.leg-hit-list mark, .leg-snip mark { background: #fff3bf; color: var(--ink); }
.leg.is-all #leg-prev, .leg.is-all #leg-next, .leg.is-all #leg-count { display: none; }
.leg.is-all .leg-search { max-width: 520px; }
.leg.is-all .leg-search input { flex: 1; width: auto; }
.leg-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr) 270px; min-height: 70vh; background: var(--paper); border: 1px solid var(--line); }
.leg-shell > * { min-width: 0; }
.leg-comment, .leg-card, .leg-card *, #leg-modal-body, .leg-explain { overflow-wrap: anywhere; word-break: break-word; }
#leg-doc { grid-column: 2; }
#leg-help { grid-column: 3; }
.leg.is-list-off .leg-shell { grid-template-columns: minmax(0, 1fr) 270px; }
.leg.is-list-off #leg-doc { grid-column: 1; }
.leg.is-list-off #leg-help { grid-column: 2; }
.leg.is-help-off .leg-shell { grid-template-columns: 250px minmax(0, 1fr); }
.leg.is-list-off.is-help-off .leg-shell { grid-template-columns: minmax(0, 1fr); }
.leg.is-list-off.is-help-off #leg-doc { grid-column: 1; }
.leg.is-list-off #leg-list, .leg.is-help-off #leg-help { display: none; }
#leg-list, #leg-help, #leg-doc { min-width: 0; background: var(--paper); }
.leg-help-tabs { display: flex; border-bottom: 1px solid var(--line); }
.leg-help-tabs button { flex: 1; border: 0; background: #fff; color: var(--ink); padding: 8px 6px; font: 13px "Segoe UI", system-ui, sans-serif; cursor: pointer; }
.leg-help-tabs button.on { color: var(--green); font-weight: 700; box-shadow: inset 0 -2px 0 var(--green); }
.leg-toc { display: flex; flex-direction: column; gap: 4px; margin: 8px 12px 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; }
.leg-toc a { color: var(--green); text-decoration: none; }
.leg-tags span { display: inline-block; margin-right: 6px; color: var(--muted); font-size: 12px; }
.leg-sign, .leg-author { color: var(--muted); font-size: 13px; }
.leg-recent-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; }
.leg-history, .leg-bm-page { border: 1px solid var(--line); background: #fff; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; }
.leg-bm-page { display: inline-block; margin: 8px 10px; padding: 8px 10px; }
.leg-history { padding: 4px 8px; font: 13px "Segoe UI", system-ui, sans-serif; }
.leg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.leg-chips a { border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; text-decoration: none; color: var(--ink); font-size: 13px; background: #fff; }
#leg-list { border-right: 1px solid var(--line); }
#leg-help { border-left: 1px solid var(--line); }
.leg-pane-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.leg-hide { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 8px; font-size: 12px; color: var(--ink); cursor: pointer; }
#leg-list ul { list-style: none; margin: 0; padding: 8px; }
#leg-list a { display: block; text-decoration: none; color: var(--ink); border-radius: 8px; padding: 8px 10px; }
#leg-list a small { display: block; color: var(--muted); font-size: 12px; }
#leg-list a.on { background: #e8f6ee; }
.leg-subtabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.leg-subtabs a { flex: 1 1 30%; text-align: center; padding: 8px 4px; font-size: 12px; line-height: 1.3; text-decoration: none; color: var(--ink); }
.leg-subtabs a.on { color: var(--green); font-weight: 700; box-shadow: inset 0 -2px 0 var(--green); }
#leg-doc { padding: 16px 22px 48px; font-family: Georgia, serif; }
#leg-doc h1 { font-family: "Segoe UI", system-ui, sans-serif; font-size: 22px; margin: 0 0 4px; }
.leg-meta, .leg-note { color: var(--muted); font-size: 13px; font-family: "Segoe UI", system-ui, sans-serif; }
.leg-early { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--green); border-radius: 8px; background: #e7f6ee; color: var(--navy); font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; }
.leg-notes { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); }
.leg-notes h2 { font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; margin: 0 0 8px; }
.leg-fn { margin: 0 0 6px; font-size: 14px; line-height: 1.45; color: var(--ink); }
.leg-l0, .leg-l1, .leg-l2 { margin: 0 0 8px; }
.leg-l0 { padding-left: 2.4em; }
.leg-l1 { padding-left: 4.8em; }
.leg-l2 { padding-left: 7.2em; }
.leg-num { display: inline-block; min-width: 2.4em; margin-left: -2.4em; text-indent: 0; }
.leg-node details, .leg-node button, .leg-line details, .leg-line button, .leg-xref, .leg-update, .leg-change { text-indent: 0; }
a.leg-ext { text-decoration: underline; }
a.leg-ext::after { content: " \2197"; }
.leg-node.leg-head { font-family: "Segoe UI", system-ui, sans-serif; font-weight: 700; margin-top: 18px; }
.leg-node.leg-sign { text-align: right; font-style: italic; }
.leg-xref { color: var(--green); font-weight: 700; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; }
.leg-update, .leg-change { display: inline-block; margin-left: 8px; border: 0; background: var(--green); color: #fff; border-radius: 8px; padding: 2px 8px; font: 12px "Segoe UI", system-ui, sans-serif; cursor: pointer; }
.leg-diff { background: #e5f6ec; }
.leg mark.leg-hit { background: #fff3bf; }
.leg mark.leg-now { outline: 2px solid var(--green); }
#leg-help { padding: 0 0 16px; }
.leg-lock, .leg-comment { margin: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.leg-lock { background: #f7f8fa; color: var(--muted); }
.leg-comment { border-left: 4px solid var(--green); }
.leg-flap { display: none; position: fixed; z-index: 20; top: 46%; background: var(--navy); color: #fff; border: 0; padding: 10px 6px; font-size: 12px; letter-spacing: .04em; writing-mode: vertical-rl; cursor: pointer; }
.leg.is-list-off .leg-flap-l { display: block; left: 0; border-radius: 0 8px 8px 0; }
.leg.is-help-off .leg-flap-r { display: block; right: 0; border-radius: 8px 0 0 8px; }
.leg-modal { display: none; position: fixed; inset: 0; background: rgba(27, 42, 74, .45); z-index: 40; align-items: center; justify-content: center; padding: 16px; }
.leg-modal.on { display: flex; }
.leg-box { background: #fff; width: min(560px, 100%); max-height: 80vh; overflow: auto; border-radius: 12px; padding: 16px; border-top: 4px solid var(--green); color: var(--ink); }
#leg-close { border: 0; background: var(--navy); color: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.leg-mobilebar { display: none; }
.leg-sec-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 0 0 0 8px; vertical-align: middle; }
.leg-sec-actions button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 8px; font: 12px "Segoe UI", system-ui, sans-serif; color: var(--muted); cursor: pointer; }
.leg-sec-actions button:hover, .leg-sec-actions button:focus { color: var(--ink); }
.leg-star[aria-pressed="true"] { color: var(--green); border-color: var(--green); }
.leg-fold { border-bottom: 1px solid var(--line); padding: 8px 10px; font-family: "Segoe UI", system-ui, sans-serif; }
.leg-fold summary { cursor: pointer; font-weight: 700; }
.leg-bm-list, .leg-recent-list { list-style: none; margin: 8px 0 0; padding: 0; }
.leg-bm-list li, .leg-recent-list li { display: flex; gap: 4px; align-items: center; }
.leg-bm-list a, .leg-recent-list a { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.leg-bm-list small, .leg-recent-list small { display: block; color: var(--muted); font-size: 12px; }
.leg-bm-x { border: 0; background: transparent; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--ink); font-size: 18px; }
.leg-bm-guest { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.leg-home { padding: 8px 4px 24px; }
.leg-flash { background: #fff3bf; }
.leg-toast { display: none; position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; border-radius: 8px; padding: 10px 14px; z-index: 60; }
.leg-toast.on { display: block; }
.leg-bm-sheet { display: none; background: #fff; color: var(--ink); }
.leg-bm-sheet-h { margin: 0; padding: 10px 12px; font: 700 16px "Segoe UI", system-ui, sans-serif; color: var(--ink); border-bottom: 1px solid var(--line); }
.leg-bm-sheet-list { list-style: none; margin: 0; padding: 0; }
.leg-bm-sheet-list a { display: block; padding: 10px 12px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.leg-bm-sheet-list small { display: block; color: var(--muted); font-size: 12px; }
.leg-close-row { margin: 0; }
#leg-doc, .leg-node { -webkit-tap-highlight-color: transparent; }
.leg button:focus-visible, .leg a:focus-visible, .leg summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (hover: none) {
  .leg-sec-actions { max-height: none; opacity: 1; overflow: visible; }
}
@media (max-width: 800px) {
  .leg-num { min-width: 2em; margin-left: -2em; }
  .leg-l0 { padding-left: 2em; }
  .leg-l1 { padding-left: 4em; }
  .leg-l2 { padding-left: 6em; }
  .leg-shell, .leg.is-list-off .leg-shell, .leg.is-help-off .leg-shell, .leg.is-list-off.is-help-off .leg-shell { display: block; }
  #leg-doc, .leg.is-list-off #leg-doc, .leg.is-list-off #leg-help, .leg.is-list-off.is-help-off #leg-doc { grid-column: auto; }
  #leg-list, #leg-help { position: fixed; top: 0; bottom: 0; width: min(86vw, 320px); z-index: 30; overflow: auto; box-shadow: 0 0 24px rgba(27, 42, 74, .2); }
  #leg-list { left: 0; }
  #leg-help { right: 0; }
  .leg { width: 100%; max-width: 100%; overflow-x: clip; font-size: 16px; }
  #leg-doc { font-size: 16px; line-height: 1.5; overflow-x: clip; }
  .leg-num { width: 2em; min-width: 2em; margin-left: -2em; }
  .leg-node:not(.leg-annex), .leg-xref, a.leg-ext { overflow-wrap: anywhere; }
  .leg-node.leg-annex { overflow-x: auto; max-width: 100%; }
  .leg-node { scroll-margin-top: 56px; }
  .leg.is-list-off .leg-flap-l { display: block !important; left: 0; border-radius: 0 8px 8px 0; }
  .leg.is-help-off .leg-flap-r { display: block !important; right: 0; border-radius: 8px 0 0 8px; }
  .leg-mobilebar [data-pane="list"] { display: none; }
  .leg-mobilebar { display: flex; position: sticky; top: 0; z-index: 36; background: var(--navy); }
  .leg-mobilebar button { flex: 1; min-height: 44px; background: transparent; color: #fff; border: 0; border-right: 1px solid rgba(255, 255, 255, .15); font: 15px "Segoe UI", system-ui, sans-serif; cursor: pointer; }
  .leg-tools { display: none; }
  .leg.is-find .leg-scrim, .leg.is-bm .leg-scrim { display: block; position: fixed; inset: 0; background: rgba(27, 42, 74, .45); z-index: 50000; }
  .leg.is-find .leg-tools,
  .leg.is-find.is-all .leg-tools,
  .leg.is-bm .leg-bm-sheet { display: block; position: fixed; left: 0; right: 0; top: auto; bottom: var(--leg-kb, 0px); width: 100%; max-height: 85vh; z-index: 50001; overflow: auto; background: #fff; border-radius: 16px 16px 0 0; border-bottom: 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 0 24px rgba(27, 42, 74, .2); }
  .leg.is-find .leg-modes button, .leg.is-find .leg-scopes button, .leg.is-find .leg-pages button { flex: 1 1 calc(50% - 6px); min-width: 0; white-space: normal; line-height: 1.2; text-align: center; }
  .leg-search { max-width: none; }
  .leg-search input { flex: 1; width: auto; min-height: 44px; font-size: 16px; }
  .leg-search button { min-height: 44px; width: 44px; }
  .leg.is-find.is-all .leg-hit-list { max-height: none; }
  .leg-modes button, .leg-scopes button, .leg-pages button, .leg-filters button, .leg-badge, .leg-sk { min-height: 44px; }
  .leg-sec-actions { max-height: none; opacity: 1; overflow: visible; }
  .leg-sec-actions button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; font-size: 18px; }
  .leg-act-label { display: none; }
  .leg-mobilebar a { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; border-right: 1px solid rgba(255, 255, 255, .15); font: 15px "Segoe UI", system-ui, sans-serif; }
  #leg-list { top: 48px; width: min(100%, 360px); }
  .leg.is-sheet:not(.is-list-off) .leg-scrim { z-index: 50000; }
  .leg:not(.is-list-off) #leg-list { display: flex; flex-direction: column; left: 0; right: 0; top: auto !important; bottom: var(--leg-kb, 0px); width: 100%; height: auto; max-height: 85vh; border-radius: 16px 16px 0 0; overflow: hidden; z-index: 50001; }
  .leg:not(.is-list-off) #leg-list .leg-subtabs { order: 0; flex: 0 0 auto; }
  .leg:not(.is-list-off) #leg-list .leg-fold { order: 1; flex: 0 0 auto; }
  .leg:not(.is-list-off) #leg-list ul { order: 2; flex: 1 1 auto; min-height: 0; overflow: auto; }
  .leg:not(.is-list-off) #leg-list .leg-pane-h { order: 3; flex: 0 0 auto; flex-direction: column; align-items: stretch; background: #fff; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .leg:not(.is-list-off) #leg-list .leg-hide { min-height: 44px; width: 100%; margin-left: 0; }
  .leg.is-sheet .leg-scrim { display: block; position: fixed; inset: 0; background: rgba(27, 42, 74, .45); z-index: 28; }
  .leg:not(.is-help-off) #leg-help { display: flex; flex-direction: column; left: 0; right: 0; top: auto; bottom: var(--leg-kb, 0px); width: 100%; height: auto; max-height: 85vh; border-radius: 16px 16px 0 0; }
  #leg-help-body { order: 1; overflow: auto; min-height: 0; }
  #leg-help .leg-pane-h { order: 2; position: sticky; bottom: 0; background: #fff; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  #leg-help .leg-hide { min-height: 44px; width: 100%; }
  #leg-comment { order: 1; overflow: auto; }
  .leg-modal { align-items: flex-end; padding: 0 0 var(--leg-kb, 0px); }
  .leg-box { width: 100%; max-height: min(85vh, 100%); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; padding: 16px 16px 0; }
  #leg-modal-body { overflow: auto; flex: 1 1 auto; }
  .leg-close-row { position: sticky; bottom: 0; background: #fff; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
  #leg-close { min-height: 44px; width: 100%; }
}
body.leg-lock { overflow: hidden; }
.leg-ex-tools { margin: 12px; }
.leg-ex-tools button, .leg-ex-edit { border: 0; background: var(--green); color: #fff; border-radius: 8px; padding: 8px 12px; font: 14px "Segoe UI", system-ui, sans-serif; font-weight: 700; cursor: pointer; }
.leg-sec-actions .leg-ex-add { background: #fff; color: var(--green); border: 1px solid var(--green); font-weight: 700; }
#leg-ex-modal .leg-box { width: min(720px, 100%); }
.leg-ex-form h2 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.leg-ex-form input[type=text], .leg-ex-form textarea { width: 100%; max-width: none; box-sizing: border-box; }
.leg-lang-tabs { display: flex; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 8px 0 12px; }
.leg-lang-tabs button { background: #fff; border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 8px 14px; color: var(--ink); font-weight: 700; cursor: pointer; }
.leg-lang-tabs button.on { color: var(--green); border-bottom-color: var(--green); }
.leg-anon { color: var(--muted); font-size: 13px; }
#leg-ex-close { border: 0; background: var(--navy); color: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; margin-left: 8px; }
@media print {
  .leg-sec-actions, .leg-help-tabs, .leg-history, .leg-bm-page, .leg-ex-tools, .leg-ex-edit, [data-ex-edit] { display: none !important; }
}
