:root {
      --primary:        #6b21a8;
      --primary-light:  #9333ea;
      --primary-dark:   #4c1d95;
      --accent:         #a855f7;
      --accent-soft:    rgba(168, 85, 247, 0.12);
      --accent-glow:    rgba(168, 85, 247, 0.25);

      --bg:             #faf5ff;
      --surface:        #ffffff;
      --surface-2:      #f3e8ff;
      --border:         #e9d5ff;
      --border-strong:  #c084fc;

      --text-primary:   #3b0764;
      --text-secondary: #7c3aed;
      --text-muted:     #a78bfa;

      --toolbar-h: 68px;
      --radius: 12px;
      --shadow-sm: 0 1px 3px rgba(109,40,217,.08), 0 1px 2px rgba(109,40,217,.06);
      --shadow-md: 0 4px 16px rgba(109,40,217,.12), 0 2px 6px rgba(109,40,217,.08);
      --shadow-lg: 0 8px 32px rgba(109,40,217,.15), 0 4px 12px rgba(109,40,217,.10);
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    html, body {
      font-family: 'Cairo', Tahoma, sans-serif;
      background: var(--bg);
      height: 100%;
      overflow: hidden;
    }

    /* ─── Toolbar ─── */
    .toolbar {
      position: sticky;
      top: 0;
      z-index: 300;
      height: var(--toolbar-h);
      background: var(--surface);
      border-bottom: 1.5px solid var(--border);
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0 20px;
      box-shadow: var(--shadow-sm);
    }

    /* Subtle top accent stripe */
    .toolbar::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 3px;
      background: linear-gradient(90deg, var(--primary-dark), var(--accent), var(--primary-light));
      border-radius: 0 0 2px 2px;
    }

    /* Brand badge */
    .brand {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 14px 6px 10px;
      background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
      border-radius: 10px;
      box-shadow: 0 2px 10px rgba(109,40,217,.35);
      text-decoration: none;
      flex-shrink: 0;
      transition: box-shadow .2s, transform .2s;
    }
    .brand:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(109,40,217,.45); }
    .brand-logo {
      width: 28px; height: 28px;
      background: rgba(255,255,255,.2);
      border-radius: 6px;
      display: flex; align-items: center; justify-content: center;
      color: #fff; font-size: 13px;
    }
    .brand-text { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .5px; }

    /* Divider */
    .divider {
      width: 1px;
      height: 32px;
      background: var(--border);
      flex-shrink: 0;
    }

    /* Title area */
    .title-wrap {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      overflow: hidden;
    }
    .file-icon {
      width: 38px; height: 38px;
      border-radius: 10px;
      background: linear-gradient(135deg, var(--primary), var(--accent));
      display: flex; align-items: center; justify-content: center;
      color: #fff; font-size: 15px;
      box-shadow: 0 2px 10px var(--accent-glow);
      flex-shrink: 0;
    }
    .title-meta { min-width: 0; }
    .doc-label {
      font-size: 10px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: .8px;
    }
    .doc-title {
      color: var(--text-primary);
      font-size: 14px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Actions */
    .actions { display: flex; gap: 8px; flex-shrink: 0; }

    .tb-btn {
      display: flex; align-items: center; gap: 7px;
      background: var(--surface-2);
      color: var(--primary);
      border: 1.5px solid var(--border);
      padding: 8px 16px;
      border-radius: var(--radius);
      cursor: pointer;
      font-size: 13px;
      font-family: 'Cairo', sans-serif;
      font-weight: 600;
      transition: all .18s;
      white-space: nowrap;
      box-shadow: var(--shadow-sm);
    }
    .tb-btn:hover {
      background: var(--accent-soft);
      border-color: var(--border-strong);
      color: var(--primary-dark);
      box-shadow: var(--shadow-md);
      transform: translateY(-1px);
    }
    .tb-btn:active { transform: translateY(0); }

    .tb-btn.primary {
      background: linear-gradient(135deg, var(--primary), var(--accent));
      border-color: transparent;
      color: #fff;
      box-shadow: 0 3px 12px var(--accent-glow);
    }
    .tb-btn.primary:hover {
      background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
      color: #fff;
      box-shadow: 0 5px 18px var(--accent-glow);
    }

    /* Keyboard hint badge */
    .kbd {
      display: inline-flex; align-items: center;
      background: rgba(255,255,255,.25);
      border: 1px solid rgba(255,255,255,.35);
      border-radius: 4px;
      padding: 1px 5px;
      font-size: 10px;
      font-family: monospace;
      letter-spacing: .5px;
    }

    /* ─── Viewer ─── */
    #viewerContainer {
      position: relative;
      height: calc(100vh - var(--toolbar-h));
      width: 100%;
      background: var(--bg);
    }

    #pdfFrame {
      width: 100%;
      height: 100%;
      border: none;
      display: block;
    }

    /* ─── Loading ─── */
    #loadingScreen {
      position: absolute; inset: 0;
      background: var(--bg);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 20px;
      transition: opacity .4s;
      z-index: 10;
    }
    #loadingScreen.hidden { opacity: 0; pointer-events: none; }

    .loader-icon {
      width: 72px; height: 72px;
      border-radius: 18px;
      background: linear-gradient(135deg, var(--primary), var(--accent));
      display: flex; align-items: center; justify-content: center;
      color: #fff; font-size: 28px;
      box-shadow: 0 8px 28px var(--accent-glow);
      animation: pulse 1.8s ease-in-out infinite;
    }
    @keyframes pulse {
      0%, 100% { transform: scale(1);   box-shadow: 0 8px 28px var(--accent-glow); }
      50%       { transform: scale(1.06); box-shadow: 0 12px 36px rgba(168,85,247,.4); }
    }

    .loader-bar {
      width: 200px; height: 4px;
      background: var(--border);
      border-radius: 4px;
      overflow: hidden;
    }
    .loader-bar-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--primary), var(--accent));
      border-radius: 4px;
      animation: load 1.6s ease-in-out infinite;
    }
    @keyframes load {
      0%   { width: 0%;   margin-right: 100%; }
      50%  { width: 60%;  margin-right: 20%; }
      100% { width: 0%;   margin-right: 100%; }
    }

    .loader-text {
      color: var(--text-secondary);
      font-size: 14px;
      font-weight: 600;
    }

    /* ─── Print styles ─── */
    @media print {
      .toolbar { display: none !important; }
      #viewerContainer { height: 100vh !important; }
      body { overflow: auto !important; }
      #loadingScreen { display: none !important; }
    }