/* ============================================================ tokens ==== */
:root {
  --bg: #eef0f3;
  --bg-2: #ffffff;
  --bg-3: #e9ebef;
  --bg-hover: #f2f3f5;
  --border: #dfe2e7;
  --text: #1b1e24;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.14), 0 1px 3px rgba(15, 23, 42, 0.08);
  --page-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 6px 18px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --topbar-h: 48px;
  --lib-w: 320px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --bg-2: #1e2127; --bg-3: #2a2e36; --bg-hover: #272b33; --border: #30353f;
    --text: #e7e9ed; --text-muted: #9aa1ab; --accent: #5b8def; --accent-soft: rgba(91, 141, 239, 0.18);
    --danger: #f87171; --warn: #fbbf24; --ok: #4ade80;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --page-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --bg-2: #1e2127; --bg-3: #2a2e36; --bg-hover: #272b33; --border: #30353f;
  --text: #e7e9ed; --text-muted: #9aa1ab; --accent: #5b8def; --accent-soft: rgba(91, 141, 239, 0.18);
  --danger: #f87171; --warn: #fbbf24; --ok: #4ade80;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --page-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ============================================================== base ==== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.4; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.center { justify-content: center; }
.row.space { justify-content: space-between; }
.pad { padding: 12px; }
.noscript { padding: 40px; text-align: center; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================ controls == */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; user-select: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.icon-btn { width: 32px; padding: 0; border-color: transparent; background: transparent; }
.btn.icon-btn:hover { background: var(--bg-3); }
.btn.active { background: var(--accent-soft); color: var(--accent); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; height: auto; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.small { height: 28px; font-size: 12px; padding: 0 10px; }
.btn.block { width: 100%; }

.input {
  height: 32px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); font-size: 13px; min-width: 0; width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input.no-match { color: var(--danger); }
.select { padding-right: 26px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 14px; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.badge { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; padding: 1px 6px; border-radius: 999px; background: var(--bg-3); color: var(--text-muted); margin-left: 6px; text-transform: none; vertical-align: middle; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
kbd { font-family: var(--mono); font-size: 11.5px; background: var(--bg-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; white-space: nowrap; }

/* ============================================================== layout == */
#app {
  display: grid; height: 100%; grid-template-rows: var(--topbar-h) minmax(0, 1fr); grid-template-columns: 0 minmax(0, 1fr);
  transition: grid-template-columns .18s ease; opacity: 0;
}
#app.ready { opacity: 1; }
#app.library-open { grid-template-columns: var(--lib-w) minmax(0, 1fr); }

#topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; padding: 0 10px; height: var(--topbar-h);
  background: var(--bg-2); border-bottom: 1px solid var(--border); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; font-weight: 650; letter-spacing: -.01em; user-select: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand-mark .icon { width: 15px; height: 15px; }
.topbar-group { display: flex; gap: 2px; padding: 0 4px; margin: 0 2px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

/* ------------------------------------------------------------- library -- */
#library {
  grid-row: 2; grid-column: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--bg-2); border-right: 1px solid var(--border); width: var(--lib-w);
}
.library-scrim { display: none; }
.library-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 14px; }
.library-head h2 { font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.lib-close { display: none; }
.library-tools { display: flex; gap: 8px; padding: 2px 12px 10px; }
.library-tools .select { width: 130px; flex: none; }
.library-upload { padding: 0 12px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.library-body { flex: 1; overflow: auto; padding: 4px 0 8px; }
.lib-section { padding-bottom: 6px; }
.lib-section-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.lib-section-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lib-section-title .icon { width: 14px; height: 14px; }
.lib-note { padding: 10px 14px; font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; }
.lib-note.error { color: var(--danger); }
.lib-group-head { width: 100%; display: flex; align-items: center; gap: 6px; padding: 6px 14px; background: none; border: 0; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.lib-group-head:hover { background: var(--bg-hover); }
.lib-group-head .icon { width: 15px; height: 15px; color: var(--text-muted); }
.lib-group-head span:last-child { margin-left: auto; font-weight: 400; }
.lib-group .doc-item { padding-left: 26px; }

.doc-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; cursor: pointer; position: relative; }
.doc-item:hover, .doc-item:focus-visible { background: var(--bg-hover); outline: none; }
.doc-item.open { box-shadow: inset 3px 0 0 var(--accent); }
.doc-item.open .doc-title { color: var(--accent); }
.doc-icon { color: var(--text-muted); }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.doc-tags { display: inline-flex; gap: 4px; }
.tag { background: var(--bg-3); border-radius: 999px; padding: 0 6px; font-size: 10.5px; line-height: 16px; }
.doc-actions { display: none; gap: 0; flex: none; }
.doc-actions .btn { width: 28px; height: 28px; }
.doc-item:hover .doc-actions, .doc-item:focus-within .doc-actions { display: flex; }

.library-foot { border-top: 1px solid var(--border); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.meter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.meter-label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.meter-label .icon { width: 14px; height: 14px; color: var(--text-muted); }
.meter-bar { height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; margin-top: 5px; }
.meter-detail { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; min-width: 0; }
.meter-bar.warn .meter-fill { background: var(--warn); }
.meter-bar.danger .meter-fill { background: var(--danger); }

/* ----------------------------------------------------------- workspace -- */
#workspace { grid-row: 2; grid-column: 2; display: flex; min-width: 0; min-height: 0; position: relative; background: var(--bg); --ratio: .5; }
#workspace.split-horizontal { flex-direction: column; }
.pane { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; min-height: 0; position: relative; background: var(--bg); container-type: inline-size; }
#workspace.split .pane[data-pane="a"] { flex: var(--ratio) 1 0; }
#workspace.split .pane[data-pane="b"] { flex: calc(1 - var(--ratio)) 1 0; }
#workspace.split .pane.focused .tabstrip::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.divider { flex: none; width: 6px; background: var(--border); cursor: col-resize; position: relative; z-index: 5; transition: background .12s; }
#workspace.split-horizontal .divider { width: auto; height: 6px; cursor: row-resize; }
.divider:hover, #workspace.resizing .divider { background: var(--accent); }
#workspace.resizing { user-select: none; cursor: col-resize; }
#workspace.resizing.split-horizontal { cursor: row-resize; }
#workspace.resizing .pane { pointer-events: none; }

.tabstrip { display: flex; align-items: stretch; height: 36px; flex: none; background: var(--bg-2); border-bottom: 1px solid var(--border); position: relative; }
.tabs { display: flex; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-add { align-self: center; margin: 0 4px; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 6px 0 12px; min-width: 110px; max-width: 220px; flex: 0 1 auto;
  border-right: 1px solid var(--border); color: var(--text-muted); font-size: 13px; cursor: default; user-select: none; position: relative;
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tab.dragging { opacity: .5; }
.tab-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-close { width: 22px; height: 22px; border: 0; background: none; border-radius: 4px; color: inherit; display: grid; place-items: center; opacity: 0; cursor: pointer; padding: 0; }
.tab-close .icon { width: 14px; height: 14px; }
.tab:hover .tab-close, .tab.active .tab-close { opacity: .8; }
.tab-close:hover { background: var(--bg-3); opacity: 1; }
.tab-status { width: 7px; height: 7px; border-radius: 50%; flex: none; display: none; }
.tab.loading .tab-status { display: block; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.tab.error .tab-status { display: block; background: var(--danger); }
.tab.drop-before::before, .tab.drop-after::after { content: ""; position: absolute; top: 6px; bottom: 6px; width: 2px; background: var(--accent); z-index: 2; }
.tab.drop-before::before { left: -1px; }
.tab.drop-after::after { right: -1px; }

.toolbar { display: flex; align-items: center; height: 40px; flex: none; padding: 0 4px; background: var(--bg-2); border-bottom: 1px solid var(--border); gap: 0; overflow: hidden; }
.tb-group { flex: none; }
.tb-group:last-child { margin-left: auto; }
@container (max-width: 560px) {
  .tb-secondary { display: none; }
  .zoom-select { width: 88px; }
}
@container (max-width: 430px) {
  .tb-group:first-child { display: none; }
  .page-total { display: none; }
  .tab { min-width: 90px; max-width: 160px; }
}
@container (max-width: 340px) {
  .tb-group:nth-child(3) { display: none; }
}
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1px solid var(--border); height: 24px; }
.tb-group:last-child { border-right: 0; }
.tb-spacer { flex: 1; }
.page-input { width: 50px; text-align: center; height: 28px; padding: 0 4px; }
.page-total { font-size: 12.5px; padding: 0 6px 0 4px; white-space: nowrap; }
.zoom-select { width: 116px; height: 28px; font-size: 12.5px; }

.findbar { display: flex; align-items: center; gap: 6px; height: 40px; flex: none; padding: 0 10px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.findbar .input { max-width: 320px; height: 28px; }
.find-count { font-size: 12px; white-space: nowrap; min-width: 70px; }
.find-case { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; padding: 0 4px; }

.pane-body { position: relative; flex: 1; min-height: 0; display: flex; }
.tab-body { position: absolute; inset: 0; display: flex; }
.pane-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: var(--text-muted); }
.pane-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 360px; }
.pane-empty-icon { width: 52px; height: 52px; stroke-width: 1.2; opacity: .45; }
.pane-empty h3 { font-size: 16px; color: var(--text); font-weight: 600; }
.pane.drop-target .pane-body::after {
  content: "Drop PDF to open here"; position: absolute; inset: 8px; z-index: 6; border: 2px dashed var(--accent); border-radius: 10px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 600; pointer-events: none;
}

.tab-loading { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(380px, 90%); text-align: center; padding: 40px 0; }
.tab-loading-title { font-weight: 600; }
.tab-loading .progress { width: 100%; }
.error-icon { width: 36px; height: 36px; color: var(--danger); }
.error-text { color: var(--danger); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--bg-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ============================================================== viewer == */
.viewer { display: flex; flex: 1; min-width: 0; min-height: 0; }
.viewer-sidebar { width: 210px; flex: none; display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--border); }
.viewer-sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); }
.vs-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border: 0; background: none; color: var(--text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.vs-tab .icon { width: 15px; height: 15px; }
.vs-tab:hover { color: var(--text); }
.vs-tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.viewer-sidebar-body { flex: 1; min-height: 0; display: flex; }
.thumbs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.thumb { border: 2px solid transparent; border-radius: 6px; padding: 4px; background: none; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.thumb:hover { background: var(--bg-hover); }
.thumb.active { border-color: var(--accent); }
.thumb-img { width: 100%; background: #fff; box-shadow: var(--page-shadow); }
.thumb-img canvas { width: 100%; height: auto; display: block; }
.thumb-label { font-size: 11px; color: var(--text-muted); }
.outline { flex: 1; overflow: auto; padding: 8px 6px; font-size: 13px; }
.outline-list { list-style: none; margin: 0; padding: 0; }
.outline-list .outline-list { padding-left: 14px; }
.outline-item { display: flex; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 5px 6px; border: 0; background: none; border-radius: 4px; color: var(--text); cursor: pointer; line-height: 1.3; }
.outline-item:hover { background: var(--bg-hover); }
.outline-caret { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--text-muted); transform: rotate(90deg); transition: transform .12s; }
.outline-caret-spacer { width: 14px; flex: none; }
.outline-title { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
li.collapsed > .outline-item .outline-caret { transform: none; }
li.collapsed > .outline-list { display: none; }

.viewer-scroll { flex: 1; min-width: 0; overflow: auto; position: relative; background: var(--bg); outline: none; overscroll-behavior: contain; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; width: max-content; min-width: 100%; }
.page { position: relative; flex: none; background: #fff; box-shadow: var(--page-shadow); overflow: hidden; }
.page::before { content: attr(data-page); position: absolute; inset: 0; display: grid; place-items: center; color: #c4c7cc; font-size: 15px; }
.page canvas { position: absolute; top: 0; left: 0; display: block; }
.invert-pages .page { background: #161616; }
.invert-pages .page canvas, .invert-pages .thumb-img canvas { filter: invert(0.92) hue-rotate(180deg); }
.invert-pages .thumb-img { background: #161616; }

/* PDF.js text layer (selection + search highlights) */
.textLayer { position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-align: initial; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 2; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.textLayer ::selection { background: rgba(37, 99, 235, 0.3); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
.textLayer mark.hl { color: transparent; background: rgba(250, 204, 21, 0.45); border-radius: 2px; padding: 0; }
.textLayer mark.hl.current { background: rgba(249, 115, 22, 0.65); box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.8); }

/* ================================================================ menus == */
.menu { position: fixed; z-index: 1000; min-width: 210px; padding: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; text-align: left; font-size: 13px; color: var(--text); border-radius: 5px; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-hover); outline: none; }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-muted); }
.menu-item.danger .icon { color: inherit; }
.menu-icon-spacer { width: 16px; flex: none; }
.menu-label { flex: 1; }
.menu-hint { color: var(--text-muted); font-size: 11px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ============================================================== dialogs == */
dialog.dialog { border: 0; border-radius: 12px; padding: 0; background: var(--bg-2); color: var(--text); width: 520px; max-width: min(94vw, 720px); max-height: 90vh; box-shadow: var(--shadow); }
dialog.dialog[open] { display: flex; flex-direction: column; }
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--border); }
.dialog-title { font-size: 16px; font-weight: 650; }
.dialog-body { padding: 18px 20px; overflow: auto; }
.dialog-body p { margin-bottom: 8px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

.form .muted { margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field-help { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
.field-check { flex-direction: row; align-items: flex-start; gap: 10px; font-size: 13px; }
.field-check input { margin-top: 2px; accent-color: var(--accent); }
.field-check .field-help { display: block; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.settings h3 { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 22px 0 12px; }
.settings h3:first-child { margin-top: 0; }
.settings h3 .icon { width: 14px; height: 14px; }
.settings p.muted { margin-bottom: 12px; line-height: 1.45; }
.settings .about { margin-top: 20px; }

.progress { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.progress.error .progress-fill { background: var(--danger); }
.progress-status { margin-top: 10px; font-size: 13px; }
.progress-log { margin-top: 10px; max-height: 180px; overflow: auto; font-family: var(--mono); font-size: 11.5px; display: flex; flex-direction: column; gap: 2px; }
.log-line.ok { color: var(--ok); }
.log-line.err { color: var(--danger); }

.props { border-collapse: collapse; width: 100%; font-size: 13px; }
.props th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 14px 6px 0; white-space: nowrap; vertical-align: top; width: 34%; }
.props td { padding: 6px 0; word-break: break-word; }
.props tr + tr { border-top: 1px solid var(--border); }
.shortcuts th { width: 44%; }

/* =============================================================== toasts == */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1100; pointer-events: none; }
.toast { pointer-events: auto; background: #1f2228; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: 360px; cursor: pointer; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: #b91c1c; }
.toast-success { background: #15803d; }

/* =========================================================== responsive == */
@media (max-width: 900px) {
  #app, #app.library-open { grid-template-columns: 0 minmax(0, 1fr); }
  #library { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: min(var(--lib-w), 86vw); z-index: 30; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  #app.library-open #library { transform: none; box-shadow: var(--shadow); }
  .library-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
  #app.library-open .library-scrim { opacity: 1; pointer-events: auto; }
  .lib-close { display: inline-flex; }
  .doc-actions { display: flex; }
}
@media (max-width: 720px) {
  .btn-label, .brand-name { display: none; }
  #btn-open { width: 32px; padding: 0; border-color: transparent; background: transparent; }
  .tb-secondary { display: none; }
  .zoom-select { width: 92px; }
  .viewer-sidebar { width: 150px; }
  .pages { padding: 12px; }
  .tab { min-width: 90px; max-width: 160px; }
}
@media (pointer: coarse) {
  .doc-actions { display: flex; }
  .tab-close { opacity: .8; }
}
@media print {
  #topbar, #library, .tabstrip, .toolbar, .findbar { display: none !important; }
}
