/*
 * static/css/files.css — workspace pane and file previews (the viewers' own bodies).
 *
 * Owner: WP B-16. Spec: FR §5 (viewers), §3.4 (sizes), §10 (themes, mobile, a11y), §3.6 (file pane).
 * Every selector is defined once, in one file (I7; T-CSS checks the critical ones).
 * Prefixes: `.aiwv-*` = viewer bodies (inside B-15's `.aiw-card__viewer` / `.aiw-stage__body`, or the
 * pane's `.wsp-viewer`); `.wsp-*` = the workspace pane. The card chrome, the iframe element
 * (`.aiw-frame`) and the card background toggle (`.aiw-card__body[data-bg]`) live in artifacts.css.
 * No inline style attributes: the JS sets sizes through CSSOM (CSP).
 */

/* ---- shared viewer bits ------------------------------------------------------------------ */
.aiwv-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    font-size: 12.5px;
    color: var(--card-fg-muted);
}

.aiwv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 28px;
    padding: 2px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--card-bg);
    color: var(--text-color);
    font: inherit;
    font-size: 12.5px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.aiwv-btn:hover { border-color: var(--gold-glow); color: var(--gold-accent); }
.aiwv-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--focus-border); }
.aiwv-btn[aria-pressed="true"] { border-color: var(--gold-accent); color: var(--gold-accent); background: var(--gold-soft); }

.aiwv-mode-stage { height: 100%; min-height: 0; }

/* inline cards clamp tall text-like bodies at 480 px; the card's Expand removes the clamp (FR §3.4) */
.aiwv-clamped { max-height: 480px; overflow: auto; }

/* ---- fixed error state (FR §3.2; used when no card hosts the viewer) ---------------------- */
.aiwv-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 120px;
    padding: var(--space-4);
    text-align: center;
    color: var(--text-dim);
}

.aiwv-error__text { margin: 0; font-size: 0.95rem; }
.aiwv-error__note { max-width: 100%; margin: 0; padding: var(--space-2); overflow-x: auto; background: var(--code-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: pre-wrap; }
.aiwv-error__actions { display: flex; gap: var(--space-2); }

/* ---- file card (binary, FR §5.7) ------------------------------------------------------------ */
.aiwv-filecard {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 72px;
    padding: var(--space-3) var(--space-4);
}

.aiwv-filecard__icon {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 36px;
    height: 44px;
    padding-bottom: 5px;
    border: 1px solid var(--border-strong);
    border-radius: 4px 12px 4px 4px;
    background: var(--input-bg);
}

.aiwv-filecard__icon[data-family="image"], .aiwv-filecard__icon[data-family="video"] { border-color: var(--gold-accent); }
.aiwv-filecard__icon[data-family="archive"] { border-style: dashed; }
.aiwv-filecard__ext { font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--gold-accent); }
.aiwv-filecard__info { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.aiwv-filecard__name { overflow: hidden; color: var(--text-color); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.aiwv-filecard__meta, .aiwv-filecard__note { overflow: hidden; color: var(--card-fg-muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.aiwv-filecard__gone { color: var(--danger-text); font-size: 12.5px; }
.aiwv-filecard__download { flex: 0 0 auto; }

/* ---- image (FR §5.1) ------------------------------------------------------------------------ */
.aiwv-image { position: relative; display: flex; flex-direction: column; }
.aiwv-image__canvas { display: flex; align-items: center; justify-content: center; min-height: 40px; }

.aiwv-image__img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    cursor: zoom-in;
}

.aiwv-image__img:focus-visible { outline: none; box-shadow: var(--ring); }
.aiwv-mode-stage .aiwv-image__canvas { flex: 1 1 auto; min-height: 0; }
.aiwv-mode-stage .aiwv-image__img { max-height: 100%; }
.aiwv-mode-lightbox .aiwv-image__img { cursor: default; max-height: none; }
.aiwv-image__load { margin: var(--space-6) auto; }
.aiwv-image__bar { justify-content: flex-end; }

/* the pane's own background toggle (cards use .aiw-card__body[data-bg]) */
.aiwv-image[data-bg="light"] .aiwv-image__canvas { background: var(--canvas-light); }
.aiwv-image[data-bg="dark"] .aiwv-image__canvas { background: var(--canvas-dark); }
.aiwv-image[data-bg="checker"] .aiwv-image__canvas {
    background-color: var(--checker-b);
    background-image:
        linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---- pdf / office (FR §5.3): pages are always white --------------------------------------- */
.aiwv-pdf { position: relative; display: flex; flex-direction: column; min-height: 0; }
.aiwv-pdf--full { height: 100%; }
.aiwv-pdf__status { padding: 0 var(--space-3); color: var(--card-fg-muted); font-size: 12.5px; }
.aiwv-pdf__status:empty { display: none; }
.aiwv-pdf__scroller { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.aiwv-pdf--full .aiwv-pdf__scroller { overflow: auto; padding: var(--space-4); background: var(--stage-bg); }
.aiwv-pdf__scroller:focus-visible { outline: none; box-shadow: inset var(--ring); }
.aiwv-pdf__pages { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }

.aiwv-pdf__page {
    position: relative;
    flex: 0 0 auto;
    max-width: none;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.18);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.aiwv-pdf--inline .aiwv-pdf__page { border-width: 0 0 1px; box-shadow: none; }
.aiwv-pdf__page--open { cursor: zoom-in; }
.aiwv-pdf__canvas { display: block; }
.aiwv-pdf__footer { justify-content: flex-start; border-top: 1px solid var(--card-border); }
.aiwv-pdf--full .aiwv-pdf__footer { justify-content: center; }
.aiwv-pdf__note { flex-basis: 100%; font-style: italic; }
.aiwv-pdf__pages-label { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.aiwv-pdf__pagebox { width: 4.2em; min-height: 26px; padding: 0 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text-color); font: inherit; text-align: right; }
.aiwv-pdf__zoom { min-height: 28px; padding: 0 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text-color); font: inherit; }
.aiwv-pdf__count { font-variant-numeric: tabular-nums; }
.aiwv-pdf__sep { opacity: 0.6; }
.aiwv-pdf__links { position: absolute; inset: 0; pointer-events: none; }
.aiwv-pdf__link { position: absolute; pointer-events: auto; }
.aiwv-pdf__link:hover, .aiwv-pdf__link:focus-visible { outline: 2px solid rgba(30, 90, 200, 0.55); outline-offset: 0; background: rgba(30, 90, 200, 0.08); }

/* pdf.js 4.x text layer (selection + screen readers); pdf.js sets --scale-factor via the page */
.aiwv-pdf .textLayer {
    position: absolute;
    inset: 0;
    overflow: clip;
    opacity: 1;
    line-height: 1;
    text-align: initial;
    text-size-adjust: none;
    -webkit-text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
    caret-color: CanvasText;
    z-index: 0;
}

.aiwv-pdf .textLayer :is(span, br) {
    position: absolute;
    color: transparent;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

.aiwv-pdf .textLayer .markedContent { display: contents; }
.aiwv-pdf .textLayer span[role="img"] { user-select: none; cursor: default; }
.aiwv-pdf .textLayer ::selection { background: rgba(0, 90, 255, 0.28); }
.aiwv-pdf .textLayer br::selection { background: transparent; }
.hiddenCanvasElement { position: absolute; top: 0; left: 0; width: 0; height: 0; display: none; }

/* ---- sheet (FR §5.4) ------------------------------------------------------------------------ */
.aiwv-sheet { display: flex; flex-direction: column; min-height: 0; }
.aiwv-sheet.aiwv-mode-inline { height: 360px; }
.aiwv-sheet__loading { padding: var(--space-4); color: var(--card-fg-muted); font-size: 13px; }
.aiwv-sheet__banner { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: 6px var(--space-3); border-bottom: 1px solid var(--card-border); background: var(--badge-bg); color: var(--badge-fg); font-size: 12.5px; }
.aiwv-sheet__scroller { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }

.aiwv-sheet__grid {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-color);
}

.aiwv-sheet__grid th, .aiwv-sheet__grid td {
    height: 28px;
    max-height: 28px;
    padding: 0 6px;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-2);
    line-height: 27px;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.aiwv-sheet__head th { position: sticky; top: 0; z-index: 3; background: var(--card-bar-bg); color: var(--card-fg-muted); font-weight: 600; text-align: center; }
.aiwv-sheet__corner { left: 0; z-index: 5; }
.aiwv-sheet__head .aiwv-sheet__corner { z-index: 5; }
.aiwv-sheet__rownum { position: sticky; left: 0; z-index: 2; background: var(--card-bar-bg); color: var(--card-fg-muted); font-weight: 500; text-align: right; }
.aiwv-sheet__cell { text-align: left; }
.aiwv-sheet__cell:focus { outline: 2px solid var(--gold-accent); outline-offset: -2px; }
.aiwv-sheet__cell--b { font-weight: 700; }
.aiwv-sheet__cell--i { font-style: italic; }
.aiwv-sheet__cell--u { text-decoration: underline; }
.aiwv-sheet__cell--fx { color: var(--text-muted); }
.aiwv-sheet__cell--err { color: var(--danger-text); }
.aiwv-sheet__cell--frozen-col { position: sticky; z-index: 1; }
.aiwv-sheet__cell--frozen-row { position: sticky; z-index: 2; box-shadow: inset 0 -1px 0 var(--border-strong); }
.aiwv-sheet__head .aiwv-sheet__cell--frozen-col { z-index: 4; }
.aiwv-sheet__row--frozen .aiwv-sheet__rownum { position: sticky; z-index: 4; }
.aiwv-sheet__row--frozen .aiwv-sheet__cell--frozen-col { z-index: 3; }
.aiwv-sheet__spacer { pointer-events: none; }
.aiwv-sheet__spacer td, .aiwv-sheet__spacer th { height: auto; border: 0; padding: 0; background: transparent; }
.aiwv-sheet__empty { margin: var(--space-4); color: var(--card-fg-muted); font-size: 13px; }
.aiwv-sheet[data-theme="light"] .aiwv-sheet__grid td { background: var(--canvas-light); }

.aiwv-sheet__tabs {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 0 var(--space-2);
    overflow-x: auto;
    border-top: 1px solid var(--card-border);
    background: var(--card-bar-bg);
    scrollbar-width: thin;
}

.aiwv-sheet__tab {
    flex: 0 0 auto;
    min-height: 30px;
    max-width: 220px;
    padding: 0 12px;
    overflow: hidden;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--card-fg-muted);
    font: inherit;
    font-size: 12.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.aiwv-sheet__tab[aria-selected="true"] { border-bottom-color: var(--gold-accent); color: var(--text-color); font-weight: 600; }
.aiwv-sheet__tab:focus-visible { outline: none; box-shadow: inset var(--ring); }

/* ---- text, markdown, latex (FR §5.5) ------------------------------------------------------- */
.aiwv-text { display: flex; flex-direction: column; min-height: 0; }
.aiwv-text__bar { justify-content: flex-end; border-bottom: 1px solid var(--card-border); }
.aiwv-text__body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.aiwv-mode-stage .aiwv-text__body { overflow: auto; }
.aiwv-text__note { margin: 0; padding: 6px var(--space-3); color: var(--badge-fg); background: var(--badge-bg); font-size: 12.5px; }
.aiwv-text__status { padding: var(--space-4); color: var(--card-fg-muted); font-size: 13px; }
.aiwv-text__log { margin: 0 var(--space-3) var(--space-2); padding: var(--space-2); overflow-x: auto; background: var(--code-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--danger-text); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }
.aiwv-text__block { display: flex; align-items: flex-start; min-width: 0; background: var(--code-bg); }

.aiwv-text__gutter {
    position: sticky;
    left: 0;
    flex: 0 0 auto;
    min-width: 3em;
    margin: 0;
    padding: var(--space-3) var(--space-2) var(--space-3) var(--space-3);
    border-right: 1px solid var(--border-color);
    background: var(--code-bg);
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 20px;
    text-align: right;
    user-select: none;
}

.aiwv-text__code {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: var(--space-3);
    overflow: visible;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 20px;
    tab-size: 4;
}

.aiwv-text__code code { font: inherit; background: transparent; padding: 0; }
.aiwv-text__code code.hljs { padding: 0; background: transparent; overflow: visible; } /* the body scrolls (I3B-6) */
.aiwv-text__block--wrap .aiwv-text__gutter { display: none; }
.aiwv-text__block--wrap .aiwv-text__code { white-space: pre-wrap; overflow-wrap: anywhere; }
.aiwv-text__markdown { padding: var(--space-4); line-height: 1.65; overflow-wrap: anywhere; }
.aiwv-text__latex .katex-display { margin: var(--space-3) 0; }
.aiwv-text__pdf { min-height: 0; }

/* ---- notebook (FR §5.6) --------------------------------------------------------------------- */
.aiwv-nb { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.aiwv-mode-stage.aiwv-nb { overflow: auto; }
.aiwv-nb__cell { min-width: 0; }
.aiwv-nb__cell--code { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); column-gap: var(--space-2); }
.aiwv-nb__prompt { grid-column: 1; padding-top: 8px; color: var(--gold-accent); font-family: var(--font-mono); font-size: 12px; text-align: right; white-space: nowrap; }
.aiwv-nb__input { grid-column: 2; min-width: 0; }
.aiwv-nb__source { margin: 0; padding: 8px 10px; overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--code-bg); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; }
.aiwv-nb__source code { font: inherit; background: transparent; padding: 0; }
.aiwv-nb__outputs { display: flex; grid-column: 2; flex-direction: column; gap: var(--space-2); min-width: 0; margin-top: var(--space-2); }
.aiwv-nb__pre { margin: 0; padding: 6px 10px; overflow-x: auto; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.aiwv-nb__stderr { background: var(--danger-rich-soft); }
.aiwv-nb__error { color: var(--danger-text); background: var(--danger-rich-soft); border-radius: var(--radius-sm); }
.aiwv-nb__img { display: block; max-width: 100%; height: auto; background: var(--canvas-light); }
.aiwv-nb__html { overflow-x: auto; }
.aiwv-nb__muted { margin: 0; color: var(--text-muted); font-size: 12.5px; font-style: italic; }
.aiwv-nb__raw { color: var(--text-dim); }

/* ---- media (FR §5.7) ------------------------------------------------------------------------ */
.aiwv-media { display: flex; align-items: center; justify-content: center; }
.aiwv-media--audio { min-height: 54px; padding: var(--space-2) var(--space-3); }
.aiwv-media__audio { width: 100%; }
.aiwv-media--video { background: #000; }
.aiwv-media__video { display: block; width: 100%; max-height: 70vh; aspect-ratio: var(--aiwv-media-aspect, 16 / 9); background: #000; }
.aiwv-mode-stage.aiwv-media--video .aiwv-media__video { height: 100%; max-height: none; }

/* ---- archive (FR §5.7) ---------------------------------------------------------------------- */
.aiwv-archive { display: flex; flex-direction: column; min-height: 0; }
.aiwv-archive.aiwv-mode-inline { max-height: 360px; }
.aiwv-archive__summary { padding: 6px var(--space-3); border-bottom: 1px solid var(--card-border); color: var(--card-fg-muted); font-size: 12.5px; }
.aiwv-archive__scroller { flex: 1 1 auto; min-height: 0; overflow: auto; }
.aiwv-archive__table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.aiwv-archive__table th { position: sticky; top: 0; z-index: 1; padding: 0; background: var(--card-bar-bg); text-align: left; }
.aiwv-archive__table td { padding: 4px var(--space-3); border-bottom: 1px solid var(--border-color); }
.aiwv-archive__sort { width: 100%; padding: 6px var(--space-3); border: 0; background: transparent; color: var(--card-fg-muted); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.aiwv-archive__sort:focus-visible { outline: none; box-shadow: inset var(--ring); }
.aiwv-archive__table th[aria-sort="ascending"] .aiwv-archive__sort::after { content: " ▲"; }
.aiwv-archive__table th[aria-sort="descending"] .aiwv-archive__sort::after { content: " ▼"; }
.aiwv-archive__path { max-width: 0; overflow: hidden; font-family: var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.aiwv-archive__size { width: 7em; color: var(--card-fg-muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.aiwv-archive__dir .aiwv-archive__path { color: var(--gold-accent); }
.aiwv-archive__empty { color: var(--card-fg-muted); font-style: italic; }

/* ---- workspace pane (file manager) ---------------------------------------------------------- */
.wsp-overlay {
    position: fixed;
    inset: 0;
    /* a modal overlay: above the stage pane and sheet (40), so its close button and the Workspace
       column are never covered (X36); lightbox and menus (45), notices (50) and dialogs (180) stay above */
    z-index: var(--z-files-pane);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: var(--overlay-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.wsp-panel {
    display: flex;
    flex-direction: column;
    width: min(1440px, 97vw);
    height: min(880px, 94vh);
    height: min(880px, 94dvh);
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--surface-1);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    color: var(--text-color);
}

.wsp-head {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 24px 30px 18px;
    border-bottom: 1px solid var(--border-color);
    background:
        linear-gradient(90deg, var(--gold-soft), transparent 70%),
        var(--surface-1);
}

.wsp-head__titles { min-width: 0; }
.wsp-kicker { display: block; margin-bottom: 7px; color: var(--gold-accent); font-size: 0.66rem; font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }
.wsp-title { margin: 0; font-size: clamp(1.35rem, 2vw, 1.75rem); }
.wsp-subtitle { max-width: 470px; margin: 7px 0 0; color: var(--text-dim); font-size: 0.84rem; line-height: 1.45; }
.wsp-head__actions { display: flex; flex: 0 0 auto; align-items: center; gap: var(--space-2); }
.wsp-quota { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.wsp-close {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.wsp-close:hover { border-color: var(--gold-accent); color: var(--gold-accent); }
.wsp-close:focus-visible, .wsp-btn:focus-visible, .wsp-icon-btn:focus-visible, .wsp-file__name:focus-visible { outline: none; box-shadow: var(--ring); }

.wsp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--card-bg);
    color: var(--text-color);
    font: inherit;
    font-size: 13px;
    font-weight: 550;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.wsp-btn:hover { border-color: var(--gold-glow); color: var(--gold-accent); }
.wsp-btn--primary { border-color: var(--gold-accent); background: var(--gold-accent); color: var(--gold-on); }
.wsp-btn--primary:hover { background: var(--gold-accent-hover); color: var(--gold-on); }
.wsp-btn--danger:hover { border-color: var(--danger-text); color: var(--danger-text); }

.wsp-status { flex: 0 0 auto; padding: 8px 30px; border-bottom: 1px solid var(--border-color); background: var(--gold-soft); color: var(--indicator-text); font-size: 13px; }
.wsp-status[data-level="error"] { background: var(--danger-rich-soft); color: var(--danger-text); }

.wsp-columns {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    padding: 14px;
    background: var(--chat-bg);
}

.wsp-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
}

.wsp-col--drop { border-color: var(--gold-accent); box-shadow: var(--ring); }
.wsp-col__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 14px 16px; border-bottom: 1px solid var(--border-color); }
.wsp-col__titles { min-width: 0; }
.wsp-col__title { margin: 0; font-size: 1rem; }
.wsp-col__subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }
.wsp-col__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.wsp-list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 6px; overflow-y: auto; list-style: none; }

.wsp-file {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 48px;
    padding: 6px 8px 6px 10px;
    border-radius: var(--radius-md);
}

.wsp-file:hover, .wsp-file:focus-within { background: var(--card-bg); }

.wsp-file__icon {
    flex: 0 0 auto;
    width: 26px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 3px 9px 3px 3px;
    background: var(--input-bg);
}

.wsp-file__icon[data-view="image"], .wsp-file__icon[data-view="svg"] { border-color: var(--gold-accent); background: var(--gold-soft); }
.wsp-file__icon[data-view="pdf"], .wsp-file__icon[data-view="office"] { border-color: var(--danger-soft); }
.wsp-file__icon[data-view="sheet"] { border-color: #6fbf73; }
.wsp-file__icon[data-view="html"], .wsp-file__icon[data-view="deck"] { border-color: var(--link-text); }
.wsp-file__main { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }

.wsp-file__name {
    display: block;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-color);
    font: inherit;
    font-size: 13.5px;
    font-weight: 550;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.wsp-file__name:hover .wsp-file__base { color: var(--gold-accent); }
.wsp-file__dir { color: var(--text-muted); font-weight: 450; }
.wsp-file__meta { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.wsp-file__actions { display: flex; flex: 0 0 auto; gap: 4px; }

.wsp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 1.05rem;
    text-decoration: none;
    cursor: pointer;
}

.wsp-icon-btn:hover { border-color: var(--border-color); background: var(--surface-2); color: var(--gold-accent); }
.wsp-file__delete:hover { color: var(--danger-text); }
.wsp-empty { padding: var(--space-5) var(--space-3); color: var(--text-muted); font-size: 13px; text-align: center; }
.wsp-empty--error { color: var(--danger-text); }
.wsp-nochat { display: flex; flex: 1 1 auto; align-items: center; justify-content: center; padding: var(--space-6); color: var(--text-dim); text-align: center; }

.wsp-preview { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; background: var(--chat-bg); }
.wsp-preview__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: 10px 16px; border-bottom: 1px solid var(--border-color); background: var(--surface-1); }
.wsp-preview__titles { display: flex; flex: 1 1 200px; flex-direction: column; min-width: 0; }
.wsp-preview__title { margin: 0; overflow: hidden; font-size: 0.98rem; text-overflow: ellipsis; white-space: nowrap; }
.wsp-preview__meta { color: var(--text-muted); font-size: 12px; }
.wsp-preview__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.wsp-viewer {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
    background: var(--surface-2);
}

.wsp-viewer > * { flex: 1 1 auto; min-height: 0; }
.wsp-viewer[data-view="image"] > .aiwv-image, .wsp-viewer[data-view="svg"] > .aiwv-image { justify-content: center; padding: var(--space-4); }
.wsp-viewer[data-view="media"] > .aiwv-media, .wsp-viewer[data-view="binary"] > .aiwv-filecard { flex: 0 0 auto; margin: auto 0; }
.wsp-viewer:focus-visible { outline: none; }
.wsp-viewer > iframe { height: 100%; min-height: 360px; }

@media (max-width: 768px) {
    .wsp-overlay { padding: 0; }
    .wsp-panel { width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
    .wsp-head { flex-wrap: wrap; padding: 16px 16px 12px; }
    .wsp-head__titles { flex: 1 1 60%; }
    .wsp-quota { display: none; }
    .wsp-subtitle { display: none; }
    .wsp-status { padding: 8px 16px; }
    .wsp-columns { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(220px, auto); overflow-y: auto; padding: 10px; }
    .wsp-col { overflow: visible; }
    .wsp-list { overflow: visible; }
    .wsp-file { min-height: 52px; }
    .wsp-icon-btn { width: 40px; height: 40px; }
    .wsp-preview__bar { padding: 8px 10px; }
    .aiwv-sheet.aiwv-mode-inline { height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
    .wsp-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
