/* ===================================================================
   GlobalSearch Explorer — GlobalSearch Material theme (see styling/README.md):
   Angular Material look, navy primary #152245, blue-grey accent #607d8b,
   warn #f44336, Roboto, 4px radii, uppercase buttons, filled form fields,
   64px navy app bar, ag-grid style tables.
   =================================================================== */

:root {
  --primary: #152245;
  --on-primary: #ffffff;
  --primary-container: #e3e6ee;
  --on-primary-container: #152245;
  --secondary-container: #e6ebee;
  --on-secondary-container: #1f2a30;
  --tertiary: #607d8b;
  --tertiary-container: #cfd8dc;
  --error: #f44336;
  --on-error: #ffffff;
  --error-container: #fdecea;
  --on-error-container: #b71c1c;
  --warn: #ef6c00;
  --success: #51a351;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-low: #f5f5f5;
  --surface-container: #eeeeee;
  --surface-high: #e0e0e0;
  --on-surface: #212121;
  --on-surface-variant: #666666;
  --text-hint: #9e9e9e;
  --outline: #949494;
  --outline-variant: #e0e0e0;
  --row-hover: rgba(33, 150, 243, .06);
  --row-selected: rgba(21, 34, 69, .08);
  --nav-selected: #cfd8dc;
  --grid-head: #181d1f;
  --grid-rule: #dde2eb;
  --field-bg: #f5f5f5;
  --field-bg-hover: #ececec;
  --field-underline: rgba(0, 0, 0, .42);
  --disabled-bg: rgba(0, 0, 0, .12);
  --chip-bg: #e0e0e0;
  --doc-bg: #d4d4d7;
  --scrim: rgba(0, 0, 0, .32);
  --appbar: #152245;
  --on-appbar: #ffffff;
  --appbar-variant: rgba(255, 255, 255, .7);
  --accent: #607d8b;
  --scroll-track: #e3e4e9;
  --scroll-thumb: #b0bec5;
  --inverse-surface: #323232;
  --inverse-on-surface: #ffffff;
  --watermark-filter: brightness(0);
  --watermark-opacity: .07;

  /* Material elevation levels: 1 card, 2 raised button, 4 snackbar, 8 menu, 16 dialog */
  --elev-1: 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 3px 0 rgba(0,0,0,.12);
  --elev-2: 0 3px 3px -2px rgba(0,0,0,.2), 0 3px 4px 0 rgba(0,0,0,.14), 0 1px 8px 0 rgba(0,0,0,.12);
  --elev-3: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12);
  --elev-4: 0 8px 10px -5px rgba(0,0,0,.2), 0 16px 24px 2px rgba(0,0,0,.14), 0 6px 30px 5px rgba(0,0,0,.12);

  --r-sm: 4px;
  --r-md: 4px;
  --r-lg: 4px;
  --r-xl: 4px;
  --r-chip: 16px;
  --sidebar-w: 300px;
  --toolbar-h: 64px;
  --meta-w: 320px;
  color-scheme: light;
}

/* Dark tokens: used when the OS prefers dark (unless the user picked light), or when the user picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #9fb2e6;
    --on-primary: #0f1936;
    --primary-container: #2c3a63;
    --on-primary-container: #dfe5f5;
    --secondary-container: #37474f;
    --on-secondary-container: #eceff1;
    --tertiary: #90a4ae;
    --tertiary-container: #37474f;
    --error: #ef9a9a;
    --on-error: #2b0b0b;
    --error-container: #5c1d1d;
    --on-error-container: #ffebee;
    --warn: #ffb74d;
    --success: #81c784;
    --bg: #1e2129;
    --surface: #262a34;
    --surface-low: #2b303b;
    --surface-container: #323844;
    --surface-high: #3b4250;
    --on-surface: #eceff1;
    --on-surface-variant: #b0bec5;
    --text-hint: #78909c;
    --outline: #78909c;
    --outline-variant: #3d4452;
    --row-hover: rgba(144, 202, 249, .07);
    --row-selected: rgba(159, 178, 230, .14);
    --nav-selected: #37474f;
    --grid-head: #eceff1;
    --grid-rule: #3d4452;
    --field-bg: rgba(255, 255, 255, .06);
    --field-bg-hover: rgba(255, 255, 255, .1);
    --field-underline: rgba(255, 255, 255, .5);
    --disabled-bg: rgba(255, 255, 255, .12);
    --chip-bg: #3b4250;
    --doc-bg: #3a3d45;
    --scrim: rgba(0, 0, 0, .6);
    --appbar: #0f1936;
    --on-appbar: #eceff1;
    --appbar-variant: rgba(236, 239, 241, .7);
    --accent: #90a4ae;
    --scroll-track: #262a34;
    --scroll-thumb: #4f5a6b;
    --inverse-surface: #eceff1;
    --inverse-on-surface: #212121;
    --watermark-filter: none;
    --watermark-opacity: .06;
    --elev-1: 0 1px 3px rgba(0, 0, 0, .5);
    --elev-2: 0 2px 6px rgba(0, 0, 0, .5);
    --elev-3: 0 6px 18px rgba(0, 0, 0, .6);
    --elev-4: 0 12px 36px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #9fb2e6;
  --on-primary: #0f1936;
  --primary-container: #2c3a63;
  --on-primary-container: #dfe5f5;
  --secondary-container: #37474f;
  --on-secondary-container: #eceff1;
  --tertiary: #90a4ae;
  --tertiary-container: #37474f;
  --error: #ef9a9a;
  --on-error: #2b0b0b;
  --error-container: #5c1d1d;
  --on-error-container: #ffebee;
  --warn: #ffb74d;
  --success: #81c784;
  --bg: #1e2129;
  --surface: #262a34;
  --surface-low: #2b303b;
  --surface-container: #323844;
  --surface-high: #3b4250;
  --on-surface: #eceff1;
  --on-surface-variant: #b0bec5;
  --text-hint: #78909c;
  --outline: #78909c;
  --outline-variant: #3d4452;
  --row-hover: rgba(144, 202, 249, .07);
  --row-selected: rgba(159, 178, 230, .14);
  --nav-selected: #37474f;
  --grid-head: #eceff1;
  --grid-rule: #3d4452;
  --field-bg: rgba(255, 255, 255, .06);
  --field-bg-hover: rgba(255, 255, 255, .1);
  --field-underline: rgba(255, 255, 255, .5);
  --disabled-bg: rgba(255, 255, 255, .12);
  --chip-bg: #3b4250;
  --doc-bg: #3a3d45;
  --scrim: rgba(0, 0, 0, .6);
  --appbar: #0f1936;
  --on-appbar: #eceff1;
  --appbar-variant: rgba(236, 239, 241, .7);
  --accent: #90a4ae;
  --scroll-track: #262a34;
  --scroll-thumb: #4f5a6b;
  --inverse-surface: #eceff1;
  --inverse-on-surface: #212121;
  --watermark-filter: none;
  --watermark-opacity: .06;
  --elev-1: 0 1px 3px rgba(0, 0, 0, .5);
  --elev-2: 0 2px 6px rgba(0, 0, 0, .5);
  --elev-3: 0 6px 18px rgba(0, 0, 0, .6);
  --elev-4: 0 12px 36px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font: 400 14px/20px Roboto, "Helvetica Neue", system-ui, "Segoe UI", sans-serif;
  letter-spacing: .0178571429em;
  -webkit-font-smoothing: antialiased;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: var(--scroll-track); }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
*::-webkit-scrollbar-corner { background: var(--scroll-track); }

h1 { font: 400 24px/32px Roboto, sans-serif; margin: 0; }
h2 { font: 400 20px/32px Roboto, sans-serif; margin: 0; letter-spacing: .0125em; }
h3 { font: 500 20px/32px Roboto, sans-serif; margin: 0; letter-spacing: .0125em; }
.muted { color: var(--on-surface-variant); }
.spacer { flex: 1; }
svg { flex: none; }

/* ---------- Inputs (Material filled form field) ---------- */
input, select, button, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=number], input[type=email], select {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--field-underline);
  border-radius: 4px 4px 0 0;
  background: var(--field-bg);
  min-height: 42px;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
input[type=text]:hover, input[type=password]:hover, input[type=search]:hover, input[type=date]:hover,
input[type=number]:hover, input[type=email]:hover, select:hover { background-color: var(--field-bg-hover); border-bottom-color: var(--on-surface); }
input:focus, select:focus, textarea:focus { outline: none; border-bottom-color: var(--primary); box-shadow: inset 0 -1px 0 var(--primary); }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
select option { background: var(--surface); color: var(--on-surface); }
::placeholder { color: var(--text-hint); opacity: 1; }

/* A label wrapping its input renders as one filled field: small label on top, value underneath. */
.field {
  display: grid; gap: 2px; padding: 8px 12px 0; position: relative;
  background: var(--field-bg); border-radius: 4px 4px 0 0; border-bottom: 1px solid var(--field-underline);
  font: 400 12px/16px Roboto, sans-serif; letter-spacing: .0333em; color: var(--on-surface-variant);
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.field:hover { background: var(--field-bg-hover); border-bottom-color: var(--on-surface); }
.field:focus-within { color: var(--primary); border-bottom-color: var(--primary); box-shadow: inset 0 -1px 0 var(--primary); }
.field input, .field select, .field textarea {
  border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none !important;
  padding: 0 0 8px; min-height: 32px; font: 400 16px/24px Roboto, sans-serif; letter-spacing: .03125em; color: var(--on-surface);
}
.field select { cursor: pointer; }
.field .hint { padding-bottom: 6px; color: var(--on-surface-variant); }
.field strong { font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; height: 36px; min-width: 64px; border-radius: 4px; border: 0; overflow: hidden;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 500 14px/36px Roboto, sans-serif; letter-spacing: .0892857143em; text-transform: uppercase;
  transition: box-shadow .15s, background-color .15s;
}
.btn::after, .icon-btn::after {
  content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.btn:hover:not(:disabled)::after, .icon-btn:hover:not(:disabled)::after { opacity: .08; }
.btn:active:not(:disabled)::after, .icon-btn:active:not(:disabled)::after { opacity: .16; }
.btn svg { margin-left: -4px; }
.btn-sm { height: 32px; line-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-filled { background: var(--primary); color: var(--on-primary); }
.btn-filled:hover:not(:disabled) { box-shadow: var(--elev-2); }
.btn-tonal { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 1px var(--outline-variant); }
.btn-text { background: transparent; color: var(--primary); padding: 0 8px; }
.btn-danger { background: var(--error); color: var(--on-error); }
.btn:disabled { color: var(--text-hint); background: var(--disabled-bg); box-shadow: none; cursor: default; }
.btn-text:disabled { background: transparent; }
.btn-tonal:disabled { background: transparent; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.btn-block { width: 100%; }
.btn.has-icon { padding-left: 12px; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--on-surface-variant);
  text-decoration: none; overflow: hidden;
}
.icon-btn:disabled { color: var(--text-hint); opacity: .7; cursor: default; }
.icon-btn.toggle[aria-pressed="true"] { background: var(--row-selected); color: var(--primary); }

.alert {
  padding: 10px 14px; border-radius: 4px; background: var(--error-container); color: var(--on-error-container);
  border-left: 4px solid var(--error); text-align: left; font-size: 14px;
}

.card { background: var(--surface); border-radius: 4px; box-shadow: var(--elev-1); }

.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; min-width: 0; }
.app-logo { display: inline-flex; align-items: center; height: 46px; margin: 0 4px 0 6px; }
.app-logo img { height: 46px; width: auto; display: block; }
.brand-name {
  font: 300 20px/32px Roboto, sans-serif; letter-spacing: .0125em; color: var(--appbar-variant);
  padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .28);
}

.spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block; vertical-align: -3px; flex: none;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(var(--appbar) 0 38%, var(--bg) 38%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 4px;
  padding: 0 32px 32px; box-shadow: var(--elev-4); display: grid; gap: 16px; overflow: hidden;
}
.login-brand {
  display: flex; align-items: center; justify-content: center; height: 88px; margin: 0 -32px 8px;
  background: var(--appbar); border-bottom: 4px solid var(--accent);
}
.login-brand img { height: 46px; width: auto; display: block; }
.login-title { color: var(--on-surface); }
.login-card p { margin: -14px 0 2px; }

/* ---------- App shell ---------- */
.app-view { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 4px; padding: 0 8px 0 4px; height: var(--toolbar-h);
  background: var(--appbar); color: var(--on-appbar); flex: none; box-shadow: var(--elev-2); position: relative; z-index: 5;
}
.topbar .icon-btn { color: var(--on-appbar); width: 48px; height: 48px; }
.topbar .icon-btn:disabled { color: rgba(255, 255, 255, .4); }
.topbar .user-label { color: var(--appbar-variant); }
.user-chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 0 8px; margin-right: 4px;
  min-width: 0; max-width: 340px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--on-appbar); color: var(--appbar); font-weight: 500; font-size: 14px; letter-spacing: 0;
}
.user-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--on-surface-variant); }
.th { display: none; }
#theme-btn[data-mode="system"] .th-system,
#theme-btn[data-mode="light"] .th-light,
#theme-btn[data-mode="dark"] .th-dark { display: block; }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------- Navigation drawer ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--outline-variant);
  transition: margin-left .2s cubic-bezier(.25, .8, .25, 1);
}
.layout.nav-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-head { display: grid; gap: 12px; padding: 12px; border-bottom: 1px solid var(--outline-variant); }

.db-picker {
  position: relative; display: flex; align-items: center; border-radius: 4px 4px 0 0;
  background: var(--field-bg); color: var(--on-surface); cursor: pointer;
  border-bottom: 1px solid var(--field-underline); transition: background-color .15s;
}
.db-picker:hover { background: var(--field-bg-hover); }
.db-picker:focus-within { border-bottom-color: var(--primary); box-shadow: inset 0 -1px 0 var(--primary); }
.db-picker select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 0 40px 0 46px; height: 52px; font-weight: 500; font-size: 16px; color: inherit; border-radius: 4px 4px 0 0;
}
.db-picker select:hover, .db-picker select:focus { background: transparent; box-shadow: none; }
.db-picker .db-ico { position: absolute; left: 14px; pointer-events: none; color: var(--primary); }
.db-picker .caret { position: absolute; right: 12px; pointer-events: none; color: var(--on-surface-variant); }

.search-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 12px; color: var(--on-surface-variant); pointer-events: none; }
.search-field input { padding-left: 40px; min-height: 40px; }

/* Tasks | Archives | Searches | Both */
.nav-view { display: flex; border-radius: 4px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.nav-view label { flex: 1; position: relative; min-width: 0; }
.nav-view label + label { box-shadow: inset 1px 0 0 var(--outline-variant); }
.nav-view input { position: absolute; opacity: 0; }
.nav-view span {
  display: block; text-align: center; padding: 0 4px; line-height: 32px; cursor: pointer; font-size: 12.5px; font-weight: 500;
  color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-view span:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.nav-view input:checked + span { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.nav-view input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.task-toggle { cursor: pointer; }
.task-toggle .icon-btn { margin-left: auto; }
.task-toggle .chev { transition: transform .15s; }
.task-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tree-item.flat .label { display: grid; line-height: 1.25; }
.tree-item.flat .label small { color: var(--on-surface-variant); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .default-mark { margin-left: auto; color: #f2b01e; font-size: 13px; }

.tree { overflow: auto; flex: 1; padding: 0 0 20px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 16px; }
.tree-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 0 12px; border: 0; background: none; text-align: left; cursor: pointer;
  color: var(--on-surface); min-height: 40px; border-radius: 0; font-weight: 400; overflow: hidden;
}
.tree-item::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .15s; pointer-events: none; }
.tree-item:hover::after { opacity: .04; }
.tree-item.archive { font-weight: 500; }
.tree-item.search { font-weight: 400; font-size: 13px; }
.tree-item.selected { background: var(--nav-selected); color: var(--on-surface); font-weight: 500; }
.tree-item .chev { width: 18px; flex: none; transition: transform .15s; color: var(--on-surface-variant); }
.tree-item.open .chev { transform: rotate(90deg); }
/* The arrow opens an archive (clicking its name runs the default search): give it a real target. */
.tree-item.archive .chev { box-sizing: content-box; padding: 5px; margin: -5px; border-radius: 50%; }
.tree-item.archive .chev:hover { background: color-mix(in srgb, var(--on-surface) 10%, transparent); color: var(--on-surface); }
.tree-item .ico { flex: none; color: var(--on-surface-variant); }
.tree-item.archive .ico { color: var(--primary); }
.tree-item.search .ico { color: var(--accent); }
.tree-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 500; padding: 0 8px; line-height: 18px; border-radius: 10px;
  background: var(--surface-container); color: var(--on-surface-variant);
}
.tree-note { padding: 6px 12px 6px 42px; color: var(--on-surface-variant); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.tree-note.err { color: var(--error); }

/* ---------- Workspace ---------- */
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; padding: 0; }
.workspace-body { flex: 1; min-width: 0; min-height: 0; display: flex; position: relative; }

/* Results / Documents view tabs (Material tabs) */
.view-tabs {
  flex: none; display: flex; gap: 0; padding: 0 8px; background: var(--surface);
  border-bottom: 1px solid var(--outline-variant);
}
.view-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 20px; border: 0;
  background: transparent; cursor: pointer; color: var(--on-surface-variant);
  font: 500 14px/20px Roboto, sans-serif; letter-spacing: .0892857143em; text-transform: uppercase;
}
.view-tab:hover:not(:disabled) { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.view-tab.active { color: var(--primary); }
.view-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.view-tab:disabled { color: var(--text-hint); cursor: default; }
.view-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.view-tab.active::after { bottom: 0; }
.view-tab { flex: none; }
/* A Documents tab: name of its first document, how many it holds, and an X to close it */
.view-tab.doc-group { padding: 0 4px 0 16px; text-transform: none; letter-spacing: .0178em; max-width: 260px; }
.view-tab.doc-group .view-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.view-tab .view-x { width: 28px; height: 28px; color: var(--on-surface-variant); }
.view-tab .view-x svg { width: 16px; height: 16px; }
.view-tab .view-x:hover { color: var(--on-surface); }
.view-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; line-height: 20px; text-align: center;
  background: var(--primary); color: var(--on-primary); font-size: 12px; letter-spacing: 0;
}
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; container-type: inline-size; }

/* When the document panel squeezes the results column, compact the search header. */
@container (max-width: 640px) {
  .search-header h2 { font-size: 18px; }
  .search-header .lbl { display: none; }
  .search-header-actions .btn { min-width: 0; width: 40px; padding: 0; }
  .search-header-actions .btn svg { margin: 0; }
}

.welcome {
  margin: auto; max-width: 460px; text-align: center; padding: 24px; display: grid; gap: 8px; justify-items: center;
}
.welcome-art {
  width: 230px; height: auto; margin-bottom: 16px; user-select: none; pointer-events: none;
  filter: var(--watermark-filter); opacity: var(--watermark-opacity);
}
.welcome p { margin: 0; }

/* Resume: the last search, with its database and archive told apart */
.resume-card {
  display: flex; align-items: center; gap: 16px; width: 100%; max-width: 420px; margin-top: 12px; padding: 14px 18px;
  border: 0; border-radius: 4px; background: var(--surface); box-shadow: var(--elev-1); cursor: pointer; text-align: left;
  color: var(--on-surface); transition: box-shadow .15s;
}
.resume-card:hover { box-shadow: var(--elev-2); }
.resume-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--primary); color: var(--on-primary); }
.resume-text { display: grid; gap: 2px; min-width: 0; }
.resume-over { font: 500 11px/16px Roboto, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); }
.resume-name { font: 500 16px/22px Roboto, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-where { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; font-size: 13px; color: var(--on-surface-variant); }
.resume-where > span { display: inline-flex; align-items: center; gap: 5px; }
.resume-where svg { color: var(--accent); width: 16px; height: 16px; }

.search-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 0; }

.search-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex: none; flex-wrap: wrap; min-height: var(--toolbar-h);
  background: var(--surface-low); border-bottom: 1px solid var(--outline-variant);
}
.search-header-text { min-width: 0; flex: 1; display: grid; gap: 2px; }
.search-header-actions { display: flex; gap: 8px; align-items: center; }
.crumbs { color: var(--on-surface-variant); font-size: 12px; line-height: 16px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.crumbs .sep { opacity: .5; }
.crumbs:empty { display: none; }

/* Bottom status bar: database › archive, and the rows shown with paging */
.status-bar {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px 0 16px;
  background: var(--surface-low); border-top: 1px solid var(--outline-variant); color: var(--on-surface-variant); font-size: 12.5px;
}
.status-bar .sep { opacity: .5; margin: 0 4px; }
.status-bar .status-where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.status-bar .status-range { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-bar .icon-btn { width: 30px; height: 30px; }
.status-bar .page-size { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; }
.status-bar .page-size-box {
  display: inline-flex; align-items: center; height: 28px; border-radius: 4px 4px 0 0;
  background: var(--field-bg); border-bottom: 1px solid var(--field-underline);
}
.status-bar .page-size-box:focus-within { border-bottom-color: var(--primary); box-shadow: inset 0 -1px 0 var(--primary); }
.status-bar .page-size-box input {
  width: 6ch; height: 27px; min-height: 0; padding: 0 2px 0 8px; border: 0 !important; background: transparent !important;
  box-shadow: none !important; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.status-bar .page-size-box button {
  display: grid; place-items: center; width: 24px; height: 27px; padding: 0; border: 0; background: none;
  color: var(--on-surface-variant); cursor: pointer; border-radius: 0 4px 0 0;
}
.status-bar .page-size-box button:hover { background: var(--surface-container); color: var(--on-surface); }
.res-tools .icon-btn { width: 36px; height: 36px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 0 12px; height: 28px; white-space: nowrap;
  border-radius: var(--r-chip); border: 0; background: var(--chip-bg); color: var(--on-surface-variant);
}
.chip strong { color: var(--on-surface); font-weight: 500; }
.chip.filled { background: var(--tertiary-container); color: var(--on-surface); }
.chip.fixed { background: transparent; box-shadow: inset 0 0 0 1px var(--outline-variant); }

/* ---------- Results ---------- */
.results { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 0; box-shadow: none; }
.results-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px;
  font-size: 13px; color: var(--on-surface-variant); flex: none; min-height: 56px;
  border-bottom: 1px solid var(--grid-rule);
}
.count-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: 28px; border-radius: var(--r-chip);
  background: var(--tertiary-container); color: var(--on-surface); font-weight: 500;
}
.pager { display: flex; align-items: center; gap: 0; margin-left: auto; white-space: nowrap; }
.table-wrap { overflow: auto; flex: 1; }
.results-empty { padding: 48px 16px; text-align: center; color: var(--on-surface-variant); display: grid; gap: 10px; justify-items: center; }
.results-empty .big-ico {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-container); color: var(--on-surface-variant);
}

/* Data grid (ag-grid look) */
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left;
  padding: 0 16px; height: 48px; font-weight: 700; font-size: 12px; color: var(--grid-head);
  border-bottom: 1px solid var(--grid-rule); white-space: nowrap; cursor: pointer; user-select: none;
}
.grid th:hover { background: var(--surface-low); }
.grid th .sort { color: var(--primary); margin-left: 4px; }
.grid th .sort sup { font-size: 9px; margin-left: 1px; vertical-align: 4px; }
/* The arrow in each header: sort and filter that column */
.grid th[data-col] { padding-right: 36px; }
.grid th .col-menu {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 4px; background: none; cursor: pointer;
  color: var(--on-surface-variant); opacity: .45; transition: opacity .12s, background-color .12s;
}
.grid th:hover .col-menu, .grid th .col-menu:focus-visible { opacity: 1; }
.grid th .col-menu:hover { background: color-mix(in srgb, var(--on-surface) 10%, transparent); }
.grid th.filtered { color: var(--primary); }
.grid th.filtered .col-menu { opacity: 1; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.col-filter-pop {
  position: fixed; z-index: 60; width: 260px; background: var(--surface); color: var(--on-surface); border-radius: 4px;
  box-shadow: var(--elev-3, 0 4px 16px rgba(0,0,0,.18)); font-size: 13px; overflow: hidden;
}
.col-filter-pop .cfp-sort { display: grid; padding: 4px 0; border-bottom: 1px solid var(--outline-variant); }
.col-filter-pop .cfp-sort button {
  text-align: left; border: 0; background: none; padding: 8px 16px; font: inherit; color: inherit; cursor: pointer;
}
.col-filter-pop .cfp-sort button:hover { background: color-mix(in srgb, var(--on-surface) 6%, transparent); }
.col-filter-pop .cfp-body { display: grid; gap: 8px; padding: 12px 16px 10px; }
.col-filter-pop .cfp-label { font-size: 12px; color: var(--on-surface-variant); }
.col-filter-pop select, .col-filter-pop input { width: 100%; }
.col-filter-pop input.invalid { border-bottom-color: var(--error); box-shadow: inset 0 -1px 0 var(--error); }
.col-filter-pop .cfp-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 2px; }
.grid tr.no-match td { color: var(--on-surface-variant); padding: 24px 16px; }
/* Drag a header's right edge to resize the column */
.grid th[data-col] { overflow: hidden; text-overflow: ellipsis; }
.grid th .col-resizer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2;
  border-right: 2px solid transparent; transition: border-color .12s;
}
.grid th:hover .col-resizer { border-right-color: var(--grid-rule); }
.grid th .col-resizer:hover, body.col-resizing .grid th .col-resizer { border-right-color: var(--primary); }
body.col-resizing { cursor: col-resize; user-select: none; }
.grid td {
  padding: 0 16px; height: 42px; border-bottom: 1px solid var(--grid-rule);
  white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.grid td.num { font-variant-numeric: tabular-nums; }
/* System fields (set by GlobalSearch, read only): a slightly darker gray. Translucent so row hover/selection show through. */
.grid td.sys { background: color-mix(in srgb, var(--on-surface) 5%, transparent); color: var(--on-surface-variant); }
.grid th.sys { background: color-mix(in srgb, var(--on-surface) 5%, var(--surface)); }
/* Columns fit their content; the empty last column takes the leftover width, so a few fields aren't stretched */
.grid th, .grid td { width: 1px; }
.grid th.fill, .grid td.fill { width: auto; padding: 0; }
.grid th.fill { cursor: default; }
.grid th.fill:hover { background: var(--surface); }
.grid tbody tr { cursor: pointer; transition: background-color .1s; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tbody tr.selected { background: var(--row-selected); color: inherit; }
.grid tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.ft {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; background: var(--surface-container); color: var(--on-surface-variant);
}
.ft.pdf { background: color-mix(in srgb, #c62828 14%, transparent); color: #c62828; }
.ft.img { background: color-mix(in srgb, #00695c 14%, transparent); color: #00695c; }
.ft.office { background: color-mix(in srgb, #283593 14%, transparent); color: #283593; }
:root[data-theme="dark"] .ft.pdf { color: #ef9a9a; }
:root[data-theme="dark"] .ft.img { color: #80cbc4; }
:root[data-theme="dark"] .ft.office { color: #9fa8da; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ft.pdf { color: #ef9a9a; }
  :root:not([data-theme="light"]) .ft.img { color: #80cbc4; }
  :root:not([data-theme="light"]) .ft.office { color: #9fa8da; }
}

/* ---------- pdf.js viewer ---------- */
.pdf-viewer { flex: 1; min-width: 0; position: relative; display: block; background: var(--doc-bg); }
.pdf-toolbar {
  position: absolute; top: 0; left: 0; right: 0; height: 48px; z-index: 2;
  display: flex; align-items: center; gap: 4px; padding: 0 6px; overflow-x: auto; overflow-y: hidden;
  background: var(--surface-low); border-bottom: 1px solid var(--outline-variant); scrollbar-width: none;
}
.pdf-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; flex: none; }
.pdf-group + .pdf-group { border-left: 1px solid var(--outline-variant); }
.pdf-toolbar .icon-btn { width: 34px; height: 34px; }
.pdf-page { width: 5ch !important; min-height: 30px !important; padding: 2px 6px !important; text-align: center; }
.pdf-count { color: var(--on-surface-variant); font-size: 13px; padding: 0 4px; white-space: nowrap; }
.pdf-zoom { width: auto !important; min-height: 32px !important; padding: 2px 8px !important; border-radius: 4px 4px 0 0 !important; font-size: 13px; }
.pdf-find { flex: 0 1 auto; min-width: 220px; margin-left: auto; color: var(--on-surface-variant); } /* right-hand end */
.pdf-toolbar .icon-btn.toggle[aria-pressed="true"] { background: var(--row-selected); color: var(--primary); }

/* Page thumbnails beside the document (shown by default; the toolbar's first button hides them) */
.pdf-thumbs {
  position: absolute; left: 0; top: 48px; bottom: 0; width: 148px; z-index: 2; display: none; flex-direction: column;
  background: var(--surface-low); border-right: 1px solid var(--outline-variant);
}
.pdf-viewer.thumbs-open .pdf-thumbs { display: flex; }
.pdf-viewer.thumbs-open .pdf-scroll, .pdf-viewer.thumbs-open .pdf-status { left: 148px; }
.pdf-viewer.annotating .pdf-thumbs { top: calc(48px + var(--annot-h, 48px)); }
.pdf-thumbs-list { flex: 1; overflow: auto; padding: 10px 8px; display: grid; gap: 10px; align-content: start; justify-items: center; }
.pdf-thumb { position: relative; display: grid; justify-items: center; gap: 4px; padding: 6px; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.pdf-thumb:hover { background: color-mix(in srgb, var(--on-surface) 5%, transparent); }
.pdf-thumb.current { border-color: var(--primary); }
.pdf-thumb.dragging { opacity: .4; }
.pdf-thumb.drop-before { box-shadow: 0 -3px 0 var(--primary); }
.pdf-thumb.drop-after { box-shadow: 0 3px 0 var(--primary); }
.pdf-thumb-img { display: grid; place-items: center; min-width: 60px; min-height: 80px; }
.pdf-thumb canvas { display: block; max-width: 104px; background: #fff; box-shadow: var(--elev-1); }
.pdf-thumb-no { font-size: 12px; color: var(--on-surface-variant); }
.pdf-thumb-acts { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; }
.pdf-thumb:hover .pdf-thumb-acts, .pdf-thumb:focus-within .pdf-thumb-acts { display: flex; }
.pdf-thumb-acts .icon-btn { width: 26px; height: 26px; background: var(--surface); box-shadow: var(--elev-1); color: var(--on-surface-variant); }
.pdf-thumb-acts .icon-btn:hover { color: var(--primary); }
.pdf-thumbs-foot { display: flex; gap: 6px; justify-content: center; padding: 8px; border-top: 1px solid var(--outline-variant); background: var(--surface); }
.pdf-thumbs-foot[hidden] { display: none; }

/* The viewer bar doesn't repeat the tab name, archive or file type (the ⓘ button has them). */
#viewer .viewer-heading { display: none; }
.pdf-find-input { min-height: 32px !important; border-radius: 4px 4px 0 0 !important; padding: 2px 12px !important; max-width: 260px; font-size: 13px; }
.pdf-find-input.not-found { border-bottom-color: var(--error) !important; box-shadow: inset 0 -1px 0 var(--error) !important; }
.pdf-find-count { font-size: 12px; white-space: nowrap; min-width: 56px; }
.pdf-scroll { position: absolute; top: 48px; left: 0; right: 0; bottom: 0; overflow: auto; outline: none; }
.pdf-scroll .pdfViewer { padding: 12px 0 24px; }
.pdf-scroll .pdfViewer .page { margin: 0 auto 14px; box-shadow: var(--elev-2); border: 0; }
.pdf-status { position: absolute; inset: 48px 0 0; display: grid; place-items: center; color: var(--on-surface); }
.pdf-status .file-card { color: var(--on-surface); }
@container (max-width: 560px) { .hide-xs { display: none; } }
.doc-pane { container-type: inline-size; }

/* ---------- Context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 70; min-width: 220px; padding: 8px 0; border-radius: 4px;
  background: var(--surface); color: var(--on-surface); box-shadow: var(--elev-3); animation: pop .12s ease-out;
}
.ctx-menu .ctx-head {
  padding: 4px 16px 8px; font: 500 12px/16px Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase;
  color: var(--on-surface-variant); border-bottom: 1px solid var(--outline-variant); margin-bottom: 4px;
}
.ctx-menu button {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 0 16px; height: 44px;
  border: 0; background: none; cursor: pointer; text-align: left; color: inherit;
}
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: color-mix(in srgb, var(--on-surface) 4%, transparent); outline: none; }
.ctx-menu button svg { color: var(--on-surface-variant); }
.tree-item .more { margin-left: auto; opacity: .45; width: 28px; height: 28px; } /* always visible: it holds Import document */
.tree-item:hover .more, .tree-item:focus-visible .more { opacity: 1; }
.tree-item .badge + .more { margin-left: 4px; }

/* ---------- Metadata tabs, history, versions ---------- */
/* Material tabs: label, 2px primary ink bar under the active one */
.meta-tabs { display: flex; flex: 1 1 100%; border-bottom: 1px solid var(--outline-variant); margin: 0 -12px; }
.meta-tab {
  position: relative; flex: 1 1 0; height: 48px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  font: 500 14px/20px Roboto, sans-serif; letter-spacing: .0892857143em; text-transform: uppercase; color: var(--on-surface-variant);
}
.meta-tab:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.meta-tab.active { color: var(--primary); }
.meta-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.meta-panel:not(.tab-details) #v-edit { display: none; }
.history { list-style: none; margin: 0; padding: 8px 16px 20px; font-size: 13px; }
.history li { position: relative; padding: 0 0 14px 22px; }
.history li::before { content: ""; position: absolute; left: 5px; top: 18px; bottom: 0; width: 2px; background: var(--outline-variant); }
.history li:last-child::before { display: none; }
.history .dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--tertiary); }
.history .dot.create { background: #2e7d32; } .history .dot.edit { background: var(--primary); }
.history .dot.move { background: #f9a825; } .history .dot.export { background: var(--outline); }
.history .msg { font-weight: 500; }
.history .when { color: var(--on-surface-variant); font-size: 12px; }
.versions { padding: 12px 16px 20px; display: grid; gap: 8px; font-size: 13px; }
.version-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--outline-variant); }
.version-item .v { font-weight: 600; } .version-item .btn { margin-left: auto; }
.panel-note { padding: 16px; color: var(--on-surface-variant); font-size: 13px; }

/* ---------- Workflow tasks ---------- */
.tasks { padding: 0 0 8px; border-bottom: 1px solid var(--outline-variant); }
/* Section header band (Favorites / My tasks), as in the GlobalSearch navigation pane */
.tasks-head {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 8px 0 12px;
  background: var(--surface-high); color: var(--on-surface); font: 500 14px/20px Roboto, sans-serif; letter-spacing: .0178em;
}
.tasks-head .icon-btn { width: 32px; height: 32px; margin-left: auto; }
.task-wf { padding: 4px 12px 2px; font-size: 12px; color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 12px 0 14px; border: 0; background: none;
  border-radius: 0; cursor: pointer; color: var(--on-surface); font: inherit; text-align: left;
}
.task-item:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.task-item.selected { background: var(--nav-selected); font-weight: 500; }
.task-item.empty { color: var(--on-surface-variant); }
.task-item .ico { color: var(--accent); flex: none; }
.task-item.empty .ico { color: var(--outline); }
.task-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .badge {
  margin-left: auto; min-width: 22px; text-align: center; font-size: 11.5px; font-weight: 500; padding: 0 7px; line-height: 18px; border-radius: 10px;
  background: var(--accent); color: var(--surface);
}
.task-item.empty .badge { background: var(--surface-high); color: var(--on-surface-variant); }
.tree-item.search.queue .ico { color: var(--accent); }
.chip.archive-switch { cursor: pointer; }
.chip.archive-switch.active { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.action-step { padding: 4px 10px 8px; font-size: 12.5px; color: var(--on-surface-variant); }

/* ---------- Results toolbar, columns, thumbnails ---------- */
.res-tools { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.res-tools .icon-btn.on { background: var(--row-selected); color: var(--primary); }
.popover {
  position: fixed; z-index: 70; min-width: 260px; max-height: 70vh; overflow: auto; padding: 8px; border-radius: var(--r-md);
  background: var(--surface); color: var(--on-surface); box-shadow: var(--elev-3); animation: pop .12s ease-out;
}
/* ⓘ next to a label or heading: hover (or focus) shows the details in data-tip. Labels stay short. */
.info-tip {
  position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 6px; vertical-align: -2px;
  border: 1.5px solid var(--accent); border-radius: 50%; color: var(--accent); cursor: help; flex: none;
  font: 700 10px/1 Roboto, sans-serif; letter-spacing: 0; text-transform: none;
}
.info-tip::before { content: "i"; }
.info-tip:hover, .info-tip:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }
.info-tip::after {
  content: attr(data-tip); position: absolute; left: -8px; top: calc(100% + 8px); z-index: 1000;
  width: max-content; max-width: 280px; padding: 8px 10px; border-radius: 4px; white-space: normal; text-align: left;
  background: var(--inverse-surface); color: var(--inverse-on-surface); box-shadow: var(--elev-3);
  font: 400 12.5px/1.4 Roboto, sans-serif; letter-spacing: .0178em; text-transform: none;
  opacity: 0; visibility: hidden; transition: opacity .12s; pointer-events: none;
}
.info-tip:hover::after, .info-tip:focus-visible::after { opacity: 1; visibility: visible; }
.info-tip.tip-left::after { left: auto; right: -8px; }

/* Document info (the info button right of Actions) */
.doc-info { margin: 0; padding: 0 8px 4px; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; min-width: 240px; }
.doc-info dt { font-size: 12px; color: var(--on-surface-variant); }
.doc-info dd { margin: 0; display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--on-surface); word-break: break-word; }
.doc-info dd span { user-select: all; }
.doc-info .icon-btn { width: 28px; height: 28px; }
.popover h4 { margin: 4px 8px 8px; font: 500 12px/16px Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; color: var(--on-surface-variant); }
.col-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; font-size: 13px; }
.col-row:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.col-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-row .icon-btn { width: 28px; height: 28px; }
.popover .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 4px; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.popover .menu-item:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.popover .pop-foot { display: flex; justify-content: space-between; padding: 8px 6px 2px; border-top: 1px solid var(--outline-variant); margin-top: 6px; }
.grid td.thumb { width: 52px; padding: 3px 6px; }
.grid td.thumb img { display: block; height: 40px; width: 32px; object-fit: cover; object-position: top; border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px var(--outline-variant); }
.thumb-preview {
  position: fixed; z-index: 75; pointer-events: none; background: #fff; border-radius: 4px; box-shadow: var(--elev-3);
  padding: 4px; max-height: 70vh;
}
.thumb-preview img { display: block; max-height: calc(70vh - 8px); max-width: 360px; }
.select-all-bar { font-size: 13px; }
.select-all-bar button { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; text-decoration: underline; padding: 0 4px; }
.resume { margin-top: 10px; }
.chip.content { background: var(--tertiary-container); border-color: transparent; color: var(--on-surface); }
.content-field { grid-column: 1 / -1; }

/* ---------- Page editor ---------- */
.page-editor { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; background: var(--doc-bg); }
.pe-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; min-height: 56px; border-bottom: 1px solid var(--outline-variant); background: var(--surface-low); }
.pe-bar .sep { width: 1px; height: 24px; background: var(--outline-variant); margin: 0 4px; }
.pe-bar .count { font-size: 12.5px; color: var(--on-surface-variant); margin-right: auto; }
.pe-grid { flex: 1; overflow: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; align-content: start; }
.pe-page {
  position: relative; display: grid; gap: 6px; justify-items: center; padding: 8px; border-radius: var(--r-md);
  background: var(--surface); border: 2px solid transparent; cursor: grab; user-select: none; box-shadow: var(--elev-1);
}
.pe-page.selected { border-color: var(--primary); }
.pe-page.dragging { opacity: .4; }
.pe-page.drop-before { box-shadow: -4px 0 0 var(--accent), var(--elev-1); }
.pe-page.drop-after { box-shadow: 4px 0 0 var(--accent), var(--elev-1); }
.pe-page .canvas-wrap { width: 130px; height: 170px; display: grid; place-items: center; background: var(--surface-container); border-radius: 4px; overflow: hidden; }
.pe-page canvas { max-width: 130px; max-height: 170px; box-shadow: 0 1px 4px rgba(0,0,0,.25); background: #fff; }
.pe-page .pe-label { font-size: 12px; color: var(--on-surface-variant); display: flex; gap: 6px; align-items: center; }
.pe-page .pe-src { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--tertiary-container); }
.pe-page .pe-actions { display: flex; gap: 2px; }
.pe-page .pe-actions .icon-btn { width: 30px; height: 30px; }
.pe-page .pe-check { position: absolute; top: 8px; left: 8px; }
/* Indexing mode */
.idx-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; background: var(--primary); color: var(--on-primary); }
.idx-title { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.idx-title svg { color: #ffb74d; }
.idx-progress { flex: 0 1 160px; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .25); overflow: hidden; }
.idx-progress > div { height: 100%; background: #fff; border-radius: 3px; transition: width .2s; }
.idx-tip { color: rgb(255 255 255 / .8) !important; }
.idx-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.idx-strip .btn-text { color: var(--on-primary); }
.idx-strip .btn-text:disabled { color: rgb(255 255 255 / .45); }
.idx-strip .btn-filled:disabled { background: rgb(255 255 255 / .2); color: rgb(255 255 255 / .5); }
.idx-strip .btn-filled { background: var(--on-primary); color: var(--primary); }
.fill-chip { position: fixed; z-index: 2000; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; border-radius: 4px;
  background: var(--primary); color: var(--on-primary); font: 500 13px/1.2 Roboto, sans-serif; box-shadow: var(--elev-3); cursor: pointer; }
/* Filter and group */
.grid-filter { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 4px 4px 0 0; background: var(--field-bg); border-bottom: 1px solid var(--field-underline);
  color: var(--on-surface-variant); min-width: 160px; flex: 0 1 240px; }
.grid-filter input { border: 0 !important; background: transparent !important; padding: 0; height: 34px; min-height: 0; min-width: 0; width: 100%; box-shadow: none !important; }
.grid-filter:focus-within { border-bottom-color: var(--primary); box-shadow: inset 0 -1px 0 var(--primary); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }
.group-chip { display: inline-flex; align-items: center; gap: 4px; }
.chip-x { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: inherit; padding: 0 2px; }
.grid tr.group-row td { background: var(--surface-low); padding: 4px 8px; height: 36px; font-weight: 500; }
.group-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--on-surface); padding: 2px 4px; }
.group-toggle .chev { transition: transform .15s; transform: rotate(90deg); }
.group-row.closed .group-toggle .chev { transform: rotate(0deg); }
/* In-place editing in the results grid */
.grid td[data-cell] { cursor: default; }
.grid tbody tr:hover td[data-cell]:hover { box-shadow: inset 0 0 0 1px var(--outline-variant); }
.grid td.editing { padding: 2px 4px; overflow: visible; position: relative; z-index: 2; }
.cell-editor { position: relative; min-width: 120px; }
.cell-editor input, .cell-editor select { width: 100%; height: 34px; min-height: 0; padding: 3px 8px; font-size: 13px; }
.grid td.saving { opacity: .6; }
.grid td.saved { animation: cell-saved 1.2s ease-out; }
@keyframes cell-saved { from { background: color-mix(in srgb, var(--success, #2e7d32) 25%, transparent); } }
.grid td.invalid .cell-editor input, .grid td.invalid .cell-editor select { border-bottom-color: var(--error); box-shadow: inset 0 -1px 0 var(--error); }
.cell-error { position: absolute; left: 0; top: calc(100% + 2px); z-index: 5; min-width: 200px; max-width: 320px; white-space: normal; padding: 6px 8px;
  border-radius: 4px; background: #b71c1c; color: #fff; font-size: 12px; box-shadow: var(--elev-3); }
/* Workflow actions strip (open document in a workflow step) */
.wf-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 14px;
  background: var(--surface-low); border-bottom: 1px solid var(--outline-variant); font-size: 13px; }
.wf-step { display: inline-flex; align-items: center; gap: 6px; color: var(--on-surface-variant); }
.wf-step svg { color: #ef6c00; }
.wf-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
/* Friendly empty and error states */
.results-empty.friendly { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 48px 24px; }
.results-empty.friendly h3 { margin: 6px 0 0; font: 400 20px/32px Roboto, sans-serif; color: var(--on-surface); }
.results-empty.friendly p { margin: 0; max-width: 420px; }
.results-empty.friendly .big-ico { color: var(--on-surface-variant); opacity: .7; }
.results-empty .empty-actions { margin-top: 10px; }
.results-empty details.tech { margin-top: 14px; font-size: 12px; color: var(--on-surface-variant); }
.results-empty details.tech summary { cursor: pointer; }
.results-empty details.tech code { display: block; margin-top: 6px; max-width: 520px; white-space: pre-wrap; word-break: break-word; text-align: left; }
/* Keyboard shortcuts dialog */
.keys-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; font-size: 13.5px; }
.keys-grid h4 { grid-column: 1 / -1; margin: 12px 0 0; font: 500 12px/16px Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; color: var(--on-surface-variant); }
.keys-grid kbd { display: inline-block; min-width: 22px; padding: 2px 6px; text-align: center; border-radius: 4px; border: 1px solid var(--outline-variant);
  border-bottom-width: 2px; background: var(--surface-low); font: 500 12px/1.3 Roboto, sans-serif; }
/* Grouped menus (Actions / More) */
.viewer-bar .in-menu { display: none !important; }
.menu-btn { gap: 2px; padding-right: 8px; }
.menu-btn svg { margin-left: 0; }
.menu-btn[aria-expanded="true"] { background: var(--primary); color: var(--on-primary); }
.annotate-btn[aria-pressed="true"], .annotate-btn.on { background: var(--primary); color: var(--on-primary); }
.ctx-menu.grouped { min-width: 260px; max-height: calc(100vh - 24px); overflow: auto; padding: 8px 0; }
.ctx-menu .ctx-group + .ctx-group { border-top: 1px solid var(--outline-variant); margin-top: 8px; padding-top: 8px; }
.ctx-menu .ctx-title { padding: 4px 16px 4px; font: 500 12px/16px Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; color: var(--on-surface-variant); }
.ctx-menu .ctx-label { flex: 1; text-align: left; }
.ctx-menu kbd { font: 500 11px/1 Roboto, sans-serif; padding: 3px 6px; border-radius: 4px; background: var(--surface-high); color: var(--on-surface-variant); }
.ctx-menu button:disabled, .ctx-menu button:disabled svg { color: var(--text-hint); cursor: default; }
.ctx-menu button:disabled:hover { background: none; }
.ctx-menu button.danger, .ctx-menu button.danger svg { color: var(--error); }
.ctx-menu .ico-gap { width: 18px; flex: none; }
/* Reordering columns and fields by drag */
.grid th[draggable="true"] { cursor: grab; }
.grid th.dragging, #v-meta dt.dragging { opacity: .4; }
.grid th.drop-before { box-shadow: inset 3px 0 0 var(--primary); }
.grid th.drop-after { box-shadow: inset -3px 0 0 var(--primary); }
#v-meta dt[draggable="true"] { cursor: grab; }
#v-meta dt.drop-before { box-shadow: 0 -2px 0 var(--primary); }
#v-meta dt.drop-after + dd { box-shadow: 0 2px 0 var(--primary); }
.grid th.tbl-col { color: var(--primary); }
.grid th .tbl-ico { vertical-align: -2px; margin-right: 4px; }
/* Shapes, notes and text marks (shapes.js) */
svg.shape-layer { position: absolute; inset: 0; z-index: 30; pointer-events: none; overflow: visible; }
svg.shape-layer.drawing { pointer-events: auto; cursor: crosshair; }
svg.shape-layer .shape { pointer-events: all; cursor: move; }
svg.shape-layer line.shape:not(.hit), svg.shape-layer polyline.shape { pointer-events: none; }
svg.shape-layer .shape.hit { pointer-events: stroke; }
svg.shape-layer rect.shape.hit { pointer-events: all; }
svg.shape-layer .shape-outline { fill: none; stroke: var(--primary, #1d4ed8); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
svg.shape-layer .shape-handle { fill: #fff; stroke: var(--primary, #1d4ed8); stroke-width: 1.5; pointer-events: all; cursor: nwse-resize; }
.text-marking .textLayer { cursor: text; }
.shape-text { position: absolute; z-index: 40; width: 240px; padding: 8px; background: var(--surface); border: 1px solid var(--outline-variant);
  border-radius: 4px; box-shadow: var(--elev-3); display: grid; gap: 6px; }
.shape-text textarea { width: 100%; resize: vertical; padding: 6px 8px; border: 0; border-bottom: 1px solid var(--field-underline); border-radius: 4px 4px 0 0; font: 13px/1.4 Roboto, sans-serif; background: var(--field-bg); color: var(--on-surface); }
.shape-text-actions { display: flex; justify-content: flex-end; gap: 6px; }
.shape-kinds { display: inline-flex; gap: 0; padding: 0; border-radius: 4px; overflow: hidden; background: transparent; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.shape-kinds button { width: 32px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 0; background: transparent; color: var(--on-surface-variant); cursor: pointer; }
.shape-kinds button + button { box-shadow: inset 1px 0 0 var(--outline-variant); }
.shape-kinds button.on { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.fill-opts { display: inline-flex; align-items: center; gap: 4px; }
.annot-swatch.none { background: linear-gradient(135deg, transparent 45%, #d32f2f 45% 55%, transparent 55%), var(--surface); }
/* Annotations (annotations.js) */
#v-annotate.on { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.annot-bar { position: absolute; top: 48px; left: 0; right: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 6px 8px; background: var(--surface-low); border-bottom: 1px solid var(--outline-variant); font-size: 13px; }
.pdf-viewer.annotating .pdf-scroll { top: calc(48px + var(--annot-h, 48px)); }
/* Tools are picked from the Annotate menu; the bar keeps only the current tool's options, undo/delete and save. */
.annot-bar .annot-tools, .annot-actions [data-act="rotl"], .annot-actions [data-act="rotr"] { display: none !important; }
.annot-tools { display: flex; gap: 0; padding: 0; border-radius: 4px; overflow: hidden; background: var(--surface); box-shadow: inset 0 0 0 1px var(--outline-variant); }
.annot-tools button, .annot-actions button { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border: 0; border-radius: 0;
  background: transparent; color: var(--on-surface-variant); cursor: pointer; font: inherit; font-weight: 500; }
.annot-actions button { border-radius: 4px; }
.annot-tools button + button { box-shadow: inset 1px 0 0 var(--outline-variant); }
.annot-tools button.on { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.annot-tools button { white-space: nowrap; }
.annot-bar.compact .annot-tools button > span { display: none; }
.annot-bar.compact .annot-tools button.on > span { display: inline; } /* the active tool keeps its name */
.annot-tools button:hover, .annot-actions button:hover:not(:disabled) { color: var(--on-surface); }
.annot-actions { display: flex; gap: 0; }
.annot-actions button { padding: 0 7px; }
.annot-actions button:disabled { opacity: .35; cursor: default; }
.annot-actions button[aria-pressed="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.annot-count:not(:empty) { font-size: 11px; font-weight: 700; }
.annot-opts { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.annot-opts > span { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.annot-opts label { display: inline-flex; align-items: center; gap: 4px; color: var(--on-surface-variant); }
.annot-opts input[type=range] { width: 70px; }
.annot-opts select { width: auto; padding: 2px 6px; font-size: 12px; }
.annot-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--outline-variant); background: var(--c); cursor: pointer; padding: 0; flex: none; }
.annot-swatch.on { outline: 2px solid var(--primary); outline-offset: 1px; }
.annot-hint { color: var(--on-surface-variant); font-size: 12px; }
.annot-save { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.annot-status { color: var(--on-surface-variant); font-size: 12px; }
.annot-btn { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--outline-variant);
  background: transparent; color: var(--primary); cursor: pointer; font: 500 13px/1 Roboto, sans-serif; letter-spacing: .0892857143em; text-transform: uppercase; }
.annot-btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.annot-btn:disabled { color: var(--text-hint); background: transparent; border-color: var(--outline-variant); cursor: default; }
.annot-btn.primary:disabled { background: var(--disabled-bg); border-color: transparent; }
.annot-btn.small { height: 26px; padding: 0 9px; font-size: 11.5px; }
.annot-list { position: absolute; right: 8px; top: calc(56px + var(--annot-h, 48px)); bottom: 8px; width: min(300px, calc(100% - 16px)); z-index: 4;
  display: flex; flex-direction: column; background: var(--surface); color: var(--on-surface); border: 1px solid var(--outline-variant);
  border-radius: 4px; box-shadow: var(--elev-3); font-size: 13px; }
.annot-list-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 4px 8px 4px 16px; background: var(--surface-low); border-bottom: 1px solid var(--outline-variant); font-weight: 500; }
.annot-x { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--on-surface-variant); }
.annot-list-body { overflow: auto; padding: 6px 8px; display: grid; gap: 6px; align-content: start; }
.annot-item { display: flex; gap: 6px; align-items: flex-start; padding: 6px; border-radius: 4px; border: 1px solid var(--outline-variant); }
.annot-item.gone { opacity: .55; }
.annot-item.gone strong { text-decoration: line-through; }
.annot-go { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; padding: 0; }
.annot-page, .annot-author { color: var(--on-surface-variant); font-size: 11.5px; }
.annot-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.annot-removed { position: absolute; z-index: 30; pointer-events: auto; border: 2px dashed #d32f2f;
  background: repeating-linear-gradient(45deg, rgb(211 47 47 / .18) 0 6px, rgb(211 47 47 / .05) 6px 12px); }
.annot-flash { position: absolute; z-index: 30; pointer-events: none; border: 3px solid var(--primary); border-radius: 4px; animation: annot-flash 1.6s ease-out forwards; }
@keyframes annot-flash { from { box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 35%, transparent); } to { opacity: 0; } }
.sig-dialog { border: 0; border-radius: 4px; padding: 24px; box-shadow: var(--elev-4); width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--on-surface); }
.sig-dialog::backdrop { background: var(--scrim); }
.sig-dialog h3 { margin: 0 0 12px; }
.sig-tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--outline-variant); }
.sig-tabs button { position: relative; border: 0; border-radius: 0; height: 48px; padding: 0 24px; background: transparent; cursor: pointer; font: 500 14px/20px Roboto, sans-serif; letter-spacing: .0892857143em; text-transform: uppercase; color: var(--on-surface-variant); }
.sig-tabs button.on { color: var(--primary); }
.sig-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.sig-canvas { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--outline); border-radius: 4px; touch-action: none; cursor: crosshair; }
.sig-name { width: 100%; font: italic 28px "Segoe Script", "Brush Script MT", cursive; padding: 12px; }
.sig-row, .sig-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.sig-row label { display: inline-flex; gap: 6px; align-items: center; }
.sig-actions { justify-content: flex-end; }
/* Favorites */
.favorites { padding: 0 0 8px; border-bottom: 1px solid var(--outline-variant); }
.fav-head { width: 100%; border: 0; cursor: pointer; text-align: left; }
.fav-head:hover { background: color-mix(in srgb, var(--surface-high) 80%, var(--on-surface)); }
.fav-head .badge { font-size: 11px; font-weight: 500; padding: 0 8px; line-height: 18px; border-radius: 10px; background: var(--surface); color: var(--on-surface-variant); }
.fav-head > svg:first-child { color: #f2b01e; flex: none; }
.fav-head .chev { margin-left: auto; transition: transform .15s; }
.fav-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.fav-list { list-style: none; margin: 0; padding: 0; }
.fav-item .label { display: grid; line-height: 1.25; }
.fav-item .label small { color: var(--on-surface-variant); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-item .fav-act { width: 26px; height: 26px; flex: none; opacity: 0; }
.fav-item:hover .fav-act, .fav-item:focus-visible .fav-act { opacity: 1; }
.fav-item .fav-act svg { width: 15px; height: 15px; }
.star-btn .star-on { display: none; }
.star-btn.on .star-on { display: block; color: #f2b01e; }
.star-btn.on .star-off { display: none; }
/* Background jobs */
.jobs-btn { position: relative; }
.jobs-btn.pulse { animation: jobs-pulse .8s ease-in-out 2; }
@keyframes jobs-pulse { 50% { background: color-mix(in srgb, #fff 25%, transparent); } }
.jobs-badge { position: absolute; top: 6px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px;
  font-weight: 500; line-height: 18px; text-align: center; background: #ef6c00; color: #fff; letter-spacing: 0; }
.jobs-panel { position: fixed; top: calc(var(--toolbar-h) + 4px); right: 12px; z-index: 900; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 80px); overflow: auto;
  background: var(--surface); color: var(--on-surface); border-radius: 4px; box-shadow: var(--elev-3); }
.jobs-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 8px 12px 16px; background: var(--surface-low); border-bottom: 1px solid var(--outline-variant); }
.jobs-head strong { font-weight: 500; font-size: 16px; }
.jobs-head .btn { margin-left: auto; }
.jobs-list { list-style: none; margin: 0; padding: 0; }
.job { padding: 12px 16px; border-bottom: 1px solid var(--outline-variant); display: grid; gap: 6px; }
.job-top { display: flex; gap: 8px; align-items: baseline; }
.job-time { margin-left: auto; font-size: 11.5px; color: var(--on-surface-variant); white-space: nowrap; }
.job-status { font-size: 12.5px; color: var(--on-surface-variant); }
.job.failed .job-status, .job.cancelled .job-status { color: var(--error); }
.job.completed .progress-bar { background: var(--success, #2e7d32); }
.job-problems { font-size: 12px; }
.job-problems ul { margin: 4px 0 0; padding-left: 16px; max-height: 120px; overflow: auto; }
.job-actions { display: flex; gap: 6px; justify-content: flex-end; }
.job-actions:empty { display: none; }
/* Idle warning & sessions */
.idle-bar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 16px;
  padding: 8px 8px 8px 16px; min-height: 48px; border-radius: 4px; background: var(--inverse-surface); color: var(--inverse-on-surface);
  box-shadow: var(--elev-3); max-width: calc(100vw - 32px); flex-wrap: wrap; }
.idle-bar .btn-filled { background: transparent; color: #a8dab5; }
.ss-wrap { max-height: 50vh; overflow: auto; margin: 8px 0; }
.ss-table { width: 100%; }
.ss-table td, .ss-table th { padding: 10px 16px; height: auto; text-align: left; vertical-align: top; }
/* Email & print */
.email-grid { display: grid; gap: 12px; margin: 4px 0 12px; }
.email-grid textarea { width: 100%; resize: vertical; }
.email-grid .doc-list { max-height: 140px; overflow: auto; margin: 0; }
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
/* Redact & stamp */
.markup:focus { outline: none; }
.markup .seg { padding: 0; gap: 0; background: var(--surface); overflow: hidden; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 0; background: transparent;
  cursor: pointer; font-weight: 500; font-size: 13px; color: var(--on-surface-variant); }
.seg-btn + .seg-btn { box-shadow: inset 1px 0 0 var(--outline-variant); }
.seg-btn.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.mk-stamp-opts { display: inline-flex; gap: 6px; }
.mk-stamp-opts select { width: auto; padding: 4px 8px; font-size: 13px; }
.markup .pe-bar .count { margin: 0 0 0 auto; }
.mk-pages { flex: 1; overflow: auto; padding: 20px 24px; display: grid; justify-items: center; gap: 20px; align-content: start; background: var(--doc-bg); }
.mk-page { position: relative; box-shadow: var(--elev-2); background: #fff; line-height: 0; }
.mk-page canvas { display: block; max-width: 100%; height: auto; }
.mk-layer { position: absolute; inset: 0; cursor: crosshair; touch-action: none; overflow: hidden; line-height: normal; }
.mk-pages[data-tool="stamp"] .mk-layer { cursor: copy; }
.mk-no { position: absolute; right: -34px; top: 0; font-size: 12px; color: var(--on-surface-variant); line-height: normal; }
.mk-redact { position: absolute; background: #000; outline: 1px solid rgb(255 255 255 / .35); cursor: move; }
.mk-stamp { position: absolute; white-space: nowrap; font: 700 1em/1 Helvetica, Arial, sans-serif; padding: .35em; border: .09em solid currentColor;
  border-radius: .3em; opacity: .85; cursor: move; user-select: none; }
.mk-redact.selected, .mk-stamp.selected { box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px rgb(255 255 255 / .8); }
.pe-where { width: auto; padding: 4px 8px; font-size: 12.5px; }
.pe-bar label.btn.is-disabled { opacity: .45; pointer-events: none; }
.pe-actions label.icon-btn { cursor: pointer; }
.page-editor:focus { outline: none; }
.pe-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--outline-variant); background: var(--surface); }
.pe-foot #pe-msg { flex: 1 1 220px; min-width: 0; }
.pe-foot .spacer { display: none; }
.pe-foot .btn { flex: none; }

/* ---------- Move/copy & merge dialogs ---------- */
/* Material button-toggle group */
.seg-toggle { display: inline-flex; border-radius: 4px; overflow: hidden; width: fit-content; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.seg-toggle label { position: relative; }
.seg-toggle label + label { box-shadow: inset 1px 0 0 var(--outline-variant); }
.seg-toggle input { position: absolute; opacity: 0; }
.seg-toggle span {
  display: block; padding: 0 20px; line-height: 40px; cursor: pointer; font-weight: 500;
  text-transform: uppercase; letter-spacing: .0892857143em; color: var(--on-surface-variant);
}
.seg-toggle input:checked + span { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.seg-toggle input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.small-text { font-size: 12px; line-height: 16px; }
.small-text .lost { color: var(--warn); }
.doc-list.sortable li { cursor: grab; border-radius: 4px; padding: 6px 8px; }
.doc-list.sortable li:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.doc-list.sortable li.dragging { opacity: .4; }

/* ---------- Metadata editing ---------- */
.btn-xs { height: 28px; line-height: 28px; min-width: 0; padding: 0 10px; font-size: 12px; gap: 6px; }
.meta-panel.editing .meta-head #v-edit { display: none; }
.meta-edit { padding: 8px 12px 0; display: grid; gap: 12px; }
.meta-edit .alert { font-size: 13px; }
.meta-edit-actions {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 0 16px; background: var(--surface); border-top: 1px solid var(--outline-variant);
}
.meta-readonly { margin: 0; font-size: 13px; }
.meta-readonly .ro-head {
  font: 500 12px/16px Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; color: var(--on-surface-variant);
  padding-top: 12px; border-top: 1px solid var(--outline-variant);
}
.meta-readonly dt { color: var(--on-surface-variant); font-size: 12px; margin-top: 8px; }
.meta-readonly dd { margin: 2px 0 0; color: var(--on-surface-variant); }
.meta-readonly dd.empty { opacity: .6; }
.import-grid.single { grid-template-columns: 1fr; max-height: none; overflow: visible; gap: 16px; }
.import-grid.single input, .import-grid.single select { min-height: 44px; font-size: 16px; }

.import-grid .fld-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.import-grid .fld-head > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-grid .fld.toggleable { padding: 8px 10px 10px; border-radius: 4px; border: 1px solid var(--outline-variant); transition: border-color .15s, background-color .15s; }
.import-grid .fld.toggleable.applied { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
.import-grid .fld.toggleable :disabled { opacity: .45; }

/* ---------- Import dialog ---------- */
.import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; max-height: 46vh; overflow: auto; padding: 2px; }
.import-grid .fld { display: grid; align-content: start; min-width: 0; gap: 4px; font: 400 12px/16px Roboto, sans-serif; letter-spacing: .0333em; color: var(--on-surface-variant); }
.import-grid .fld:focus-within > .fld-head { color: var(--primary); }
.import-grid .fld input, .import-grid .fld select { font-size: 15px; letter-spacing: .03125em; }
.import-grid .fld .req { color: var(--error); margin-left: 2px; }
.import-grid .fld .hint { font-weight: 400; font-size: 12px; opacity: .85; }
.import-grid .fld .err { color: var(--error); font-weight: 400; font-size: 12px; }
.import-grid .fld.invalid input, .import-grid .fld.invalid select { border-bottom-color: var(--error); box-shadow: inset 0 -1px 0 var(--error); }
.import-grid .fld.invalid > .fld-head { color: var(--error); }
.import-grid .fld-wide { grid-column: 1 / -1; }
/* Multi-value fields: one row per value */
.mv { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 6px; }
.mv-row { display: flex; gap: 4px; align-items: center; }
.mv-row > :first-child { flex: 1; min-width: 0; }
.mv-row .icon-btn, .tbl-edit .icon-btn { width: 32px; height: 32px; }
.mv-add { justify-self: start; padding: 0 8px; }
.mv:disabled .mv-add, .mv:disabled .mv-del { display: none; }
/* Table (line-item) fields */
.tbl-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--grid-rule); border-radius: 4px; }
.tbl-edit { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl-edit th { text-align: left; font-weight: 700; font-size: 12px; color: var(--grid-head); padding: 10px 8px; white-space: nowrap; background: var(--surface); border-bottom: 1px solid var(--grid-rule); position: sticky; top: 0; }
.tbl-edit td { padding: 3px; border-top: 1px solid var(--grid-rule); }
.tbl-edit td input, .tbl-edit td select { min-width: 90px; min-height: 34px; padding: 5px 8px; font-size: 13px; }
.tbl-edit .tbl-x { width: 34px; padding: 0 2px; }
/* DataXChange lookup */
.lookup-bar { display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 4px;
  background: var(--surface-low); border-left: 4px solid var(--accent); }
.lookup-bar select { width: auto; flex: 0 1 220px; padding: 4px 8px; }
.lookup-label { font-weight: 500; color: var(--on-surface); }
.lookup-status { font-weight: 400; font-size: 12px; }
.lookup-matches { flex-basis: 100%; display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.lookup-match { display: flex; flex-wrap: wrap; gap: 4px 14px; text-align: left; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--outline-variant); border-radius: 4px; background: var(--surface); font-size: 13px; color: var(--on-surface); }
.lookup-match:hover { border-color: var(--primary); background: var(--row-hover); }
.lookup-match em { font-style: normal; color: var(--on-surface-variant); margin-right: 4px; }
/* Details panel: lists and tables */
#v-meta dd.mv-chips { display: flex; flex-wrap: wrap; gap: 4px; }
#v-meta dd.mv-chips .chip { height: 24px; font-size: 13px; background: var(--surface); }
#v-meta dd.meta-table table { border-collapse: collapse; font-size: 12px; width: 100%; }
#v-meta dd.meta-table .tbl-wrap { background: var(--surface); }
#v-meta dd.meta-table th, #v-meta dd.meta-table td { padding: 6px 8px; text-align: left; border-top: 1px solid var(--grid-rule); white-space: nowrap; }
#v-meta dd.meta-table th { background: var(--surface); color: var(--grid-head); font-weight: 700; border-top: 0; }
.drop.compact { padding: 16px 12px; grid-template-columns: auto 1fr; justify-items: start; text-align: left; }

/* ---------- Selection ---------- */
.grid th.sel, .grid td.sel { width: 48px; padding: 0 4px 0 16px; cursor: default; }
.cb {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; display: block; cursor: pointer; flex: none;
  border: 2px solid var(--on-surface-variant); border-radius: 2px; position: relative; transition: background-color .1s, border-color .1s;
}
.cb:checked, .cb:indeterminate { background: var(--primary); border-color: var(--primary); }
.cb:checked::after {
  content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 10px;
  border: solid var(--on-primary); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.cb:indeterminate::after { content: ""; position: absolute; left: 2px; right: 2px; top: 6px; height: 2px; background: var(--on-primary); }
.cb:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.grid tbody tr.checked { background: var(--row-selected); }
.grid tbody tr.open-doc td:first-child { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }

.results-head.selecting { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); color: var(--on-surface); }
.results-head.selecting .sel-count { font-weight: 500; font-size: 14px; }
.sel-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.btn-danger-tonal { background: transparent; color: var(--error); box-shadow: inset 0 0 0 1px var(--outline-variant); }
.icon-btn.danger:hover { color: var(--error); }

/* ---------- Document tabs (Material tabs with an ink bar) ---------- */
.doc-tabs {
  display: flex; gap: 0; padding: 0 8px; overflow-x: auto; flex: none;
  border-bottom: 1px solid var(--outline-variant); background: var(--surface); scrollbar-width: thin;
}
.doc-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 220px; flex: none;
  padding: 0 4px 0 16px; height: 40px; border: 0; border-radius: 0; cursor: pointer;
  background: transparent; color: var(--on-surface-variant); font-size: 13px; font-weight: 500;
}
.doc-tab:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.doc-tab.active { color: var(--primary); }
.doc-tab.active::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--primary);
}
.doc-tab .tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tab .tab-x { width: 28px; height: 28px; }
.doc-tab .tab-x svg { width: 16px; height: 16px; }
.doc-pane { flex: 1; min-width: 0; display: flex; position: relative; }
.doc-pane:not(.active) { display: none; }

/* ---------- Delete dialog ---------- */
.doc-list {
  margin: 0; padding: 8px 12px; list-style: none; max-height: 180px; overflow: auto;
  background: var(--surface-low); border-radius: 4px; font-size: 13px;
}
.doc-list li { padding: 4px 0; display: flex; gap: 8px; align-items: baseline; }
.doc-list li .id { color: var(--on-surface-variant); font-variant-numeric: tabular-nums; min-width: 44px; }
.doc-list li.more { color: var(--on-surface-variant); font-style: italic; }
.doc-list li.fail { color: var(--error); }
/* Material linear progress */
.progress { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--primary) 25%, transparent); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
#delete-progress { background: color-mix(in srgb, var(--error) 25%, transparent); }
#delete-progress .progress-bar { background: var(--error); }

/* ---------- Resizer (6px splitter) ---------- */
.resizer { flex: none; width: 0; position: relative; cursor: col-resize; touch-action: none; display: none; background: var(--outline-variant); transition: background-color .15s; }
.workspace.viewer-open .resizer { display: block; width: 6px; }
.resizer::after {
  content: ""; position: absolute; top: 50%; left: 2px; width: 2px; height: 32px; margin-top: -16px;
  border-radius: 1px; background: var(--outline); opacity: .6;
}
.resizer:hover, .resizer.dragging { background: var(--primary); }
.resizer:hover::after, .resizer.dragging::after { background: var(--on-primary); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }

/* ---------- Document side panel ---------- */
.viewer {
  flex: none; width: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: 0; box-shadow: none;
  opacity: 0; transition: width .26s cubic-bezier(.25, .8, .25, 1), opacity .2s;
}
.workspace.viewer-open .viewer { width: var(--viewer-w, 58%); min-width: 360px; opacity: 1; }
body.resizing .viewer { transition: none; }

.viewer-bar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px; flex: none; min-height: 56px;
  background: var(--surface-low); border-bottom: 1px solid var(--outline-variant);
}
.viewer-heading { display: grid; min-width: 0; margin-left: 4px; }
.viewer-title { font-size: 16px; font-weight: 500; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-sub { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; border-radius: 4px; background: transparent; margin-right: 4px; }
.seg .icon-btn { width: 36px; height: 36px; }
/* ‹ 2 of 5 › : the open documents */
.doc-nav { align-items: center; margin-right: 8px; }
.doc-pos {
  height: 32px; min-width: 64px; padding: 0 10px; border: 0; border-radius: 4px; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--on-surface); font: 500 13px/32px Roboto, sans-serif; font-variant-numeric: tabular-nums;
}
.doc-pos:hover, .doc-pos[aria-expanded="true"] { background: color-mix(in srgb, var(--on-surface) 6%, transparent); }
#v-replace { margin-left: 6px; }

.viewer-body { flex: 1; display: flex; min-height: 0; }
.doc-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.doc-col > .doc-frame { min-height: 0; }

/* Items panel: table (line-item) fields under the document, as in GlobalSearch */
.items-panel {
  flex: none; max-height: 42%; overflow: auto; background: var(--surface);
  border-top: 1px solid var(--outline-variant); box-shadow: 0 -2px 4px rgba(0, 0, 0, .06);
}
.items-table + .items-table { border-top: 1px solid var(--grid-rule); }
.items-head { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px 4px; }
.items-head h3 { font: 400 20px/32px Roboto, sans-serif; }
.items-head .muted { font-size: 12px; }
.items-panel .tbl-wrap { border: 0; border-radius: 0; }
table.items-grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.items-grid th {
  position: sticky; top: 0; background: var(--surface); text-align: left; white-space: nowrap;
  height: 48px; padding: 0 16px; font-weight: 700; font-size: 12px; color: var(--grid-head); border-bottom: 1px solid var(--grid-rule);
}
.items-grid td { height: 42px; padding: 0 16px; border-bottom: 1px solid var(--grid-rule); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.items-grid tbody tr:hover td { background: var(--row-hover); }
.items-grid .empty-row td { color: var(--text-hint); }
.items-panel .items-edit { max-height: none; overflow: visible; padding: 12px 16px 16px; gap: 16px; }
.items-edit .tbl-fld > .fld-head { font: 400 20px/32px Roboto, sans-serif; color: var(--on-surface); }
.doc-frame { flex: 1; min-width: 0; background: var(--doc-bg); display: flex; position: relative; }
.doc-frame iframe { border: 0; width: 100%; height: 100%; flex: 1; }
.doc-frame .img-wrap { overflow: auto; flex: 1; padding: 16px; }
.doc-frame img { max-width: 100%; margin: auto; display: block; background: #fff; border-radius: 0; box-shadow: var(--elev-2); }
.doc-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--primary); pointer-events: none; }

.file-card {
  margin: auto; text-align: center; padding: 32px 24px; display: grid; gap: 12px; justify-items: center;
  background: var(--surface); color: var(--on-surface); border-radius: 4px; box-shadow: var(--elev-1);
  max-width: 340px;
}
.file-card .file-ico {
  width: 64px; height: 80px; border-radius: 2px 16px 2px 2px; display: grid; place-items: end center;
  padding-bottom: 12px; background: var(--primary); color: var(--on-primary);
  font-weight: 700; letter-spacing: .04em; font-size: 14px;
}
.file-card p { margin: 0; color: var(--on-surface-variant); font-size: 14px; }
.file-card .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Right-hand fields pane: each field reads as a Material filled form field */
.meta-panel { width: var(--meta-w); flex: none; overflow: auto; background: var(--surface); border-left: 1px solid var(--outline-variant); }
.viewer.meta-hidden .meta-panel { display: none; }
.meta-head {
  position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0;
  background: var(--surface); padding: 0 12px;
}
.meta-head #v-edit { margin: 12px 0 0 auto; }
.meta-panel dl { margin: 0; padding: 4px 12px 24px; }
.meta-panel dl > dt {
  margin-top: 12px; padding: 8px 12px 0; border-radius: 4px 4px 0 0; background: var(--field-bg);
  font: 400 12px/16px Roboto, sans-serif; letter-spacing: .0333em; color: var(--on-surface-variant);
}
.meta-panel dl > dd {
  margin: 0; padding: 2px 12px 8px; background: var(--field-bg); border-bottom: 1px solid var(--field-underline);
  font: 400 16px/24px Roboto, sans-serif; letter-spacing: .03125em; color: var(--on-surface); word-break: break-word;
}
.meta-panel dl > dd.empty { color: var(--text-hint); min-height: 34px; }
/* Renaming a Documents tab in place */
.tab-rename { width: 160px; min-height: 30px !important; padding: 2px 8px !important; font-size: 14px; text-transform: none; letter-spacing: normal; }
.meta-panel dl > dd.meta-table { padding: 4px 8px 8px; }
.meta-panel dl.meta-readonly { padding: 0 0 8px; }
.meta-panel .meta-readonly > dt, .meta-panel .meta-readonly > dd { background: transparent; border-bottom: 0; padding-left: 0; padding-right: 0; }
.meta-panel .meta-readonly > dd { font-size: 14px; color: var(--on-surface-variant); }

.when-max { display: none; }
.viewer-max .when-max { display: block; }
.viewer-max .when-normal { display: none; }
/* Maximized: the document takes the entire window. */
.app-view.viewer-max .viewer {
  position: fixed; inset: 0; z-index: 40; width: auto !important; border-radius: 0; min-width: 0;
}

/* ---------- Dialogs ---------- */
.dialog {
  border: 0; border-radius: 4px; padding: 24px; width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--on-surface); box-shadow: var(--elev-4);
  max-height: calc(100vh - 32px);
}
.dialog-wide { width: min(760px, calc(100vw - 32px)); }
.dialog[open] { animation: pop .15s cubic-bezier(0, 0, .2, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.8); } }
.dialog::backdrop { background: var(--scrim); }
.dialog form { display: grid; gap: 16px; }
.dialog p { margin: 0; }
.dialog-head { display: flex; align-items: center; gap: 16px; }
.dialog-head h3 { line-height: 32px; }
.dialog-x { margin-left: auto; align-self: flex-start; }
.dialog-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--primary); color: var(--on-primary);
}
.dialog-icon svg { width: 22px; height: 22px; }
.dialog-icon.danger { background: var(--error); color: var(--on-error); }
.dialog .warn { color: var(--warn); font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
.inline-label { display: inline-flex; align-items: center; gap: 12px; color: var(--on-surface); }
.inline-label select { width: auto; min-height: 36px; padding: 4px 12px; }
.inline-label > svg { color: var(--on-surface-variant); }

/* Search form: one field per row */
.prompt-grid { display: grid; grid-template-columns: 1fr; gap: 14px; max-height: 60vh; overflow: auto; padding: 2px; }
.prompt-grid:empty { display: none; }
.prompt-grid label { display: grid; gap: 4px; font: 400 12px/16px Roboto, sans-serif; letter-spacing: .0333em; color: var(--on-surface-variant); }
.prompt-grid label:focus-within { color: var(--primary); }
.prompt-grid input, .prompt-grid select { font-size: 15px; letter-spacing: .03125em; }
.prompt-grid label .hint { font-weight: 400; font-size: 12px; opacity: .85; }

.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 24px 12px; cursor: pointer;
  border: 2px dashed var(--outline-variant); border-radius: 4px; color: var(--on-surface-variant);
  position: relative; transition: border-color .15s, background-color .15s, color .15s;
}
.drop:hover, .drop.over { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.has-file { color: var(--on-surface); border-style: solid; border-color: var(--primary); }

/* Material snackbar */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--inverse-surface); color: var(--inverse-on-surface); padding: 14px 16px; border-radius: 4px;
  box-shadow: var(--elev-3); min-width: min(344px, calc(100vw - 32px)); max-width: min(640px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 16px; animation: toast-in .2s cubic-bezier(0, 0, .2, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } }
.toast .btn-text, .toast .link-btn { color: #a8dab5; }
.toast.error { background: #b71c1c; color: #fff; }

.scrim { display: none; }

/* ---------- Under 900px: 56px toolbar (Material) ---------- */
@media (max-width: 900px) {
  :root { --toolbar-h: 56px; }
  .app-logo, .app-logo img { height: 40px; }
}

/* ---------- Medium: document panel overlays the results as a sheet ---------- */
@media (max-width: 1100px) {
  .resizer { display: none !important; }
  .viewer {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 30; width: auto !important;
    left: 0; min-width: 0 !important; transform: translateX(105%); opacity: 1;
    transition: transform .26s cubic-bezier(.25, .8, .25, 1);
    box-shadow: var(--elev-4);
  }
  .workspace.viewer-open .viewer { transform: none; }
  .meta-panel { width: 260px; }
}

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  :root { --sidebar-w: min(320px, 86vw); }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; z-index: 35; margin-left: 0 !important;
    transform: translateX(-102%); transition: transform .2s cubic-bezier(.25, .8, .25, 1);
    background: var(--surface); box-shadow: var(--elev-4); border-radius: 0;
  }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .scrim { display: block; position: absolute; inset: 0; background: rgba(0, 0, 0, .6); z-index: 34; }
  .workspace { padding: 0; }
  .viewer { right: 0; left: 0; bottom: 0; }
  .user-chip, .brand-name, .hide-sm, .search-header .lbl, .viewer-bar .lbl { display: none; }
  .search-header { padding: 8px 12px; }
  .search-header-actions .btn { min-width: 0; width: 40px; padding: 0; }
  .search-header-actions .btn svg { margin: 0; }
  .viewer-body { flex-direction: column-reverse; }
  .meta-panel { width: auto; max-height: 34%; border-left: 0; border-bottom: 1px solid var(--outline-variant); }
  .dialog { padding: 16px; }
}

/* Indexing: imported files one at a time, preview beside the index form */
.workspace.ix-open .main-col, .workspace.ix-open .resizer, .workspace.ix-open .viewer { display: none !important; }
.indexer { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.indexer[hidden] { display: none; }
.indexer .viewer-heading { margin-left: 4px; }
.ix-panel .meta-edit { padding-top: 16px; }
.ix-state { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 4px; font-weight: 500; }
.ix-state.saved { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.ix-state.skipped { background: var(--surface-low); color: var(--on-surface-variant); }
.ix-tab .view-label { font-weight: 500; }

/* Results collapsed: the open document takes the full width (also how a document opened in a new browser tab starts). */
.workspace.viewer-open.results-collapsed .main-col,
.workspace.viewer-open.results-collapsed .resizer { display: none !important; }
.workspace.viewer-open.results-collapsed .viewer {
  position: relative; inset: auto; flex: 1; width: auto !important; min-width: 0 !important;
  opacity: 1; transform: none; box-shadow: none;
}

/* Selection bar: wrap instead of clipping in a narrow results pane */
.results-head.selecting { flex-wrap: wrap; row-gap: 6px; }
.results-head.selecting .sel-actions { flex-wrap: wrap; row-gap: 6px; }

body.indexing .meta-edit-actions { display: none; }
