/* Library: company file browser (folder tree left, contents right), upload tray and the full-window viewer. */

.library {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.library-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.library-head h1 {
  margin: 2px 0 0;
}
.library-tree-toggle {
  display: none;
}
.library-body {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 200px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Folder tree */
.library-tree {
  flex: none;
  width: var(--library-tree-width, 280px);
  min-width: 200px;
  max-width: 560px;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
}
.library-tree > .tree,
.library-tree-head {
  padding: 0 8px;
}
.library-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.library-tree .tree {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow: auto;
  padding-bottom: 16px;
}
.tree,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-children {
  padding-left: 14px;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
  margin: 1px 0;
}
.tree-row:hover {
  background: var(--surface-sunken);
}
.tree-row.is-current {
  background: var(--accent-soft);
}
.tree-row.is-current .tree-link {
  color: var(--accent-strong);
  font-weight: 600;
}
.tree-toggle,
.tree-toggle-spacer {
  flex: none;
  width: 22px;
  height: 22px;
}
.tree-toggle {
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.tree-toggle:hover {
  background: var(--border-soft);
  color: var(--text);
}
.tree-toggle::before {
  content: "▸";
}
.tree-toggle[aria-expanded="true"]::before {
  content: "▾";
}
.tree-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 4px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.93rem;
}
.tree-link:hover {
  color: var(--text);
}
.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-count {
  font-size: 0.76rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.glyph-folder {
  flex: none;
  color: var(--accent);
}
.tree-archive {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 8px 16px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 0 0 8px 8px;
}
.tree-archive:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.tree-archive.is-current {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.glyph-archive {
  flex: none;
  color: var(--text-muted);
}
.library-empty .glyph-archive {
  width: 36px;
  height: 32px;
}
.library-table .col-restore {
  width: 176px;
  text-align: right;
  white-space: nowrap;
}
.library-table .col-restore form {
  margin-left: 4px;
}
.library-splitter {
  flex: none;
  width: 6px;
  margin-left: -3px;
  margin-right: -3px;
  cursor: col-resize;
  position: relative;
  z-index: 2;
  background: transparent;
}
.library-splitter:hover,
.library-splitter:focus-visible,
.library-splitter.is-dragging {
  background: var(--accent-border);
  outline: none;
}

/* Contents */
.library-content {
  flex: 1;
  min-width: 0;
  padding: 16px 22px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.library-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.library-crumbs a {
  color: var(--text-muted);
  text-decoration: none;
}
.library-crumbs a:hover {
  color: var(--text);
  text-decoration: underline;
}
.library-crumbs a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}
.crumb-sep {
  color: #b9b4ab;
}
.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.library-folder-name {
  margin: 0;
  font-size: 1.6rem;
  overflow-wrap: anywhere;
}
.library-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.library-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.library-search-field {
  flex: 1 1 260px;
  min-width: 0;
}
.library-search-field input {
  width: 100%;
}
.library-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.library-sort > span:first-child {
  margin: 0;
}
.library-scope {
  margin: -2px 0 0;
}

/* Popovers (New folder, Upload files) */
details.popover {
  position: relative;
}
details.popover > summary {
  list-style: none;
}
details.popover > summary::-webkit-details-marker {
  display: none;
}
.popover-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: min(360px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 36px rgba(19, 24, 29, 0.16);
  padding: 14px 16px;
}
.compact-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compact-fieldset legend {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
}

/* List */
.library-list {
  position: relative;
  border-radius: 10px;
}
.library-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.library-table th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
.library-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  font-size: 0.93rem;
}
.library-table tbody tr:hover {
  background: var(--surface-muted);
}
.library-table .col-date {
  width: 132px;
}
.library-table .col-size {
  width: 104px;
}
.library-table .col-by {
  width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-table .col-actions {
  width: 56px;
  text-align: right;
}
.library-table td.col-name {
  overflow: hidden;
}
.sort-link {
  color: var(--text-muted);
  text-decoration: none;
}
.sort-link:hover,
.sort-link.is-active {
  color: var(--text);
}
.item-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 44px);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  vertical-align: middle;
}
.item-link:hover .item-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-path {
  margin: 2px 0 0 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.version-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-faint);
  border: 1px solid var(--border);
  text-decoration: none;
  vertical-align: middle;
}
.version-chip.has-history {
  color: var(--accent-strong);
  border-color: var(--accent-border);
  background: var(--accent-wash);
}
.file-glyph {
  position: relative;
  flex: none;
  width: 22px;
  height: 28px;
  color: #9aa1a8;
}
.file-glyph svg {
  display: block;
}
.file-glyph-type {
  position: absolute;
  left: -3px;
  bottom: 3px;
  padding: 0 2px;
  border-radius: 3px;
  background: var(--neutral-strong);
  color: #fff;
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
}
.file-glyph[data-type="pdf"] .file-glyph-type {
  background: #b3261e;
}
.file-glyph[data-type="docx"] .file-glyph-type,
.file-glyph[data-type="doc"] .file-glyph-type {
  background: #2b579a;
}
.file-glyph[data-type="xlsx"] .file-glyph-type,
.file-glyph[data-type="xls"] .file-glyph-type,
.file-glyph[data-type="csv"] .file-glyph-type {
  background: #217346;
}
.file-glyph[data-type="pptx"] .file-glyph-type,
.file-glyph[data-type="ppt"] .file-glyph-type {
  background: #c43e1c;
}
.file-glyph[data-type="html"] .file-glyph-type,
.file-glyph[data-type="htm"] .file-glyph-type {
  background: var(--accent-strong);
}
.file-glyph[data-type="png"] .file-glyph-type,
.file-glyph[data-type="jpg"] .file-glyph-type,
.file-glyph[data-type="jpeg"] .file-glyph-type,
.file-glyph[data-type="svg"] .file-glyph-type,
.file-glyph[data-type="gif"] .file-glyph-type,
.file-glyph[data-type="webp"] .file-glyph-type {
  background: #6b4ea0;
}
.file-row:target,
.file-row.is-focused {
  background: var(--accent-wash);
}
.row-menu .menu-panel a.danger {
  color: var(--danger);
}
.library-empty {
  text-align: center;
  padding: 56px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
}
.library-empty .glyph-folder {
  width: 36px;
  height: 32px;
}
.library-empty-title {
  font-weight: 600;
  color: var(--text-2);
  margin: 10px 0 4px;
}
.library-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.library-foot {
  margin: 4px 0 0;
}
.library-decisions {
  border: 1px solid var(--warning-border);
  background: var(--warning-soft);
  border-radius: 10px;
  padding: 12px 14px;
}
.library-decisions h3 {
  margin: 0 0 4px;
  color: var(--warning-text);
}
.library-decisions ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.library-decisions li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}
.decision-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.decision-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

/* Drag and drop */
.is-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--accent-wash) !important;
}
.library-drop-hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 70;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(19, 24, 29, 0.3);
  pointer-events: none;
}

/* Upload tray */
.upload-tray {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  width: min(460px, calc(100vw - 32px));
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(19, 24, 29, 0.22);
}
.upload-tray-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.upload-tray-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
}
.upload-tray-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow: auto;
}
.upload-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--divider);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}
.upload-item:last-child {
  border-bottom: none;
}
.upload-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-status {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.upload-item.is-done .upload-status {
  color: var(--success-strong);
}
.upload-item.is-failed .upload-status,
.upload-item.is-rejected .upload-status {
  color: var(--danger);
}
.upload-item.is-conflict .upload-status {
  color: var(--warning-strong);
}
.upload-bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.upload-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}
.upload-item.is-done .upload-bar > span {
  background: var(--success);
}
.upload-actions {
  display: inline-flex;
  gap: 6px;
}
.upload-choices {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.upload-tray-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.library-dialog .field-error {
  color: var(--danger);
  margin: 0;
}

/* Narrow screens: the tree becomes a collapsible panel above the contents. */
@media (max-width: 900px) {
  .library-tree-toggle:not([hidden]) {
    display: inline-flex;
  }
  .library-body {
    flex-direction: column;
    min-height: 0;
  }
  .library-tree {
    width: auto;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .library-tree .tree {
    position: static;
    max-height: 45vh;
  }
  .library.tree-collapsed .library-tree {
    display: none;
  }
  .library-splitter {
    display: none;
  }
  .library-content {
    padding: 14px 14px 18px;
  }
}
@media (max-width: 700px) {
  .library-table .col-by,
  .library-table .col-size {
    display: none;
  }
  .library-table .col-restore {
    width: 92px;
    white-space: normal;
  }
  .library-table .col-restore .button,
  .library-table .col-restore form {
    margin: 2px 0;
  }
  .library-table .col-date {
    width: 96px;
    font-size: 0.82rem;
  }
  .library-sort > span:first-child {
    display: none;
  }
  .popover-panel {
    position: fixed;
    left: 16px;
    right: 16px;
    top: auto;
    width: auto;
  }
}

/* ---------------------------------------------------------------------------------------------------------
   Viewer: fills the window; the navigation and folder pane are not rendered on this page. */

body.viewer-page {
  background: #1b1f24;
  overflow: hidden;
}
.viewer-frame {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.viewer-frame > .flashes {
  margin: 0;
}
.viewer-frame > .attribution {
  margin: 0;
  flex: none;
  padding: 3px 12px;
  font-size: 0.72rem;
  background: #13181d;
  color: #8f98a1;
  border-top: 1px solid #262e36;
}
.viewer-frame > .attribution a {
  color: #aab2ba;
}
.viewer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}
.viewer:fullscreen {
  background: #1b1f24;
}
.viewer-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--ink);
  color: #fff;
  border-bottom: 1px solid #262e36;
}
.viewer-bar .button.secondary,
.viewer-bar button.secondary,
.viewer-controls button,
.viewer-controls select,
.viewer-controls input {
  background: #242b32;
  color: #e9ecef;
  border-color: #3a434c;
}
.viewer-bar .button.secondary:hover,
.viewer-bar button.secondary:hover,
.viewer-controls button:hover {
  background: #2f3841;
  color: #fff;
}
.viewer-bar .button[aria-disabled="true"] {
  background: #1f252b;
  color: #69727b;
  border-color: #2c343b;
}
.viewer-bar .button:not(.secondary) {
  background: var(--accent);
  border-color: var(--accent);
}
.viewer-bar .button:not(.secondary):hover {
  background: var(--accent-strong);
}
.viewer-title {
  flex: 1 1 auto;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.viewer-title .file-glyph {
  color: #6f7881;
}
.viewer-title-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.viewer-name {
  margin: 0;
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-meta {
  font-size: 0.78rem;
  color: #9aa3ab;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex: none;
}
.viewer-controls:empty {
  display: none;
}
.viewer-controls button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.84rem;
  border-radius: 7px;
}
.viewer-controls select,
.viewer-controls input {
  width: auto;
  max-width: 180px;
  min-height: 30px;
  height: 30px;
  padding: 0 6px;
  font-size: 0.84rem;
  border-radius: 7px;
}
.viewer-controls input {
  width: 3.4em;
  text-align: center;
}
.viewer-controls .control-label {
  font-size: 0.8rem;
  color: #aab2ba;
  white-space: nowrap;
}
.viewer-controls .control-sep {
  width: 1px;
  height: 22px;
  background: #3a434c;
  margin: 0 4px;
}
.viewer-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.viewer-position {
  min-width: 4.5em;
  text-align: center;
  font-size: 0.85rem;
  color: #c3c9cf;
  font-variant-numeric: tabular-nums;
}
.viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.viewer-stage {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: auto;
  background: #2a2f35;
  color: var(--text);
}
.viewer-details {
  flex: none;
  width: 330px;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px 18px;
}
.viewer-details h2 {
  font-family: var(--font);
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.viewer-details h3 {
  font-size: 0.92rem;
  margin: 18px 0 6px;
}
.viewer-details .kv {
  grid-template-columns: 1fr;
  gap: 2px;
}
.viewer-details .kv dt {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.viewer-details .kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.viewer-versions {
  list-style: none;
  margin: 0;
  padding: 0;
}
.viewer-versions li {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--divider);
}
.viewer-versions li.is-shown > a:first-child {
  font-weight: 700;
}
.viewer-fallback,
.pv-info {
  max-width: 520px;
  margin: 8vh auto;
  padding: 36px 28px;
  text-align: center;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.viewer-fallback .file-glyph,
.pv-info .file-glyph {
  display: inline-block;
  transform: scale(2);
  margin: 12px 0 18px;
}
.viewer-fallback-title,
.pv-info-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}
.pv-info dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  text-align: left;
  margin: 18px auto;
  max-width: 380px;
  font-size: 0.9rem;
}
.pv-info dt {
  color: var(--text-muted);
}
.pv-info dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.pv-info .pv-reason {
  margin: 14px 0;
  color: var(--text-3);
}
.pv-info.is-error .pv-info-title {
  color: var(--danger);
}
.pv-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #c3c9cf;
}
.pv-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #3a434c;
  border-top-color: var(--accent-light);
  animation: pv-spin 0.9s linear infinite;
}
@keyframes pv-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .pv-spinner {
    animation-duration: 3s;
  }
}

/* PDF */
.pv-pdf {
  padding: 16px 12px 40px;
}
.pv-page {
  position: relative;
  margin: 0 auto 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.pv-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pv-page-label {
  position: absolute;
  right: 8px;
  bottom: -18px;
  font-size: 0.72rem;
  color: #8f98a1;
}

/* Images */
.pv-image {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#30363d 0% 25%, #2a2f35 0% 50%) 50% / 24px 24px;
}
.pv-image img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}
.pv-image.is-zoomed {
  display: block;
  cursor: grab;
}
.pv-image.is-zoomed img {
  max-width: none;
  max-height: none;
  margin: 0 auto;
}
.pv-image.is-panning {
  cursor: grabbing;
}

/* Frames (HTML, DOCX) */
.pv-framewrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.pv-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
.pv-notice {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--warning-soft);
  color: var(--warning-text);
  border-bottom: 1px solid var(--warning-border);
}
.pv-notice.info {
  background: var(--info-soft);
  color: var(--text-2);
  border-color: var(--border);
}
.pv-notice details {
  flex-basis: 100%;
}
.pv-notice ul {
  margin: 4px 0 0;
  padding-left: 18px;
  max-height: 140px;
  overflow: auto;
  overflow-wrap: anywhere;
}
.pv-notice button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.82rem;
}

/* Text, Markdown, JSON */
.pv-text {
  margin: 0;
  min-height: 100%;
  padding: 20px 24px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 4;
}
.pv-text.is-wrapped {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pv-markdown {
  max-width: 900px;
  min-height: 100%;
  margin: 0 auto;
  padding: 36px 44px 60px;
  background: #fff;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.pv-markdown pre {
  background: var(--surface-sunken);
  padding: 12px 14px;
  border-radius: 8px;
  overflow: auto;
}
.pv-markdown table {
  border-collapse: collapse;
}
.pv-markdown th,
.pv-markdown td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}
.pv-markdown img {
  max-width: 100%;
}
.pv-banner {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 14px;
  font-size: 0.82rem;
  background: var(--info-soft);
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}

/* Tables (CSV, XLSX) */
.pv-sheet {
  min-height: 100%;
  background: #fff;
}
.pv-table {
  width: auto;
  border-collapse: collapse;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
.pv-table th,
.pv-table td {
  text-transform: none;
  letter-spacing: normal;
  border: 1px solid #e3e0da;
  padding: 3px 8px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.pv-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  font-weight: 600;
  z-index: 1;
}
.pv-table .pv-rownum {
  position: sticky;
  left: 0;
  background: var(--surface-muted);
  color: var(--text-faint);
  text-align: right;
  font-size: 0.76rem;
}
.pv-table thead .pv-rownum {
  z-index: 2;
}

/* Slides (PPTX) */
.pv-slides {
  padding: 18px;
}
.pv-slide {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.pv-shape {
  position: absolute;
  overflow: hidden;
  color: #1c1c1c;
}
.pv-shape p {
  margin: 0 0 0.2em;
  line-height: 1.18;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pv-shape p.bullet::before {
  content: "•";
  margin-right: 0.45em;
}
.pv-shape img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.pv-shape.pv-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #bbb;
  color: #777;
  font-size: 12px;
  text-align: center;
}
.pv-shape table {
  border-collapse: collapse;
  width: 100%;
  height: 100%;
}
.pv-shape td {
  border: 1px solid #999;
  padding: 2px 4px;
  vertical-align: top;
}
.pv-flow {
  position: static;
  padding: 0 4%;
}

/* Media */
.pv-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pv-media video {
  max-width: 100%;
  max-height: 100%;
  background: #000;
}
.pv-media audio {
  width: min(640px, 100%);
}

@media (max-width: 900px) {
  .viewer-bar {
    flex-wrap: wrap;
  }
  .viewer-title {
    flex-basis: calc(100% - 110px);
    order: 1;
  }
  .viewer-close {
    order: 2;
    margin-left: auto;
  }
  .viewer-nav {
    order: 3;
  }
  .viewer-controls {
    order: 5;
    flex-basis: 100%;
    flex-wrap: wrap;
  }
  .viewer-bar [data-viewer-download],
  .viewer-bar [data-viewer-fullscreen],
  .viewer-bar [data-viewer-details] {
    order: 4;
  }
  .viewer-details {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(330px, 90vw);
    z-index: 5;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  }
  .viewer-body {
    position: relative;
  }
  .pv-markdown {
    padding: 22px 18px 40px;
  }
}
