* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { touch-action: manipulation; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f5f6f8; color: #0f172a; min-height: 100vh; font-size: 14px; }
.app { touch-action: pan-y; }
#auth-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); z-index: 1000; }
.auth-card { background: #fff; border-radius: 12px; padding: 40px; width: 400px; max-width: 94vw; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { font-size: 18px; color: #1e3a5f; letter-spacing: 1px; }
.auth-header p { font-size: 13px; color: #64748b; margin-top: 4px; }
#auth-content .form-stack { display: flex; flex-direction: column; gap: 12px; }
#auth-content input { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; outline: none; }
#auth-content input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
#auth-content .btn-primary { width: 100%; padding: 10px; font-size: 15px; margin-top: 4px; }
#auth-content .form-error { color: #dc2626; font-size: 13px; text-align: center; }
body.role-estudante { --accent: #f59e0b; --accent-bg: #fef3c7; }
body.role-pesquisador { --accent: #22d3ee; --accent-bg: #ecfeff; }
body.role-admin { --accent: #2563eb; --accent-bg: #eff6ff; }
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }

/* ===== Header ===== */
header { padding: 4px 10px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 4px; }
header h1 { font-size: 13px; color: #0f172a; text-transform: uppercase; letter-spacing: 1px; text-align: center; white-space: nowrap; margin: 0 6px; flex: 1 1 auto; min-width: 200px; }
.header-left { display: flex; align-items: center; gap: 4px; flex-shrink: 0; border-right: 1px solid #e2e8f0; padding-right: 8px; }
.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; border-left: 1px solid #e2e8f0; padding-left: 8px; }
.h-shortcut { font-size: 10px; color: #64748b; white-space: nowrap; }
.h-shortcut kbd { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px; padding: 1px 3px; font-size: 9px; color: #334155; font-family: "SF Mono", "Cascadia Code", monospace; margin: 0 1px; }
.h-tips { font-size: 10px; color: #64748b; white-space: nowrap; padding: 4px 0 4px 6px; border-left: 1px solid #cbd5e1; margin-left: 2px; display: inline-flex; align-items: center; gap: 2px; }
.h-tips kbd { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px; padding: 1px 3px; font-size: 9px; color: #334155; font-family: "SF Mono", "Cascadia Code", monospace; }
.header-group { display: flex; align-items: center; gap: 3px; padding: 2px 4px; border: 1px solid #e2e8f0; border-radius: 5px; background: #ffffff; }
.header-group label { font-size: 10px; color: #475569; text-transform: uppercase; letter-spacing: .5px; }
.header-group .btn-primary { padding: 2px 6px; font-size: 11px; }
.header-group .btn-secondary { padding: 2px 5px; font-size: 11px; }
.admin-dropdown { position: fixed; z-index: 99999; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 230px; max-width: min(300px, 94vw); box-shadow: 0 12px 32px rgba(0,0,0,0.18); }
.admin-dropdown .btn-secondary { width: 100%; text-align: left; padding: 9px 12px; font-size: 13.5px; font-weight: 500; color: #1e293b; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; white-space: nowrap; transition: all 0.15s ease; cursor: pointer; }
.admin-dropdown .btn-secondary:hover { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
#admin-menu-wrap { position: relative; }
#btn-admin-menu { background: #e2e8f0; color: #334155; }

/* ===== Buttons ===== */
.btn-primary { background: #2563eb; color: #fff; border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #e2e8f0; color: #334155; border: none; padding: 3px 8px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { background: #e2e8f0; color: #334155; border: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: #cbd5e1; }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-icon { background: none; border: none; color: #64748b; cursor: pointer; font-size: 16px; padding: 4px; }
.btn-icon:hover { color: #0f172a; }

/* ===== Search bar ===== */
.search-bar { padding: 10px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: grid; grid-template-columns: 1.4fr 1fr; gap: 0 16px; }
.search-bar input[type="text"] { padding: 8px 14px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; }
.search-bar input[type="text"]::placeholder { color: #94a3b8; }
.search-left { display: flex; flex-direction: column; gap: 6px; justify-content: flex-start; }
.search-right { border-left: 1px solid #e2e8f0; padding-left: 16px; display: flex; flex-direction: column; gap: 4px; justify-content: flex-end; }
.search-input-row { display: flex; gap: 6px; align-items: center; }
.search-input-row #search-input { flex: 1; min-width: 0; }
.search-input-row #btn-search { flex-shrink: 0; }
.search-input-row #btn-clear { flex-shrink: 0; }
.search-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.search-opts label { font-size: 12px; color: #475569; cursor: pointer; padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 4px; user-select: none; }
.search-opts label:has(input:checked) { background: #dbeafe; color: #2563eb; border-color: #93c5fd; }
.search-opts input { display: none; }

/* ===== Scope input (autocomplete "Buscar em") ===== */
.scope-input-wrap { position: relative; min-width: 200px; display: flex; flex-direction: column; gap: 4px; z-index: 600; }
.scope-chips { display: none; flex-wrap: wrap; gap: 3px; align-items: center; }
.scope-chips:not(:empty) { display: flex; }
.scope-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 3px 1px 5px; font-size: 10px; border-radius: 3px; cursor: default; user-select: none; max-width: 160px; background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1; }
.scope-chip-icon { display: none; }
.scope-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.scope-chip-x { background: none; border: none; color: #64748b; cursor: pointer; font-size: 10px; padding: 0 1px; opacity: .5; }
.scope-chip-x:hover { opacity: 1; color: #f87171; }
.scope-chip-clear { background: none; border: none; color: #64748b; font-size: 9px; padding: 1px 4px; cursor: pointer; }
.scope-chip-clear:hover { color: #f87171; }
.scope-input-wrap input { width: 100%; padding: 8px 12px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 13px; }
.scope-input-wrap input::placeholder { color: #94a3b8; font-size: 12px; }
.scope-input-wrap input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); }
.scope-dropdown { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 601; background: #fef08a; border: 2px solid #f59e0b; border-radius: 6px; max-height: 360px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.15); color: #000; }
.scope-dropdown .scope-item-row { display: flex; align-items: center; padding: 6px 12px; font-size: 13px; color: #1e293b; cursor: pointer; border-bottom: 1px solid #fde68a; }
.scope-dropdown .scope-item-row:last-child { border-bottom: none; }
.scope-dropdown .scope-item-row:hover, .scope-dropdown .scope-item-row.highlighted { background: #fde68a; color: #000; }
.scope-dropdown .scope-item-row.selected { background: #fbbf24; }
.scope-dropdown .scope-item-row.selected .scope-label { color: #1e293b; font-weight: 700; }
.scope-dropdown .scope-item-row input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none; }
.scope-dropdown .scope-icon { font-size: 14px; flex-shrink: 0; margin-right: 0; }
.scope-dropdown .scope-label { width: auto; flex: 1; min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-dropdown .scope-sub { font-size: 11px; color: #92400e; flex-shrink: 0; margin-left: auto; padding-right: 12px; }
.scope-dropdown .scope-empty { padding: 12px; font-size: 12px; color: #92400e; text-align: center; }
.scope-dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #fde68a; border-bottom: 1px solid #f59e0b; position: sticky; top: 0; z-index: 1; color: #92400e; }
.scope-close-btn { background: none; border: none; cursor: pointer; font-size: 16px; padding: 2px 8px; color: #92400e; border-radius: 4px; line-height: 1; }
.scope-close-btn:hover { background: rgba(0,0,0,0.1); }
.scope-dropdown-hint { padding: 8px 12px; font-size: 11px; color: #92400e; text-align: center; border-top: 1px solid #f59e0b; }
.scope-toggle { font-size: 10px; flex-shrink: 0; width: 14px; cursor: pointer; color: #b45309; user-select: none; }
.scope-toggle:hover { color: #7c2d12; }
.scope-toggle-spacer { visibility: hidden; }
.scope-child-row { padding-left: 28px !important; }

/* ===== Main layout ===== */
.main { display: grid; grid-template-columns: 380px 1fr; overflow: hidden; }

/* ===== Results panel ===== */
.results-panel { overflow-y: auto; border-right: 1px solid #e2e8f0; }
.results-header { padding: 12px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 5; }
.results-header h3 { font-size: 12px; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-header .meta { font-size: 12px; color: #475569; margin-top: 4px; }
.term-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.term-chip-hidden { display: none; }
.term-chip { background: #fef08a; color: #92400e; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.term-toggle { color: #2563eb; cursor: pointer; font-size: 12px; margin-left: 4px; user-select: none; }
.term-toggle:hover { text-decoration: underline; }
.folder-chip { background: #eff6ff; color: #2563eb; padding: 2px 8px; border-radius: 4px; font-size: 12px; border: 1px solid #2563eb; }

.result-file-group { border-bottom: 1px solid #e2e8f0; }
.result-file-header { display: flex; align-items: center; gap: 8px; padding: 8px 20px; cursor: pointer; user-select: none; }
.result-file-header:hover { background: #f1f5f9; }
.result-file-toggle { font-size: 10px; color: #64748b; flex-shrink: 0; width: 14px; }
.result-file-name { font-weight: 600; color: #0f172a; font-size: 13px; }
.result-file-summary { font-size: 11px; color: #64748b; margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.result-file-pages.collapsed { display: none; }
.result-page { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0 8px 12px; cursor: pointer; border-radius: 4px; border-bottom: 1px solid #e2e8f0; }
.result-page:last-child { border-bottom: none; }
.result-page:hover { background: #f1f5f9; }
.result-page-meta { display: flex; flex-direction: column; align-items: center; min-width: 44px; padding-top: 2px; flex-shrink: 0; border-right: 1px solid #e2e8f0; margin-right: 8px; padding-right: 8px; }
.result-page-num { font-size: 12px; color: #64748b; white-space: nowrap; line-height: 1.4; }
.result-page-count { font-size: 10px; color: #64748b; white-space: nowrap; line-height: 1.4; }
.result-page-snippet-wrap { flex: 1; min-width: 0; }
.result-page-snippet { font-family: "SF Mono", "Cascadia Code", monospace; font-size: 12px; color: #334155; line-height: 1.5; white-space: pre-wrap; margin-bottom: 6px; }
.result-page-snippet:last-child { margin-bottom: 0; }
.result-page-snippet .hl { background: #fef08a; color: #92400e; padding: 0 2px; border-radius: 2px; font-weight: 600; }
.result-jump-input { width: 24px; padding: 1px 0; border: 1px solid #cbd5e1; border-radius: 4px; text-align: center; font-size: 11px; color: #334155; box-sizing: content-box; background: #f8fafc; }
.result-jump-input::-webkit-inner-spin-button, .result-jump-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#result-pos { white-space: nowrap; font-size: 11px; color: #475569; display: flex; align-items: center; gap: 2px; }

.results-empty { padding: 40px 20px; text-align: center; color: #64748b; }

/* ===== Viewer panel ===== */
.viewer-panel { display: flex; flex-direction: column; overflow: hidden; }
.viewer-toolbar { padding: 8px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.viewer-title { font-size: 13px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.viewer-controls { display: flex; gap: 4px; }
.viewer-canvas-wrap { flex: 1; overflow: auto; padding: 16px; background: #f1f5f9; }
.viewer-canvas { box-shadow: 0 4px 24px rgba(0,0,0,.15); display: block; }
.viewer-page .hl-box { position: absolute; background: rgba(254, 240, 138, 0.2); border: 1.5px solid rgba(245, 158, 11, 0.35); border-radius: 2px; pointer-events: none; }
.viewer-loading { padding: 40px; text-align: center; color: #64748b; }
.viewer-empty { padding: 40px; text-align: center; color: #64748b; font-size: 14px; line-height: 1.6; }

/* ===== Modals ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 24px; min-width: 340px; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.1); }
.modal h2 { font-size: 16px; color: #0f172a; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ===== Forms ===== */
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack input, .form-stack select { padding: 8px 12px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; }
.form-stack input::placeholder { color: #94a3b8; }
.form-error { color: #ef4444; font-size: 13px; min-height: 18px; }
.form-label { font-size: 12px; color: #475569; text-transform: uppercase; letter-spacing: .5px; }
.export-row { width: 100%; text-align: left; padding: 6px 10px; }
.export-section { display: contents; }
.export-section-name { font-size: 12px; color: #475569; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 4px 0; }
.export-btn { padding: 6px 10px; text-align: center; }
.export-grid { display: grid; grid-template-columns: 80px 1fr 1fr 1fr; gap: 4px 8px; align-items: center; }

/* ===== Upload ===== */
.upload-list { margin-top: 10px; }
.upload-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.upload-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.upload-name { font-size: 12px; color: #0f172a; min-width: 120px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.upload-bar-fill { height: 100%; background: #2563eb; width: 0; transition: width .3s; border-radius: 3px; }
.upload-bar-fill.ok { background: #22c55e; }
.upload-bar-fill.err { background: #ef4444; }
.upload-status { font-size: 11px; color: #475569; min-width: 80px; text-align: right; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 20px; right: 20px; padding: 10px 18px; border-radius: 8px; font-size: 13px; color: #fff; z-index: 2000; animation: toastIn .3s ease, toastOut .3s ease 3s forwards; }
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #3b82f6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ===== User chip ===== */
#user-chip { display: flex; align-items: center; gap: 6px; }
.user-chip-name { font-size: 13px; color: #0f172a; white-space: nowrap; }

/* ===== Stats ===== */
#stats { font-size: 12px; color: #64748b; grid-column: 1 / -1; }
#scope-panel { grid-column: 1 / -1; }

/* ===== Folder grouping ===== */
.result-folder { padding: 6px 20px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; }
.result-folder-name { font-weight: 700; color: #2563eb; font-size: 13px; }

/* ===== Scope filter ===== */
.scope-group { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }
.scope-group select { padding: 3px 6px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 12px; }
.scope-toggle { font-size: 11px; color: #64748b; cursor: pointer; padding: 2px 8px; user-select: none; }
.scope-toggle:hover { color: #2563eb; }
.scope-panel { display: none; flex-direction: column; gap: 2px; padding: 6px 20px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; max-height: 200px; overflow-y: auto; }
.scope-panel.open { display: flex; }
.scope-panel .scope-item { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #334155; cursor: pointer; padding: 3px 8px; border: 1px solid #e2e8f0; border-radius: 4px; user-select: none; }
.scope-panel .scope-item:has(input:checked) { background: #eff6ff; border-color: #2563eb; color: #2563eb; }
.scope-panel .scope-item input { display: none; }
.scope-panel .scope-folder-header { font-size: 12px; font-weight: 600; color: #2563eb; cursor: pointer; padding: 4px 8px; border-radius: 4px; user-select: none; }
.scope-panel .scope-folder-header:hover { background: #e2e8f0; }
.scope-panel .scope-folder-files { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 4px 20px; }

/* ===== Notes ===== */
.notes-section { border-top: 1px solid #e2e8f0; padding: 12px 16px; background: #f8fafc; }
.notes-header { font-size: 13px; font-weight: 600; color: #0f172a; margin-bottom: 8px; }
.notes-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.notes-empty { font-size: 12px; color: #64748b; padding: 8px 0; }
.notes-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 8px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; }
.notes-item-text { font-size: 13px; color: #334155; line-height: 1.4; flex: 1; white-space: pre-wrap; }
.notes-item-actions { display: flex; gap: 2px; flex-shrink: 0; }
.notes-edit, .notes-del { font-size: 13px; padding: 2px 4px; cursor: pointer; background: none; border: none; border-radius: 4px; }
.notes-edit:hover, .notes-del:hover { background: #e2e8f0; }
.notes-input-area { display: flex; gap: 8px; }
.notes-textarea { flex: 1; padding: 8px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; min-height: 48px; }
.notes-textarea::placeholder { color: #94a3b8; }
.notes-add-btn { align-self: flex-start; white-space: nowrap; }

/* ===== History dropdown ===== */
.search-bar { position: relative; }
.history-dropdown { display: none; position: absolute; top: 100%; left: 20px; right: 20px; z-index: 500; margin-top: -4px; }

/* ===== Role badge ===== */
.role-badge { font-size: 10px; padding: 1px 8px; border-radius: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-right: 6px; line-height: 18px; }
.role-badge-admin { background: #2563eb; color: #fff; }
.role-badge-pesquisador { background: #22d3ee; color: #0f172a; }
.role-badge-estudante { background: #f59e0b; color: #fff; }

/* ===== Estudante: full-width results, no viewer ===== */
body.role-estudante .main { grid-template-columns: 1fr; }
body.role-estudante .viewer-panel { display: none; }
body.role-estudante .result-page-snippet .hl { background: #fef3c7; color: #92400e; }
body.role-estudante .result-page-snippet { border-left-color: #f59e0b; }
body.role-estudante .btn-primary { background: #f59e0b; color: #fff; }
body.role-estudante .btn-primary:hover { background: #d97706; }
body.role-estudante .search-opts label:has(input:checked) { background: #fef3c7; border-color: #f59e0b; color: #92400e; }

/* ===== Mobile ===== */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .viewer-panel { display: none; }
  .viewer-panel.open { display: flex; }
  .results-panel.open { display: none; }
  .search-bar { display: flex; flex-wrap: wrap; padding: 8px 10px; gap: 4px; }
  .search-left { width: 100%; }
  .search-right { width: 100%; border-left: none; padding-left: 0; }
  .search-input-row #search-input { min-width: 120px; flex: 1; }
  .scope-input-wrap { min-width: 0; flex-direction: column; }
  #scope-input { min-width: 0; max-width: 100%; width: 100%; }
  .scope-input-wrap input { width: 100%; }
  .search-opts { flex-wrap: nowrap; overflow-x: auto; }
  .search-opts label { font-size: 10px; padding: 2px 5px; white-space: nowrap; }
  .scope-dropdown { font-size: 12px; max-height: 260px; }
  .header-group { padding: 2px 4px; }
  header h1 { font-size: 11px; }
  .h-shortcut { display: none; }
  .h-tips { display: none; }
  .header-left { border-right: none; padding-right: 0; }
  .header-right { border-left: none; padding-left: 0; }
  .viewer-canvas-wrap { padding: 8px; }
  .viewer-title { font-size: 11px; }
}
@media (max-width: 480px) {
  header { flex-wrap: wrap; padding: 4px 6px; }
  header h1 { font-size: 10px; width: 100%; order: -1; margin: 2px 0; }
  .header-left { width: auto; }
  .header-right { flex-wrap: wrap; justify-content: flex-end; }
  .search-bar { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 3px; padding: 4px 6px; }
  .search-left { width: 100%; }
  .search-right { width: 100%; border-left: none; padding-left: 0; }
  .search-input-row #search-input { flex: 1; min-width: 50px; font-size: 12px; padding: 5px 8px; }
  .scope-input-wrap { min-width: 0; flex-direction: column; }
  .scope-chips { gap: 2px; }
  .scope-chip { font-size: 9px; padding: 1px 2px 1px 4px; max-width: 110px; }
  .scope-chip-label { max-width: 90px; }
  .scope-chip-x { font-size: 8px; }
  .scope-chip-clear { font-size: 8px; padding: 0 3px; }
  #scope-input, .scope-input-wrap input { padding: 5px 8px; font-size: 12px; }
  #btn-search { width: auto; padding: 5px 8px; font-size: 11px; white-space: nowrap; }
  .search-opts { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  .search-opts label { font-size: 9px; padding: 2px 4px; white-space: nowrap; }
  .btn-sm { padding: 4px 8px; font-size: 11px; min-height: 28px; }
  .btn-primary { padding: 4px 10px; font-size: 12px; min-height: 32px; }
  .btn-secondary { padding: 4px 8px; font-size: 11px; min-height: 28px; }
  .results-header { padding: 8px 10px; }
  .results-header h3 { font-size: 12px; }
  .results-actions .btn-sm { font-size: 9px; padding: 2px 4px; }
  .result-file-header { padding: 6px 10px; }
  .result-file-name { font-size: 12px; }
  .result-file-summary { font-size: 10px; }
  .result-page { padding: 8px 6px; gap: 4px; }
  .result-page-meta { min-width: 34px; padding-right: 4px; margin-right: 4px; }
  .result-page-num { font-size: 11px; }
  .result-page-count { font-size: 9px; }
  .result-page-snippet { font-size: 11px; }
  .modal { min-width: 0; max-width: 96vw; margin: 0 2vw; padding: 16px; }
}
@media (max-width: 480px) and (orientation: landscape) {
  .main { grid-template-columns: 1fr 1fr; }
  .viewer-panel.open { display: flex; }
  .results-panel.open { display: none; }
}

/* ===== Shortcuts bar ===== */
.shortcuts-bar { padding: 4px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 14px; font-size: 11px; color: #475569; flex-wrap: wrap; }
.shortcuts-bar .grow { flex: 1; }
.shortcuts-bar kbd { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px; padding: 1px 5px; font-size: 11px; color: #334155; font-family: "SF Mono", "Cascadia Code", monospace; margin: 0 1px; }
.history-list { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 0 0 8px 8px; max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.history-item { padding: 8px 14px; font-size: 13px; color: #334155; cursor: pointer; border-bottom: 1px solid #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item:hover { background: #f1f5f9; color: #0f172a; }
.history-item:last-child { border-bottom: none; }
.history-clear { padding: 8px 14px; font-size: 12px; color: #475569; cursor: pointer; text-align: center; border-top: 1px solid #e2e8f0; }
.history-clear:hover { color: #f87171; background: #f1f5f9; }

/* ===== Clear search button ===== */
.search-clear { background: none; border: none; color: #64748b; cursor: pointer; font-size: 16px; padding: 4px 8px; }
.search-clear:hover { color: #0f172a; }

/* ===== Results actions (export + nav) ===== */
.results-actions { display: flex; align-items: center; gap: 3px; margin-top: 6px; flex-wrap: nowrap; overflow-x: auto; }
.results-actions .btn-sm { font-size: 11px; padding: 2px 5px; white-space: nowrap; }
#result-pos { font-size: 11px; color: #64748b; margin: 0 2px; }

/* ===== Active result highlight ===== */
.result-page.active { background: #eff6ff; border-left: 3px solid #2563eb; }
.result-page.active:hover { background: #dbeafe; }

/* ===== Load more ===== */
.load-more-btn { padding: 8px 20px; text-align: center; }
.load-more-btn .btn-secondary { width: 100%; }

/* ===== Help dialog ===== */
.modal-help { min-width: 480px; max-width: 680px; }
@media (max-width: 520px) {
  .modal-help { min-width: 0; width: 96vw; margin: 0 2vw; padding: 12px; }
  .modal-help table td { font-size: 12px; padding: 3px 4px !important; }
  .modal-help h3 { font-size: 13px !important; }
}

/* ===== Help dialog kbd ===== */
.help-content kbd { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px; padding: 1px 6px; font-size: 12px; color: #334155; font-family: "SF Mono", "Cascadia Code", monospace; }
.help-content code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 13px; color: #b45309; }

/* ===== Update banner ===== */
/* ===== Action Banner (persistente — avisos que exigem ação) ===== */
.action-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  animation: bannerSlideIn 0.4s ease-out;
  min-height: 44px;
}
.action-banner .action-banner-text {
  flex: 1;
  text-align: center;
}
.action-banner button {
  background: #fff;
  color: #92400e;
  border: none;
  border-radius: 6px;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s;
}
.action-banner button:hover {
  background: #fef3c7;
  transform: scale(1.04);
}
@keyframes bannerSlideIn {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
/* Quando há banner fixo, empurra o conteúdo para baixo */
body:has(.action-banner) .app,
body:has(.action-banner) #auth-screen {
  padding-top: 54px;
}

/* ===== Unified Folder & File Manager Modal ===== */
.folder-mgr-modal {
  width: 96vw !important;
  max-width: 820px !important;
  height: 85vh !important;
  max-height: 750px !important;
  min-height: 300px !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 12px !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

@media (max-width: 600px) {
  .folder-mgr-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 100vh !important;
    border-radius: 0 !important;
  }
}
.folder-mgr-top { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; flex-shrink: 0; }
.folder-mgr-search { width: 100%; padding: 12px 16px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; box-sizing: border-box; height: 44px; }
.folder-mgr-addrow { display: flex; gap: 10px; align-items: center; background: #f8fafc; padding: 12px 16px; border-radius: 8px; border: 1px solid #cbd5e1; }
.folder-mgr-tree { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; flex: 1 1 auto; min-height: 100px; padding-right: 6px; margin-top: 6px; }

@media (max-width: 600px) {
  .folder-mgr-tree { min-height: 50vh; }
  .folder-mgr-header { min-height: 60px; padding: 12px; flex-wrap: wrap; }
  .folder-mgr-title { font-size: 14px; }
  .folder-mgr-card { margin-bottom: 8px; }
}
.folder-mgr-card { background: #ffffff; border: 1px solid #cbd5e1; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); margin-bottom: 10px; }
.folder-mgr-header { display: flex; align-items: center; gap: 16px; padding: 22px 28px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; min-height: 88px; box-sizing: border-box; }
.folder-mgr-toggle { background: #e2e8f0; border: none; cursor: pointer; color: #334155; font-size: 14px; padding: 8px 14px; border-radius: 6px; font-weight: bold; line-height: 1.5; }
.folder-mgr-toggle:hover { background: #cbd5e1; color: #0f172a; }
.folder-mgr-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
.folder-mgr-title { flex: 1; font-size: 17px; font-weight: 600; color: #0f172a; line-height: 2.0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-mgr-count { font-size: 14px; color: #64748b; font-weight: 500; margin-left: 8px; }
.folder-mgr-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.folder-mgr-actions .btn-sm { padding: 10px 14px; font-size: 14px; border-radius: 6px; min-height: 40px; line-height: 1.4; }
.folder-mgr-colorpicker { width: 40px; height: 40px; padding: 3px; background: transparent; border: 1px solid #cbd5e1; border-radius: 6px; cursor: pointer; }
.folder-mgr-files { display: flex; flex-direction: column; background: #ffffff; padding: 8px 0; }
.folder-mgr-filerow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; border-bottom: 1px solid #f1f5f9; font-size: 15px; min-height: 68px; line-height: 1.8; }
.folder-mgr-filerow:last-child { border-bottom: none; }
.folder-mgr-filerow:hover { background: #f8fafc; }
.folder-mgr-fileinfo { flex: 1; color: #1e293b; font-size: 15px; line-height: 1.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-mgr-filemeta { font-size: 13px; color: #64748b; margin-left: 10px; }
.folder-mgr-fileactions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.folder-mgr-fileactions .btn-sm { padding: 8px 14px; font-size: 14px; min-height: 38px; }
.folder-mgr-emptyfile { padding: 24px 28px; font-size: 14px; color: #94a3b8; font-style: italic; text-align: center; }

