/* Themis workspace tabs: plain lists, one column, the Router's colours. */
.wsx-view{--w-ink:#294b30;--w-ink2:#4d6d42;--w-muted:#7c926b;--w-faint:#9aac89;--w-line:#e0e8d6;--w-accent:#638b49;--w-late:#9a4b2e;--w-soon:#8f8050;max-width:860px;padding-bottom:48px}
html[data-theme=dark] .wsx-view{--w-ink:#eceae6;--w-ink2:#eceae6;--w-muted:#c5c3ba;--w-faint:#9a9890;--w-line:rgba(255,255,255,.13);--w-accent:#aacb9f;--w-late:#e7a283;--w-soon:#aacb9f}
.wsx-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;padding:26px 0 18px;border-bottom:1px solid var(--w-line)}
.wsx-eyebrow{font-size:10px;letter-spacing:.12em;text-transform:uppercase;font-weight:600;color:var(--w-faint)}
.wsx-head h2{margin:6px 0 4px;font-size:26px;line-height:1.2;font-weight:570;letter-spacing:-.03em;color:var(--w-ink)}
.wsx-head p{margin:0;font-size:13px;color:var(--w-muted)}
.wsx-btn{min-height:34px;padding:0 14px;border:1px solid #d1dfc4;border-radius:999px;background:#f9fcf3;color:var(--w-ink2);font:inherit;font-size:12.5px;cursor:pointer;white-space:nowrap}
.wsx-btn.primary{background:var(--w-accent);border-color:var(--w-accent);color:#fff}
.wsx-text{min-height:0;padding:4px 2px;border:0;background:none;color:var(--w-muted);font:inherit;font-size:12px;cursor:pointer}
.wsx-text:hover{color:var(--w-ink)}
.wsx-text[data-confirm]{color:var(--w-late)}
.wsx-link{display:inline;min-height:0;padding:0;border:0;background:none;font:inherit;color:var(--w-accent);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.wsx-tag{font-style:normal;font-size:10px;letter-spacing:.06em;text-transform:uppercase;font-weight:600;color:var(--w-accent)}

.wsx-list{list-style:none;margin:0;padding:0}
.wsx-list>li{display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;padding:14px 0;border-bottom:1px solid var(--w-line)}
.wsx-main{flex:1;min-width:0;display:grid;gap:3px;min-height:0;padding:0;border:0;background:none;text-align:left;font:inherit;font-size:14px;font-weight:550;line-height:1.4;color:var(--w-ink)}
button.wsx-main{cursor:pointer}
button.wsx-main:hover{color:var(--w-accent)}
.wsx-main small{font-size:12px;font-weight:400;color:var(--w-muted)}
.wsx-main small.late{color:var(--w-late)}
.wsx-main small.soon{color:var(--w-soon)}
.wsx-actions{display:flex;align-items:center;gap:12px;flex:none}
.wsx-empty{padding:28px 0;margin:0;font-size:13px;line-height:1.6;color:var(--w-muted);list-style:none}
.wsx-note{margin:16px 0 0;font-size:11.5px;color:var(--w-faint)}
.wsx-inline{display:flex;gap:8px;align-items:center;flex:1}
.wsx-inline input{flex:1;height:34px;padding:0 10px;border:1px solid #cbd7c2;border-radius:8px;font:inherit;font-size:14px}

/* Diary */
.wsx-add{display:flex;flex-wrap:wrap;gap:8px;padding:16px 0;border-bottom:1px solid var(--w-line)}
.wsx-add input,.wsx-add select{height:34px;padding:0 10px;border:1px solid #cbd7c2;border-radius:8px;background:#fff;font:inherit;font-size:13px;color:#243d2b}
.wsx-add input[name=label]{flex:1;min-width:180px}
.wsx-date{width:118px;flex:none;font-size:12.5px;color:var(--w-muted)}
.wsx-due{font-style:normal;font-size:12px;color:var(--w-muted)}
.wsx-due.soon{color:var(--w-soon)}
.wsx-due.late{color:var(--w-late);font-weight:600}
.wsx-list>li.is-done{opacity:.55}
.wsx-more{margin-top:12px}

/* Precedents */
.wsx-search{display:flex;align-items:center;gap:10px;margin:16px 0 4px;padding:0 12px;border:1px solid #cbd7c2;border-radius:10px;background:#fff;color:var(--w-faint)}
.wsx-search svg{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8}
.wsx-search input{flex:1;height:40px;border:0;outline:none;background:none;font:inherit;font-size:14px;color:#243d2b}
.wsx-search:focus-within{border-color:#9fb88f}
html[data-theme=dark] .wsx-search{background:#1d1c1a;border-color:rgba(255,255,255,.13)}
html[data-theme=dark] .wsx-search input{color:#eceae6}
html[data-theme=dark] .wsx-search:focus-within{border-color:#aacb9f}
.wsx-detail{flex-basis:100%;padding:2px 0 4px}
.wsx-detail p{margin:0 0 6px;font-size:13px;line-height:1.65;color:var(--w-ink2)}
.wsx-detail b{font-weight:600;color:var(--w-ink)}
.wsx mark{background:#e7efc9;color:inherit;border-radius:2px}
.wsx-sheet{max-height:55vh;overflow:auto;margin-bottom:16px;padding:24px 28px;border:1px solid #e0e8d6;border-radius:8px;background:#fff;font-family:Georgia,serif;color:#1f2a1c}
.workspace-dialog .wsx-sheet p{margin:0 0 10px;font-size:13px;line-height:1.6;color:#1f2a1c}

/* Coming soon */
.wsx-soon{padding:20px 0}
.wsx-lead{margin:8px 0 10px;font-size:15px;color:var(--w-ink)}
.wsx-soon ul{margin:0;padding-left:18px;display:grid;gap:6px;font-size:13px;line-height:1.6;color:var(--w-muted)}
.wsx-sub{margin:18px 0 0;padding-top:18px;border-top:1px solid var(--w-line);font-size:13px;font-weight:600;color:var(--w-ink)}

.debt-calc-row .debt-calc-add{grid-column:2;justify-self:start;width:auto;min-height:0;margin:6px 0 0;padding:5px 12px;border:1px solid #d1dfc4;border-radius:999px;background:#f9fcf3;color:#4f6b45;font:inherit;font-size:12px;cursor:pointer}
@media(max-width:640px){.wsx-head{flex-direction:column;align-items:flex-start}.wsx-date{width:100%}}

/* Header: align the masthead and tabs with the page content */
.themis-workspace .masthead .wrap{max-width:1580px!important;margin:0 auto;padding:0 36px!important;box-sizing:border-box}
.themis-workspace .workspace-toolbar{padding-left:max(36px,calc((100% - 1508px)/2))!important;padding-right:max(36px,calc((100% - 1508px)/2))!important}

/* Rail heading: same type scale and colours as the rest of the Router */
body.debt-focus .rail-matter .context-label{font-size:10px!important;letter-spacing:.12em!important;font-weight:600!important;color:#9aac89!important;margin:0 0 6px!important}
body.debt-focus .rail-matter h1{font-family:inherit!important;font-size:20px!important;font-weight:600!important;line-height:1.3!important;letter-spacing:-.015em!important;color:#355c37!important}
body.debt-focus .rail-matter p{font-size:12px!important;color:#7c926b!important;margin:4px 0 0!important}
html[data-theme=dark] body.debt-focus .rail-matter h1{color:#eceae6!important}
html[data-theme=dark] body.debt-focus .rail-matter p{color:#c5c3ba!important}

/* Account avatar and menu */
.profile{position:relative;flex:none;margin-left:14px}
.profile-btn,.profile-face{display:grid;place-items:center;width:34px;height:34px;min-height:34px;padding:0;border-radius:50%;overflow:hidden;background:#e5efd9;border:1px solid #c4d7b2;color:#355c37;font:inherit;font-size:12px;font-weight:600;letter-spacing:.02em;cursor:pointer}
.profile-btn:hover{box-shadow:0 0 0 3px #dfead3}
.profile-btn img,.profile-face img{width:100%;height:100%;object-fit:cover;display:block}
.profile-menu{position:absolute;right:0;top:calc(100% + 10px);z-index:120;width:230px;padding:6px;border:1px solid #d7e2cb;border-radius:14px;background:#fefff9;box-shadow:0 18px 50px -20px #24462140}
.profile-head{display:flex;align-items:center;gap:10px;padding:10px 10px 12px;margin-bottom:4px;border-bottom:1px solid #e6eddd}
.profile-head .profile-face{cursor:default}
.profile-head strong{display:block;font-size:13px;font-weight:600;color:#294b30}
.profile-head small{font-size:11px;color:#9aac89}
.profile-menu button[role=menuitem]{display:block;width:100%;min-height:0;padding:9px 10px;border:0;border-radius:8px;background:none;text-align:left;font:inherit;font-size:13px;color:#4d6d42;cursor:pointer}
.profile-menu button[role=menuitem]:hover,.profile-menu button[role=menuitem]:focus-visible{background:#eef4e6;color:#294b30;outline:none}
.profile-menu hr{border:0;border-top:1px solid #e6eddd;margin:4px 0}
html[data-theme=dark] .profile-menu{background:#1d1c1a;border-color:rgba(255,255,255,.13)}
html[data-theme=dark] .profile-head strong{color:#eceae6}
html[data-theme=dark] .profile-menu button[role=menuitem]{color:#eceae6}
html[data-theme=dark] .profile-menu button[role=menuitem]:hover{background:#272624;color:#eceae6}
html[data-theme=dark] .profile-btn,html[data-theme=dark] .profile-face{background:#272624;border-color:rgba(255,255,255,.13);color:#eceae6}

/* Rail Save: a quiet pill, centred on the heading line */
body.debt-focus .rail-intro #saveRoute.rail-save{align-self:start;margin-top:15px!important;height:30px;min-height:30px!important;padding:0 12px 0 10px!important;gap:6px;border:1px solid #d1dfc4!important;border-radius:999px;background:#f9fcf3!important;color:#4f6b45!important;font-size:12px!important;font-weight:500;line-height:1;transition:background .2s,border-color .2s}
body.debt-focus .rail-intro #saveRoute.rail-save:hover{background:#eef4e6!important;border-color:#c4d7b2!important}
body.debt-focus .rail-intro #saveRoute.rail-save:hover span{text-decoration:none!important}
body.debt-focus .rail-intro #saveRoute.rail-save svg{width:13px!important;height:13px!important;stroke-width:1.8}
html[data-theme=dark] body.debt-focus .rail-intro #saveRoute.rail-save{background:#22221f!important;border-color:rgba(255,255,255,.13)!important;color:#eceae6!important}
body.debt-focus .rail-intro #saveRoute.rail-save{display:inline-flex!important;align-items:center!important;justify-content:center}
body.debt-focus .rail-intro #saveRoute.rail-save span{line-height:1!important;display:block}
body.debt-focus .rail-intro #saveRoute.rail-save svg{display:block;margin:0!important}
body.debt-focus .rail-intro #saveRoute.rail-save span{font-size:12px!important;padding-top:1px}
/* Precedents: shared collections, rail and reader. */
.prec-reader-actions{display:flex;flex-wrap:wrap;gap:8px;margin:16px 0}
#detail .prec-sheet{max-height:none;overflow:auto;margin-top:18px;padding:20px;line-height:1.65;font-size:13px}
#detail .prec-sheet p{color:#1f2a1c}
#view_precedents .lib-slot{min-width:0;position:sticky;top:132px}
#view_precedents .wsx-search input{min-width:0;width:100%}
#view_precedents div.lib-group-toggle{cursor:default}
.search-results .search-category{position:static;font-weight:600;border-top:1px solid #d7e1cf}
html[data-theme=dark] .search-results .search-category{border-color:rgba(255,255,255,.13)}
@media(max-width:820px){#view_precedents .wsx-head{align-items:flex-start;flex-direction:column}#view_precedents .lib-layout{display:block}#view_precedents .lib-slot{position:static}}
#view_precedents.wsx-view{max-width:none}
#view_precedents .wsx-head{max-width:none}
#view_precedents .lib-layout{margin-top:6px}
@media(min-width:1101px){#view_precedents .lib-layout{grid-template-columns:minmax(360px,1fr) minmax(460px,1.25fr);gap:48px}}
#view_precedents .lib-rail{min-width:0}
#view_precedents .lib-rail .wsx-search{margin:0 0 6px;background:#fffefb}
#view_precedents .lib-group{margin:10px 0;border:1px solid #d7e1cf;border-radius:12px;background:#fffefb}
#view_precedents .lib-group-toggle{display:flex;align-items:center;gap:10px;width:100%;min-height:74px;padding:15px 14px 15px 16px;border:0;border-radius:12px;background:transparent;text-align:left;cursor:pointer;color:#274632}
#view_precedents .lib-group-toggle:hover{background:#f6f9f2}
#view_precedents .lib-group-toggle:focus-visible{outline:2px solid #6a8c5a;outline-offset:-2px}
#view_precedents .lib-group-no{display:grid;place-items:center;flex:0 0 26px;width:26px;height:26px;border:1px solid #c3d0b9;border-radius:50%;background:#f3f6ef;color:#647363;font-size:10px;font-weight:700}
#view_precedents .lib-group.is-open .lib-group-no{border-color:#42613d;background:#42613d;color:#fff}
#view_precedents .lib-group-toggle strong{flex:1;min-width:0;font-size:14px;line-height:21px;font-weight:600;letter-spacing:-.01em;color:#274632}
#view_precedents .lib-group-toggle small{display:block;margin-top:4px;font-size:11px;line-height:16.5px;font-weight:400;letter-spacing:0;color:#647363}
#view_precedents .lib-group-state{margin-right:8px;font-size:10px;font-weight:500;color:#647363;white-space:nowrap}
#view_precedents .lib-items{list-style:none;margin:0;padding:0 12px 12px 52px}
#view_precedents .lib-items li{margin:2px 0}
#view_precedents .lib-item{display:block;width:100%;padding:11px 10px;border:0;border-radius:10px;background:transparent;text-align:left;cursor:pointer;color:#3c5a40}
#view_precedents .lib-item:hover{background:#f1f5ec}
#view_precedents .lib-item:focus-visible{outline:2px solid #6a8c5a;outline-offset:1px}
#view_precedents .lib-item.is-on{background:#eaf1e4}
#view_precedents .lib-item-title{display:block;font-size:13px;line-height:20px;font-weight:500;letter-spacing:-.005em}
#view_precedents .lib-item.is-on .lib-item-title{font-weight:600;color:#2e542f}
#view_precedents .lib-item-sum{display:block;margin-top:4px;font-size:11px;line-height:17.6px;color:#647363}
#view_precedents .lib-item mark{background:#dfe9d2;color:inherit;border-radius:3px;padding:0 1px}
#view_precedents .lib-rail .wsx-note{margin-top:14px}
body.lib-reading #detail .lib-note{margin:18px 0 0;font-size:11px;line-height:1.6;color:#7c926b}
body.lib-reading #detail .debt-rows dt .wsx-link{padding:0;border:0;background:none;font:inherit;font-weight:600;color:inherit;text-align:left;text-decoration:underline;text-decoration-color:#b9cbaa;text-underline-offset:3px;cursor:pointer}
body.lib-reading #detail .debt-rows dt .wsx-link:hover{text-decoration-color:currentColor}
body.lib-reading #detail .debt-reader-actions ol li b{font-weight:600}
body.lib-reading #detail .reader-navigation span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html[data-theme=dark] #view_precedents .lib-rail .wsx-search{background:#1d1c1a}
html[data-theme=dark] #view_precedents .lib-group{border-color:rgba(255,255,255,.13);background:#22221f}
html[data-theme=dark] #view_precedents .lib-group-toggle,html[data-theme=dark] #view_precedents .lib-group-toggle strong{color:#c5c3ba}
html[data-theme=dark] #view_precedents .lib-group-toggle:hover{background:#272624}
html[data-theme=dark] #view_precedents .lib-group-toggle small,html[data-theme=dark] #view_precedents .lib-group-state,html[data-theme=dark] #view_precedents .lib-item-sum{color:#c5c3ba}
html[data-theme=dark] #view_precedents .lib-group-no{border-color:rgba(255,255,255,.36);background:transparent;color:#c5c3ba}
html[data-theme=dark] #view_precedents .lib-group.is-open .lib-group-no{border-color:rgba(255,255,255,.13);background:#3c4e36;color:#eceae6}
html[data-theme=dark] #view_precedents .lib-item{color:#eceae6}
html[data-theme=dark] #view_precedents .lib-item:hover{background:#272624}
html[data-theme=dark] #view_precedents .lib-item.is-on{background:#263124}
html[data-theme=dark] #view_precedents .lib-item.is-on .lib-item-title{color:#eceae6}
html[data-theme=dark] #view_precedents .lib-item mark{background:#3c4e36}
html[data-theme=dark] body.lib-reading #detail .lib-note{color:#c5c3ba}
html[data-theme=dark] body.lib-reading #detail .debt-rows dt .wsx-link{text-decoration-color:rgba(255,255,255,.36)}
@media(max-width:820px){#view_precedents .lib-items{padding-left:16px}#view_precedents .lib-group-toggle{min-height:64px}}

/* Precedents: collection tabs sit on the header divider; category tabs sit under the search */
#view_precedents .wsx-head{border-bottom:0;padding-bottom:6px}
.prec-collections{display:flex;gap:30px;margin:0 0 22px;border-bottom:1px solid var(--w-line)}
.prec-collections button{display:flex;align-items:center;gap:8px;margin-bottom:-1px;padding:10px 0 12px;border:0;border-bottom:2px solid transparent;border-radius:0;background:none;font:inherit;font-size:14px;color:var(--w-muted);cursor:pointer}
.prec-collections button:hover{color:var(--w-ink)}
.prec-collections button[aria-selected=true]{border-bottom-color:var(--w-accent);color:var(--w-ink);font-weight:600}
.prec-collections button span{padding:1px 7px;border-radius:999px;background:#eef3e8;font-size:10.5px;font-weight:500;color:var(--w-muted)}
.prec-collections button[aria-selected=true] span{background:#e1ebd7;color:var(--w-ink2)}
.prec-collections button:focus-visible{outline:2px solid var(--w-accent);outline-offset:3px}
#view_precedents .prec-list{margin-top:8px}
#view_precedents .prec-list .lib-items{padding:8px}
#view_precedents .prec-list .wsx-empty{margin:0;padding:18px 16px}
html[data-theme=dark] .prec-collections button span{background:var(--d-raised);color:var(--d-text3)}
html[data-theme=dark] .prec-collections button[aria-selected=true] span{background:var(--d-accent-soft);color:var(--d-accent-strong)}
html[data-theme=dark] .prec-collections button[aria-selected=true]{border-bottom-color:var(--d-accent)}
html[data-theme=dark] @media(max-width:820px){.prec-collections{gap:24px;margin-bottom:16px}}

/* Precedents, third pass: reader actions, fields, letters and sheets */
#detail .prec-reader-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:4px 0 22px}
#detail .prec-reader-actions .tg-reader-tools{margin:0 0 0 auto;display:flex;gap:8px}
#detail .prec-reader-actions .wsx-btn{min-height:34px}
#detail .prec-fields{display:flex;flex-wrap:wrap;gap:6px;margin:0}
#detail .prec-fields span{padding:3px 9px;border:1px solid #dfe8d6;border-radius:6px;background:#f7faf3;font-size:11.5px;letter-spacing:.02em;color:#4d6d42}
#detail .prec-draft-note{margin:0 0 12px;font-size:12px;color:#6b7d62}
#detail .prec-sheet{margin-top:0;border:1px solid #e0e8d6;border-radius:10px;box-shadow:0 1px 2px #1f3a2208}
#view_precedents .lib-items .lib-letter{margin:10px 0 2px;padding:0 10px 4px;border-bottom:1px solid #edf2e7;font-size:10.5px;font-weight:600;letter-spacing:.1em;color:#8fa07f}
#view_precedents .lib-items .lib-letter:first-child{margin-top:4px}
#view_precedents .lib-item{position:relative}
@media(max-width:820px){#detail .prec-reader-actions .tg-reader-tools{margin-left:0;width:100%}}
html[data-theme=dark] #detail .prec-fields span{border-color:rgba(255,255,255,.12);background:rgba(255,255,255,.04);color:var(--d-text2)}
html[data-theme=dark] #detail .prec-draft-note{color:var(--d-text3)}
html[data-theme=dark] #view_precedents .lib-items .lib-letter{border-bottom-color:rgba(255,255,255,.07);color:var(--d-text3)}
body.lib-reading #detail .reader-panel>section+section:not(.debt-rows){margin-top:26px;padding-top:22px;border-top:1px solid #dfe5d7}
html[data-theme=dark] body.lib-reading #detail .reader-panel>section+section:not(.debt-rows){border-top-color:rgba(255,255,255,.085)}
@media(max-width:820px){#detail [data-template-preview]{display:none}}

/* Precedents, fourth pass: search in the header, one rail card with tabs, A to Z index and an inner scroll */
@media(min-width:821px){#view_precedents .wsx-head{flex-direction:row!important;align-items:flex-end!important;justify-content:space-between}}
.prec-collections button span{padding:0;background:none!important;font-size:12px;font-weight:400;color:var(--w-faint)!important}
.prec-panel{display:flex;flex-direction:column;border:1px solid #d7e1cf;border-radius:12px;background:#fffefb;overflow:hidden}
.prec-panel-head{padding:0 16px;border-bottom:1px solid #e6ede0}
.prec-cats{display:flex;gap:22px;overflow-x:auto;scrollbar-width:none}
.prec-cats::-webkit-scrollbar{display:none}
.prec-cats button{display:inline-flex;align-items:center;gap:6px;margin-bottom:-1px;padding:13px 0 11px;border:0;border-bottom:2px solid transparent;border-radius:0;background:none;font:inherit;font-size:12.5px;color:var(--w-muted);white-space:nowrap;cursor:pointer}
.prec-cats button:hover{color:var(--w-ink)}
.prec-cats button[aria-selected=true]{border-bottom-color:var(--w-accent);color:var(--w-ink);font-weight:600}
.prec-cats button span{font-size:11px;font-weight:400;color:var(--w-faint)}
.prec-cats button.is-empty{opacity:.45}
.prec-cats button:focus-visible{outline:2px solid var(--w-accent);outline-offset:-2px}
.prec-az{display:flex;justify-content:space-between;gap:1px;padding:7px 12px;border-bottom:1px solid #eef3e9;overflow-x:auto;scrollbar-width:none}
.prec-az::-webkit-scrollbar{display:none}
.prec-az button{flex:1 0 auto;min-width:17px;height:22px;padding:0;border:0;border-radius:5px;background:none;font:inherit;font-size:10.5px;font-weight:600;color:var(--w-muted);cursor:pointer}
.prec-az button:hover:not(:disabled){background:#eef3e8;color:var(--w-ink)}
.prec-az button.is-here{background:#eaf1e4;color:var(--w-ink)}
.prec-az button:disabled{color:#c9d3c0;cursor:default}
.prec-az button:focus-visible{outline:2px solid var(--w-accent);outline-offset:0}
.prec-scroll{position:relative;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#cfd9c6 transparent}
#view_precedents .prec-scroll .lib-items{padding:6px 8px 10px}
#view_precedents .prec-scroll .lib-items .lib-letter{position:sticky;top:0;z-index:1;margin:0;padding:9px 10px 5px;background:#fffefb;border-bottom:1px solid #eef3e9;font-size:10.5px;font-weight:600;letter-spacing:.1em;color:#8fa07f}
#view_precedents .prec-scroll .wsx-empty{margin:0;padding:22px 18px}
.prec-panel-foot{display:flex;justify-content:space-between;gap:12px;padding:10px 16px;border-top:1px solid #e6ede0;font-size:11.5px;color:var(--w-muted)}
.prec-panel-foot span:last-child{text-align:right;color:var(--w-faint)}
#view_precedents .lib-rail .wsx-note{margin-top:12px}
@media(max-width:820px){#view_precedents .wsx-head-tools{flex:none;width:100%;margin-top:14px}}
html[data-theme=dark] .prec-collections button span{color:var(--d-text3)!important}
html[data-theme=dark] .prec-panel{border-color:rgba(255,255,255,.085);background-color:var(--d-surface)}
html[data-theme=dark] :is(.prec-panel-head,.prec-az){border-bottom-color:rgba(255,255,255,.07)}
html[data-theme=dark] .prec-panel-foot{border-top-color:rgba(255,255,255,.07);color:var(--d-text3)}
html[data-theme=dark] .prec-panel-foot span:last-child{color:var(--d-text3)}
html[data-theme=dark] .prec-cats button{color:var(--d-text3)}
html[data-theme=dark] .prec-cats button:hover{color:var(--d-text2)}
html[data-theme=dark] .prec-cats button[aria-selected=true]{color:var(--d-text);border-bottom-color:var(--d-accent)}
html[data-theme=dark] .prec-cats button span{color:var(--d-text3)}
html[data-theme=dark] .prec-az button{color:var(--d-text3)}
html[data-theme=dark] .prec-az button:hover:not(:disabled){background:var(--d-hover);color:var(--d-text)}
html[data-theme=dark] .prec-az button.is-here{background:var(--d-hover-strong);color:var(--d-text)}
html[data-theme=dark] .prec-az button:disabled{color:#45443f}
html[data-theme=dark] .prec-scroll{scrollbar-color:#45443f transparent}
html[data-theme=dark] #view_precedents .prec-scroll .lib-items .lib-letter{background:var(--d-surface);border-bottom-color:rgba(255,255,255,.07);color:var(--d-text3)}
.prec-panel-head,.prec-az,.prec-panel-foot{flex:none}
/* Search fields: one focus ring on the field, not a second box around the input */
.wsx-search input:focus-visible{outline:none!important}
.wsx-search:has(input:focus-visible){outline:2px solid #8fae70;outline-offset:2px}
html[data-theme=dark] .wsx-search:has(input:focus-visible){outline-color:#aacb9f}
/* Phone: the list keeps its own scroll so the letter index stays in reach, and the index wraps to two rows */
@media(max-width:820px){
  .prec-scroll{max-height:62vh;overflow:auto;overscroll-behavior:contain}
  .prec-az{display:grid!important;grid-template-columns:repeat(13,1fr);gap:2px;overflow:visible}
  .prec-az[hidden]{display:none!important}
  .prec-az button{min-width:0;width:100%;min-height:30px}
}

/* Precedents, fifth pass: one header row (title left, collection switch right), two panes of equal height that scroll in place */
@media(min-width:821px){#view_precedents .wsx-head{align-items:center!important}}
#view_precedents .wsx-head-tools{flex:none;min-width:0}
.prec-switch{display:inline-flex;padding:3px;border:1px solid #d6e2ca;border-radius:999px;background:#e9f0e1}
.prec-switch button{display:inline-flex;align-items:center;gap:7px;min-height:34px;padding:0 16px;border:0;border-radius:999px;background:transparent;font:inherit;font-size:13px;color:#5f7152;cursor:pointer;transition:background .2s,color .2s,box-shadow .2s}
.prec-switch button span{font-size:11.5px;color:#8a9a7c;font-variant-numeric:tabular-nums}
.prec-switch button:hover{color:var(--w-ink)}
.prec-switch button[aria-selected=true]{background:#fcfdf7;color:#2d4a2c;font-weight:600;box-shadow:0 1px 4px #243e2414}
.prec-switch button[aria-selected=true] span{color:#6d7f60;font-weight:500}
.prec-switch button:focus-visible{outline:2px solid var(--w-accent);outline-offset:2px}
html[data-theme=dark] .prec-switch{border-color:rgba(255,255,255,.085);background:var(--d-sunken)}
html[data-theme=dark] .prec-switch button{color:var(--d-text3)}
html[data-theme=dark] .prec-switch button:hover{color:var(--d-text2)}
html[data-theme=dark] .prec-switch button span{color:var(--d-text3)}
html[data-theme=dark] .prec-switch button[aria-selected=true]{background:var(--d-overlay);color:var(--d-text);box-shadow:0 1px 3px #0000004d,inset 0 1px 0 rgba(255,255,255,.05)}
html[data-theme=dark] .prec-switch button[aria-selected=true] span{color:var(--d-text2)}
#view_precedents .lib-layout{margin-top:20px}
@media(min-width:821px){
  #view_precedents .lib-layout{display:grid;grid-template-columns:minmax(320px,.8fr) minmax(0,1.5fr);gap:24px;align-items:stretch;height:var(--prec-h,640px)}
  #view_precedents .lib-rail{display:flex;flex-direction:column;min-height:0}
  #view_precedents .prec-panel{position:static;flex:1 1 auto;min-height:0;max-height:none}
  #view_precedents .lib-slot{position:static;top:auto;min-height:0;height:100%}
  #libSlot .journey-reader-shell{position:relative;top:auto;height:100%}
  #libSlot .journey-reader-shell .detail{position:relative;top:auto;height:100%;max-height:none}
  #libSlot #themisGuide{height:100%!important;max-height:none}
}
@media(max-width:820px){#view_precedents .wsx-head-tools{width:100%;margin-top:16px}.prec-switch{display:flex}.prec-switch button{flex:1;justify-content:center}}
html[data-theme=dark] #detail{scrollbar-color:#45443f transparent}
/* Global search groups: small labels, like the reader eyebrows */
.search-results .search-category{position:static;margin:0;padding:12px 16px 6px;border-top:1px solid #e3eadb;font-size:10.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:#6d7f60}
.search-results .search-head+.search-prec .search-category:first-child{border-top:0}
html[data-theme=dark] .search-results .search-category{border-top-color:rgba(255,255,255,.085);color:var(--d-eyebrow)}
/* Precedents desktop: the reader carries its own Ask Themis, so the floating button would only cover the reader's navigation */
@media(min-width:821px){body.lib-reading #themisDock{display:none!important}}
/* Letter strip fits any rail width */
@media(min-width:821px){.prec-az{padding:7px 8px}.prec-az button{flex:1 1 0;min-width:0}}
/* Phone reader: no bottom padding, so the pinned navigation sits on the edge and no text shows beneath it */
@media(max-width:820px){.themis-workspace.journey-workspace.detail-open #detail{padding-bottom:0}}

/* Phones: search as an icon in the top bar; opening it lays the field over the bar */
.m-search-btn,.m-search-cancel{display:none}
@media(max-width:820px){
 body.themis-workspace .masthead .wrap{flex-wrap:nowrap!important;position:relative}
 body.themis-workspace .workspace-audience{margin-left:auto}
 body.themis-workspace .workspace-search{display:none!important}
 .m-search-btn{display:grid;place-items:center;flex:none;width:38px;height:38px;padding:0;border:0;border-radius:50%;background:transparent;color:#335b2b;cursor:pointer}
 .m-search-btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
 .m-search-btn:hover,.m-search-btn[aria-expanded=true]{background:#eaf1e2}
 body.m-search-open.themis-workspace .workspace-search{display:flex!important;align-items:center;gap:10px;position:absolute;inset:0;z-index:5;margin:0!important;padding:0 16px!important;max-width:none!important;background:inherit;background:#f8fbf3;animation:msearch .22s ease-out}
 body.m-search-open .workspace-search input{flex:1;min-width:0}
 body.m-search-open .workspace-search .key-hint{display:none}
 body.m-search-open .m-search-cancel{display:block;flex:none;padding:8px 4px;border:0;background:none;font:inherit;font-size:14px;font-weight:600;color:#335b2b;cursor:pointer}
 body.m-search-open .workspace-search .search-results{position:fixed;left:10px;right:10px;top:74px;width:auto;max-width:none;max-height:calc(100dvh - 90px)}
 html[data-theme=dark] .m-search-btn,html[data-theme=dark] body.m-search-open .m-search-cancel{color:#c5c3ba}
 html[data-theme=dark] .m-search-btn:hover,html[data-theme=dark] .m-search-btn[aria-expanded=true]{background:rgba(255,255,255,.07)}
 html[data-theme=dark] body.m-search-open.themis-workspace .workspace-search{background:#161513}
}
@keyframes msearch{from{opacity:0;transform:translateY(-4px)}}
@media(prefers-reduced-motion:reduce){body.m-search-open.themis-workspace .workspace-search{animation:none}}
@media(max-width:820px){body.m-search-open .workspace-search input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}}
/* Earlier issue reports, inside the Flag an issue dialog (the Editors tab is gone until review goes live) */
.flag-past{--w-ink:#294b30;--w-ink2:#4d6d42;--w-muted:#586c53;--w-faint:#7c926b;--w-line:#e0e8d6;--w-accent:#638b49;margin-top:18px;border-top:1px solid var(--w-line);padding-top:12px}
html[data-theme=dark] .flag-past{--w-ink:#eceae6;--w-ink2:#eceae6;--w-muted:#c5c3ba;--w-faint:#9a9890;--w-line:rgba(255,255,255,.13);--w-accent:#aacb9f}
.flag-past summary{cursor:pointer;font-size:13px;font-weight:600;color:var(--w-muted);list-style:none}
.flag-past summary::-webkit-details-marker{display:none}
.flag-past summary::after{content:" +";font-weight:400}
.flag-past[open] summary::after{content:" −"}
.flag-past .wsx-list{margin-top:10px;max-height:220px;overflow:auto}
