:root {
  --bg: #18181b;
  --surface: #1f1f23;
  --elevated: #27272a;
  --border: #2f2f35;
  --border-light: #3a3a42;
  --accent: #b8944a;
  --accent-hover: #cfa85a;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --red: #a04040;
  --success: #4a9a6a;
  --overlay: rgba(0, 0, 0, 0.7);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);

  --sidebar-width: 260px;
  --header-height: 48px;

  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-full: 9999px;
}

[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --elevated: #f0f0f1;
  --border: #e4e4e7;
  --border-light: #efefef;
  --accent: #a0803a;
  --accent-hover: #b8944a;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --red: #b05050;
  --success: #4a8a6a;
  --overlay: rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  transition: background 0.2s, color 0.2s;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; touch-action: manipulation; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== App ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 8px;
  flex-shrink: 0;
  -webkit-app-region: drag;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.menu-toggle:hover {
  background: var(--elevated);
  color: var(--text);
}

.app-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
}

.header-center {
  flex: 1;
  max-width: 360px;
  margin: 0 auto;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
  width: 13px;
  height: 13px;
}

.search-input {
  width: 100%;
  height: 30px;
  padding: 0 8px 0 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text);
  outline: none;
  transition: border 0.15s;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.search-kbd {
  position: absolute;
  right: 7px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  pointer-events: none;
  line-height: 1.8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--elevated);
  color: var(--text);
}

.btn-icon.active { color: var(--accent); }

/* ===== Main layout ===== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.filter-select {
  flex: 1;
  height: 28px;
  padding: 0 22px 0 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border 0.15s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='8' viewBox='0 0 8 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 3L4 5.5L6 3' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
}

.filter-select:focus { border-color: var(--accent); }

.recent-section.hidden { display: none; }

.section-title {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 4px;
}

.recent-item {
  padding: 2px 7px;
  font-size: 10.5px;
  background: var(--elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item:hover {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.recent-item .recent-close {
  margin-left: 3px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.4;
}

.recent-item:hover .recent-close { opacity: 1; }

/* ===== Document List ===== */
.document-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 1px;
  border-left: 2px solid transparent;
}

.doc-item:hover { background: var(--elevated); }

.doc-item.active {
  background: var(--elevated);
  border-left-color: var(--accent);
}

.doc-item.active .doc-title { color: var(--text); font-weight: 500; }

.doc-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
}

.doc-item.active .doc-icon {
  background: var(--accent);
  color: #111;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-title {
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.35;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.doc-category {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.doc-item.active .doc-category {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.doc-bookmark {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 3px;
  opacity: 0;
  transition: color 0.15s, opacity 0.15s;
}

.doc-item:hover .doc-bookmark,
.doc-bookmark.bookmarked { opacity: 1; }
.doc-bookmark.bookmarked { color: var(--accent); }

/* ===== Empty State ===== */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  flex: 1;
}

.empty-state.visible { display: flex; }

.empty-icon {
  margin-bottom: 14px;
  opacity: 0.15;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ===== Viewer ===== */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
  position: relative;
}

.viewer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 5px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 6px;
}

.viewer-header.visible { display: flex; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.breadcrumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-item:last-child {
  color: var(--text);
  font-weight: 500;
}

.breadcrumb-sep {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  font-size: 11.5px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.btn-action:hover {
  background: var(--elevated);
  color: var(--text);
}

.btn-action.active { color: var(--accent); }

.action-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

.font-size-label {
  font-size: 10.5px;
  color: var(--text-muted);
  min-width: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===== Progress Bar ===== */
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 10;
  transition: width 0.1s linear;
  opacity: 0;
}

.progress-bar.visible { opacity: 1; }

/* ===== Drop Overlay ===== */
.drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.drop-overlay.dragging {
  display: flex;
}

.drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  color: var(--accent);
  background: var(--surface);
}

.drop-content h3 {
  font-size: 15px;
  font-weight: 500;
}

/* ===== Shortcuts Modal ===== */
.shortcuts-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
}

.shortcuts-overlay.visible { display: flex; }

.shortcuts-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 320px;
  max-width: calc(100vw - 32px);
  overflow: hidden;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.shortcuts-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.shortcuts-header .btn-action {
  font-size: 18px;
  padding: 2px 6px;
}

.shortcuts-body {
  padding: 6px 16px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.shortcut-row kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  min-width: 34px;
  text-align: center;
}

/* ===== Viewer states ===== */
.viewer-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.viewer-welcome,
.viewer-loading,
.viewer-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
}

.viewer-welcome.visible,
.viewer-loading.visible,
.viewer-error.visible { display: flex; }

.welcome-icon {
  margin-bottom: 18px;
  opacity: 0.08;
  color: var(--accent);
}

.viewer-welcome h2 {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.viewer-welcome p {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 260px;
}

/* Loading */
.spinner { margin-bottom: 14px; }

.spinner-ring {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.viewer-loading p {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Error */
.viewer-error .error-icon {
  margin-bottom: 14px;
  color: var(--red);
  opacity: 0.6;
}

.viewer-error h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--red);
  margin-bottom: 4px;
}

.viewer-error .error-message {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  max-width: 320px;
}

.error-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.error-hint {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 320px;
}

.error-hint code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--elevated);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--accent);
}

/* Buttons */
.btn-primary {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #111;
  background: var(--accent);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover {
  background: var(--elevated);
  color: var(--text);
}

/* ===== Viewer Content ===== */
.viewer-content {
  display: none;
  padding: 28px 32px;
  overflow-y: auto;
  height: 100%;
  line-height: 1.75;
  font-size: 15px;
  max-width: 720px;
  margin: 0 auto;
}

.viewer-content.visible { display: block; }

.viewer-content h1,
.viewer-content h2,
.viewer-content h3,
.viewer-content h4 {
  margin-top: 1.5em;
  margin-bottom: 0.35em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.02em;
}

.viewer-content h1 {
  font-size: 1.5em;
  padding-bottom: 0.15em;
  border-bottom: 1px solid var(--border);
}

.viewer-content h2 { font-size: 1.25em; }
.viewer-content h3 { font-size: 1.1em; }
.viewer-content h4 { font-size: 1em; }

.viewer-content p { margin-bottom: 0.7em; color: var(--text); }

.viewer-content img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  margin: 1em 0;
}

.viewer-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
}

.viewer-content th,
.viewer-content td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.viewer-content th {
  background: var(--surface);
  font-weight: 600;
  font-size: 12px;
}

.viewer-content td { color: var(--text); }

.viewer-content ul,
.viewer-content ol {
  margin-bottom: 0.7em;
  padding-left: 1.3em;
}

.viewer-content li { margin-bottom: 0.2em; }

.viewer-content blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 5px 5px 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.95em;
}

.viewer-content pre {
  margin: 1em 0;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.viewer-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 4px;
  background: var(--elevated);
  border-radius: 3px;
}

.viewer-content pre code { background: none; border: none; padding: 0; }

.viewer-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.viewer-content hr {
  margin: 1.2em 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ===== Viewer Footer ===== */
.viewer-footer {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 5px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.viewer-footer.visible { display: flex; }

.btn-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.btn-nav:hover:not(:disabled) {
  background: var(--elevated);
  color: var(--text);
}

.btn-nav:disabled { opacity: 0.25; cursor: not-allowed; }

.doc-position {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  max-width: 300px;
}

.toast.success { border-left: 2px solid var(--success); }
.toast.error { border-left: 2px solid var(--red); }
.toast.info { border-left: 2px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-out {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(6px); }
}

/* ===== Print ===== */
@media print {
  .header, .sidebar, .viewer-header, .viewer-footer, .toast-container { display: none !important; }
  .main-layout { display: block; }
  .viewer { overflow: visible; }
  .viewer-body { overflow: visible; }
  .viewer-content { padding: 0; overflow: visible; max-width: none; }
  body { overflow: visible; height: auto; background: #fff; color: #111; }
  .app { height: auto; }
}

/* ===== Fullscreen ===== */
.app.fullscreen .header { display: none; }
.app.fullscreen .sidebar { display: none; }
.app.fullscreen .viewer-header { display: none !important; }
.app.fullscreen .viewer-footer { display: none !important; }

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.25s;
}

.sidebar-overlay.visible { display: block; opacity: 1; }

/* ===== Responsive — Tablet ===== */
@media (max-width: 1000px) {
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 85vw;
    min-width: 280px;
    max-width: 360px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex; }

  .viewer-content { padding: 24px; }

  .viewer-actions .btn-action {
    padding: 5px;
    width: 30px;
    height: 30px;
    justify-content: center;
  }
  .viewer-actions .btn-action span { display: none; }

  .search-kbd { display: none; }
  .header-center { max-width: none; flex: 1; }

  .btn-nav { padding: 7px 9px; }
}

/* ===== Responsive — Mobile ===== */
@media (max-width: 640px) {
  .header {
    padding: 0 8px;
    gap: 4px;
    height: 44px;
  }

  .app-title { font-size: 14px; }

  .header-left { gap: 4px; }
  .header-center { min-width: 0; }

  .search-input {
    height: 28px;
    font-size: 16px;
    padding-left: 26px;
  }

  .search-icon {
    width: 12px;
    height: 12px;
    left: 8px;
  }

  .header-right .btn-icon {
    width: 28px;
    height: 28px;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
  }

  .sidebar-header { padding: 8px 12px; }

  .filter-select { height: 32px; font-size: 12.5px; }

  .doc-item { padding: 9px; gap: 9px; }
  .doc-item .doc-bookmark { opacity: 1; }
  .doc-title { font-size: 13.5px; }

  .viewer-content {
    padding: 14px;
    font-size: 15.5px;
  }

  .viewer-header {
    padding: 5px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .breadcrumb { font-size: 10.5px; min-width: 0; flex: 1; }

  .viewer-actions .btn-action {
    width: 28px;
    height: 28px;
    padding: 4px;
  }

  .viewer-footer { padding: 5px 8px; }

  .btn-nav { padding: 7px; gap: 0; }

  .btn-nav svg {
    width: 17px;
    height: 17px;
  }

  .btn-nav span { display: none; }

  .doc-position { font-size: 10.5px; }

  .viewer-welcome h2 { font-size: 15px; }
  .viewer-welcome p { font-size: 12.5px; }

  .viewer-content h1 { font-size: 1.3em; }
  .viewer-content h2 { font-size: 1.15em; }

  .viewer-content table {
    font-size: 11.5px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .viewer-content pre { font-size: 11px; padding: 10px; }

  .toast {
    font-size: 12px;
    padding: 7px 11px;
    max-width: calc(100vw - 28px);
  }

  .sidebar-overlay.visible {
    display: block;
    opacity: 1;
  }
}

/* ===== Responsive — Small mobile ===== */
@media (max-width: 400px) {
  .header { padding: 0 5px; }
  .app-title { font-size: 13px; }

  .header-right .btn-icon {
    width: 26px;
    height: 26px;
  }

  .viewer-content {
    padding: 10px;
    font-size: 13px;
  }

  .viewer-content h1 { font-size: 1.15em; }

  .filter-row {
    flex-direction: column;
    gap: 4px;
  }

  .filter-select { height: 34px; font-size: 13px; }
  .doc-item { padding: 7px; }
  .doc-icon { width: 26px; height: 26px; }
}

/* ===== Responsive — Landscape mobile ===== */
@media (max-height: 480px) and (orientation: landscape) {
  .header { height: 38px; padding: 0 8px; }
  .app-title { font-size: 12px; }
  .sidebar-header { padding: 4px 10px; }
  .document-list { padding: 2px 6px; }
  .doc-item { padding: 4px 7px; }
  .viewer-header { padding: 3px 10px; }
  .viewer-footer { padding: 3px 10px; }
  .viewer-content { padding: 10px 16px; }
}
