/* =====================================================================
   Library layout (preview v3) — same palette as the AF LAB portal:
   deep navy-black surfaces, one muted gold accent, navy for selection.
   Loaded only by library.html, after styles.css.
   ===================================================================== */
:root{
  --bg:#f4efe9; --surface:#ffffff; --surface2:#f8f4ee; --ink:#2a1f19; --muted:#7a6a5c;
  --line:#e3d9cd; --accent:#96702f; --accent-ink:#ffffff; --accent-soft:#f3e7d3;
  --brand:#14100d; --brand-ink:#f3ece6; --navy:#5a3f2a;
  --var:#8a6528; --var-soft:#f6ecd9; --ts:#8a6a4c; --ok:#2f7a57; --img:#8a6a4c; --img-soft:#f1e7da;
  --shadow:0 1px 2px rgba(42,31,25,.07),0 10px 30px rgba(42,31,25,.08);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#14100d; --surface:#1d1713; --surface2:#261e18; --ink:#f3ece6; --muted:#a89a8f;
    --line:#33291f; --accent:#d4a66a; --accent-ink:#1a1206; --accent-soft:rgba(212,166,106,.14);
    --brand:#110c09; --brand-ink:#f3ece6; --navy:#4a3526;
    --var:#e0b983; --var-soft:rgba(212,166,106,.14); --ts:#c9a98a; --ok:#78b596; --img:#c9a98a; --img-soft:rgba(201,169,138,.12);
    --shadow:0 1px 2px rgba(0,0,0,.4),0 12px 32px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"]{
  --bg:#14100d; --surface:#1d1713; --surface2:#261e18; --ink:#f3ece6; --muted:#a89a8f;
  --line:#33291f; --accent:#d4a66a; --accent-ink:#1a1206; --accent-soft:rgba(212,166,106,.14);
  --brand:#110c09; --brand-ink:#f3ece6; --navy:#4a3526;
  --var:#e0b983; --var-soft:rgba(212,166,106,.14); --ts:#c9a98a; --ok:#78b596; --img:#c9a98a; --img-soft:rgba(201,169,138,.12);
  --shadow:0 1px 2px rgba(0,0,0,.4),0 12px 32px rgba(0,0,0,.35);
}
body.lb{background:var(--bg)}
body.lb .logo{background:var(--navy);color:#f1ede6;border:1px solid color-mix(in srgb,var(--accent) 35%,transparent)}
body.lb .logo::after{background:var(--accent)}
body.lb .tier-badge.pro,body.lb .plans th.pro{background:linear-gradient(135deg,#d4a66a,#a97d44);color:#1a1206}
body.lb .plans td.pro{background:color-mix(in srgb,#d4a66a 10%,transparent)}
body.lb .btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
body.lb .chip.active{background:var(--navy);border-color:color-mix(in srgb,var(--accent) 45%,#6b4a3a);color:#f1ede6}
body.lb .chip.active .c{background:rgba(255,255,255,.14);color:#f1ede6}
body.lb .nav-btn.active{background:var(--surface2);border-color:color-mix(in srgb,var(--accent) 50%,var(--line));box-shadow:none}
body.lb .seg button.on{background:var(--navy);color:#f1ede6}
body.lb .var-num{color:#1a1206}

/* ---------- top bar: brand · search · actions ---------- */
body.lb .topbar{background:color-mix(in srgb,var(--brand) 96%,transparent);border-bottom:1px solid var(--line);padding:10px 20px;gap:16px}
body.lb .topbar h1,body.lb .topbar .designer{color:var(--brand-ink)}
body.lb .brand .sub{display:none}
body.lb .brand .designer{font-size:12.5px;opacity:.6}
body.lb .brand h1{font-size:17px}
body.lb .logo{width:46px;height:46px;font-size:16px}
body.lb .topbar .search-wrap{flex:1 1 320px;max-width:560px;margin-inline:auto}
body.lb .topbar .search-wrap input{min-height:44px;padding:0 16px;border-radius:12px;background:#1d1713;border:1px solid #33291f;color:#f3ece6}
body.lb .topbar .search-wrap input::placeholder{color:#8a7a6c}
body.lb .topbar .search-wrap input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent)}
body.lb .topbar .icon-btn,body.lb .topbar .gal-btn{background:#1d1713;border-color:#33291f;color:#d9d4ca}
body.lb .topbar .contact-btn{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}

/* ---------- sidebar: account + libraries ---------- */
body.lb .sidebar{gap:12px}
body.lb .sidebar .user-chip{width:100%;justify-content:flex-start;border-radius:12px;background:var(--surface);order:-3}
body.lb .plan-card{order:-2;background:var(--surface);color:var(--ink);border:1px solid var(--line);box-shadow:none;padding:12px 14px}
body.lb .plan-card .bar{background:var(--line)}
body.lb .plan-card .bar span{background:var(--accent)}
body.lb .plan-card .countdown{color:var(--ink)}
body.lb .plan-card .plans-btn{background:transparent;border:1px solid var(--line);color:var(--ink);border-radius:10px;min-height:38px}
body.lb .plan-card .plans-btn:hover{border-color:var(--accent)}

/* ---------- gallery: image-first tiles ---------- */
body.lb .list-col{background:transparent;border:0;box-shadow:none;padding:0 4px}
body.lb .list-head{padding:2px 2px 6px}
body.lb .list-head h2{font-size:22px}
body.lb .crumb{color:var(--accent)}
body.lb .chips{position:sticky;top:0;z-index:4;background:var(--bg);padding:8px 0 10px}
body.lb .prompt-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));grid-auto-rows:max-content;gap:14px;align-content:start;padding:4px 2px 24px}
body.lb .prompt-list:has(> .browse-card){grid-template-columns:repeat(auto-fill,minmax(260px,1fr))!important}
body.lb .prompt-list:has(> .card){grid-template-columns:repeat(auto-fill,minmax(210px,1fr))!important}
body.lb .browse-card{min-height:0;padding:16px;background:var(--surface);transform:none}
body.lb .browse-card:hover{transform:none;border-color:var(--accent)}
body.lb .card{flex-direction:column;gap:0;padding:0;overflow:hidden;background:var(--surface);border-radius:14px;align-items:stretch}
body.lb .card .thumb{flex:none;position:relative;display:block;width:100%;height:0;min-height:0;padding-bottom:75%;border:0;border-radius:0;background:linear-gradient(145deg,#4a3526,#1b130d)}
body.lb .card .thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
body.lb .card:not(.has-pv)::before{content:"";display:block;width:100%;height:0;padding-bottom:75%;background:linear-gradient(145deg,#4a3526,#1b130d)}
body.lb .card-body{padding:12px 14px 14px;gap:6px}
body.lb .card-top{order:-1}
body.lb .card-title{font-size:15px;line-height:1.45;font-weight:700}
body.lb .card-note{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:var(--muted);font-size:12.8px;line-height:1.6}
body.lb .card.active{border-color:var(--accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 35%,transparent)}
body.lb .card:hover{border-color:color-mix(in srgb,var(--accent) 60%,var(--line))}


/* ============================ HOME: all books as large cards ============================ */
.lb-hero{max-width:1280px;margin:0 auto;padding:30px 4px 6px;display:none}
body.lb-home .lb-hero{display:block}
.lb-hero h2{font-size:30px;margin:0 0 6px;letter-spacing:-.2px}
.lb-hero p{margin:0;color:var(--muted);max-width:640px}
.lb-stats{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
.lb-stat{display:flex;align-items:baseline;gap:8px;padding:8px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.lb-stat b{font:700 18px Inter,sans-serif;color:var(--accent)} .lb-stat span{font-size:13px;color:var(--muted)}
body.lb-home .sidebar,body.lb-home .editor-col,body.lb-home .list-head,body.lb-home .chips,body.lb-home .lb-bn,body.lb-home .guest-bar:empty{display:none}
body.lb-home .layout{grid-template-columns:minmax(0,1fr);max-width:1320px;margin:0 auto}
body.lb-home .list-col{padding:0 4px}
body.lb-home .prompt-list:has(> .library-card){grid-template-columns:repeat(auto-fill,minmax(330px,1fr))!important;gap:20px;padding:18px 2px 36px}
body.lb-home .library-card{position:relative;display:flex!important;flex-direction:column;align-items:stretch;gap:0;min-height:0;padding:0;overflow:hidden;border-radius:18px;background:var(--surface);transition:border-color .18s,box-shadow .18s,transform .18s}
body.lb-home .library-card:hover{border-color:color-mix(in srgb,var(--accent) 55%,var(--line));box-shadow:var(--shadow);transform:translateY(-3px)}
.lb-cover{display:grid;grid-template-columns:1.6fr 1fr;grid-template-rows:1fr 1fr;gap:3px;height:176px;background:#1b130d}
.lb-cover img{width:100%;height:100%;object-fit:cover;display:block}
.lb-cover img:first-child{grid-row:1/3}
.lb-cover.mono{display:flex;align-items:flex-end;justify-content:space-between;padding:16px 18px;background:linear-gradient(135deg,#4a3526 0%,#1b130d 70%);position:relative}
.lb-cover.mono::before{content:"";position:absolute;inset:0;background:repeating-linear-gradient(90deg,rgba(212,166,106,.07) 0 1px,transparent 1px 34px),repeating-linear-gradient(0deg,rgba(212,166,106,.07) 0 1px,transparent 1px 34px)}
.lb-cover.mono b{position:relative;font:800 46px/1 Inter,sans-serif;letter-spacing:-1px;color:#f3ece6}
.lb-cover.mono i{position:relative;font-style:normal;font-size:12px;color:#d4a66a;letter-spacing:.14em;text-transform:uppercase}
body.lb-home .library-card .browse-index{position:absolute;top:12px;inset-inline-start:12px;background:rgba(20,14,10,.78);color:#f3ece6;backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.1)}
body.lb-home .library-card .browse-count{position:absolute;top:12px;inset-inline-end:12px;display:flex;align-items:baseline;gap:5px;padding:4px 11px;border-radius:999px;background:rgba(20,14,10,.78);color:#f3ece6;backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.1);font:700 14px Inter,sans-serif}
body.lb-home .library-card .browse-count small{font:500 11px "IBM Plex Sans Arabic",sans-serif;opacity:.8}
body.lb-home .library-card .browse-main{padding:16px 18px 18px;gap:8px;display:flex;flex-direction:column}
body.lb-home .library-card .browse-main strong{font-size:19px}
body.lb-home .library-card .browse-main small{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:var(--muted);line-height:1.6}
body.lb-home .library-card .browse-sections{display:flex;flex-wrap:wrap;gap:6px}
body.lb-home .library-card .browse-sections span{padding:3px 10px;border-radius:999px;border:1px solid var(--line);background:var(--surface2);font-size:12px;color:var(--muted)}
body.lb-home .library-card .browse-sections span:nth-child(n+4){display:none}

/* ============================ BOOK: sections · gallery · docked editor ============================ */
body.lb-book .lb-back{display:flex}
.lb-back{display:none;align-items:center;gap:8px;min-height:42px;padding:0 14px;border-radius:12px;border:1px solid var(--line);background:var(--surface);font-weight:600;font-size:14px;cursor:pointer;order:-4;width:100%}
.lb-back:hover{border-color:var(--accent)}
.lb-back svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
body.lb-book .nav-btn.lvl0{display:none}
body.lb-book .sidebar>.plan-card{display:none}
body.lb-book .tree-kids{border:0;margin:0;padding:0}

/* the docked editor: image + prompt stay on top, editing controls scroll below them */
body.lb .editor-col{background:var(--surface)}
.lb-dk-top{display:flex;flex-direction:column;gap:10px;padding:14px 16px 12px;border-bottom:1px solid var(--line);background:var(--surface)}
.lb-dk-bot{padding:0 16px 16px;display:flex;flex-direction:column;gap:12px}
body.lb .lb-dk-top .ed-head{align-items:flex-start;gap:8px}
body.lb .lb-dk-top .ed-head h2{font-size:17px}
body.lb .lb-dk-top .ed-head p{display:none}
body.lb .lb-dk-top .ed-preview{margin:0;height:168px;border-radius:12px;box-shadow:none}
body.lb .lb-dk-top .ed-preview img,body.lb .lb-dk-top .ed-preview video{width:100%;height:100%;max-height:none;object-fit:cover;aspect-ratio:auto}
body.lb .lb-dk-top .ed-preview.vid video{object-fit:contain}
body.lb .lb-dk-top .output{border:0;box-shadow:none;background:transparent;padding:0}
body.lb .lb-dk-top .output .panel-head{margin-bottom:8px}
body.lb .lb-dk-top .output .panel-head h3{font-size:13.5px;color:var(--muted);font-weight:600}
body.lb .lb-dk-top .prompt-out{max-height:132px;overflow:auto;font-size:13px;line-height:1.7;padding:10px 12px}
body.lb .lb-dk-top .fmt-row{margin-bottom:8px}
body.lb .out-actions .btn{min-height:36px;padding:0 12px;font-size:13px}
.lb-tabs{position:sticky;top:0;z-index:5;display:flex;gap:4px;padding-top:8px;background:var(--surface);border-bottom:1px solid var(--line)}
.lb-tab{flex:1 1 0;min-height:44px;border:0;border-bottom:3px solid transparent;border-radius:10px 10px 0 0;background:none;color:var(--muted);font-weight:600;font-size:14px;cursor:pointer}
.lb-tab:hover{color:var(--ink)}
.lb-tab[aria-selected="true"]{color:var(--ink);border-bottom-color:var(--accent);background:var(--surface2)}
.lb-tab:focus-visible,.lb-act button:focus-visible,.lb-bn button:focus-visible,.lb-close:focus-visible,.lb-back:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
body.lb #editorBody[data-tab="vars"]>.lb-dk-bot>#testPanel{display:none}
body.lb #editorBody[data-tab="test"]>.lb-dk-bot>.panel:not(#testPanel),
body.lb #editorBody[data-tab="test"]>.lb-dk-bot>.ed-top{display:none}
body.lb .lb-dk-bot .ed-top{display:block}
body.lb .lb-dk-bot .panel{box-shadow:none}
body.lb #emptyState{border-radius:16px;margin:16px;background:transparent}
.lb-close,.lb-act{display:none}
.lb-scrim{display:none}
.lb-close{width:38px;height:38px;border-radius:10px;border:1px solid var(--line);background:var(--surface);place-items:center;cursor:pointer;flex:none}
.lb-close svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}

/* ---------- wide screens: two states -----------------------------------
   A · browse : vertical sections panel + big image cards (page scrolls naturally)
   B · prompt : panel and cards step aside, the editor fills the page (sheet-open) */
@media (min-width:1100px){
  body.lb .topbar{position:sticky;top:0;z-index:30}
  body.lb .layout{width:100%;max-width:1680px;margin:0 auto;align-items:start;padding:20px 24px 40px}
  body.lb-book .layout{grid-template-columns:300px minmax(0,1fr);gap:24px}
  body.lb .sidebar{position:sticky;top:84px;height:calc(100dvh - 104px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 4px 12px 0;padding-inline:0 4px}
  body.lb .list-col{height:auto;overflow:visible;display:block;min-width:0}
  body.lb .prompt-list{overflow:visible;max-height:none}
  body.lb-book .prompt-list:has(> .card){grid-template-columns:repeat(auto-fill,minmax(250px,1fr))!important;gap:18px}
  body.lb-book .prompt-list:has(> .browse-card){grid-template-columns:repeat(auto-fill,minmax(300px,1fr))!important}
  body.lb .chips{top:64px}
  body.lb .editor-col{display:none}
  body.lb.lb-home .layout{display:block}
  body.lb.lb-home .list-col{display:block}
  .lb-bn{display:none}

  /* B · prompt open */
  body.lb-book.sheet-open .sidebar,body.lb-book.sheet-open .list-col{display:none}
  body.lb-book.sheet-open .layout{grid-template-columns:minmax(0,1fr);max-width:1320px}
  body.lb-book.sheet-open .editor-col{display:block;position:static;height:auto;overflow:visible;border:0;background:transparent;padding:0;visibility:visible;transform:none;box-shadow:none}
  body.lb-book.sheet-open #editorBody{display:grid;grid-template-columns:minmax(380px,5fr) minmax(0,6fr);gap:22px;align-items:start;padding:0;max-height:none;overflow:visible}
  body.lb-book.sheet-open .lb-dk-top{position:sticky;top:84px;border:1px solid var(--line);border-radius:16px;padding:16px;background:var(--surface)}
  body.lb-book.sheet-open .lb-dk-bot{border:1px solid var(--line);border-radius:16px;background:var(--surface);padding:0 18px 18px;min-width:0}
  body.lb-book.sheet-open .lb-dk-top .ed-preview{height:300px}
  body.lb-book.sheet-open .lb-dk-top .prompt-out{max-height:260px}
  body.lb-book.sheet-open .lb-dk-top .ed-head h2{font-size:19px}
  body.lb .lb-ret{display:flex}
  .lb-close{display:none!important}
}
@media (min-width:1100px) and (max-height:780px){ body.lb-book.sheet-open .lb-dk-top .ed-preview{height:210px} }

/* ---------- phone / tablet: editor becomes a full-screen sheet ---------- */
@media (max-width:1099px){
  body.lb{padding-bottom:0}
  body.lb-book{padding-bottom:70px}
  body.lb .topbar{position:static;flex-wrap:wrap;padding:10px 14px;gap:10px}
  body.lb .brand{flex:1 1 auto;width:auto}
  body.lb .top-actions{width:auto;gap:8px}
  body.lb .topbar .search-wrap{order:5;flex:1 1 100%;max-width:none;margin:0}
  body.lb .layout{display:block;padding:8px 14px}
  body.lb .sidebar,body.lb .list-col{display:none;position:static;height:auto}
  body.lb-home .list-col{display:block}
  body.lb-book[data-view="sec"] .sidebar{display:flex}
  body.lb-book[data-view="list"] .list-col{display:flex;flex-direction:column}
  body.lb .prompt-list{max-height:none;overflow:visible}
  body.lb-home .prompt-list{grid-template-columns:1fr!important}
  body.lb-home .lb-hero h2{font-size:24px}
  body.lb .prompt-list:has(> .card){grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px}
  body.lb .prompt-list:has(> .browse-card):not(.lb-lib-list){grid-template-columns:1fr!important}
  body.lb .card-body{padding:10px 11px 12px} body.lb .card-title{font-size:13.5px} body.lb .card .meta{display:none}
  body.lb .editor-col{position:fixed;inset:0;z-index:60;width:100vw;height:100dvh;overflow-y:auto;border:0;border-radius:0;background:var(--bg);transform:translateY(100%);visibility:hidden;transition:transform .28s cubic-bezier(.2,.8,.2,1),visibility 0s linear .28s}
  html[dir] body.lb.sheet-open .editor-col{transform:none;visibility:visible;transition:transform .28s cubic-bezier(.2,.8,.2,1),visibility 0s}
  body.lb #editorBody{display:flex;flex-direction:column;padding:0 0 76px}
  .lb-dk-top{position:static;border-bottom:0;background:var(--bg);padding:12px 14px 4px}
  .lb-dk-bot{padding:0 14px 8px}
  body.lb .lb-dk-top .ed-preview{height:150px}
  .lb-close{display:grid}
  .lb-act{position:fixed;z-index:70;inset-inline:10px;bottom:calc(10px + env(safe-area-inset-bottom));display:flex;gap:8px;padding:8px;background:color-mix(in srgb,var(--surface) 95%,transparent);backdrop-filter:blur(12px);border:1px solid var(--line);border-radius:14px;box-shadow:0 -6px 24px rgba(0,0,0,.35)}
  body.lb:not(.sheet-open) .lb-act{display:none}
  .lb-act button{min-height:46px;padding:0 16px;border-radius:12px;border:1px solid var(--line);background:var(--surface2);font-weight:600;font-size:14px;cursor:pointer;white-space:nowrap}
  .lb-act .primary{flex:1 1 auto;background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
  .lb-act button[hidden]{display:none}
  body.lb .lb-dk-top .output .out-actions #copyBtn,body.lb .lb-dk-top .output .out-actions #openGpt{display:none}
  .lb-bn{position:fixed;inset-inline:0;bottom:0;z-index:50;display:grid;grid-template-columns:repeat(2,1fr);gap:6px;padding:6px 12px calc(6px + env(safe-area-inset-bottom));background:color-mix(in srgb,var(--brand) 97%,transparent);backdrop-filter:blur(14px);border-top:1px solid var(--line)}
  .lb-bn button{min-height:50px;border:0;border-radius:12px;background:none;color:#a89a8f;font-weight:600;font-size:13px;display:flex;align-items:center;justify-content:center;gap:8px;cursor:pointer}
  .lb-bn button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .lb-bn button[aria-current="page"]{color:#f1ede6;background:var(--navy)}
}
@media (prefers-reduced-motion:reduce){body.lb .editor-col{transition:none}}

/* return-to-cards bar (shown above the open prompt) */
.lb-ret{display:none;align-items:center;gap:12px;margin:0 0 14px;flex-wrap:wrap}
.lb-ret button{display:flex;align-items:center;gap:8px;min-height:44px;padding:0 18px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--ink);font-weight:700;font-size:14px;cursor:pointer}
.lb-ret button:hover{border-color:var(--accent)}
.lb-ret button svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
html[dir=rtl] .lb-ret button svg{transform:scaleX(-1)}
.lb-ret .lb-where{color:var(--muted);font-size:13px}
@media (max-width:1099px){ .lb-ret{display:none!important} }

/* =====================================================================
   BOOK PAGE  (/library/<book>) — the book's own panel + every prompt of the section
   ===================================================================== */
.lb-book-view{display:none}
body.lb-boot .list-col,body.lb-boot .lb-hero{visibility:hidden}
body.lb-book .sidebar,body.lb-book .list-col,body.lb-search .sidebar{display:none!important}
body.lb-book .lb-book-view{display:grid;grid-template-columns:minmax(0,1fr);gap:0;min-width:0}
body.lb-book.sheet-open .lb-book-view{display:none}
body.lb-search .list-col{display:block!important}
body.lb-search .lb-bn,body.lb-home .lb-bn{display:none!important}
body.lb-book .layout{grid-template-columns:minmax(0,1fr)!important}

.lb-panel{display:flex;flex-direction:column;gap:14px;min-width:0}
.lb-allbooks{display:flex;align-items:center;gap:8px;min-height:44px;padding:0 14px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--ink);font-weight:700;font-size:14px;text-decoration:none}
.lb-allbooks:hover{border-color:var(--accent)}
.lb-allbooks svg,.lb-share svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
html[dir=rtl] .lb-allbooks svg{transform:none} html[dir=ltr] .lb-allbooks svg{transform:scaleX(-1)}
.lb-bk{padding:16px 16px 14px;border:1px solid var(--line);border-radius:16px;background:linear-gradient(160deg,color-mix(in srgb,var(--navy) 70%,var(--surface)),var(--surface));display:flex;flex-direction:column;gap:6px}
.lb-bk small{font-size:11.5px;letter-spacing:.06em;color:var(--accent)}
.lb-bk h2{margin:0;font-size:21px;line-height:1.35}
.lb-bk-meta{font-size:13px;color:var(--muted)} .lb-bk-meta b{color:var(--ink)}
.lb-share{margin-top:6px;display:flex;align-items:center;justify-content:center;gap:8px;min-height:38px;border-radius:10px;border:1px dashed color-mix(in srgb,var(--accent) 55%,var(--line));background:transparent;color:var(--ink);font-size:13px;font-weight:600;cursor:pointer}
.lb-share:hover{background:var(--accent-soft)}
.lb-secs{display:flex;flex-direction:column;gap:4px}
.lb-sec{width:100%;display:flex;align-items:center;gap:10px;text-align:start;padding:10px 12px;border-radius:12px;border:1px solid transparent;background:none;color:var(--ink);font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
.lb-sec:hover{background:var(--surface)}
.lb-sec i{flex:none;width:24px;height:24px;border-radius:8px;display:grid;place-items:center;font:700 12px Inter,sans-serif;font-style:normal;background:var(--accent-soft);color:var(--accent)}
.lb-sec span{flex:1}
.lb-sec em{font-style:normal;font-size:12px;color:var(--muted)}
.lb-sec-wrap.on>.lb-sec{background:var(--surface);border-color:color-mix(in srgb,var(--accent) 50%,var(--line))}
.lb-sec-wrap.on>.lb-sec i{background:var(--accent);color:var(--accent-ink)}
.lb-grps{display:flex;flex-direction:column;margin:4px 0 6px;margin-inline-start:22px;padding-inline-start:10px;border-inline-start:2px solid color-mix(in srgb,var(--accent) 38%,transparent)}
.lb-grps a{display:flex;justify-content:space-between;gap:8px;padding:6px 10px;border-radius:8px;font-size:12.8px;color:var(--muted);text-decoration:none;line-height:1.45}
.lb-grps a:hover{color:var(--ink);background:color-mix(in srgb,var(--accent) 9%,transparent)}
.lb-grps a em{font-style:normal;font-size:11.5px}

.lb-main{min-width:0}
.lb-sechead{padding:2px 2px 14px;border-bottom:1px solid var(--line);margin-bottom:6px}
.lb-crumb{font-size:13px;color:var(--accent);font-weight:600}
.lb-sechead h2{margin:4px 0 6px;font-size:26px;line-height:1.35}
.lb-sechead p{margin:0 0 10px;color:var(--muted);max-width:760px;line-height:1.75;font-size:14px}
.lb-count{display:inline-block;padding:3px 12px;border-radius:999px;border:1px solid var(--line);background:var(--surface);font-size:12.5px;color:var(--muted)}
.lb-grp{padding-top:18px;scroll-margin-top:84px}
.lb-grp h3{display:flex;align-items:baseline;gap:10px;margin:0 0 12px;font-size:16.5px}
.lb-grp h3 small{font-size:12px;font-weight:500;color:var(--muted);padding:1px 9px;border:1px solid var(--line);border-radius:999px}
.lb-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:16px;align-items:start}
.lbc{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:14px;background:var(--surface);overflow:hidden;color:var(--ink);text-decoration:none;transition:border-color .16s,transform .16s,box-shadow .16s;min-width:0}
.lbc:hover{border-color:color-mix(in srgb,var(--accent) 65%,var(--line));transform:translateY(-2px);box-shadow:var(--shadow)}
.lbc:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.lbc-img{position:relative;display:block;width:100%;height:0;padding-bottom:72%;background:linear-gradient(145deg,#4a3526,#1b130d);overflow:hidden}
.lbc-img img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.lbc-play{position:absolute;inset-inline-end:10px;bottom:10px;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:rgba(20,14,10,.72);color:#fff;font-size:11px}
.lbc-b{display:flex;flex-direction:column;gap:6px;padding:12px 14px 14px}
.lbc-top{display:flex;justify-content:space-between;gap:8px;font-size:11.5px;color:var(--muted)}
.lbc-top b{font:600 11.5px Inter,sans-serif;color:var(--accent);letter-spacing:.02em}
.lbc-top i{font-style:normal}
.lbc strong{font-size:14.5px;line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.lbc small{font-size:12.6px;line-height:1.65;color:var(--muted);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}

@media (min-width:1100px){
  body.lb-book .lb-book-view{grid-template-columns:300px minmax(0,1fr);gap:28px;align-items:start}
  body.lb-book .lb-panel{position:sticky;top:84px;max-height:calc(100dvh - 104px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding-bottom:12px}
}
@media (max-width:1099px){
  body.lb-book .lb-book-view{display:block}
  body.lb-book[data-view="sec"] .lb-main,body.lb-book[data-view="list"] .lb-panel{display:none}
  body.lb-book.sheet-open .lb-book-view{display:none}
  .lb-cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .lbc-b{padding:10px 11px 12px;gap:4px} .lbc strong{font-size:13.5px} .lbc small{display:none}
  .lb-sechead h2{font-size:21px}
}

/* variables are retired in this layout: the prompt is shown as written, the test-image window stays */
body.lb #edTop,body.lb #imagePanel,body.lb .lb-tabs{display:none!important}
body.lb #editorBody>.lb-dk-bot>#testPanel{display:block!important}
body.lb .prompt-out .v{background:none;color:inherit;font-weight:inherit;padding:0;border-radius:0;cursor:text}
body.lb .lb-dk-bot{padding-top:18px}
body.lb #resetBtn{display:none!important}

/* the page itself scrolls (the original app locked the body height) */
html,body.lb{height:auto!important;min-height:100dvh;overflow:visible!important}
body.lb{display:block!important}
body.lb .layout{height:auto!important;min-height:0;overflow:visible!important}
body.lb .topbar{position:sticky;top:0;z-index:30}
body.lb.no-scroll{overflow:hidden!important}
body.lb .prompt-list{max-height:none;overflow:visible}

.lbc.locked .lbc-img img{filter:grayscale(.5) brightness(.7)}
.lbc.locked{opacity:.9}
.lbc-lock{position:absolute;z-index:2;top:10px;inset-inline-start:10px;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:rgba(20,14,10,.78);font-size:14px;border:1px solid rgba(255,255,255,.12)}
