/* ─── Chat Panel ─── */

.chat-panel {

  display: flex;

  flex-direction: column;

  position: relative;

  min-width: 0;

  max-width: 100vw;

  height: 100dvh;

  overflow: hidden;

}

.temporary-chat-bar {

  position: absolute;

  top: 18px;

  right: 18px;

  left: 18px;

  z-index: 9;

  display: flex;

  align-items: center;

  justify-content: space-between;

  pointer-events: none;

}

.chat-panel > .temporary-chat-bar {

  position: absolute;

}

.temporary-chat-label {

  display: inline-flex;

  align-items: center;

  min-height: 34px;

  padding: 0 12px;

  border: 1px solid var(--border);

  border-radius: 999px;

  background: var(--bg);

  color: var(--text);

  font-size: 13px;

  font-weight: 650;

  box-shadow: var(--shadow-sm);

  pointer-events: auto;

}

.temporary-chat-toggle {

  display: inline-flex;

  align-items: center;

  justify-content: center;

  margin-left: auto;

  width: 40px;

  height: 40px;

  border: 1px solid var(--border);

  border-radius: 999px;

  background: var(--bg-secondary);

  color: var(--text-secondary);

  cursor: pointer;

  box-shadow: var(--shadow-sm);

  pointer-events: auto;

  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);

}

.temporary-chat-toggle:hover,

.temporary-chat-toggle.active {

  border-color: var(--accent);

  background: var(--accent-soft);

  color: var(--accent);

}

.temporary-chat-toggle:active {

  transform: scale(0.96);

}

.document-viewer {

  position: relative;

  display: flex;

  flex-direction: column;

  min-width: 0;

  height: 100dvh;

  background: var(--bg-secondary);

  border-left: 1px solid var(--border);

  overflow: hidden;

  transform-origin: right center;

}

.document-viewer-resizer {

  position: absolute;

  inset: 0 auto 0 -7px;

  width: 14px;

  cursor: col-resize;

  z-index: 3;

}

.document-viewer-resizer::after {

  content: "";

  position: absolute;

  left: 5px;

  top: 50%;

  width: 4px;

  height: 42px;

  border-radius: 999px;

  background: #c9c9c9;

  transform: translateY(-50%);

  box-shadow: 0 0 0 1px rgba(0,0,0,0.04);

}

.document-viewer-resizer:hover::after,

body.document-viewer-resizing .document-viewer-resizer::after {

  background: #8c8c8c;

}

body.document-viewer-resizing {

  cursor: col-resize;

  user-select: none;

}

.document-viewer-header {

  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 16px;

  height: 56px;

  padding: 0 16px 0 22px;

  background: var(--bg);

  border-bottom: 1px solid var(--border-light);

  flex-shrink: 0;

}

.document-viewer-title-wrap {

  min-width: 0;

}

.document-viewer-title {

  color: var(--text);

  font-size: 14px;

  font-weight: 650;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;

}

.document-viewer-meta {

  color: var(--text-secondary);

  font-size: 12px;

  line-height: 1.2;

  text-transform: uppercase;

}

.document-viewer-actions {

  display: inline-flex;

  align-items: center;

  gap: 8px;

  flex-shrink: 0;

  position: relative;

}

.document-download-menu {

  position: absolute;

  z-index: 8;

  top: calc(100% + 8px);

  right: 40px;

  width: 190px;

  padding: 6px;

  border: 1px solid var(--border);

  border-radius: 8px;

  background: var(--bg);

  box-shadow: var(--shadow-lg);

}

.document-download-menu button {

  display: flex;

  align-items: center;

  justify-content: space-between;

  width: 100%;

  min-height: 38px;

  padding: 0 10px;

  border: 0;

  border-radius: 5px;

  background: transparent;

  color: var(--text);

  font-size: 13px;

  text-align: left;

}

.document-download-menu button:hover {

  background: var(--bg-secondary);

}

.document-download-menu small {

  color: var(--text-tertiary);

  font-size: 11px;

}

.document-viewer-action,

.document-viewer-close {

  display: inline-flex;

  align-items: center;

  justify-content: center;

  min-height: 32px;

  padding: 0 12px;

  border-radius: 6px;

  border: 1px solid var(--border);

  background: var(--bg);

  color: var(--text);

  font-size: 13px;

  font-weight: 650;

  text-decoration: none;

}

.document-viewer-close {

  width: 32px;

  padding: 0;

}

.document-viewer-action:hover,

.document-viewer-close:hover {

  background: var(--bg-secondary);

}

.document-viewer-body {

  flex: 1;

  min-height: 0;

  overflow: auto;

  padding: 18px;

  background: var(--bg-secondary);

}

.document-editor-shell {

  display: flex;

  flex-direction: column;

  min-height: calc(100% + 36px);

  margin: -18px;

  background: var(--bg-secondary);

}

.document-editor-toolbar,

.document-table-toolbar {

  position: sticky;

  z-index: 5;

  display: flex;

  align-items: center;

  gap: 3px;

  overflow-x: auto;

  padding: 7px 12px;

  border-bottom: 1px solid var(--border-light);

  background: var(--bg);

  scrollbar-width: none;

}

.document-editor-toolbar {

  top: 0;

}

.document-table-toolbar {

  top: 43px;

  z-index: 4;

  background: var(--bg-secondary);

}

.document-editor-toolbar::-webkit-scrollbar,

.document-table-toolbar::-webkit-scrollbar {

  display: none;

}

.document-editor-toolbar button,

.document-table-toolbar button {

  flex: 0 0 auto;

  min-width: 28px;

  height: 28px;

  padding: 0 7px;

  border: 0;

  border-radius: 5px;

  background: transparent;

  color: var(--text-secondary);

  font-size: 12px;

}

.document-editor-toolbar button:hover,

.document-table-toolbar button:hover,

.document-editor-toolbar button.active {

  background: var(--border-light);

  color: var(--text);

}

.document-editor-toolbar button:disabled {

  opacity: 0.3;

}

.document-table-toolbar button.danger:hover {

  color: var(--danger);

}

.document-editor-divider {

  flex: 0 0 auto;

  width: 1px;

  height: 20px;

  margin: 0 3px;

  background: var(--border);

}

.document-editor-scroll {

  flex: 1;

  padding: 22px;

}

.document-editor-paper {

  width: min(100%, 780px);

  min-height: 960px;

  margin: 0 auto;

  padding: clamp(34px, 7vw, 72px);

  border: 1px solid var(--border-light);

  background: var(--bg);

  box-shadow: var(--shadow-sm);

}

.document-editor-content {

  min-height: 780px;

  color: var(--text);

  font-size: 15px;

  line-height: 1.7;

  outline: none;

}

.document-editor-content > :first-child {

  margin-top: 0;

}

.document-editor-content h1,

.document-editor-content h2,

.document-editor-content h3 {

  letter-spacing: 0;

  line-height: 1.25;

}

.document-editor-content h1 {

  margin: 0 0 28px;

  font-size: 30px;

}

.document-editor-content h2 {

  margin: 30px 0 10px;

  font-size: 21px;

}

.document-editor-content h3 {

  margin: 24px 0 8px;

  font-size: 17px;

}

.document-editor-content p,

.document-editor-content ul,

.document-editor-content ol,

.document-editor-content blockquote,

.document-editor-content pre,

.document-editor-content table {

  margin: 0 0 16px;

}

.document-editor-content blockquote {

  padding-left: 14px;

  border-left: 3px solid var(--border);

  color: var(--text-secondary);

}

.document-editor-content code {

  padding: 2px 4px;

  border-radius: 4px;

  background: var(--code-inline-bg);

  font-size: 0.9em;

}

.document-editor-content pre {

  overflow-x: auto;

  padding: 14px;

  border: 1px solid var(--code-border);

  border-radius: 6px;

  background: var(--code-bg);

}

.document-editor-content pre code {

  padding: 0;

  background: transparent;

}

.document-editor-content .tableWrapper {

  overflow-x: auto;

  margin: 0 0 18px;

}

.document-editor-content table {

  width: 100%;

  border-collapse: collapse;

}

.document-editor-content th,

.document-editor-content td {

  min-width: 90px;

  padding: 8px 10px;

  border: 1px solid var(--border);

  text-align: left;

  vertical-align: top;

}

.document-editor-content th {

  background: var(--bg-secondary);

  font-weight: 650;

}

.document-editor-content .selectedCell::after {

  content: "";

  position: absolute;

  inset: 0;

  pointer-events: none;

  background: rgba(80, 120, 255, 0.12);

}

.document-editor-content th,

.document-editor-content td {

  position: relative;

}

@media (max-width: 700px) {

  .document-editor-scroll {

    padding: 0;

  }

  .document-editor-paper {

    min-height: 100%;

    padding: 28px 20px;

    border: 0;

    box-shadow: none;

  }

}

/* Editable document surface */
.document-viewer-header {
  height: 68px;
  padding: 0 16px;
}

.document-viewer-title-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
}

.document-viewer-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.document-viewer-title-copy {
  min-width: 0;
}

.document-viewer-title {
  font-size: 14px;
  font-weight: 700;
}

.document-viewer-meta {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0;
}

.document-viewer-action {
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border-color: var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}

.document-viewer-action:hover {
  background: var(--accent-hover);
}

.document-viewer-action:active,
.document-viewer-icon-action:active,
.document-viewer-close:active,
.document-editor-toolbar button:active,
.document-table-toolbar button:active {
  transform: scale(0.96);
}

.document-download-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -1px;
}

.document-viewer-icon-action,
.document-viewer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  transition: transform 140ms var(--ease-out), background-color 140ms ease, color 140ms ease;
}

.document-viewer-icon-action:hover,
.document-viewer-close:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.document-download-menu {
  top: calc(100% + 8px);
  right: auto;
  left: 0;
  transform-origin: top left;
}

.document-viewer-body.is-editable {
  padding: 0;
  background: var(--bg);
}

.document-editor-shell {
  position: relative;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

.document-editor-toolbar {
  top: 0;
  min-height: 48px;
  padding: 7px 16px;
  gap: 4px;
  border-bottom: 1px solid var(--border-light);
}

.document-editor-toolbar button,
.document-table-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 7px;
  font-size: 14px;
  transition: transform 120ms var(--ease-out), background-color 120ms ease, color 120ms ease;
}

.document-editor-toolbar button svg,
.document-table-toolbar button svg {
  pointer-events: none;
}

.document-editor-toolbar button.active {
  background: color-mix(in srgb, var(--text) 9%, transparent);
}

.formula-icon {
  font-size: 16px;
  letter-spacing: 0;
}

.document-editor-divider {
  height: 22px;
  margin: 0 4px;
}

.document-editor-scroll {
  padding: 0;
}

.document-editor-paper {
  width: 100%;
  min-height: calc(100dvh - 117px);
  margin: 0;
  padding: clamp(42px, 6vw, 76px);
  border: 0;
  background: var(--bg);
  box-shadow: none;
}

.document-table-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  width: max-content;
  max-width: calc(100% - 20px);
  min-height: 44px;
  padding: 5px;
  gap: 3px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.06);
}

.document-table-toolbar .document-editor-divider {
  height: 24px;
  margin: 0 2px;
}

.document-table-toolbar button.danger {
  color: var(--danger);
}

.document-formula-popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9;
  width: min(274px, calc(100% - 24px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.14), 0 1px 4px rgba(0,0,0,0.06);
}

.document-formula-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  overflow: auto;
}

.document-formula-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.document-formula-input-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
  background: var(--bg-secondary);
  color: var(--text);
  font: 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.document-formula-input-row input:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.document-formula-input-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.document-formula-input-row button:active {
  transform: scale(0.97);
}

.document-revise-pill {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  max-width: min(320px, calc(100% - 24px));
  min-height: 36px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.06);
  transform-origin: bottom left;
  transition: opacity 160ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), transform 160ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}

.document-revise-pill.hidden {
  display: none;
}

.document-revise-ask {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}

.document-revise-ask:hover {
  background: var(--bg-secondary);
}

.document-revise-ask:active {
  transform: scale(0.97);
}

.document-revise-form {
  display: flex;
  align-items: center;
  gap: 4px;
  width: min(280px, 72vw);
  padding: 0 2px 0 8px;
}

.document-revise-form.hidden {
  display: none;
}

.document-revise-form input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.document-revise-form input::placeholder {
  color: var(--text-tertiary);
}

.document-revise-send,
.document-revise-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  transition: transform 140ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), opacity 140ms ease;
}

.document-revise-send:active,
.document-revise-stop:active {
  transform: scale(0.97);
}

.document-revise-send.hidden,
.document-revise-stop.hidden {
  display: none;
}

.document-editor-content .doc-revise-pending {
  border-radius: 4px;
  color: transparent;
  background-image: linear-gradient(
    110deg,
    color-mix(in srgb, var(--text-secondary) 35%, transparent) 0%,
    color-mix(in srgb, var(--text) 70%, transparent) 45%,
    color-mix(in srgb, var(--text-secondary) 35%, transparent) 90%
  );
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  filter: blur(1.2px);
  animation: doc-revise-shimmer 1.15s linear infinite;
}

@keyframes doc-revise-shimmer {
  from { background-position: 100% center; }
  to { background-position: 0% center; }
}

@media (prefers-reduced-motion: reduce) {
  .document-revise-pill,
  .document-revise-ask,
  .document-revise-send,
  .document-revise-stop {
    transition: none;
  }

  .document-editor-content .doc-revise-pending {
    animation: none;
    filter: blur(0.6px);
    opacity: 0.72;
  }
}

body.document-viewer-fullscreen {
  overflow: hidden;
}

body.document-viewer-fullscreen .app-shell {
  visibility: hidden;
}

body.document-viewer-fullscreen .document-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  width: auto;
  height: 100dvh;
  border: 0;
}

body.document-viewer-fullscreen .document-viewer-resizer {
  display: none;
}

@media (max-width: 700px) {
  body.document-viewer-fullscreen .document-viewer {
    inset: 0;
  }

  .document-viewer-header {
    height: 60px;
    padding: 0 10px;
  }

  .document-viewer-file-icon {
    display: none;
  }

  .document-viewer-actions {
    gap: 3px;
  }

  .document-viewer-action {
    min-height: 34px;
    padding: 0 10px;
  }

  .document-editor-toolbar {
    padding-inline: 8px;
  }

  .document-editor-paper {
    min-height: calc(100dvh - 109px);
    padding: 32px 20px;
  }
}

.pdf-pages {

  display: grid;

  justify-items: center;

  gap: 18px;

  width: 100%;

  min-height: 100%;

}

.office-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.office-viewer iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.pdf-page {

  width: fit-content;

  max-width: 100%;

  background: white;

  box-shadow: 0 1px 5px rgba(0,0,0,0.12);

}

.pdf-page canvas {

  display: block;

  max-width: 100%;

  height: auto !important;

  background: white;

}

.pdf-page-placeholder {

  width: min(100%, 720px);

  min-width: min(100%, 320px);

  min-height: inherit;

  display: flex;

  align-items: center;

  justify-content: center;

  color: var(--text-secondary);

  background: white;

}

.document-viewer-empty {

  min-height: 100%;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 8px;

  color: var(--text-secondary);

  font-size: 14px;

  text-align: center;

  padding: 24px;

}

.sheet-viewer {

  min-width: max-content;

}

.sheet-tabs {

  position: sticky;

  top: -18px;

  z-index: 3;

  display: flex;

  gap: 4px;

  padding: 10px 0;

  background: var(--bg-secondary);

}

.sheet-tabs button {

  min-height: 30px;

  padding: 0 10px;

  border: 1px solid var(--border);

  border-radius: 6px;

  background: var(--bg);

  color: var(--text-secondary);

  font-size: 12px;

}

.sheet-tabs button[aria-selected="true"] {

  border-color: var(--text-secondary);

  color: var(--text);

}

.sheet-grid table {

  border-spacing: 0;

  border-collapse: separate;

  background: var(--bg);

  font-size: 12px;

}

.sheet-grid th,

.sheet-grid td {

  min-width: 96px;

  max-width: 320px;

  padding: 7px 9px;

  border-right: 1px solid var(--border-light);

  border-bottom: 1px solid var(--border-light);

  color: var(--text);

  text-align: left;

  white-space: pre-wrap;

  overflow-wrap: anywhere;

}

.sheet-grid thead th,

.sheet-grid tbody th {

  position: sticky;

  background: var(--bg-secondary);

  color: var(--text-secondary);

  font-weight: 600;

}

.sheet-grid thead th {

  top: 42px;

  z-index: 2;

  text-align: center;

}

.sheet-grid tbody th {

  left: 0;

  z-index: 1;

  min-width: 42px;

  width: 42px;

  text-align: right;

}

.sheet-grid .sheet-corner {

  left: 0;

  z-index: 3;

  min-width: 42px;

}

body[data-mode="dark"] .sheet-grid td {

  background: #1b1b1b;

  border-color: #454545;

}

body[data-mode="dark"] .sheet-grid tr:nth-child(even) td {

  background: #202020;

}

body[data-mode="dark"] .sheet-grid thead th,

body[data-mode="dark"] .sheet-grid tbody th {

  background: #2f2f2f;

  border-color: #4a4a4a;

}

/* ─── Top Bar ─── */

.topbar {

  display: flex;

  align-items: center;

  justify-content: flex-end;

  gap: 10px;

  height: 56px;

  padding: 0 24px;

  flex-shrink: 0;

}

.context-meter {

  display: inline-flex;

  align-items: center;

  gap: 8px;

  min-width: 132px;

  padding: 5px 10px;

  border-radius: var(--radius-full);

  background: var(--bg-secondary);

  color: var(--text-tertiary);

  font-size: 12px;

  font-weight: 600;

}

.context-meter-track {

  position: relative;

  width: 42px;

  height: 4px;

  overflow: hidden;

  border-radius: var(--radius-full);

  background: rgba(0, 0, 0, 0.08);

}

.context-meter-fill {

  position: absolute;

  inset: 0 auto 0 0;

  width: 0;

  border-radius: inherit;

  background: var(--accent);

  transition: width var(--transition);

}

.context-meter.warn .context-meter-fill {

  background: #d97706;

}

.context-meter.over .context-meter-fill {

  background: #dc2626;

}

.context-meter.over {

  color: #dc2626;

}

.usage-pill {

  font-size: 12px;

  font-weight: 600;

  color: var(--text-tertiary);

  padding: 4px 10px;

  border-radius: var(--radius-full);

  background: var(--bg-secondary);

}

.usage-pill:empty { display: none; }

/* Shared preview navigation also serves the embedded Dojo source viewer. */
.document-preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-shrink: 0; padding: 8px; border-bottom: 1px solid var(--border); background: var(--bg); color: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.document-page-controls, .document-preview-tools, .document-zoom-control { display: flex; align-items: center; gap: 3px; }
.document-preview-tools { margin-left: auto; }
.document-preview-toolbar [hidden] { display: none; }
.document-preview-toolbar button { width: 25px; height: 29px; display: grid; place-items: center; padding: 4px; border: 0; border-radius: 6px; color: var(--text-secondary); background: transparent; cursor: pointer; transition: transform 140ms cubic-bezier(.23, 1, .32, 1); }
.document-preview-toolbar button:active { transform: scale(.97); }
.document-preview-toolbar button:disabled { opacity: .3; cursor: default; }
.document-preview-toolbar input { width: 38px; height: 28px; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-secondary); color: var(--text); text-align: center; font: inherit; appearance: textfield; }
.document-preview-toolbar input::-webkit-inner-spin-button { appearance: none; }
.document-preview-toolbar select { max-width: 60px; border: 0; padding: 4px 0; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.document-zoom-control > svg { width: 15px; height: 15px; }
.document-preview-toolbar :is(button, input, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.document-viewer .pdf-pages { margin-inline: auto; }
.document-viewer .pdf-page { max-width: none; }
.document-viewer .pdf-page canvas { max-width: none; }
.document-viewer[data-source-format="pdf"] .document-viewer-file-icon { color: #ce535b; background: #d8586110; }
.document-viewer[data-source-format="slides"] .document-viewer-file-icon { color: #d47736; background: #dd7c3012; }
.document-viewer[data-source-format="word"] .document-viewer-file-icon { color: #4a80d0; background: #4d82d614; }
@media (hover: hover) and (pointer: fine) {
  .document-preview-toolbar button:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text); }
}
@media (prefers-reduced-motion: reduce) {
  .document-preview-toolbar button { transition: none; }
  .document-preview-toolbar button:active { transform: none; }
}

/* Selectable text over rendered pages (pdf.js text layer). */
.document-viewer .pdf-page { position: relative; }
.document-viewer .textLayer { --scale-round-x: 1px; --scale-round-y: 1px; position: absolute; inset: 0; overflow: clip; line-height: 1; text-align: initial; opacity: 1; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 1; }
.document-viewer .textLayer :is(span, br) { position: absolute; color: transparent; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.document-viewer .textLayer > :not(.markedContent), .document-viewer .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.document-viewer .textLayer span.markedContent { top: 0; height: 0; }
.document-viewer .textLayer span[role="img"] { user-select: none; cursor: default; }
.document-viewer .textLayer ::selection { background: rgba(37, 99, 235, 0.28); }
.document-viewer .textLayer br::selection { background: transparent; }
.document-viewer .textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.document-viewer .textLayer.selecting .endOfContent { top: 0; }

/* Ask Klui: a bar at the bottom for the whole document, a pill at a selection. */
.document-viewer .pdf-pages { padding-bottom: 88px; }
.doc-ask { position: absolute; left: 50%; bottom: 20px; z-index: 6; display: flex; justify-content: center; width: min(560px, calc(100% - 24px)); transform: translateX(-50%); pointer-events: none; }
.doc-ask > * { pointer-events: auto; }
.doc-ask.hidden, .doc-ask-pill.hidden, .doc-ask [hidden] { display: none !important; }
.doc-ask { transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s; }
.doc-ask.is-behind-pill:not(.is-busy) { opacity: 0; visibility: hidden; transform: translateX(-50%) translateY(8px) scale(0.96); transition: opacity 140ms ease-in, transform 140ms ease-in, visibility 0s 140ms; }
/* Each part pops in when it appears and fades out before it is hidden (setAskShown). A part on its way
   out leaves the layout so the one replacing it takes its place at once. */
.doc-ask-open, .doc-ask-form, .doc-ask-status { transform-origin: 50% 100%; animation: doc-ask-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.doc-ask-pill { transform-origin: 50% 0; animation: doc-ask-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.doc-ask > .is-leaving { position: absolute; bottom: 0; }
.doc-ask .is-leaving, .doc-ask-pill.is-leaving { pointer-events: none !important; animation: doc-ask-out 150ms ease-in forwards; }
@keyframes doc-ask-in { from { opacity: 0; transform: translateY(6px) scale(0.94); } }
@keyframes doc-ask-out { to { opacity: 0; transform: translateY(4px) scale(0.96); } }
.hiddenCanvasElement { position: absolute; top: 0; left: 0; width: 0; height: 0; display: none; }
.doc-ask-open, .doc-ask-status { display: inline-flex; align-items: center; gap: 9px; height: 46px; padding: 0 22px; border: 0; border-radius: 999px; background: #1d1d1f; color: #f5f5f7; font: 500 15px/1 var(--font-sans); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.06); cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.doc-ask-open:hover { background: #2a2a2d; transform: translateY(-1px); }
.doc-ask-status { cursor: default; font-weight: 400; }
.doc-ask-status .artifact-spinner { width: 15px; height: 15px; }
.doc-ask-form, .doc-ask-pill { display: flex; align-items: flex-end; gap: 8px; width: 100%; padding: 7px 7px 7px 18px; border-radius: 24px; background: #1d1d1f; box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.06); }
.doc-ask-pill { position: absolute; z-index: 7; }
.doc-ask-form textarea, .doc-ask-pill textarea { flex: 1; min-width: 0; max-height: 120px; padding: 7px 0; border: 0; outline: 0; resize: none; background: transparent; color: #f5f5f7; font: 400 15px/22px var(--font-sans); }
.doc-ask-form textarea::placeholder, .doc-ask-pill textarea::placeholder { color: #9a9aa0; }
.doc-ask-send { flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f5f5f7; color: #1d1d1f; cursor: pointer; }
.doc-ask-send:hover { background: #fff; }
/* The same shape and size as the selection pill (380px wide, see showPill). */
.doc-ask-form { width: min(380px, 100%); }
.doc-ask-klui { flex: 0 0 auto; width: 22px; height: 14px; }
.doc-ask-mark { position: absolute; z-index: 2; border-radius: 2px; background: rgba(37, 99, 235, 0.26); pointer-events: none; }
.document-viewer-body.is-asking .doc-ask-mark { animation: doc-ask-pulse 1.3s ease-in-out infinite; }
@keyframes doc-ask-pulse { 50% { background: rgba(37, 99, 235, 0.12); } }
@media (prefers-reduced-motion: reduce) { .document-viewer-body.is-asking .doc-ask-mark { animation: none; } .doc-ask-open { transition: none; } .doc-ask, .doc-ask-open, .doc-ask-form, .doc-ask-status, .doc-ask-pill { animation: none !important; transition: none !important; } }
.document-download-menu button[hidden] { display: none; }
