/* ── Design tokens ──────────────────────────────────────────────── */
    :root {
      /* Blue & White palette */
      --bg:          #f0f4fb;
      --surface:     #ffffff;
      --surface2:    #f4f6fd;
      --surface3:    #eaeefc;
      --border:      #d5daf0;
      --border2:     #bcc4e8;
      --accent:      #2f6ee0;
      --accent2:     #4a84f5;
      --accent-dim:  rgba(47,110,224,.10);
      --accent-glow: rgba(47,110,224,.25);
      --red:         #e03545;
      --green:       #1da462;
      --blue:        #2f6ee0;
      --purple:      #7c5cf0;
      --text:        #1a1c2e;
      --text2:       #4a4f6a;
      --text3:       #8890b0;
      --font-head:   'Syne', sans-serif;
      --font-body:   'Manrope', sans-serif;
      --font-mono:   'DM Mono', monospace;
      --radius:      10px;
      --radius-lg:   16px;
      --shadow:      0 8px 32px rgba(47,110,224,.12);
      --shadow-sm:   0 2px 12px rgba(47,110,224,.08);
    }

    /* ── Create PDF modal ───────────────────────────────────────────── */
    .pdf-size-btn.active, .pdf-orient-btn.active {
      background: var(--accent-dim);
      border-color: var(--accent);
      color: var(--accent);
    }
    .create-bg-btn:hover { transform: scale(1.12); }

    /* ── Light mode btn-primary: blue instead of yellow ───────────── */

    

    
    /* But keep fast transitions for interactive elements */
    .tool-btn, .btn-forge, .zoom-btn, .color-dot,
    .page-thumb, #btn-shortcuts, #btn-help, 

    /* ── Light mode specific overrides ─────────────────────────────── */
    /* Theme toggle button */
    
    
    
    

    /* ── Reset & base ───────────────────────────────────────────────── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html, body { height: 100%; overflow: hidden; }
    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--font-body);
      font-size: 13px;
    }

    /* ── Scrollbar ──────────────────────────────────────────────────── */
    ::-webkit-scrollbar { width: 5px; height: 5px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

    /* ── Layout ─────────────────────────────────────────────────────── */
    #app { display: flex; flex-direction: column; height: 100vh; }

    /* ── Topbar ─────────────────────────────────────────────────────── */
    #topbar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 0 14px;
      height: 48px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      z-index: 100;
    }
    .brand {
      font-family: var(--font-head);
      font-size: 20px;
      font-weight: 800;
      color: var(--accent);
      letter-spacing: -0.5px;
      white-space: nowrap;
      user-select: none;
    }
    .brand span { color: var(--text2); font-weight: 700; }
    .topbar-sep { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }
    .topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

    /* ── Toolbar (tool strip) ───────────────────────────────────────── */
    #toolbar {
      display: flex;
      align-items: center;
      gap: 2px;
      padding: 0 16px;
      height: 44px;
      background: var(--surface2);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      overflow-x: auto;
    }
    .tool-btn {
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 5px 10px;
      border-radius: 6px;
      border: none;
      background: transparent;
      color: var(--text);
      font-family: var(--font-body);
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      white-space: nowrap;
      transition: all .15s;
    }
    .tool-btn:hover { background: var(--surface3); color: var(--text); }
    .tool-btn.active { background: var(--accent-dim); color: var(--accent); }
    .tool-btn i { font-size: 14px; }
    .tool-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

    /* ── Main area ──────────────────────────────────────────────────── */
    #main {
      display: flex;
      flex: 1;
      overflow: hidden;
    }

    /* ── Left sidebar — pages ───────────────────────────────────────── */
    #sidebar {
      width: 180px;
      flex-shrink: 0;
      background: var(--surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .sidebar-header {
      padding: 10px 14px;
      font-size: 10px;
      font-weight: 600;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--text3);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    #page-list {
      flex: 1;
      overflow-y: auto;
      padding: 8px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .page-thumb {
      position: relative;
      border-radius: 6px;
      border: 1.5px solid var(--border);
      overflow: hidden;
      cursor: pointer;
      transition: all .15s;
      background: #fff;
    }
    .page-thumb:hover { border-color: var(--border2); }
    .page-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
    .page-thumb canvas { display: block; width: 100%; height: auto; }
    .page-num {
      position: absolute;
      bottom: 4px;
      right: 6px;
      font-size: 9px;
      font-family: var(--font-mono);
      color: var(--text2);
      background: rgba(0,0,0,.55);
      padding: 1px 5px;
      border-radius: 4px;
    }
    .page-thumb .del-page {
      display: none;
      position: absolute;
      top: 4px;
      right: 4px;
      width: 20px;
      height: 20px;
      background: var(--red);
      border: none;
      border-radius: 4px;
      color: #fff;
      font-size: 11px;
      cursor: pointer;
      align-items: center;
      justify-content: center;
    }
    .page-thumb:hover .del-page { display: flex; }

    /* ── Canvas area ────────────────────────────────────────────────── */
    #canvas-wrap {
      flex: 1;
      overflow: auto;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 28px;
      background:
        radial-gradient(ellipse at 30% 20%, rgba(47,110,224,.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(47,110,224,.04) 0%, transparent 50%),
        var(--bg);
    }
    #canvas-container {
      position: relative;
      box-shadow: 0 12px 60px rgba(0,0,0,.7);
      border-radius: 4px;
      overflow: hidden;
      cursor: crosshair;
      background: white;
    }
    #pdf-canvas { display: block; }
    #annotation-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }
    #annotation-layer.draw-mode  { pointer-events: all; cursor: crosshair; }
    #annotation-layer.text-mode  { pointer-events: all; cursor: text; }
    #annotation-layer.erase-mode { pointer-events: all; cursor: cell; }

    /* ── Annotation elements ────────────────────────────────────────── */
    .annotation {
      position: absolute;
      pointer-events: all;
      cursor: move;
    }
    /* ── Text annotation wrapper ───────────────────────────────────── */
    .ann-text-wrap {
      position: absolute;
      /* no border/bg here — wrapper is just a positionable container */
    }
    /* The actual editable region — NEVER contains the delete button */
    .ann-text {
      display: block;
      min-width: 80px;
      min-height: 28px;
      padding: 5px 10px;
      border: 1.5px solid var(--accent);
      background: transparent;
      border-radius: 4px;
      /* Text color comes from inline style set by JS */
      font-size: 16px;
      font-family: var(--font-body);
      line-height: 1.5;
      outline: none;
      cursor: text;
      resize: both;
      overflow: hidden;
      white-space: pre-wrap;
      word-break: break-word;
      transition: border-color .15s, box-shadow .15s;
      box-sizing: border-box;
      /* caret always appears at text start, not near delete button */
      direction: ltr;
      text-align: left;
      vertical-align: top;
    }
    .ann-text:focus {
      border-color: var(--accent);
      background: transparent;
      box-shadow: 0 0 0 2px var(--accent-glow);
    }
    .ann-text:empty::before {
      content: 'Type here…';
      color: rgba(80,90,130,.4);
      pointer-events: none;
      font-style: italic;
    }
    /* Frozen: invisible chrome, plain-text look */
    .ann-text.frozen {
      border-color: transparent;
      background: transparent;
      box-shadow: none;
      resize: none;
      cursor: move;
    }
    .ann-text.frozen:empty { display: none; }
    /* Hover on frozen shows subtle outline so user knows it's selectable */
    .ann-text-wrap:hover .ann-text.frozen:not(:empty) {
      border: 1.5px dashed rgba(232,197,71,.35);
    }
    /* Floating toolbar above the text box while editing */
    .ann-text-toolbar {
      position: absolute;
      top: -36px;
      left: 0;
      display: none;
      align-items: center;
      gap: 3px;
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 8px;
      padding: 4px 6px;
      box-shadow: 0 4px 16px rgba(0,0,0,.25);
      white-space: nowrap;
      z-index: 100;
    }
    .ann-text-wrap.editing .ann-text-toolbar { display: flex; }
    .ann-tb-btn {
      width: 24px; height: 24px;
      border-radius: 5px;
      border: none;
      background: transparent;
      color: var(--text2);
      font-size: 12px;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background .1s, color .1s;
    }
    .ann-tb-btn:hover { background: var(--surface2); color: var(--text); }
    .ann-tb-btn.active { background: var(--accent-dim); color: var(--accent); }
    .ann-tb-sep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }
    /* Size indicator badge */
    .ann-tb-size {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--text3);
      padding: 0 4px;
      min-width: 28px;
      text-align: center;
    }
    .ann-highlight {
      border-radius: 2px;
      opacity: .35;
      mix-blend-mode: multiply;
    }
    .ann-shape {
      border: 2px solid var(--red);
      border-radius: 2px;
      background: rgba(255,95,107,0.15); /* default semi-fill; JS overrides */
    }
    .ann-shape.circle { border-radius: 50%; }
    /* Image annotation */
    .ann-image {
      border: 2px dashed #5b8dee;
      border-radius: 4px;
      overflow: hidden;
      background: transparent;
      cursor: move;
      box-sizing: border-box;
    }
    .ann-image img {
      width: 100%;
      height: 100%;
      object-fit: fill;
      display: block;
      pointer-events: none;
      user-select: none;
    }
    .ann-image .img-resize-handle {
      position: absolute;
      bottom: 0; right: 0;
      width: 14px; height: 14px;
      background: #5b8dee;
      border-radius: 3px 0 3px 0;
      cursor: se-resize;
      display: flex; align-items: center; justify-content: center;
    }
    .ann-image .img-resize-handle i { font-size: 9px; color: #fff; pointer-events: none; }
    .ann-image.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
    .annotation .ann-del,
    .ann-text-wrap .ann-del {
      display: none;
      position: absolute;
      top: -13px;
      right: -13px;
      width: 26px;
      height: 26px;
      background: var(--surface);
      border-radius: 50%;
      border: 2px solid #ff5f6b;
      color: #ff5f6b;
      font-size: 13px;
      font-weight: 700;
      line-height: 1;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 20;
      box-shadow: 0 2px 8px rgba(0,0,0,.5);
      transition: background .12s, color .12s, transform .12s;
    }
    .annotation:hover .ann-del, .ann-text-wrap:hover .ann-del { display: flex; }
    .ann-del:hover { background: #ff5f6b !important; color: #fff !important; transform: scale(1.15); }

    /* ── Right panel — properties ───────────────────────────────────── */
    #props-panel {
      width: 220px;
      flex-shrink: 0;
      background: var(--surface);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      overflow-x: hidden;
    }
    /* Override inline margin-top:auto on last section — not needed when scrolling */
    #props-panel .panel-section:last-child { margin-top: 0; }
    .panel-section {
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
    }
    .panel-label {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--text3);
      margin-bottom: 10px;
    }
    .prop-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 8px;
    }
    .prop-row label { color: var(--text2); font-size: 12px; }
    .prop-input {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
      font-family: var(--font-mono);
      font-size: 12px;
      padding: 4px 8px;
      width: 80px;
      transition: border .15s;
    }
    .prop-input:focus { outline: none; border-color: var(--accent); }
    .color-row { display: flex; gap: 6px; flex-wrap: wrap; }
    .color-dot {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      border: 2px solid transparent;
      cursor: pointer;
      transition: all .12s;
    }
    .color-dot:hover { transform: scale(1.15); }
    .color-dot.active { border-color: var(--text); }
    .zoom-row { display: flex; align-items: center; gap: 8px; }
    .zoom-btn {
      width: 28px; height: 28px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text2);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px;
      transition: all .12s;
    }
    .zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
    #zoom-val {
      font-family: var(--font-mono);
      font-size: 12px;
      color: var(--text);
      min-width: 40px;
      text-align: center;
    }
    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .stat-box {
      background: #f0f4fb;
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 8px 10px;
    }
    .stat-val { font-size: 18px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
    .stat-lbl { font-size: 10px; color: var(--text3); margin-top: 2px; }

    /* ── Buttons ────────────────────────────────────────────────────── */
    .btn-forge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      border-radius: 7px;
      border: none;
      font-family: var(--font-body);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all .15s;
      white-space: nowrap;
    }
    .btn-primary {
      background: var(--accent);
      color: #ffffff;
    }
    .btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); color: #ffffff; }
    .btn-ghost {
      background: #ffffff;
      color: var(--text);
      border: 1px solid var(--border2);
    }
    .btn-ghost:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
    .btn-danger {
      background: transparent;
      color: var(--red);
      border: 1px solid #ff5f6b44;
    }
    .btn-danger:hover { background: #ff5f6b22; }

    /* ── Drop zone ──────────────────────────────────────────────────── */
    #drop-zone {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 16px;
      height: 100%;
      width: 100%;
    }
    .drop-icon {
      width: 80px;
      height: 80px;
      border-radius: var(--radius-lg);
      background: rgba(47,110,224,.08);
      border: 2px dashed var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 32px;
      color: var(--accent);
      transition: all .2s;
    }
    #drop-zone.drag-over .drop-icon { transform: scale(1.1); background: var(--accent-glow); }
    .drop-title { font-family: var(--font-head); font-size: 22px; font-weight: 800; }
    .drop-sub { color: var(--text2); font-size: 13px; }

    /* ── Status bar ─────────────────────────────────────────────────── */
    #statusbar {
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 0 16px;
      height: 26px;
      background: var(--surface);
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--text3);
    }
    #statusbar .sep { width: 1px; height: 12px; background: var(--border); }
    #status-msg { margin-left: auto; color: var(--green); }

    /* ── Toast ──────────────────────────────────────────────────────── */
    #toast-wrap {
      position: fixed;
      bottom: 40px;
      right: 24px;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
    }
    .toast-item {
      padding: 10px 16px;
      border-radius: 8px;
      background: var(--surface2);
      border: 1px solid var(--border2);
      color: var(--text);
      font-size: 12px;
      font-weight: 500;
      box-shadow: var(--shadow);
      animation: toastIn .25s ease both;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .toast-item.success { border-color: #4ade9a44; }
    .toast-item.success i { color: var(--green); }
    .toast-item.error { border-color: #ff5f6b44; }
    .toast-item.error i { color: var(--red); }
    @keyframes toastIn {
      from { opacity: 0; transform: translateX(20px); }
      to   { opacity: 1; transform: translateX(0); }
    }

    /* ── Drawing canvas ─────────────────────────────────────────────── */
    #draw-canvas {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }
    #draw-canvas.active { pointer-events: all; cursor: crosshair; }

    /* ── Misc ───────────────────────────────────────────────────────── */
    .badge-forge {
      font-size: 10px;
      font-family: var(--font-mono);
      font-weight: 500;
      padding: 2px 8px;
      border-radius: 99px;
      background: rgba(47,110,224,.10);
      color: var(--accent);
      border: 1px solid rgba(47,110,224,.25);
    }
    #file-input { display: none; }

    /* ── Keyboard shortcut badge ─────────────────────────────────── */
    .kbd {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 1px 5px;
      border-radius: 4px;
      background: var(--surface2);
      border: 1px solid var(--border2);
      font-family: var(--font-mono);
      font-size: 10px;
      color: var(--text);
      white-space: nowrap;
      box-shadow: 0 1px 0 var(--border2);
    }

    /* range slider */
    input[type=range] { accent-color: var(--accent); }

    /* ── Shortcuts modal ────────────────────────────────────────── */
    #shortcuts-modal-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.65);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      z-index: 9000;
      align-items: center;
      justify-content: center;
    }
    #shortcuts-modal-backdrop.open { display: flex; }
    #shortcuts-modal {
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 16px;
      box-shadow: 0 24px 80px rgba(0,0,0,.8);
      width: 580px;
      max-width: 95vw;
      max-height: 85vh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      animation: modalIn .2s cubic-bezier(.34,1.56,.64,1) both;
    }
    @keyframes modalIn {
      from { opacity:0; transform: scale(.92) translateY(12px); }
      to   { opacity:1; transform: scale(1)  translateY(0); }
    }
    #shortcuts-modal .modal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 22px 14px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    #shortcuts-modal .modal-title {
      font-family: var(--font-head);
      font-size: 18px;
      font-weight: 800;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 10px;
    }
    #shortcuts-modal .modal-title i { color: var(--accent); font-size: 20px; }
    #shortcuts-modal .modal-close {
      width: 32px; height: 32px;
      border-radius: 8px;
      border: 1px solid var(--border2);
      background: var(--surface2);
      color: var(--text2);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px;
      transition: all .12s;
    }
    #shortcuts-modal .modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); }
    #shortcuts-modal .modal-body {
      padding: 20px 22px;
      overflow-y: auto;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 18px 24px;
    }
    .shortcut-group { display: flex; flex-direction: column; gap: 2px; }
    .shortcut-group-title {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--accent);
      margin-bottom: 6px;
      padding-bottom: 4px;
      border-bottom: 1px solid var(--border);
    }
    .shortcut-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 4px 0;
      border-radius: 5px;
    }
    .shortcut-row:hover { background: var(--surface2); padding: 4px 6px; margin: 0 -6px; }
    .shortcut-desc { font-size: 12px; color: var(--text2); }
    .shortcut-keys { display: flex; gap: 3px; align-items: center; }
    .modal-footer {
      padding: 12px 22px;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-shrink: 0;
    }
    .modal-footer-tip { font-size: 11px; color: var(--text3); }
    /* Shortcut trigger button in topbar */
    #btn-shortcuts {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 5px 10px;
      border-radius: 7px;
      border: 1px solid var(--border2);
      background: var(--surface2);
      color: var(--text2);
      font-family: var(--font-body);
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      transition: all .15s;
    }
    #btn-shortcuts:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
    #btn-shortcuts kbd {
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 4px;
      padding: 0 4px;
      font-size: 10px;
      font-family: var(--font-mono);
      color: var(--text);
      line-height: 1.6;
    }


    /* ── Font selector — custom searchable dropdown ─────────────────── */
    .font-selector-wrap {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 0 4px;
      position: relative;
    }
    .font-selector-wrap label {
      font-size: 11px;
      color: var(--text3);
      white-space: nowrap;
    }
    #font-dropdown-trigger {
      height: 28px;
      padding: 0 10px;
      border-radius: 6px;
      border: 1px solid var(--border2);
      background: var(--surface);
      color: var(--text);
      font-size: 12px;
      font-family: var(--font-body);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 2px;
      min-width: 138px;
      transition: border-color .15s, background .15s;
      user-select: none;
    }
    #font-dropdown-trigger:hover { border-color: var(--accent); background: var(--surface2); }
    #font-dropdown-trigger.open  { border-color: var(--accent); background: var(--surface2); }
    #font-trigger-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* panel */
    #font-picker-panel {
      display: none;
      position: fixed;
      z-index: 9500;
      width: 280px;
      max-height: 420px;
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 10px;
      box-shadow: 0 12px 40px rgba(0,0,0,.5);
      overflow: hidden;
      flex-direction: column;
    }
    #font-picker-panel.open { display: flex; animation: fadeIn .13s ease; }
    @keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }

    /* search */
    #font-picker-search-wrap {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 10px 12px 8px;
      border-bottom: 1px solid var(--border);
    }
    #font-search-icon { color: var(--text3); font-size: 13px; flex-shrink: 0; }
    #font-picker-search {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      color: var(--text);
      font-size: 13px;
      font-family: var(--font-body);
    }
    #font-picker-search::placeholder { color: var(--text3); }
    #font-search-clear {
      background: none; border: none; cursor: pointer;
      color: var(--text3); font-size: 13px; padding: 0 2px;
      display: none;
    }
    #font-search-clear:hover { color: var(--text); }

    /* category chips */
    #font-picker-categories {
      display: flex;
      gap: 5px;
      padding: 8px 10px 6px;
      flex-wrap: wrap;
      border-bottom: 1px solid var(--border);
    }
    .font-cat-chip {
      padding: 2px 9px;
      border-radius: 20px;
      border: 1px solid var(--border2);
      font-size: 10px;
      font-weight: 600;
      letter-spacing: .04em;
      cursor: pointer;
      color: var(--text2);
      background: var(--surface2);
      transition: all .12s;
      user-select: none;
    }
    .font-cat-chip:hover { border-color: var(--accent); color: var(--accent); }
    .font-cat-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

    /* list */
    #font-picker-list {
      overflow-y: auto;
      flex: 1;
      min-height: 0;
      padding: 4px 0;
    }
    #font-picker-list::-webkit-scrollbar { width: 4px; }
    #font-picker-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
    .font-item {
      padding: 7px 14px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      transition: background .1s;
    }
    .font-item:hover  { background: var(--surface2); }
    .font-item.active { background: var(--accent-dim); }
    .font-item-name {
      font-size: 13px;
      color: var(--text);
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .font-item-preview {
      font-size: 15px;
      color: var(--text2);
      flex-shrink: 0;
    }
    .font-item-cat {
      font-size: 9px;
      font-weight: 700;
      letter-spacing: .06em;
      text-transform: uppercase;
      color: var(--text3);
      flex-shrink: 0;
    }
    .font-no-results {
      padding: 24px 14px;
      text-align: center;
      color: var(--text3);
      font-size: 13px;
    }

    .hidden { display: none !important; }

    /* page nav */
    .page-nav {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .page-nav button {
      width: 26px; height: 26px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 5px;
      color: var(--text2);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 13px;
      transition: all .12s;
    }
    .page-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
    .page-nav button:disabled { opacity: .3; cursor: not-allowed; }
    #page-indicator { font-family: var(--font-mono); font-size: 12px; color: var(--text2); }
    /* ── Topbar layout ───────────────────────────────────────────── */
    .topbar-center {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .topbar-right {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }
    .topbar-link {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-family: var(--font-body);
      font-size: 12px;
      font-weight: 600;
      color: var(--text2);
      text-decoration: none;
      padding: 4px 8px;
      border-radius: 6px;
      white-space: nowrap;
      transition: color .15s, background .15s;
    }
    .topbar-link:hover { color: var(--accent); background: var(--accent-dim); }
    .topbar-link i { font-size: 13px; }
