/* blob-bridge - Application styling */
/* */
/* Layout, design tokens, and component styles for the portal and blob explorer. */

/* MARK: View Transitions */
/* Native browser page transitions via View Transitions API */
::view-transition-old(root) {
  animation: page-fade-out 0.2s ease-out forwards;
}

::view-transition-new(root) {
  animation: page-fade-in 0.2s ease-in forwards;
}

@keyframes page-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* MARK: Design Tokens */
/* Light theme tuned for file browsing */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-subtle: #eef1f6;
  --panel: #ffffff;
  --text: #1a2332;
  --muted: #5c6b80;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --border: #d8dee9;
  --border-strong: #c4cdd9;
  --danger: #dc2626;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --folder: #d97706;
  --container: #0284c7;
  --storage: #4f46e5;
  --title-start: #64748b;
  --title-end: #475569;
  --row-hover: #f8fafc;
  --on-accent: #ffffff;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fca5a5;
  --warning-border: #fcd34d;
  --overlay-backdrop: rgba(15, 23, 42, 0.55);
  --overlay-loading: rgba(244, 246, 249, 0.88);
  --video-bg: #0f172a;
  --font-ui: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.2);
  --label-size: 0.72rem;
  --label-weight: 700;
  --label-spacing: 0.05em;
}

/* MARK: Base Styles */
/* Core element defaults */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

/* MARK: Page Layout */
/* Shell, container, and card structure */
.app-shell {
  width: min(1120px, 94vw);
  margin: 0 auto;
  padding: 1rem 0 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 650;
}

.card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.card p:last-child {
  margin-bottom: 0;
}

/* MARK: Site Header */
/* AIT logo, org name, and session controls; header hidden until authenticated */
.app-shell:not(.is-authenticated) .site-header {
  display: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0 0.85rem;
}

.brand {
  min-width: 0;
}

.brand-text {
  min-width: 0;
}

.site-header h1 {
  line-height: 1.2;
}

.site-header p,
.brand-tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-actions[hidden] {
  display: none;
}

.user-badge {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-subtle);
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* MARK: Test Banner */
/* Visible when running in local test mode */
.test-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
}

.test-banner[hidden] {
  display: none;
}

.test-banner strong {
  font-weight: 700;
}

/* MARK: Buttons */
/* Primary, secondary, and inline actions */
button {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary,
.btn-secondary,
.upload-btn {
  display: inline-block;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.btn-primary,
.upload-btn {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.5rem 0.9rem;
  font-size: 0.92rem;
  transition: background 0.15s ease;
  text-decoration: none;
}

.btn-primary:hover:not(:disabled),
.upload-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  font-size: 0.92rem;
  transition: background 0.15s ease;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-primary.btn-danger-solid {
  background: var(--danger);
}

.btn-primary.btn-danger-solid:hover:not(:disabled) {
  background: var(--danger-hover);
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

button.is-busy,
.upload-btn.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

button.is-busy::before,
.upload-btn.is-busy::before {
  content: "";
  width: 0.85em;
  height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.btn-primary:focus-visible,
.upload-btn:focus-visible,
.btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* MARK: Auth Views */
/* #appShell.is-authenticated toggles login vs explorer; login-active centers the sign-in card */
.app-shell:not(.is-authenticated) #browserView {
  display: none;
}

.app-shell.is-authenticated #loginView {
  display: none;
}

main.login-active {
  align-items: center;
  justify-content: center;
}

.login-card {
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 2rem 1.75rem;
  text-align: center;
}

.login-header {
  margin-bottom: 0.35rem;
}

.app-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--title-start) 0%, var(--accent) 52%, var(--title-end) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.app-title-header {
  font-size: clamp(1.2rem, 3.5vw, 1.45rem);
}

.login-card .brand-tagline {
  margin-bottom: 1.35rem;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-width: min(100%, 16.5rem);
  min-height: 2.55rem;
  margin-top: 0;
  padding: 0.55rem 1rem;
  border: 1px solid #8c8c8c;
  border-radius: 4px;
  background: #ffffff;
  color: #5e5e5e;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-microsoft:hover {
  background: #f3f3f3;
  border-color: #707070;
}

.btn-microsoft:focus-visible {
  outline: 2px solid #0078d4;
  outline-offset: 2px;
}

.microsoft-logo {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.auth-error {
  margin: 1rem 0 0;
  padding: 0.65rem 0.85rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  text-align: center;
}

/* MARK: Storage Info */
/* Target account summary in the explorer chrome bar */
.explorer-chrome {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  padding: 0.9rem 1.15rem;
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 6.75rem;
  overflow: hidden;
}

.explorer-chrome-main {
  display: grid;
  grid-template-rows: auto 1.375rem;
  gap: 0.9rem;
  min-width: 0;
  flex: 1;
  align-content: start;
}

.explorer-location {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.explorer-location-label,
.explorer-target-key,
.panel-heading {
  font-size: var(--label-size);
  font-weight: var(--label-weight);
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
}

.explorer-location-label {
  margin: 0;
}

.explorer-target-key {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.explorer-current-path {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  height: 1.375rem;
  min-height: 1.375rem;
  max-height: 1.375rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.375;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.explorer-path-separator {
  flex-shrink: 0;
  color: var(--muted);
}

.explorer-path-current {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 1.375rem;
  padding: 0 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-path-link {
  flex-shrink: 0;
  appearance: none;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 1.375rem;
  padding: 0 0.4rem;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.explorer-path-link:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}

.explorer-path-link:active:not(:disabled) {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--border));
}

.explorer-path-link:focus-visible {
  outline: 1px solid var(--border-strong);
  outline-offset: 2px;
}

.explorer-target-row {
  height: 1.375rem;
  min-height: 1.375rem;
  max-height: 1.375rem;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.explorer-target {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  min-width: 0;
  overflow: hidden;
}

.explorer-target[hidden] {
  display: none;
}

.explorer-target-divider[hidden],
.explorer-target-container[hidden] {
  display: none;
}

.explorer-target-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.explorer-target-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--border-strong);
}

.explorer-target code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--panel);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 0.45rem;
  align-items: center;
  padding-top: calc(0.72rem * 1.25 + 0.35rem);
}

.explorer-actions .btn-primary.is-muted,
.explorer-actions .btn-secondary.is-muted,
.row-actions-item.is-muted {
  opacity: 0.42;
  cursor: not-allowed;
}

.explorer-actions .btn-primary.is-muted,
.explorer-actions .btn-secondary.is-muted {
  filter: grayscale(0.35);
}

.row-actions-item.is-muted {
  color: var(--muted);
}

/* MARK: Blob Browser */
/* Tree sidebar, file table, and explorer row styling */
.browser {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.browser-panel {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.explorer-layout {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.folder-tree-panel {
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel-heading {
  padding: 0.6rem 0.9rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.folder-tree-panel .panel-heading {
  background: transparent;
}

.folder-tree {
  list-style: none;
  margin: 0;
  padding: 0.45rem 0;
  overflow: auto;
  flex: 1;
}

.folder-tree[hidden] {
  display: none;
}

.tree-group {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-node {
  margin: 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.28rem 0.55rem 0.28rem calc(0.55rem + var(--tree-depth, 0) * 0.85rem);
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  margin: 0 0.25rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row:hover {
  background: var(--row-hover);
}

.tree-row.is-selected {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;
}

.tree-toggle:not(:disabled):hover {
  color: var(--text);
  background: transparent;
}

.tree-toggle:disabled,
.tree-toggle[hidden] {
  visibility: hidden;
}

.tree-toggle .explorer-icon svg {
  width: 0.75rem;
  height: 0.75rem;
  transition: transform 0.15s ease;
}

.tree-toggle .explorer-icon.is-expanded svg {
  transform: rotate(90deg);
}

.file-list-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.file-list-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  padding-right: 0.35rem;
}

.file-list-body.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--overlay-loading);
  pointer-events: none;
}

.file-list-body.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 1.35rem;
  height: 1.35rem;
  margin: -0.675rem 0 0 -0.675rem;
  border: 2px solid var(--muted);
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  pointer-events: none;
}

.file-list-body.is-loading .blob-table {
  pointer-events: none;
}

.browser-status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  color: var(--muted);
  text-align: center;
  background: var(--panel);
}

.browser-status[hidden] {
  display: none;
}

.blob-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.blob-table col.col-name {
  width: auto;
}

.blob-table col.col-size {
  width: 6.5rem;
}

.blob-table col.col-modified {
  width: 10.5rem;
}

.blob-table col.col-actions {
  width: 2.75rem;
}

.blob-table th,
.blob-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.blob-table td:first-child {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blob-table td:nth-child(2),
.blob-table td:nth-child(3) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.explorer-empty-row:hover {
  background: transparent;
}

.explorer-empty-cell {
  padding: 2rem 1.25rem;
  color: var(--muted);
  text-align: center;
  border-top: 0;
}

.blob-table tbody tr:hover {
  background: var(--row-hover);
}

.blob-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-subtle);
  border-top: 0;
  box-shadow: 0 1px 0 var(--border);
}

.explorer-row {
  cursor: pointer;
}

.explorer-row.is-selected {
  background: var(--accent-soft);
}

.explorer-name {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  overflow: hidden;
}

.explorer-name-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.explorer-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.explorer-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.explorer-icon.icon-folder {
  color: var(--folder);
}

.explorer-icon.icon-container {
  color: var(--container);
}

.explorer-icon.icon-storage {
  color: var(--storage);
}

.explorer-icon.icon-file {
  color: var(--muted);
}

.explorer-icon.icon-filePdf {
  color: var(--danger);
}

.explorer-icon.icon-fileImage {
  color: var(--accent);
}

.explorer-icon.icon-fileVideo {
  color: #7c3aed;
}

.explorer-icon.icon-fileAudio {
  color: #db2777;
}

.explorer-icon.icon-fileArchive {
  color: #9333ea;
}

.explorer-icon.icon-fileSpreadsheet {
  color: #059669;
}

.explorer-icon.icon-fileDocument {
  color: var(--container);
}

.explorer-icon.icon-filePresentation {
  color: #ea580c;
}

.explorer-icon.icon-fileCode {
  color: var(--folder);
}

.explorer-icon.icon-fileData {
  color: #0d9488;
}

.explorer-icon.icon-fileText {
  color: var(--success);
}

.explorer-icon.icon-fileWeb {
  color: #0891b2;
}

.explorer-icon.icon-fileFont {
  color: var(--title-start);
}

.explorer-icon.icon-fileBinary {
  color: var(--title-end);
}

.blob-table th:last-child,
.blob-table td.actions-cell {
  padding-inline: 0.35rem;
  text-align: center;
}

.actions-cell {
  vertical-align: middle;
  line-height: 1;
  overflow: visible;
}

.row-actions-menu {
  position: relative;
  display: inline-flex;
  justify-content: center;
}

.row-actions-trigger {
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  cursor: pointer;
}

.row-actions-trigger:hover,
.row-actions-trigger[aria-expanded="true"] {
  color: var(--text);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.row-actions-dropdown {
  z-index: 120;
  min-width: 9.5rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.row-actions-dropdown[hidden] {
  display: none;
}

.row-actions-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
}

.row-actions-item:hover:not(:disabled) {
  background: var(--row-hover);
}

.row-actions-item-view {
  color: var(--accent);
}

.row-actions-item-danger {
  color: var(--danger);
}

.row-actions-item-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.row-actions-item.is-busy {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* MARK: File Preview */
/* Modal overlay and inline viewers for common blob types */
body.preview-open,
body.modal-open {
  overflow: hidden;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-modal[hidden] {
  display: none;
}

.app-modal-backdrop,
.preview-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-backdrop);
}

.app-modal-dialog,
.preview-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(960px, 96vw);
  max-height: min(88vh, 900px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.app-modal-dialog-sm {
  width: min(420px, 96vw);
  max-height: none;
}

.app-modal-header,
.preview-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-modal-title,
.preview-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
}

.preview-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-modal-body {
  padding: 1rem 1.15rem 1.15rem;
}

.app-modal-message {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.app-modal-subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.app-modal-field {
  display: block;
  margin-top: 0.85rem;
}

.app-modal-field[hidden] {
  display: none !important;
}

.app-modal-field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.app-modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.app-modal-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* MARK: Properties Dialog */
/* Metadata grids and ACL table inside the item properties modal */
.explorer-properties-modal .app-modal-dialog {
  max-height: min(78vh, 560px);
  min-height: min(50vh, 400px);
}

.explorer-properties-modal .app-modal-header {
  padding: 0.55rem 0.85rem;
}

.explorer-properties-modal .app-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.85rem;
}

.explorer-properties-modal .app-modal-footer {
  padding: 0.5rem 0.85rem;
}

.explorer-properties-modal .app-modal-subtitle {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.properties-loading,
.properties-error {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.properties-error {
  color: var(--danger);
}

.properties-section + .properties-section {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.properties-section-title {
  margin: 0 0 0.3rem;
  font-size: var(--label-size);
  font-weight: var(--label-weight);
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
}

.properties-grid {
  display: grid;
  grid-template-columns: minmax(5.5rem, 32%) 1fr;
  gap: 0.12rem 0.55rem;
  margin: 0;
}

.properties-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.properties-grid dd {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.3;
  word-break: break-word;
}

.properties-acl-summary {
  grid-template-columns: minmax(4.5rem, 28%) 1fr;
}

.properties-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.properties-acl-scroll {
  max-height: 10rem;
  margin-top: 0.35rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.properties-acl-table {
  width: 100%;
  margin-top: 0;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.properties-acl-table th,
.properties-acl-table td {
  padding: 0.18rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.properties-acl-table tr:last-child td {
  border-bottom: 0;
}

.properties-acl-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: var(--label-weight);
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.properties-acl-raw {
  margin: 0.55rem 0 0;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  word-break: break-all;
}

.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 9rem;
  padding: 1.25rem;
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--bg-subtle);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-dropzone.is-dragover,
.upload-dropzone:hover:not(.is-disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-dropzone.is-disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.upload-dropzone-title {
  margin: 0;
  font-weight: 650;
  color: var(--text);
}

.upload-dropzone-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-browse-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.upload-queue {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.upload-queue-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.upload-queue-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  font-size: 0.86rem;
}

.upload-queue-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.upload-queue-size {
  flex-shrink: 0;
  color: var(--muted);
}

.upload-queue-status {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.transfer-file-name {
  margin: 0 0 0.75rem;
  font-weight: 600;
  word-break: break-word;
}

.transfer-progress {
  height: 0.45rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.transfer-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.15s ease;
}

.transfer-progress-label {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.transfer-progress-stats {
  margin: 0.15rem 0 0;
  min-height: 1.2em;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.preview-modal[hidden] {
  display: none;
}

.preview-header-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.45rem;
}

.preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.preview-status {
  margin: 0;
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

.preview-status[hidden] {
  display: none;
}

.preview-loading {
  padding: 2rem 1.25rem 2.5rem;
  text-align: center;
}

.preview-loading[hidden] {
  display: none;
}

.preview-loading-title {
  margin: 0 0 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.preview-loading .transfer-progress {
  max-width: 28rem;
  margin: 0 auto;
}

.preview-loading .transfer-progress-label {
  margin-top: 0.55rem;
}

.preview-loading .transfer-progress-stats {
  margin-top: 0.15rem;
}

.preview-content {
  min-height: 12rem;
}

.preview-content[hidden] {
  display: none;
}

.preview-text {
  margin: 0;
  padding: 1rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 780px);
  margin: 0 auto;
  padding: 1rem;
  object-fit: contain;
}

.preview-video {
  display: block;
  width: 100%;
  max-height: min(72vh, 780px);
  background: var(--video-bg);
}

.preview-audio {
  display: block;
  width: calc(100% - 2rem);
  margin: 2rem 1rem;
}

.preview-pdf {
  display: block;
  width: 100%;
  height: min(72vh, 780px);
  border: 0;
  background: var(--bg-subtle);
}

/* MARK: Auth Overlay */
/* Full-screen loading state while session is checked */
.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-loading);
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.auth-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.auth-overlay[hidden] {
  display: none;
}

.auth-overlay p {
  color: var(--muted);
}

/* MARK: Site Footer */
.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  padding-top: 1.25rem;
  margin-top: auto;
}

.footer-logo {
  display: block;
  height: 1.15rem;
  width: auto;
  max-width: 5.5rem;
  object-fit: contain;
  opacity: 0.55;
}

.footer-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .explorer-chrome {
    flex-direction: column;
    align-items: stretch;
    height: 9rem;
  }

  .explorer-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 0;
  }

  .explorer-target-divider {
    display: none;
  }

  .explorer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .folder-tree-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 10rem;
  }

  .file-list-panel {
    min-height: 14rem;
  }

  .blob-table col.col-name {
    width: 42%;
  }

  .blob-table col.col-modified {
    width: 0;
  }

  .blob-table th:nth-child(3),
  .blob-table td:nth-child(3) {
    display: none;
  }
}

/* MARK: Toasts */
/* Short-lived stacked notifications (top-right) */
.toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  position: relative;
  overflow: hidden;
  padding: 0.7rem 0.85rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  color: var(--text);
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: auto;
  cursor: pointer;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(12px);
}

.toast-message {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 550;
  line-height: 1.4;
}

.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  transform-origin: left center;
  animation-name: toast-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-success .toast-progress {
  background: var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-error .toast-progress {
  background: var(--danger);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-info .toast-progress {
  background: var(--accent);
}

.toast-warning {
  border-left: 3px solid var(--folder);
}

.toast-warning .toast-progress {
  background: var(--folder);
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary,
  .upload-btn,
  .btn-secondary {
    transition: none;
  }

  button.is-busy::before,
  .upload-btn.is-busy::before {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.45;
  }

  .toast {
    transition: none;
  }

  .toast-progress {
    animation: none;
    display: none;
  }
}
