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

:root {
  /* ── LIGHT THEME (default) ── */
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #d1d9e0;
  --border-hi: #b0bcc8;
  --text: #1a2233;
  --muted: #6b7a8d;
  --accent: #2563eb;
  --accent-dim: #dbeafe;
  --folder: #d97706;
  --file: #64748b;
  --success: #16a34a;
  --error: #dc2626;
  --mono: "IBM Plex Mono", monospace;
  --sans: "IBM Plex Sans", sans-serif;
  --radius: 10px;
  --transition: 0.15s ease;
  --row-h: 36px;
  --row-gap: 0.4rem;
  --base-font: 15px;
}
html {
  font-size: var(--base-font);
}

/* ── DARK THEME ── */
body.dark {
  --bg: #0e1117;
  --surface: #161b25;
  --border: #232b3a;
  --border-hi: #2e3a50;
  --text: #d4dde8;
  --muted: #5a6a7e;
  --accent: #3b82f6;
  --accent-dim: #1d3b6e;
  --folder: #f59e0b;
  --file: #64748b;
  --success: #22c55e;
  --error: #ef4444;
}
body.dark .pwd-modal {
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(59, 130, 246, 0.08);
}
body.dark .row:hover {
  background: rgba(59, 130, 246, 0.08);
}

html,
body {
  min-height: 100vh;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── PASSWORD MODAL ── */
#app-loading {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 1100;
  color: rgba(255, 255, 255, 0.7);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.9rem;
}
#app-loading.hidden {
  display: none;
}
.app-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.pwd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.25s ease;
}
.pwd-backdrop.hidden {
  display: none;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes modal-up {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.pwd-modal {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 360px;
  margin: 1.5rem;
  animation: modal-up 0.3s ease;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(37, 99, 235, 0.1);
}
.pwd-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.pwd-logo img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}
.pwd-logo-text h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.pwd-logo-text p {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 1px;
}
.pwd-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.pwd-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.pwd-field {
  position: relative;
  margin-bottom: 1rem;
}
.pwd-field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 0.65rem 0.65rem 0.65rem 0.9rem;
  padding-right: 2.75rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  letter-spacing: 0.1em;
}
#pwd-email {
  padding-right: 0.9rem;
  letter-spacing: normal;
}
.pwd-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.pwd-field input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.pwd-toggle {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0.2rem;
  transition: color 0.15s;
}
.pwd-toggle:hover {
  color: var(--text);
}
.pwd-toggle svg {
  width: 16px;
  height: 16px;
}
.pwd-btn {
  width: 100%;
  padding: 0.7rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.1s;
}
.pwd-btn:hover {
  background: #2563eb;
}
.pwd-btn:active {
  transform: scale(0.98);
}
.pwd-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 0.5rem;
  min-height: 1em;
  font-family: var(--mono);
}
.pwd-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
  cursor: pointer;
  user-select: none;
}
.pwd-remember input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* shake animation */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}
.pwd-field input.shake {
  animation: shake 0.35s ease;
}

/* ── LOGIN ERROR POPUP ── */
.err-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fade-in 0.2s ease;
}
.err-popup-backdrop.hidden {
  display: none;
}
.err-popup {
  background: var(--surface);
  border: 1px solid var(--error);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  margin: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: modal-up 0.2s ease;
  overflow: hidden;
}
.err-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border-bottom: 1px solid var(--error);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--error);
}
.err-popup-close {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: background 0.12s;
}
.err-popup-close:hover {
  background: rgba(239, 68, 68, 0.15);
}
.err-popup-body {
  margin: 0;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
  line-height: 1.6;
}

/* ── SITE FOOTER ── */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
}
.site-footer.hidden {
  display: none;
}
.site-footer-inner {
  padding: 0 2.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-footer-right {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  position: relative;
}
.site-footer-user {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.site-footer-logout {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  transition: color 0.12s;
}
.site-footer-logout {
  padding-left: 0.5rem;
}
.site-footer-logout:hover {
  color: var(--error);
}

/* ── LAYOUT ── */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2.5rem 4rem;
  width: 100%;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo-icon-img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.logo-icon-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.logo-icon-img a {
  display: block;
  border-radius: 6px;
}
.logo-icon-img a:hover img {
  opacity: 0.85;
  transition: opacity 0.15s ease;
}
.logo-text h1 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}
.logo-text p {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── ADMIN INSIGHTS POPUP ── */
.admin-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fade-in 0.2s ease;
}
.admin-popup-backdrop.hidden {
  display: none;
}
.admin-popup {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  width: 90%;
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: modal-up 0.2s ease;
  overflow: hidden;
}
.admin-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.admin-popup-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.admin-popup-refresh,
.admin-popup-copy,
.admin-popup-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition:
    background 0.12s,
    color 0.12s;
}
.admin-popup-refresh:hover,
.admin-popup-copy:hover,
.admin-popup-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
.admin-popup-refresh.spinning svg {
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.admin-popup-body {
  margin: 0;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  overflow: auto;
  white-space: pre;
  flex: 1;
}

/* ── MODE TOGGLE BUTTON ── */
.font-size-btn {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--mono);
  font-weight: 600;
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
  white-space: nowrap;
}
.font-size-btn:hover:not(:disabled) {
  background: var(--accent-dim);
}
.font-size-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.adv-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--mono);
  font-weight: 600;
  height: 2rem;
  padding: 0 0.6rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
  white-space: nowrap;
}
.adv-toggle-btn:hover {
  background: var(--accent-dim);
}
.adv-toggle-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}
.adv-toggle-btn.active:hover {
  background: #2563eb;
}

.mode-toggle-btn {
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
}
.mode-toggle-btn:hover {
  background: var(--accent-dim);
}
.mode-toggle-btn.mode-advanced {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}
.mode-toggle-btn.mode-advanced:hover {
  background: #2563eb;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

/* ── REFRESH BUTTON ── */
.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
}
.refresh-btn:hover {
  background: var(--accent-dim);
}
.refresh-btn:active {
  transform: scale(0.92);
}
.refresh-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.refresh-btn.spinning svg {
  animation: spin360 0.7s linear infinite;
}
@keyframes spin360 {
  to {
    transform: rotate(360deg);
  }
}

/* ── BREADCRUMB ── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-bottom: var(--row-gap);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  height: var(--row-h);
  box-sizing: border-box;
  padding: 0 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: background var(--transition);
}
.breadcrumb a:hover {
  background: var(--accent-dim);
}
.breadcrumb .sep {
  color: var(--border-hi);
  margin: 0 0.1rem;
}
.breadcrumb .crumb-current {
  color: var(--text);
}
.breadcrumb-copy {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition:
    color var(--transition),
    background var(--transition);
}
.breadcrumb-copy:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.breadcrumb-copy svg {
  width: 12px;
  height: 12px;
}

/* ── Notice banner ── */
.notice-banner {
  margin: 0 0 0.75rem 0;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  position: relative;
  animation: notice-in 0.25s ease;
}
@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.notice-banner.hidden {
  display: none;
}
.notice-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-family: var(--sans);
  padding-right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  letter-spacing: -0.1px;
}
.notice-title svg {
  flex-shrink: 0;
}
.notice-body {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.55;
  font-family: var(--sans);
}
.notice-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.notice-join-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.notice-join-btn:hover {
  opacity: 0.85;
}
.notice-join-btn svg {
  width: 13px;
  height: 13px;
}
.notice-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 180px;
}
.notice-meta-row {
  display: grid;
  grid-template-columns: 14px 90px 1fr;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  color: var(--muted);
  font-family: var(--sans);
  line-height: 1.8;
  white-space: nowrap;
}
.notice-meta-icon {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  color: var(--muted);
}
.notice-meta-label {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}
.notice-meta-row strong {
  color: var(--text);
  font-weight: 600;
}
.notice-phone-link {
  color: var(--text);
  text-decoration: none;
}
.notice-phone-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.notice-steps {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}
.notice-step {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
  font-family: var(--sans);
}
body.dark .notice-step {
  background: rgba(255, 255, 255, 0.04);
}
.notice-step svg {
  width: 10px;
  height: 10px;
  opacity: 0.7;
}
.notice-intro {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.6rem;
  font-family: var(--sans);
}
.notice-time {
  color: var(--accent);
  font-weight: 700;
  font-style: normal;
}
.notice-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  flex-shrink: 0;
}
.notice-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition:
    color var(--transition),
    background var(--transition);
}
.notice-close:hover {
  color: var(--error);
  background: rgba(220, 38, 38, 0.08);
}

/* ── TOOLBAR ── */
.admin-toolbar {
  margin-bottom: 0.25rem !important;
}
.admin-dropdown {
  position: relative;
}
.admin-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.admin-dropdown-chevron {
  flex-shrink: 0;
  transition: transform 0.15s;
}
.admin-dropdown.open .admin-dropdown-chevron {
  transform: rotate(180deg);
}
.admin-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  min-width: 140px;
  z-index: 200;
  overflow: hidden;
  animation: modal-up 0.15s ease;
}
.admin-dropdown-menu.hidden {
  display: none;
}
.admin-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.85rem;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
  white-space: nowrap;
}
.admin-dropdown-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}
.preview-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition:
    color var(--transition),
    border-color var(--transition);
  font-family: var(--sans);
}
.preview-toggle:hover {
  color: var(--text);
  border-color: var(--border-hi);
}
.preview-toggle.active {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.preview-toggle svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ── FILE LIST ── */
.listing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.listing-empty {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.listing-empty svg {
  width: 32px;
  height: 32px;
  margin: 0 auto 0.75rem;
  display: block;
  opacity: 0.3;
}

/* ── Recently Viewed ── */
.recent-section {
  margin-bottom: 0.75rem;
}
.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.75rem;
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
}
.recent-header:hover {
  color: var(--text);
}
.recent-header-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.recent-chevron {
  transition: transform 0.2s ease;
  font-style: normal;
}
.recent-section.collapsed .recent-chevron {
  transform: rotate(-90deg);
}
.recent-clear {
  font-size: 0.65rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  transition: color var(--transition);
}
.recent-clear:hover {
  color: var(--error);
}
.recent-list {
  overflow: hidden;
}
.recent-section.collapsed .recent-list {
  display: none;
}
.recent-row {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  height: 32px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.recent-row:last-child {
  border-bottom: none;
}
.recent-row:hover {
  background: rgba(59, 130, 246, 0.06);
}
.recent-icon {
  color: var(--file);
  display: flex;
  align-items: center;
}
.recent-icon svg {
  width: 13px;
  height: 13px;
}
.recent-name {
  font-size: 0.8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
}
.recent-path {
  font-size: 0.65rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.recent-name-wrap {
  min-width: 0;
}
.recent-open-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0.2rem;
  border-radius: 3px;
  transition: color var(--transition);
}
.recent-open-btn:hover {
  color: var(--accent);
}
.recent-open-btn svg {
  width: 11px;
  height: 11px;
}
.recent-divider {
  height: 1px;
  background: var(--border);
  margin: 0 0 0.5rem 0;
}

/* ── PDF Thumbnail Sidebar ── */
.pdf-thumb-sidebar.hidden {
  display: none;
}
.pdf-viewer-wrap {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.pdf-thumb-sidebar {
  width: 120px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.3rem;
  box-sizing: border-box;
}
.pdf-thumb {
  width: 100px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.pdf-thumb:hover {
  border-color: var(--border-hi);
}
.pdf-thumb.active {
  border-color: var(--accent);
}
.pdf-thumb canvas {
  width: 100%;
  display: block;
}
.pdf-thumb-label {
  font-size: 0.6rem;
  color: var(--muted);
  font-family: var(--mono);
  text-align: center;
  margin-top: 0.15rem;
}
.pdf-thumb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── ROW ── */
.row {
  display: grid;
  grid-template-columns: 28px 1fr 72px 96px auto;
  align-items: center;
  gap: 0.75rem;
  height: var(--row-h);
  box-sizing: border-box;
  padding: 0 0.1rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.row:last-child {
  border-bottom: none;
}
.row:hover {
  background: rgba(59, 130, 246, 0.06);
}
.row:hover .row-name {
  color: var(--text);
}
.row:active {
  background: rgba(59, 130, 246, 0.1);
}

/* Listing-level transition animations */
@keyframes listing-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes listing-back {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.listing.anim-in {
  animation: listing-in 0.2s ease both;
}
.listing.anim-back {
  animation: listing-back 0.2s ease both;
}

/* Search highlight */
.hl {
  background: rgba(251, 191, 36, 0.25);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

.row-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.row-icon svg {
  width: 15px;
  height: 15px;
}

.row-icon.folder-icon {
  background: rgba(245, 158, 11, 0.12);
  color: var(--folder);
}
.row-icon.file-icon {
  background: rgba(100, 116, 139, 0.12);
  color: var(--file);
}
.row-icon.up-icon {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.row-name-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  min-width: 0;
}
.row-status-badge {
  flex-shrink: 0;
  font-size: 0.58rem;
  padding: 0.08rem 0.35rem;
  vertical-align: middle;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  justify-content: flex-end;
}
.row-props-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  flex-shrink: 0;
  transition:
    color var(--transition),
    background var(--transition);
}
.row-props-btn:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.row-props-btn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}
.row-name {
  font-size: 0.875rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition);
  min-width: 0;
  flex: 1 1 0;
}
.row-name.folder-name {
  font-weight: 500;
}
.row-name.up-name {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.row-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta.empty-folder {
  color: rgba(245, 158, 11, 0.5);
  font-style: italic;
}
.row-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  color: var(--muted);
  opacity: 1;
  transition:
    color var(--transition),
    background var(--transition);
  flex-shrink: 0;
  text-decoration: none;
}
.row-download:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.row-download svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}
/* Experimental extras */
/* ── Search row ── */
.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0;
  margin-bottom: var(--row-gap);
  flex-shrink: 0;
}
.search-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 0.75rem;
  height: var(--row-h);
  box-sizing: border-box;
}
.search-bar-inner:focus-within {
  border-color: var(--accent);
}
.search-bar-inner svg {
  width: 13px;
  height: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.search-bar-inner input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  color: var(--text);
  outline: none;
  font-family: var(--sans);
}
.search-bar-inner input::placeholder {
  color: var(--muted);
}
.search-bar-inner button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
}
.search-bar-inner button:hover {
  color: var(--text);
}

.search-row {
  position: relative;
}
.tag-autocomplete {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.tag-autocomplete.visible {
  display: block;
}
.tag-ac-item {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  font-family: var(--mono);
}
.tag-ac-item:hover,
.tag-ac-item.ac-active {
  background: var(--accent);
  color: #fff;
}
/* .search-bar legacy removed — see .search-row */
.sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.68rem;
  font-family: var(--mono);
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.sort-btn:hover {
  color: var(--text);
}
.sort-btn.active {
  color: var(--accent);
}
.col-header {
  display: none;
  grid-template-columns: 28px 1fr 72px 96px auto;
  align-items: center;
  gap: 0.75rem;
  height: var(--row-h);
  box-sizing: border-box;
  padding: 0 0.75rem;
  margin-bottom: var(--row-gap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.col-header.visible {
  display: grid;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}
.col-header.visible + .listing {
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.col-header-spacer {
  width: 28px;
}
.col-h-name,
.col-h-size,
.col-h-date {
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--muted);
}
.col-h-size {
  display: flex;
  justify-content: flex-end;
}
.col-h-date {
  display: flex;
  justify-content: flex-end;
}
.col-h-size .sort-btn,
.col-h-date .sort-btn {
  justify-content: flex-end;
}
/* Search result path display */
/* ── Metadata info icon + popover ── */
.desc-info-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  color: var(--accent);
  opacity: 0.6;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  vertical-align: middle;
  transition: opacity 0.15s;
}
.desc-info-icon:hover {
  opacity: 1;
}
.meta-popover {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  width: 375px;
  z-index: 1000;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text);
  overflow: hidden;
}
.meta-popover.visible {
  display: block;
}

/* Header */
.meta-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.5rem;
  background: linear-gradient(135deg, var(--accent-dim), transparent);
  border-bottom: 1px solid var(--border);
}
.meta-pop-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.meta-pop-divider {
  display: none;
}

/* Rows */
.meta-pop-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.meta-pop-key {
  font-size: 0.67rem;
  font-family: var(--mono);
  color: var(--muted);
  flex-shrink: 0;
  width: 62px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.05rem;
}
.meta-pop-val {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: #1a2233;
  line-height: 1.45;
  word-break: break-word;
}
body.dark .meta-pop-val {
  color: #d4dde8;
}
.meta-pop-filename {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: #1a2233;
  word-break: break-all;
}
body.dark .meta-pop-filename {
  color: #d4dde8;
}
.meta-pop-row-file {
  align-items: center;
}
.meta-pop-file-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
}
.meta-pop-file-right .meta-pop-filename {
  flex: 1;
  min-width: 0;
}
.meta-pop-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  text-decoration: none;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
}
.meta-pop-file-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Description block */
.meta-pop-desc {
  padding: 0.35rem 0.75rem 0.3rem;
  border-bottom: 1px solid var(--border);
}
.meta-pop-desc .meta-pop-key {
  width: auto;
  margin-bottom: 0.2rem;
  display: block;
}
.meta-pop-desc-text {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: #1a2233;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
body.dark .meta-pop-desc-text {
  color: #d4dde8;
}

/* Keywords block (standalone — kept for backward compat) */
.meta-pop-keywords {
  padding: 0.35rem 0.75rem 0.45rem;
}
.meta-pop-keywords .meta-pop-key {
  width: auto;
  margin-bottom: 0.25rem;
  display: block;
}
.meta-pop-kw-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
/* When tags appear inside the unified desc container, add spacing before description */
.meta-pop-desc .meta-pop-tags {
  margin-top: 0.4rem;
}
.meta-pop-desc.meta-pop-tags-only {
  display: flex;
  align-items: center;
}
.meta-pop-desc.meta-pop-tags-only .meta-pop-tags {
  margin-top: 0;
}
.meta-kw-chip {
  font-size: 0.67rem;
  font-family: var(--mono);
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  white-space: nowrap;
}

/* Badges */
.meta-pop-badge {
  display: inline-block;
  font-size: 0.63rem;
  font-family: var(--mono);
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid currentColor;
  white-space: nowrap;
  flex-shrink: 0;
}
.meta-badge-type {
  background: #f0f4ff;
  color: #4338ca;
  border-color: #6366f1;
}
.meta-badge-draft {
  background: #fef3c7;
  color: #92400e;
  border-color: #d97706;
}
.meta-badge-final {
  background: #dcfce7;
  color: #166534;
  border-color: #16a34a;
}
.meta-badge-approved {
  background: #dcfce7;
  color: #166534;
  border-color: #16a34a;
}
.meta-badge-archived {
  background: #f1f5f9;
  color: #475569;
  border-color: #94a3b8;
}
.meta-badge-pending {
  background: #fef3c7;
  color: #92400e;
  border-color: #d97706;
}
.meta-badge-new {
  background: #fff4ce;
  color: #7a4f00;
  border-color: #c8a400;
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0;
  border-radius: 3px;
  font-family: var(--sans);
}
.meta-badge-new svg {
  flex-shrink: 0;
}
body.dark .meta-badge-type {
  background: #1e1b4b;
  color: #a5b4fc;
  border-color: #6366f1;
}
body.dark .meta-badge-draft,
body.dark .meta-badge-pending {
  background: #451a03;
  color: #fbbf24;
  border-color: #d97706;
}
body.dark .meta-badge-final,
body.dark .meta-badge-approved {
  background: #052e16;
  color: #4ade80;
  border-color: #16a34a;
}
body.dark .meta-badge-archived {
  background: #1e293b;
  color: #94a3b8;
  border-color: #475569;
}
body.dark .meta-badge-new {
  background: #3d2e00;
  color: #ffd335;
  border-color: #c8a400;
}

.row-name.search-result-path {
  font-size: 0.8rem;
}
.row-name.search-result-path .path-dir {
  color: var(--muted);
  font-size: 0.72rem;
}
.search-scope-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  padding: 0.3rem 1rem;
  background: rgba(59, 130, 246, 0.05);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.search-scope-label svg {
  width: 11px;
  height: 11px;
  opacity: 0.6;
}
.copy-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  color: var(--muted);
  opacity: 1;
  transition:
    color var(--transition),
    background var(--transition);
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.copy-link-btn:hover {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}
.copy-link-btn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}
/* editable breadcrumb */
.breadcrumb-input {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  outline: none;
  width: 100%;
}

/* ── ERROR BANNER ── */
.error-banner {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.error-banner.show {
  display: flex;
}
.error-banner svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.error-banner button {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--error);
  opacity: 0.6;
  font-size: 1rem;
  padding: 0 0.2rem;
}
.error-banner button:hover {
  opacity: 1;
}

/* ── MOBILE ── */
@media (max-width: 600px) {
  :root {
    --row-h: 44px;
  }
  #preview-toggle {
    display: none !important;
  }
  #mode-toggle {
    display: none !important;
  }
  .shell {
    padding: 1.25rem 1rem 3rem;
  }
  /* Compact header: logo hidden, title = MWDOC, refresh right-aligned */
  header {
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    align-items: center;
  }
  .logo-icon-img {
    display: none;
  }
  .logo {
    gap: 0.4rem;
    min-width: 0;
    flex: 1;
  }
  .logo-text h1 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
  }
  .logo-text p {
    font-size: 0.7rem;
  }
  #site-title {
    font-size: 1rem;
    font-weight: 700;
  }
  .site-title-full {
    display: none;
  }
  .header-right {
    flex-shrink: 0;
    gap: 0.35rem;
  }
  #adv-toggle-btn {
    display: none !important;
  }
  .site-footer-inner {
    padding: 0 1rem;
  }
  .breadcrumb {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
  }
  /* Mobile: icon | name | actions */
  .row,
  .col-header {
    grid-template-columns: 28px 1fr auto;
    gap: 0.5rem;
  }
  .row-meta,
  .col-h-size,
  .col-h-date {
    display: none;
  }
  .row-name {
    font-size: 0.88rem;
  }
  .listing-empty {
    padding: 2rem 1rem;
  }
  .toolbar {
    margin-bottom: 0.4rem;
  }
  .pwd-modal {
    padding: 1.75rem 1.5rem;
  }
}

/* ── SPLIT PANE ── */
/* Hide size/date columns in preview (split) mode to save space */
body.split-active .row,
body.split-active .col-header {
  grid-template-columns: 28px 1fr auto;
}
body.split-active .row-meta {
  display: none;
}
body.split-active .col-h-size,
body.split-active .col-h-date {
  display: none;
}

body.split-active .shell {
  max-width: none;
  padding: 0;
}
.split-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
.split-left {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: 90vw;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}
/* When preview is off, split-left fills the whole layout */
body:not(.split-active) .split-left {
  max-width: 100%;
  width: 100% !important;
  flex: 1;
}
.split-left .shell-inner {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 3rem;
}
.split-divider {
  width: 5px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}
.split-divider:hover,
.split-divider.dragging {
  background: var(--accent);
}
.split-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}
.preview-toolbar .preview-filename {
  flex: 1;
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.72rem;
  font-family: var(--sans);
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
}
.preview-action-btn:hover {
  color: var(--text);
  border-color: var(--border-hi);
  background: rgba(0, 0, 0, 0.03);
}
.preview-action-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}
.preview-action-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.preview-toolbar a.preview-open {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.75rem;
  white-space: nowrap;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
}
.preview-toolbar a.preview-open:hover {
  background: var(--accent-dim);
}
.preview-toolbar button.preview-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
}
.preview-toolbar button.preview-close:hover {
  color: var(--error);
}
.preview-fs-btn {
  padding: 0.2rem 0.4rem;
}
.preview-fs-btn svg {
  width: 13px;
  height: 13px;
}
/* Fullscreen overlay state */
.split-right.pv-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999 !important;
  width: 100% !important;
  flex: unset !important;
  display: flex !important;
}
.preview-frame-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.preview-frame-wrap iframe,
.preview-frame-wrap object,
.preview-frame-wrap img.preview-img {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  flex: 1;
}
.preview-frame-wrap img.preview-img {
  object-fit: contain;
  background: var(--bg);
}
.preview-blocked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem;
}
.preview-blocked svg {
  opacity: 0.25;
  margin-bottom: 0.25rem;
}
.preview-blocked a {
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
.preview-blocked a:hover {
  background: var(--accent-dim);
}
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 0.75rem;
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem;
}
.preview-placeholder svg {
  opacity: 0.2;
}

/* PDF.js canvas renderer */
.pdf-canvas-wrap {
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  box-sizing: border-box;
  background: var(--bg);
  cursor: grab;
  user-select: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  align-items: flex-start;
}
.pdf-canvas-wrap.panning {
  cursor: grabbing;
}
.pdf-canvas-wrap canvas {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  border-radius: 3px;
  pointer-events: none;
  display: block;
  flex-shrink: 0;
}
/* Page container — positions text layer over canvas */
.pdf-page-container {
  position: relative;
  margin: 0 auto;
  flex-shrink: 0;
  line-height: 1;
}

/* PDF controls bar — lives in the static preview toolbar */
.pdf-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  flex-shrink: 0;
}
.pdf-controls button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  line-height: 1.4;
  font-family: var(--mono);
  transition:
    border-color var(--transition),
    background var(--transition);
}
.pdf-controls button:hover:not(:disabled) {
  border-color: var(--border-hi);
  background: var(--surface);
}
.pdf-controls button:disabled {
  opacity: 0.3;
  cursor: default;
}
#pdf-page-num,
#pdf-zoom-label {
  min-width: 4.5rem;
  text-align: center;
}
.pdf-ctrl-sep {
  flex: 1;
}
.pdf-ctrl-gap {
  flex: 0;
  width: 0.5rem;
}
.pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 100%;
  color: var(--muted);
  font-size: 0.8rem;
}
.pdf-loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin360 0.7s linear infinite;
}
.pdf-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 100%;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
}
/* active row highlight */
.row.preview-active {
  background: var(--accent-dim) !important;
  border-left: 3px solid var(--accent);
}
/* normal (non-split) shell gets its padding back */
body:not(.split-active) .shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2.5rem 4rem;
  width: 100%;
}
body.wide:not(.split-active) .shell {
  max-width: none;
  padding-left: 1rem;
  padding-right: 1rem;
}
