*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

  :root {
    --bg: #0c0f16;
    --surface: #141820;
    --surface-hover: #1a1f2b;
    --surface-active: #222938;
    --border: #242a36;
    --border-active: #2d5a4b;
    --text: #dce3ea;
    --text-muted: #9ba7b6;
    --text-light: #8e99a8;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.18);
    --accent-text: #6ee7b7;
    --primary-gradient: linear-gradient(135deg, #059669, #10b981);
    --danger: #f87171;
    --warning: #fbbf24;
    --radius: 18px;
    --radius-sm: 10px;
    --font: 'Assistant', 'Heebo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  }

  body {
    font-family: var(--font);
    font-size: 100%;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
      radial-gradient(ellipse 80% 60% at 50% 0%, rgba(16, 185, 129, 0.07), transparent),
      radial-gradient(ellipse 40% 50% at 80% 100%, rgba(16, 185, 129, 0.04), transparent);
    direction: rtl;
  }

  .container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.5rem 1rem 0.75rem;
    box-sizing: border-box;
  }

  /* Header & Navigation Bar (Persistent Sticky) */
  .top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(9, 13, 22, 0.94);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
  }

  .system-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.72rem;
    color: var(--text-muted);
  }
  .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
  }
  .status-dot.online { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
  .status-dot.offline { background: var(--danger); }

  .brand {
    text-align: center;
    margin-bottom: 0.45rem;
  }
  .brand svg { width: 24px; height: 24px; margin-bottom: 0.15rem; }
  .brand h1 {
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    margin: 0;
    line-height: 1.2;
  }
  .brand h1 span { color: var(--accent-text); }
  .brand p {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 300;
    margin: 0.1rem 0 0;
  }

  /* Main Card */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
    transition: border-color 0.3s, box-shadow 0.3s;
  }
  .card.active {
    border-color: var(--border-active);
    box-shadow: 0 2px 20px rgba(0,0,0,0.3), 0 0 30px var(--accent-glow);
  }

  /* Optional Metadata Section */
  .metadata-toggle {
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.01);
  }
  .metadata-toggle summary {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s, background 0.2s;
  }
  .metadata-toggle summary:hover {
    color: var(--accent-text);
    background: var(--surface-hover);
  }
  .metadata-body {
    padding: 1.2rem 1.5rem;
    background: var(--surface-hover);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    border-top: 1px solid var(--border);
  }
  .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }
  .form-group.full-width {
    grid-column: 1 / -1;
  }
  .form-group label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
  }
  .form-control {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.8rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
  }
  .form-control:focus {
    border-color: var(--accent);
  }
  :focus-visible {
    outline: 2px solid var(--accent, #0d9488) !important;
    outline-offset: 2px !important;
  }
  .btn:focus-visible, .tab:focus-visible, .modal-close:focus-visible, .drop-zone:focus-visible {
    outline: 2px solid var(--accent, #0d9488) !important;
    outline-offset: 2px !important;
  }

  /* Drop Zone */
  .drop-zone {
    padding: 0.75rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
    border-bottom: 1px solid var(--border);
  }
  .drop-zone:hover { background: var(--surface-hover); }
  .drop-zone.dragover {
    background: var(--surface-hover);
    border-bottom-color: var(--border-active);
  }

  .drop-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    margin-bottom: 0.2rem;
  }
  .drop-icon svg { width: 16px; height: 16px; color: var(--accent); }
  .drop-zone h3 { font-size: 0.92rem; font-weight: 600; margin: 0.1rem 0; }
  .drop-zone p { font-size: 0.75rem; color: var(--text-muted); margin: 0; }

  .file-list {
    list-style: none;
    max-height: 180px;
    overflow-y: auto;
  }
  .file-list:empty { display: none; }
  .file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1.5rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
  }
  .file-list li:last-child { border-bottom: none; }
  .file-list li:hover { background: var(--surface-hover); }
  .file-list .file-size { color: var(--text-muted); font-size: 0.8rem; font-weight: 300; }
  .file-list .file-remove {
    background: transparent; border: none; font-family: inherit; outline: none;
    cursor: pointer; color: var(--text-muted); padding: 3px 8px;
    border-radius: 5px; font-size: 1.1rem; line-height: 1; transition: color 0.2s;
  }
  .file-list .file-remove:hover { color: var(--danger); }
  .file-reorder-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0.2rem 0.45rem;
    line-height: 1;
    transition: all 0.2s;
  }
  .file-reorder-btn:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-active);
  }
  .file-reorder-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
  }

  /* Actions */
  .actions {
    padding: 0.5rem 1rem;
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: wrap;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.42rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
  }
  .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }
  .btn-primary {
    flex: 2;
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 10px rgba(5, 150, 105, 0.25);
  }
  .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 5px 18px rgba(5, 150, 105, 0.35);
    transform: translateY(-1px);
  }
  .btn-primary:active:not(:disabled) { transform: translateY(0); }
  .btn-primary.loading {
    pointer-events: none;
    opacity: 0.85;
  }

  .btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-secondary:hover:not(:disabled) {
    background: var(--surface-active);
    border-color: var(--border-active);
  }

  .btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
  }
  .btn-ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
  }

  /* Progress area */
  .progress-wrap {
    padding: 0.35rem 1rem 0.65rem;
    display: none;
  }
  .progress-wrap.visible { display: block; }

  .progress-bar-track {
    height: 7px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
  }
  .progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #059669, #34d399);
    border-radius: 4px;
    transition: width 0.4s ease;
  }
  .progress-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.35rem;
    gap: 0.5rem;
  }
  .progress-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    min-height: 1.2em;
    flex: 1;
  }
  .progress-pct-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--accent-text);
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 0.05rem 0.45rem;
    border-radius: 4px;
    flex-shrink: 0;
    display: none;
  }

  /* Result Area */
  .result-area {
    padding: 0 1.5rem 1.5rem;
    display: none;
  }
  .result-area.visible { display: block; }

  .result-card {
    background: var(--surface-hover);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.4s ease;
  }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

  .result-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
  }
  .result-icon {
    flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-glow); display: flex; align-items: center; justify-content: center;
  }
  .result-icon svg { width: 22px; height: 22px; color: var(--accent); }
  .result-title h4 { font-size: 0.95rem; font-weight: 600; color: var(--accent-text); }
  .result-title p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

  .download-button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
  }
  .btn-download {
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all 0.2s;
  }
  .btn-download:hover {
    background: var(--surface-active);
    border-color: var(--accent);
    color: var(--accent-text);
  }
  .btn-download.btn-view-report {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    grid-column: 1 / -1;
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  .btn-download.btn-view-report:hover {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  }

  /* Modals & Drawers */
  .modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
  }
  .modal-overlay.open { display: flex; }

  .modal-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
  }
  .modal-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .modal-header h3 { font-size: 1.1rem; color: var(--text); font-weight: 600; }
  .modal-close {
    cursor: pointer; background: transparent; border: none; color: var(--text-muted); font-size: 1.4rem; padding: 0.2rem 0.5rem; border-radius: 6px;
  }
  .modal-close:hover { color: var(--danger); background: var(--surface-hover); }
  .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
  }
  .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    background: var(--surface-hover);
  }

  /* History Drawer */
  .history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .history-item {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s;
  }
  .history-item:hover { border-color: var(--border-active); }
  .history-meta h4 { font-size: 0.95rem; color: var(--text); }
  .history-meta p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
  .history-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

  /* In-App Report Viewer Iframe */
  .report-frame {
    width: 100%;
    height: 72vh;
    border: none;
    background: #fafafa;
    border-radius: 8px;
  }

  .footer {
    text-align: center;
    margin-top: 2.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.6;
  }

  /* Light Theme */
  body.light-theme {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --surface-active: #e2e8f0;
    --border: #cbd5e1;
    --border-active: #10b981;
    --text: #0f172a;
    --text-muted: #475569;
    --text-light: #596579;
    --accent: #059669;
    --accent-glow: rgba(5, 150, 105, 0.15);
    --accent-text: #059669;
    --primary-gradient: linear-gradient(135deg, #059669, #10b981);
  }

  .top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .icon-btn:hover {
    background: var(--surface-hover);
    color: var(--accent-text);
    border-color: var(--border-active);
  }

  .workspace-cache-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1;
  }
  .workspace-cache-btn:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-hover);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
  }
  .workspace-cache-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  /* Live Progress Stepper */
  .stepper-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    padding: 0 0.5rem;
    gap: 0.3rem;
  }
  .step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    text-align: center;
  }
  .step-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-hover);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
  }
  .step-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s ease;
  }
  .step-item.active .step-circle {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulse 1.5s infinite;
  }
  .step-item.active .step-label {
    color: var(--accent-text);
    font-weight: 600;
  }
  .step-item.completed .step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
  }
  .step-item.completed .step-label {
    color: var(--text);
  }
  .step-line {
    height: 2px;
    background: var(--border);
    flex: 1;
    margin-bottom: 1.2rem;
    transition: background 0.3s ease;
  }
  .step-line.completed {
    background: var(--accent);
  }
  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
  }

  /* Interactive Wait Hub (Trivia & Quiz) - Sized for 2 full lines of facts without truncation */
  .interactive-panel {
    margin-top: 0.6rem;
    background: rgba(16, 185, 129, 0.04);
    border: 1px dashed var(--border-active);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 94px;
    max-height: 94px;
    box-sizing: border-box;
    transition: height 0.25s ease, max-height 0.25s ease;
    animation: fadeIn 0.4s ease;
  }
  .interactive-panel.collapsed {
    height: 26px !important;
    max-height: 26px !important;
  }
  .interactive-panel.collapsed .panel-body {
    display: none !important;
  }
  .panel-tabs {
    display: flex;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border);
    height: 26px;
    box-sizing: border-box;
  }
  .panel-tab {
    flex: 1;
    padding: 0 0.6rem;
    height: 26px;
    line-height: 26px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .panel-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.02);
  }
  .panel-tab.active {
    color: var(--accent-text);
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
    font-weight: 600;
  }
  .panel-body {
    padding: 0.35rem 0.65rem;
    height: 68px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .trivia-banner-inner {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.8rem;
    line-height: 1.35;
    position: relative;
    height: 100%;
  }
  .trivia-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    line-height: 1;
    transition: transform 0.25s ease;
  }
  .trivia-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    transition: opacity 0.25s ease;
  }
  .trivia-content.fade-out { opacity: 0; }
  .trivia-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.15rem;
    gap: 0.4rem;
  }
  .trivia-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.08rem 0.45rem;
    border-radius: 9999px;
    letter-spacing: 0.02em;
    user-select: none;
    line-height: 1.2;
    transition: all 0.25s ease;
  }
  .trivia-badge.category-chuck {
    background: rgba(245, 158, 11, 0.14);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
  }
  .trivia-badge.category-tat {
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
  }
  .trivia-badge.category-scors {
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
  }
  .trivia-badge.category-quote {
    background: rgba(168, 85, 247, 0.14);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
  }
  .trivia-badge.category-humor {
    background: rgba(236, 72, 153, 0.14);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.35);
  }
  .trivia-next-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    font-size: 0.68rem;
    font-family: inherit;
    padding: 0.1rem 0.45rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    line-height: 1.2;
  }
  .trivia-next-btn:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-hover);
  }
  .trivia-text-wrapper {
    font-size: 0.78rem;
    line-height: 1.38;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.85em;
  }
  .trivia-text-wrapper strong {
    color: var(--accent-text);
  }

  /* Mindful Breathing Pacer */
  .breathing-toggle {
    margin-top: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
  }
  .breathing-toggle summary {
    padding: 0.55rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
  }
  .breathing-container {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
  }
  .breathing-circle-outer {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .breathing-circle-inner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    opacity: 0.6;
    animation: breathe 16s infinite ease-in-out;
  }
  .breathing-text {
    position: relative;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    text-align: center;
    pointer-events: none;
  }
  .breathing-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    text-align: center;
  }
  @keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    25% { transform: scale(2.4); opacity: 0.85; }
    50% { transform: scale(2.4); opacity: 0.85; }
    75% { transform: scale(1); opacity: 0.4; }
  }

  /* Toast Notification */
  .toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-active);
    color: var(--text);
    border: 1px solid var(--accent);
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    pointer-events: none;
  }
  .toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }

  /* =========================================================================
     Responsive Mobile Styles for Index / App View
     ========================================================================= */
  @media (max-width: 768px) {
    .container {
      padding: 1.25rem 0.85rem 3.5rem;
    }
    .brand {
      margin-bottom: 1.25rem;
    }
    .brand svg {
      width: 38px;
      height: 38px;
    }
    .brand h1 {
      font-size: 1.4rem;
    }
    .brand p {
      font-size: 0.82rem;
    }
    .system-status-pill {
      font-size: 0.72rem;
      padding: 0.35rem 0.65rem;
      line-height: 1.35;
      text-align: center;
    }

    /* Metadata Form */
    .metadata-toggle summary {
      padding: 0.75rem 1rem;
      font-size: 0.82rem;
    }
    .metadata-body {
      padding: 1rem;
      grid-template-columns: 1fr;
      gap: 0.75rem;
    }

    /* Drop Zone */
    .drop-zone {
      padding: 1.5rem 1rem;
    }
    .drop-icon {
      width: 48px;
      height: 48px;
      margin-bottom: 0.75rem;
    }
    .drop-icon svg {
      width: 22px;
      height: 22px;
    }
    .drop-zone h3 {
      font-size: 0.95rem;
    }
    .drop-zone p {
      font-size: 0.78rem;
    }

    /* Actions Bar */
    .actions {
      padding: 1rem;
      gap: 0.5rem;
      flex-direction: column;
    }
    .actions .btn {
      width: 100%;
      flex: 1 1 100%;
      padding: 0.65rem 1rem;
      font-size: 0.88rem;
      justify-content: center;
    }
    .force-refresh-label {
      width: 100%;
      justify-content: center;
      padding: 0.45rem 0.65rem;
      font-size: 0.78rem;
    }

    /* Stepper */
    .stepper-wrap {
      padding: 0;
      gap: 0.15rem;
      margin-bottom: 0.9rem;
    }
    .step-circle {
      width: 22px;
      height: 22px;
      font-size: 0.68rem;
    }
    .step-label {
      font-size: 0.62rem;
      max-width: 58px;
      word-break: break-word;
      line-height: 1.15;
    }
    .step-line {
      margin-bottom: 1rem;
    }

    /* Interactive Wait Panel */
    .interactive-panel {
      margin-top: 0.75rem;
      height: auto;
      min-height: 94px;
      max-height: none;
    }
    .panel-tab {
      padding: 0.45rem 0.5rem;
      font-size: 0.75rem;
    }
    .panel-body {
      padding: 0.4rem 0.65rem;
      height: auto;
      min-height: 68px;
    }
    .trivia-banner-inner {
      gap: 0.5rem;
    }
    .trivia-icon {
      font-size: 1.1rem;
    }
    .trivia-text-wrapper {
      font-size: 0.8rem;
      line-height: 1.38;
      max-height: none;
      -webkit-line-clamp: 2;
    }

    /* Result Card & Buttons */
    .result-area {
      padding: 0 1rem 1rem;
    }
    .result-card {
      padding: 1rem;
    }
    .result-icon {
      width: 36px;
      height: 36px;
    }
    .result-icon svg {
      width: 18px;
      height: 18px;
    }
    .result-title h4 {
      font-size: 0.88rem;
    }
    .download-button-grid {
      grid-template-columns: 1fr;
      gap: 0.5rem;
    }
    .btn-download {
      padding: 0.6rem 0.8rem;
      font-size: 0.82rem;
    }

    /* Modals */
    .modal-overlay {
      padding: 0.5rem;
    }
    .modal-container {
      max-height: 94vh;
      border-radius: 14px;
    }
    .modal-header {
      padding: 0.85rem 1rem;
    }
    .modal-header h3 {
      font-size: 0.95rem;
    }
    .modal-body {
      padding: 0.75rem;
    }
    .modal-footer {
      padding: 0.75rem 1rem;
      flex-direction: column;
      gap: 0.4rem;
    }
    .modal-footer .btn {
      width: 100%;
      justify-content: center;
      padding: 0.6rem 0.8rem;
      font-size: 0.84rem;
    }
    .report-frame {
      height: 68vh;
    }
    #ocrEditTextarea {
      height: 36vh;
      font-size: 0.88rem;
      padding: 0.75rem;
    }
    .ocr-toolbar {
      gap: 0.3rem;
    }
    .ocr-toolbar .file-reorder-btn {
      font-size: 0.68rem;
      padding: 0.2rem 0.4rem;
    }
  }

  @media (max-width: 420px) {
    .container {
      padding: 0.85rem 0.5rem 3rem;
    }
    .brand h1 {
      font-size: 1.25rem;
    }
    .step-label {
      font-size: 0.58rem;
      max-width: 48px;
    }
  }
