/* Paperhaus Drive. Colors only through tokens; accent is deep teal via data-product="drive". */

.beta-badge { margin-left: var(--sp-1); flex: none; }

/* ---------- app frame: the list scrolls, not the page ---------- */
.main[data-drive-main] { overflow: hidden; display: flex; flex-direction: column; }
.drive { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: var(--sp-2) var(--sp-4) 0; }
.drive-head { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--ctl-xl); flex-wrap: wrap; }
.drive-tools { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.view-seg button { padding: 0 var(--sp-3); }
/* one control height across the toolbar: sort, view switch and details */
.drive-tools .btn-sm { min-height: var(--ctl-md); }
.drive-tools .seg button { min-height: calc(var(--ctl-md) - 2px); }
.drive-note { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; margin: 0; }

/* breadcrumbs */
.crumbs { min-width: 0; flex: 1 1 280px; }
.crumbs ol { list-style: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; }
.crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.crumbs li + li::before { content: "\203A"; color: var(--text-3); padding: 0 var(--sp-1); font-size: var(--fs-20); }
.crumbs a, .crumbs span { display: inline-block; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-pill); font-size: var(--fs-20); color: var(--text-2); text-decoration: none; }
.crumbs span[aria-current] { color: var(--text); font-weight: 500; }
.crumbs a:hover { background: color-mix(in srgb, var(--state) 8%, transparent); color: var(--text); }
.crumbs.small a, .crumbs.small span, .crumbs.small .btn { font-size: var(--fs-14); }
.crumbs.small { margin-bottom: var(--sp-3); }
.drop-hover { background: var(--accent-container) !important; color: var(--on-accent-container) !important; outline: 2px solid var(--accent); outline-offset: -2px; }

/* selection toolbar */
/* overlays the header row so selecting never shifts the list */
.selbar { position: absolute; z-index: 3; top: var(--sp-2); left: var(--sp-4); right: var(--sp-4); display: flex; align-items: center; gap: var(--sp-1); min-height: var(--ctl-xl); padding: 0 var(--sp-2); border-radius: var(--r-pill); background: var(--accent-container); color: var(--on-accent-container); flex-wrap: wrap; }
.selbar .icon-btn { color: var(--on-accent-container); }
.selcount { font-weight: 600; padding: 0 var(--sp-2); }
.trash-note { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-2); border-radius: var(--r-input); background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.trash-note p { margin: 0; flex: 1 1 240px; }

/* ---------- list area ---------- */
.drive-body { flex: 1 1 auto; min-height: 0; display: flex; gap: var(--sp-3); }
.drive-scroll { --r-in: calc(var(--r-card) - 1px); --lh-pad: calc(var(--sp-4) + 32px + var(--sp-3)); position: relative; flex: 1 1 auto; min-width: 0; overflow-y: auto; overflow-x: hidden; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); }
.drive-scroll > .status-msg { padding: var(--sp-2) var(--sp-4) 0; margin: 0; }
.list-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr 180px 100px; gap: var(--sp-3); padding: 0 var(--sp-4) 0 var(--lh-pad); height: 40px; align-items: center; background: var(--raised); border-radius: var(--r-in) var(--r-in) 0 0; /* matches the card so no square corner shows */ border-bottom: 1px solid var(--line); font-size: var(--fs-13); font-weight: 600; color: var(--text-2); }
.list-head .c-size, .vi-size { text-align: right; }
.vsizer { position: relative; min-height: 1px; }
.vlist { position: absolute; inset: 0; outline: none; }
.vlist:focus-visible { outline: none; }
.vitem { position: absolute; left: 0; right: 0; height: 52px; display: grid; grid-template-columns: 32px 1fr 180px 100px; gap: var(--sp-3); align-items: center; padding: 0 var(--sp-4); border-bottom: 1px solid var(--line); cursor: default; user-select: none; color: var(--text); }
.vitem:hover { background: color-mix(in srgb, var(--state) 5%, transparent); }
.vitem[aria-selected="true"] { background: var(--accent-container); color: var(--on-accent-container); }
.vlist.kb .vitem.focus { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
.vi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--text-2); }
.vi-icon.is-folder { color: var(--accent); }
.vitem[aria-selected="true"] .vi-icon { color: inherit; }
.vi-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.vi-name .skel { width: 60%; margin: 0; }
.vi-mod, .vi-size { color: var(--text-3); font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vitem[aria-selected="true"] :is(.vi-mod, .vi-size, .vi-sub) { color: inherit; }

/* grid */
.vlist.grid .vitem { height: 204px; right: auto; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; margin-top: var(--sp-3); }
.vlist.grid .vitem[aria-selected="true"] { background: var(--accent-container); border-color: var(--accent); }
.vlist.grid .vlist.kb .vitem.focus { border-radius: var(--r-card); }
.vi-thumb { flex: 1 1 auto; display: grid; place-items: center; margin: var(--sp-2) var(--sp-2) 0; border-radius: var(--r-input); background: var(--raised); color: var(--text-3); overflow: hidden; --fold: 16px; }
.vi-thumb .i.lg { width: var(--ic-xl); height: var(--ic-xl); }
.vi-thumb.has-img { background: var(--canvas-deep); }
.vi-thumb img { width: 100%; height: 100%; object-fit: cover; }
.vi-label { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) 0; min-width: 0; }
.vi-label .vi-icon { width: var(--ic-lg); height: var(--ic-lg); flex: none; }
.vi-sub { --sub-pad: calc(var(--sp-3) + var(--ic-lg) + var(--sp-2)); padding: 0 var(--sp-3) var(--sp-2) var(--sub-pad); color: var(--text-3); font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* skeleton and states */
.skel-list { padding: var(--sp-2) var(--sp-4); }
.skel-row { display: grid; grid-template-columns: 32px 1fr 120px; gap: var(--sp-3); align-items: center; height: 52px; border-bottom: 1px solid var(--line); }
.skel-row .skel.sq { width: 28px; height: 28px; }
.skel-row .skel.line { margin: 0; }
.skel-row .skel.short { width: 70%; justify-self: end; }
.drive-scroll .empty { padding-top: var(--sp-8); }

/* storage */
.storage { padding: var(--sp-5); max-width: 640px; }
.storage h2 { margin-bottom: var(--sp-4); }
.storage-meter.big { width: 100%; height: 14px; }
.storage-text { margin: var(--sp-3) 0 var(--sp-4); font-size: var(--fs-16); }
.storage-list { border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: var(--sp-4); }
meter { accent-color: var(--accent); }
.drawer-storage { display: grid; gap: var(--sp-1); margin: var(--sp-4) var(--sp-4) 0; padding: var(--sp-3) 0 0; border-top: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-12); text-decoration: none; }
.drawer-storage meter { width: 100%; height: 8px; }
.drawer-storage:hover { color: var(--text); text-decoration: none; }
@media (min-width: 768px) and (max-width: 1099.98px) { .drawer-storage { display: none; } }
@media (min-width: 1100px) { :root[data-drawer="rail"] .drawer-storage { display: none; } }

/* details panel */
.details { flex: 0 0 300px; min-width: 0; overflow-y: auto; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.details-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.details-head h2 { flex: 1; font-size: var(--fs-16); }
.details-name { display: grid; justify-items: start; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.details-name .i.lg { color: var(--accent); width: 32px; height: 32px; }
.details-name p { font-weight: 600; font-size: var(--fs-16); }
.facts { display: grid; gap: var(--sp-1) 0; margin: 0; }
.facts dt { color: var(--text-3); font-size: var(--fs-12); margin-top: var(--sp-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 1099.98px) {
  .details { position: fixed; z-index: var(--z-panel); right: var(--sp-3); top: calc(var(--bar-h) + var(--sp-3)); bottom: var(--sp-3); width: min(320px, calc(100vw - 24px)); box-shadow: var(--shadow-3); background: var(--overlay); }
}

/* menus placed by script or fixed */
.new-menu { position: fixed; top: calc(var(--bar-h) + 76px); left: var(--sp-3); }
.ctx-menu { position: fixed; }
.menu-item.danger { color: var(--danger); }

/* dialogs */
.dialog-foot.flush { padding: var(--sp-4) 0 0; }
.dialog-foot .grow { flex: 1; }
#dlg-move .dialog-foot { align-items: center; }
.move-list { max-height: min(360px, 50dvh); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-input); }
.move-row { width: 100%; border: 0; background: none; text-align: left; color: var(--text); font: inherit; }
.move-row .chev { margin-left: auto; color: var(--text-3); }
.share-name { font-weight: 600; margin-bottom: 0; }
.share-link { margin-top: var(--sp-4); }
.share-list { border: 1px solid var(--line); border-radius: var(--r-input); }
.share-list .list-row { min-height: 52px; }
.extract-facts { margin: 0 0 var(--sp-3) var(--sp-5); list-style: disc; }

/* ---------- viewer ---------- */
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; background: var(--canvas-deep); color: var(--text); display: none; flex-direction: column; animation: none; }
dialog.viewer[open] { display: flex; }
dialog.viewer::backdrop { background: var(--canvas-deep); }
.vw-bar { display: flex; align-items: center; gap: var(--sp-1); min-height: var(--bar-h); padding: 0 var(--sp-2); background: var(--surface); border-bottom: 1px solid var(--line); }
.vw-name { flex: 1 1 auto; font-size: var(--fs-16); font-weight: 500; min-width: 0; }
.vw-pos { flex: none; padding: 0 var(--sp-2); }
.vw-body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.vw-stage:has(.pv-zip) { justify-content: flex-start; }
.vw-stage { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: auto; padding: var(--sp-4) var(--sp-8); }
.vw-nav { position: absolute; top: 50%; z-index: 2; transform: translateY(-50%); width: var(--ctl-lg); height: var(--ctl-lg); border-radius: 50%; border: 1px solid var(--line); background: var(--overlay); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow-2); }
.vw-nav.prev { left: var(--sp-3); }
.vw-nav.next { right: var(--sp-3); }
.vw-details { flex: 0 0 300px; overflow-y: auto; padding: var(--sp-4); background: var(--surface); border-left: 1px solid var(--line); }
@media (max-width: 767.98px) {
  .vw-stage { padding: var(--sp-3); }
  .vw-nav { top: auto; bottom: var(--sp-3); transform: none; }
  .vw-details { position: absolute; inset: auto 0 0 0; max-height: 60%; border-left: 0; border-top: 1px solid var(--line); z-index: 3; }
}

/* previews */
.pv-loading { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-2); }
.spinner { width: var(--ic); height: var(--ic); border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin var(--dur-loop) linear infinite; }
.pv-note { display: grid; justify-items: center; gap: var(--sp-3); text-align: center; max-width: 44ch; }
.pv-note .glyph { width: 72px; height: 88px; border-radius: var(--r-sm); border: 1.5px solid var(--line-strong); background: var(--raised); --fold: 20px; display: grid; place-items: center; color: var(--text-3); }
.pv-title { font-size: var(--fs-16); font-weight: 600; margin: 0; }
.pv-image { flex: 1 1 auto; width: 100%; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.pv-image img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform var(--dur) linear; }
.pv-image.zoomed { cursor: grab; }
.pv-image:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pv-zoom { display: flex; align-items: center; gap: var(--sp-1); margin-top: var(--sp-2); padding: 0 var(--sp-2); border-radius: var(--r-pill); background: var(--overlay); border: 1px solid var(--line); }
.pv-media { max-width: 100%; max-height: 100%; }
audio.pv-media { width: min(560px, 100%); }
.pv-pdf { width: 100%; height: 100%; border: 0; border-radius: var(--r-sm); background: var(--raised); }
.pv-codebox, .pv-csv { width: 100%; height: 100%; overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-input); }
.pv-codebox:focus-visible, .pv-csv:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pv-code { --ln-w: 3.25rem; --ln-pad: calc(var(--ln-w) + var(--sp-4)); margin: 0; padding: var(--sp-4) var(--sp-4) var(--sp-4) 0; font: var(--fs-13) / 1.7 var(--font-mono); color: var(--text); white-space: pre; min-width: max-content; tab-size: 2; }
.pv-code .ln { display: block; position: relative; padding-left: var(--ln-pad); min-height: 1.7em; }
.pv-code .ln::before { content: attr(data-n); position: absolute; left: 0; width: var(--ln-w); text-align: right; color: var(--text-3); user-select: none; }
.pv-csv .table { border: 0; border-radius: 0; width: max-content; min-width: 100%; }
.pv-csv th { position: sticky; top: 0; }
.pv-csv { --r-in: calc(var(--r-input) - 1px); }
.pv-csv tr:first-child th:first-child { border-top-left-radius: var(--r-in); }
.pv-csv tr:first-child th:last-child { border-top-right-radius: var(--r-in); }
.pv-csv td, .pv-csv th { white-space: pre; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; }
.pv-more { margin-top: var(--sp-2); }
.pv-zip { width: min(820px, 100%); align-self: stretch; margin: 0 auto; display: flex; flex-direction: column; min-height: 0; }
.pv-zip-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.pv-zip-head p { flex: 1 1 240px; margin: 0; }
.pv-zip-list { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); overflow-y: auto; }
.pv-zip-list .list-row { min-height: 48px; padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-4); }
.pv-zip-preview { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 0; flex: 1; }
.pv-zip-preview .btn { align-self: flex-start; }
.pv-zip-stage { flex: 1; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-name, .hljs-doctag, .hljs-section { color: var(--syn-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-symbol, .hljs-selector-attr { color: var(--syn-string); }
.hljs-number, .hljs-bullet, .hljs-link { color: var(--syn-number); }
.hljs-comment, .hljs-quote { color: var(--syn-comment); font-style: italic; }
.hljs-title { color: var(--text); font-weight: 600; }
.hljs-type, .hljs-built_in, .hljs-selector-class, .hljs-selector-id { color: var(--syn-type); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-params, .hljs-property { color: var(--syn-attr); }
.hljs-meta { color: var(--syn-meta); }
.hljs-deletion { color: var(--danger); }

/* ---------- uploads panel ---------- */
.uploads { position: fixed; z-index: var(--z-float); right: var(--sp-4); bottom: var(--sp-4); width: min(400px, calc(100vw - 24px)); max-height: min(60dvh, 520px); display: flex; flex-direction: column; background: var(--overlay); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-3); overflow: hidden; }
.up-head { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.up-title { flex: 1; font-size: var(--fs-14); font-weight: 600; }
.uploads.collapsed .up-body { display: none; }
.uploads.collapsed [data-up="toggle"] .i { transform: rotate(180deg); }
.up-body { display: flex; flex-direction: column; min-height: 0; padding: var(--sp-3) var(--sp-4); gap: var(--sp-2); }
.uploads progress { width: 100%; height: 6px; accent-color: var(--accent); }
.up-stats { display: flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-12); color: var(--text-2); flex-wrap: wrap; }
.up-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.up-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0; border-top: 1px solid var(--line); }
.up-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--sp-2); align-items: center; }
.up-name { font-size: var(--fs-13); }
.up-status { font-size: var(--fs-12); color: var(--text-3); }
.up-row.failed .up-status { color: var(--danger); }
.up-main progress { grid-column: 1 / -1; height: 4px; }
.up-more:empty { display: none; }

/* drop overlay */
.drop-overlay { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; background: color-mix(in srgb, var(--accent-container) 70%, transparent); pointer-events: none; }
.drop-card { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-7); border: 2px dashed var(--accent); border-radius: var(--r-card); background: var(--overlay); color: var(--text); box-shadow: var(--shadow-3); text-align: center; --fold: 22px; }
.drop-card .i { color: var(--accent); }

/* ---------- share, report, notice pages ---------- */
.share-page { --max: 1040px; }
.share-card { padding: var(--sp-5); }
.share-head { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.share-icon { width: 56px; height: 64px; border-radius: var(--r-sm); border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--accent); --fold: 16px; flex: none; }
.share-info { flex: 1 1 240px; min-width: 0; }
.share-title { font-size: var(--fs-24); }
.share-info p { margin: var(--sp-1) 0 0; }
.share-stage { min-height: 320px; height: min(70dvh, 760px); border-radius: var(--r-input); background: var(--canvas-deep); padding: var(--sp-4); }
.share-stage .skel.block { width: 100%; height: 100%; }
.share-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-4); }
.notice-card { max-width: var(--w-narrow); margin: var(--sp-6) auto 0; display: grid; justify-items: center; text-align: center; gap: var(--sp-3); padding: var(--sp-6) var(--sp-5); }
.notice-card .glyph { width: 64px; height: 76px; border-radius: var(--r-sm); border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--accent); --fold: 18px; }
.notice-card h1 { font-size: var(--fs-24); }
.report-card { justify-items: stretch; text-align: left; }
.report-card .glyph, .report-card h1 { justify-self: center; }
.actions.center-actions { justify-content: center; }
.actions.end { justify-content: flex-end; }

/* ---------- small screens ---------- */
@media (max-width: 767.98px) {
  .drive { padding: var(--sp-1) var(--sp-2) 0; }
  .topbar .product { flex: none; padding: 0 var(--sp-1); }
  .beta-badge { height: 20px; padding: 0 var(--sp-1); font-size: var(--fs-12); margin-left: 0; }
  .selbar { left: var(--sp-2); right: var(--sp-2); top: var(--sp-1); }
  .crumbs a, .crumbs span { font-size: var(--fs-16); max-width: 18ch; }
  .drive-scroll { --lh-pad: calc(var(--sp-3) + 32px + var(--sp-3)); }
  .list-head { grid-template-columns: 1fr 80px; }
  .list-head .c-mod, .vi-mod { display: none; }
  .vitem { grid-template-columns: 32px 1fr 80px; padding: 0 var(--sp-3); }
  .drive-note { display: none; }
  .uploads { right: var(--sp-2); bottom: var(--sp-2); }
  .new-menu { top: calc(var(--bar-h) + 60px); }
  .share-card { padding: var(--sp-4); }
  .share-stage { padding: var(--sp-2); height: 60dvh; }
}
@media print { .uploads, .drop-overlay, .selbar { display: none !important; } }
