/* ==========================================================================
   App layout, file manager, transfers panel. Uses the design tokens from style.css.
   ========================================================================== */

.cb-app { min-height: 100vh; }
.cb-boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.cb-fatal { max-width: 460px; margin: 18vh auto; padding: 24px; text-align: center; }
.cb-fatal h1 { font-size: 20px; margin: 0 0 8px; }
.cb-fatal p { color: var(--muted); margin: 0 0 18px; }
.cb-app .topbar-inner { max-width: 1440px; }
.cb-burger { display: none; }
.cb-hide-sm { }
.cb-as-btn { width: 100%; background: none; border: none; cursor: pointer; font-family: inherit; text-align: left; }
.cb-menu-title { padding: 6px 10px 2px; font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cb-theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; }
.cb-theme-dot { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid transparent; background: none; border-radius: var(--r-sm); cursor: pointer; font: 500 12px var(--font-sans); color: var(--text-soft); }
.cb-theme-dot:hover { background: var(--bg); }
.cb-theme-dot.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.cb-theme-dot .theme-swatch { width: 14px; height: 14px; display: inline-block; flex-shrink: 0; }
.nav-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.nav-search-results.hidden { display: none; }
.nav-search-item { text-decoration: none; }

/* ---------- Layout ---------- */
.cb-layout { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 58px); }
.cb-side { position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px); overflow-y: auto; padding: 16px 12px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.cb-main { padding: 22px 24px 60px; min-width: 0; outline: none; }
.cb-side-new { width: 100%; padding: 11px 16px; justify-content: center; font-size: 14px; border-radius: var(--r-lg); }
.cb-side-nav { display: flex; flex-direction: column; gap: 2px; }
.cb-side-h { margin: 14px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cb-side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-md); color: var(--text-soft); font-size: 13.5px; font-weight: 550; transition: background var(--t-fast), color var(--t-fast); }
.cb-side-link:hover { background: var(--card); color: var(--text); text-decoration: none; }
.cb-side-link.is-active { background: var(--primary-soft); color: var(--primary); }
.cb-side-count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--bg); border: 1px solid var(--border); padding: 0 7px; border-radius: 999px; color: var(--muted); }
.cb-side-count.hidden { display: none; }
.cb-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.cb-side-backdrop { display: none; }

.cb-storage { padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); font-size: 12.5px; }
.cb-storage-head { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text-soft); margin-bottom: 8px; }
.cb-storage-head b { margin-left: auto; color: var(--text); }
.cb-storage-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--border); }
.cb-storage-bar i { display: block; height: 100%; min-width: 0; }
.cb-storage-bar.warn { box-shadow: 0 0 0 1px #f59e0b; }
.cb-storage-bar.danger { box-shadow: 0 0 0 1px var(--danger); }
.cb-storage-text { margin-top: 8px; color: var(--muted); }
.cb-storage-more { margin-top: 6px; color: var(--muted); }
.cb-storage-more summary { cursor: pointer; font-size: 12px; user-select: none; }
.cb-storage-more ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.cb-storage-more li { display: flex; align-items: center; gap: 8px; }
.cb-storage-more li b { margin-left: auto; color: var(--text-soft); font-weight: 600; }
.cb-storage-warn { margin-top: 8px; color: #b45309; font-weight: 600; font-size: 12px; }
.cb-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cb-seg-photos { background: #0ea5e9; } .cb-seg-videos { background: #a855f7; } .cb-seg-audio { background: #ec4899; }
.cb-seg-documents { background: #22c55e; } .cb-seg-archives { background: #f59e0b; } .cb-seg-other { background: #94a3b8; }

/* ---------- Bottom nav (phones) ---------- */
.cb-bottom { display: none; }

/* ---------- View header ---------- */
.cb-fv-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; margin-bottom: 14px; flex-wrap: wrap; }
.cb-fv-left { min-width: 0; flex: 1; }
.cb-fv-title { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.cb-fv-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cb-fv-tools { display: flex; align-items: center; gap: 8px; }
.cb-fv-count { color: var(--muted); font-size: 12.5px; margin: 0 2px 8px; }
.cb-seg-icons { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card); }
.cb-seg-icons button { width: 30px; height: 28px; border: none; background: none; color: var(--muted); border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cb-seg-icons button.on { background: var(--primary-soft); color: var(--primary); }
.cb-i.flip { transform: rotate(180deg); }
.cb-new { padding-left: 12px; }

.cb-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.cb-crumb { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r-md); color: var(--text-soft); font-weight: 550; font-size: 14px; max-width: 240px; transition: background var(--t-fast); }
.cb-crumb span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cb-crumb:hover { background: var(--card); text-decoration: none; color: var(--text); }
.cb-crumb.is-last { color: var(--text); font-weight: 700; font-size: 17px; }
.cb-crumb.is-drop { background: var(--primary-soft); outline: 2px dashed var(--primary); }
.cb-crumb-sep { color: var(--muted); opacity: .6; }

/* ---------- Selection bar ---------- */
.cb-selbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px 6px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); border-radius: var(--r-lg); animation: popIn var(--t-fast); }
.cb-selcount { font-weight: 650; font-size: 13px; padding: 0 8px 0 2px; color: var(--primary); }
.cb-sel-actions { display: flex; gap: 2px; flex-wrap: wrap; }
.cb-selbtn { width: auto; padding: 0 10px; gap: 6px; color: var(--text-soft); }
.cb-selbtn-l { font-size: 12.5px; font-weight: 600; }
.cb-selbtn:hover { background: var(--card); }
.cb-selbtn.is-danger:hover, .cb-selbtn.is-danger:hover svg { color: var(--danger); }

/* ---------- Drop affordances ---------- */
.cb-fv-wrap { position: relative; }
.cb-dropzone-hint { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: color-mix(in srgb, var(--primary) 12%, var(--bg)); border: 2px dashed var(--primary); border-radius: var(--r-lg); color: var(--primary); font-weight: 650; pointer-events: none; }
.cb-dropzone-hint.hidden { display: none; }
.is-drop { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft) !important; }
.cb-ghost { position: fixed; top: -100px; left: -100px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: 13px; max-width: 260px; color: var(--text); }
.cb-loading { padding: 40px; text-align: center; color: var(--muted); }
.cb-sentinel { height: 1px; }

/* ---------- List ---------- */
.cb-lh, .cb-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 96px 124px 112px; align-items: center; gap: 10px; padding: 0 12px; }
.cb-lh { height: 36px; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.cb-col { background: none; border: none; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; text-align: left; }
.cb-col.on { color: var(--text); }
.cb-col.cb-c-size, .cb-c-size { justify-self: end; text-align: right; }
.cb-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.cb-lh + .cb-list { border-top-left-radius: var(--r-lg); }
.cb-row { min-height: 54px; border-bottom: 1px solid var(--border); cursor: default; transition: background var(--t-fast); position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cb-row:last-child { border-bottom: none; }
.cb-row:hover { background: var(--card-hover); }
.cb-row.is-sel { background: var(--primary-soft); }
.cb-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 0; }
.cb-c-chk { display: flex; align-items: center; justify-content: center; }
.cb-chk { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.cb-c-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cb-c-size, .cb-c-mod { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cb-c-act { display: flex; align-items: center; justify-content: flex-end; gap: 0; }
.cb-c-act .icon-btn { opacity: 0; transition: opacity var(--t-fast), background var(--t-fast); }
.cb-row:hover .cb-c-act .icon-btn, .cb-row:focus-within .cb-c-act .icon-btn, .cb-row.is-sel .cb-c-act .icon-btn, .cb-c-act .icon-btn.is-star { opacity: 1; }
.cb-name { min-width: 0; flex: 1; }
.cb-name-t { display: block; width: fit-content; max-width: 100%; color: var(--text); font-weight: 550; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
a.cb-name-t:hover { color: var(--primary); text-decoration: none; }
.cb-path { font-size: 11.5px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cb-path a { color: inherit; }
.cb-starmark { color: #f59e0b; display: inline-flex; flex-shrink: 0; }
.cb-starmark svg { fill: currentColor; }
.icon-btn.is-star svg, .cb-card-star svg { fill: currentColor; }

.cb-thumb { position: relative; width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); overflow: hidden; }
.cb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--bg); }
.cb-thumb.has-thumb { box-shadow: 0 0 0 1px var(--border); }
.cb-thumb .cb-ico { width: 100%; height: 100%; }

/* ---------- Grid ---------- */
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
.cb-card { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; cursor: default; transition: box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cb-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.cb-card.is-sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow-md); background: var(--primary-soft); }
.cb-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cb-card-top { position: relative; }
.cb-card .cb-thumb.big { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; background: var(--bg); }
.cb-card .cb-thumb.big .cb-ico { width: 64px; height: 64px; border-radius: var(--r-lg); }
.cb-card .cb-thumb.big.has-thumb .cb-ico { display: none; }
.cb-card-chk { position: absolute; top: 8px; left: 8px; z-index: 2; opacity: 0; width: 18px; height: 18px; }
.cb-card:hover .cb-card-chk, .cb-card.is-sel .cb-card-chk, .cb-card:focus-within .cb-card-chk { opacity: 1; }
.cb-card-more { position: absolute; top: 4px; right: 4px; z-index: 2; opacity: 0; background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(4px); }
.cb-card:hover .cb-card-more, .cb-card:focus-within .cb-card-more { opacity: 1; }
.cb-card-star { position: absolute; bottom: 8px; left: 8px; z-index: 2; color: #f59e0b; display: inline-flex; background: color-mix(in srgb, var(--card) 85%, transparent); border-radius: 999px; padding: 3px; }
.cb-card-meta { padding: 10px 12px 12px; }
.cb-card-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Transfers panel ---------- */
.cb-up { position: fixed; right: 20px; bottom: 20px; z-index: 120; width: 340px; max-width: calc(100vw - 24px); background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; animation: popIn var(--t-base); }
.cb-up-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 14px; }
.cb-up-title { flex: 1; font-weight: 650; font-size: 13.5px; }
.cb-up > .cb-progress { border-radius: 0; height: 3px; }
.cb-up-list { max-height: 260px; overflow-y: auto; padding: 4px 0; }
.cb-up.collapsed .cb-up-list { display: none; }
.cb-up.collapsed .cb-up-head .icon-btn:first-of-type svg { transform: rotate(180deg); }
.cb-up-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.cb-up-row .cb-ico { width: 30px; height: 30px; }
.cb-up-info { flex: 1; min-width: 0; }
.cb-up-name { font-size: 13px; font-weight: 550; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 4px; }
.cb-up-row.is-done .cb-up-name, .cb-up-row.is-cancelled .cb-up-name, .cb-up-row.is-error .cb-up-name { margin-bottom: 0; }
.cb-up-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.cb-up-row.is-done .cb-up-sub, .cb-up-row.is-error .cb-up-sub, .cb-up-row.is-cancelled .cb-up-sub { margin-top: 0; }
.cb-up-sub.err { color: var(--danger); }
.cb-up-row.is-done .cb-up-sub { color: var(--success); }

/* ---------- Folder picker + details ---------- */
.cb-pick-crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; color: var(--muted); }
.cb-pick-crumb { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; padding: 4px 6px; border-radius: var(--r-sm); cursor: pointer; font: 550 13px var(--font-sans); color: var(--text-soft); }
.cb-pick-crumb:hover { background: var(--bg); }
.cb-pick-list { border: 1px solid var(--border); border-radius: var(--r-md); max-height: 300px; overflow-y: auto; min-height: 120px; background: var(--bg); }
.cb-pick-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer; text-align: left; color: var(--text); font: 500 14px var(--font-sans); }
.cb-pick-row:last-child { border-bottom: none; }
.cb-pick-row:hover:not(:disabled) { background: var(--card); }
.cb-pick-row:disabled { opacity: .4; cursor: not-allowed; }
.cb-pick-row .cb-ico { width: 28px; height: 28px; }
.cb-pick-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pick-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.cb-details-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.cb-details-name { font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.cb-kvs { display: flex; flex-direction: column; }
.cb-kv { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cb-kv:last-child { border-bottom: none; }
.cb-kv span { color: var(--muted); flex-shrink: 0; }
.cb-kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .cb-layout { grid-template-columns: 1fr; }
  .cb-burger { display: inline-flex; }
  .cb-side { position: fixed; z-index: 140; top: 0; left: 0; bottom: 0; height: 100%; width: 288px; max-width: 86vw; padding: 16px 14px; background: var(--bg-elevated); border-right: 1px solid var(--border); box-shadow: var(--shadow-pop); transform: translateX(-102%); transition: transform var(--t-base); }
  .cb-side.open { transform: none; }
  .cb-side-backdrop { display: block; position: fixed; inset: 0; z-index: 130; background: rgba(8,10,16,.5); opacity: 0; pointer-events: none; transition: opacity var(--t-base); }
  .cb-side-backdrop.on { opacity: 1; pointer-events: auto; }
  .cb-main { padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); }
  .cb-bottom { display: flex; position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: saturate(180%) blur(16px); border-top: 1px solid var(--border); align-items: center; justify-content: space-around; }
  .cb-bottom a, .cb-bottom > button:not(.cb-bottom-plus) { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 10px; min-width: 56px; border: none; background: none; color: var(--muted); font: 600 10.5px var(--font-sans); border-radius: var(--r-md); cursor: pointer; }
  .cb-bottom a.is-active { color: var(--primary); }
  .cb-bottom a:hover { text-decoration: none; }
  .cb-bottom-plus { width: 50px; height: 50px; margin-top: -22px; border-radius: 50%; border: none; background: var(--primary); color: #fff; box-shadow: 0 6px 18px var(--primary-soft), var(--shadow-md); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
  .cb-up { bottom: calc(76px + env(safe-area-inset-bottom)); right: 10px; left: 10px; width: auto; }
  .toast-container { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
  .cb-hide-sm { display: none !important; }
  .cb-lh { display: none; }
  .cb-row { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 0 8px; min-height: 58px; }
  .cb-c-size, .cb-c-mod { display: none; }
  .cb-c-act .icon-btn { opacity: 1; }
  .cb-fv-title { font-size: 19px; }
  .cb-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .cb-card-chk, .cb-card-more { opacity: 1; }
  .cb-selbtn-l { display: none; }
  .cb-selbtn { padding: 0; width: 34px; }
  .cb-fv-head { align-items: stretch; }
  .cb-fv-tools { justify-content: space-between; }
  .cb-crumb { padding: 6px 7px; max-width: 150px; }
}
@media (hover: none) { .cb-c-act .icon-btn, .cb-card-chk, .cb-card-more { opacity: 1; } }

/* ==========================================================================
   Syntax colours
   ========================================================================== */
:root { --hl-k: #8250df; --hl-s: #0a7a3d; --hl-c: #6e7781; --hl-n: #b35900; --hl-f: #0550ae; --hl-t: #b0306a; --hl-a: #116329; --hl-v: #953800; --hl-p: #6e7781; --hl-b: var(--text); --ed-line: #cfd8ff22; }
[data-theme="dark"], [data-theme="private"] { --hl-k: #c792ea; --hl-s: #8bd49c; --hl-c: #7d8799; --hl-n: #f0a868; --hl-f: #82aaff; --hl-t: #f78fb3; --hl-a: #addb67; --hl-v: #ffcb8b; --hl-p: #8b95a7; }
[data-theme="ocean"] { --hl-k: #6f42c1; --hl-s: #067d5b; --hl-f: #0969da; }
[data-theme="sunset"] { --hl-k: #a626a4; --hl-s: #50843a; --hl-f: #c24d00; --hl-n: #b35900; }
.hl-k { color: var(--hl-k); font-weight: 600; } .hl-s { color: var(--hl-s); } .hl-c { color: var(--hl-c); font-style: italic; }
.hl-n { color: var(--hl-n); } .hl-f { color: var(--hl-f); } .hl-t { color: var(--hl-t); } .hl-a { color: var(--hl-a); }
.hl-v { color: var(--hl-v); } .hl-p { color: var(--hl-p); } .hl-b { font-weight: 700; color: var(--hl-b); }

/* ==========================================================================
   Preview overlay
   ========================================================================== */
.cb-viewer { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: rgba(9, 11, 17, .95); color: #fff; animation: fadeIn var(--t-base); }
.cb-viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: linear-gradient(rgba(0,0,0,.45), transparent); }
.cb-viewer-id { flex: 1; min-width: 0; }
.cb-viewer-title { font-weight: 650; font-size: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cb-viewer-meta { font-size: 12px; color: rgba(255,255,255,.65); }
.cb-viewer-actions { display: flex; align-items: center; gap: 2px; }
.cb-viewer .icon-btn { color: #e5e7eb; width: 38px; height: 38px; }
.cb-viewer .icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.cb-viewer .icon-btn.is-star { color: #fbbf24; }
.cb-viewer .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.22); box-shadow: none; }
.cb-viewer .btn:hover { background: rgba(255,255,255,.2); }
.cb-viewer-main { position: relative; flex: 1; min-height: 0; display: flex; }
.cb-viewer-stage { flex: 1; min-width: 0; min-height: 0; display: flex; }
.cb-viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; z-index: 3; backdrop-filter: blur(6px); }
.cb-viewer-nav:hover { background: rgba(0,0,0,.7); }
.cb-viewer-nav.prev { left: 12px; } .cb-viewer-nav.next { right: 12px; }
.cb-viewer-tools { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.5)); }
.cb-viewer-tools.hidden { display: none; }
.cb-v-zlabel { min-width: 60px; text-align: center; font-size: 12.5px; color: rgba(255,255,255,.85); font-variant-numeric: tabular-nums; }
.cb-v-center { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: auto; }
.cb-v-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(360px, 80vw); text-align: center; }
.cb-v-loading .upload-progress-bar { width: 100%; }
.cb-v-lname { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-v-loading .cb-hint { color: rgba(255,255,255,.65); }
.cb-v-msg { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; text-align: center; color: rgba(255,255,255,.85); }
.cb-v-msgname { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; }
.cb-v-msg .cb-hint { color: rgba(255,255,255,.65); }
.cb-v-imgwrap { flex: 1; min-width: 0; overflow: auto; display: flex; padding: 8px; }
.cb-v-imgwrap.panning { cursor: grabbing; }
.cb-v-img { margin: auto; display: block; background: repeating-conic-gradient(rgba(255,255,255,.06) 0 25%, transparent 0 50%) 0 0 / 20px 20px; border-radius: 4px; }
.cb-v-img.fit { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.cb-v-img:not(.fit) { max-width: none; cursor: grab; flex-shrink: 0; }
.cb-v-video { max-width: 100%; max-height: 100%; border-radius: 6px; background: #000; outline: none; }
.cb-v-audiocard { width: min(420px, 92vw); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; background: rgba(255,255,255,.07); border-radius: var(--r-xl); }
.cb-v-audiocard img { width: 200px; height: 124px; object-fit: cover; border-radius: var(--r-md); }
.cb-v-audioname { font-weight: 650; text-align: center; overflow-wrap: anywhere; }
.cb-v-audio { width: 100%; }
.cb-v-pdf { flex: 1; min-width: 0; overflow: auto; padding: 14px 0; background: rgba(255,255,255,.04); }
.cb-v-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cb-v-page { background: #fff; box-shadow: 0 4px 22px rgba(0,0,0,.45); flex-shrink: 0; max-width: none; }
.cb-v-canvas { display: block; }
.cb-v-text, .cb-v-zip { flex: 1; min-width: 0; max-width: 1040px; margin: 12px auto 0; background: var(--card); color: var(--text); border-radius: var(--r-lg) var(--r-lg) 0 0; overflow: auto; }
.cb-v-text > .cb-callout { margin: 12px; }
.cb-code { display: flex; min-width: min-content; font: 13px/1.6 var(--font-mono); }
.cb-code pre { margin: 0; padding: 14px 0; font: inherit; tab-size: 2; }
.cb-code-ln { position: sticky; left: 0; padding: 14px 12px !important; text-align: right; color: var(--muted); background: var(--bg); border-right: 1px solid var(--border); user-select: none; }
.cb-code-body { padding: 14px 16px !important; flex: 1; }
.cb-v-ziplist { max-height: calc(100vh - 220px); overflow: auto; }
.cb-v-zipsum { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; flex-wrap: wrap; }
.cb-v-zipsum .btn { background: var(--card); color: var(--text); border-color: var(--border); }
.cb-v-ziprow { display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
.cb-v-ziprow svg { color: var(--muted); }
.cb-v-zipname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
.cb-v-zipsize { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) {
  .cb-viewer-nav { width: 38px; height: 38px; }
  .cb-viewer-nav.prev { left: 4px; } .cb-viewer-nav.next { right: 4px; }
  .cb-v-text, .cb-v-zip { margin: 0; border-radius: 0; }
}

/* Markdown body (rendered preview) */
.cb-md { padding: 20px 28px 36px; max-width: 860px; margin: 0 auto; line-height: 1.7; font-size: 15px; color: var(--text); overflow-wrap: anywhere; }
.cb-md h1, .cb-md h2 { padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.cb-md h1 { font-size: 1.9em; } .cb-md h2 { font-size: 1.45em; } .cb-md h3 { font-size: 1.2em; }
.cb-md code { font: .88em var(--font-mono); background: var(--bg); padding: .15em .4em; border-radius: 5px; border: 1px solid var(--border); }
.cb-md pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; overflow: auto; }
.cb-md pre code { background: none; border: none; padding: 0; }
.cb-md blockquote { margin: 1em 0; padding: 0 1em; border-left: 4px solid var(--border-strong); color: var(--text-soft); }
.cb-md table { border-collapse: collapse; display: block; overflow: auto; }
.cb-md th, .cb-md td { border: 1px solid var(--border); padding: 6px 12px; }
.cb-md img { max-width: 100%; }
.cb-md hr { border: none; border-top: 1px solid var(--border); }
.cb-md .md-blocked-img { color: var(--muted); font-style: italic; }

/* ==========================================================================
   Editor
   ========================================================================== */
.cb-ed { --ed-fs: 13px; display: flex; flex-direction: column; height: calc(100vh - 58px - 44px); min-height: 420px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.ed-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ed-name { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.ed-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ed-bar-r { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.ed-bar-r .cb-seg-icons { margin-right: 6px; }
.save-status.is-dirty { color: #d97706; }
.ed-main { flex: 1; min-height: 0; display: flex; }
.ed-main > * { flex: 1; min-width: 0; }
.ed-main[hidden], .ed-main .hidden { display: none !important; }
.ed-scroll { overflow: auto; position: relative; background: var(--card); }
.cb-ed[data-mode="split"] .ed-scroll { border-right: 1px solid var(--border); }
.ed-preview { overflow: auto; background: var(--card); }
.ed-inner { position: relative; display: flex; min-height: 100%; min-width: 100%; width: max-content; }
.cb-ed.wrap .ed-inner { width: 100%; }
.ed-gutter { position: sticky; left: 0; z-index: 3; margin: 0; padding: 12px 10px 12px 14px; text-align: right; color: var(--muted); background: var(--bg); border-right: 1px solid var(--border); font: var(--ed-fs)/1.6 var(--font-mono); user-select: none; min-width: 42px; }
.ed-code { position: relative; flex: 1; min-width: 0; }
.ed-layer { margin: 0; padding: 12px 16px; font: var(--ed-fs)/1.6 var(--font-mono); tab-size: 2; -moz-tab-size: 2; letter-spacing: 0; white-space: pre; overflow-wrap: normal; word-break: normal; border: 0; }
.cb-ed.wrap .ed-layer { white-space: pre-wrap; overflow-wrap: anywhere; }
.ed-hl { position: relative; min-height: 100%; pointer-events: none; color: var(--text); }
.ed-marks { position: absolute; inset: 0; pointer-events: none; color: transparent; }
.ed-marks mark { background: rgba(250, 204, 21, .35); color: transparent; border-radius: 2px; }
.ed-marks mark.cur { background: rgba(249, 115, 22, .55); outline: 1px solid #f97316; }
.ed-ta { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--text); outline: none; }
.ed-ta::selection { background: color-mix(in srgb, var(--primary) 32%, transparent); -webkit-text-fill-color: transparent; }
.ed-ta:disabled { opacity: 1; }
.ed-find { padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.ed-find.hidden, .ed-frow.hidden { display: none; }
.ed-frow { display: flex; align-items: center; gap: 6px; }
.ed-frow .cb-input { max-width: 320px; padding: 7px 10px; font-size: 13px; }
.ed-fcount { font-size: 12px; color: var(--muted); min-width: 64px; white-space: nowrap; }
.ed-case b { font-size: 12px; }
.ed-status { display: flex; align-items: center; gap: 14px; padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: var(--bg); flex-wrap: wrap; }
.ed-grow { flex: 1; }
.ed-lang { padding: 3px 24px 3px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--card); color: var(--text-soft); font-family: inherit; }
.ed-auto { font-size: 12px; }
.ed-auto input { width: 14px; height: 14px; }
@media (max-width: 900px) {
  .cb-ed[data-mode="split"] .ed-scroll { display: none; }
  .cb-ed { height: calc(100vh - 58px - 90px); border-radius: var(--r-md); }
  .ed-bar-r .icon-btn[aria-label^="Smaller"], .ed-bar-r .icon-btn[aria-label^="Larger"] { display: none; }
}

/* uploads that keep going after the app is closed */
.cb-up-keep { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; color: var(--success); }
.cb-up-keep svg { flex: none; }
.cb-progress.indet > i { animation: cb-indet 1.4s ease-in-out infinite; }
@keyframes cb-indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .cb-progress.indet > i { animation: none; margin-left: 0; width: 100% !important; opacity: .45; } }
.cb-bg-list { display: grid; gap: 8px; margin: 10px 0 2px; padding: 0; list-style: none; }
.cb-bg-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--text-soft); }
.cb-bg-list .dot { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--muted); }
.cb-bg-list .dot.ok { background: var(--success); }
.cb-bg-list .dot.no { background: var(--danger); }
.cb-bg-list .dot.maybe { background: #d97706; }
.cb-bg-list b { color: var(--text); font-weight: 650; }
.cb-bg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
