:root {
  --in-oklab: ;
  --in-oklch: ;
  --font-sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-teal: #2dd4bf;
  --accent-rose: #fb7185;
  --accent-green: #22c55e;
}

@supports (background: linear-gradient(in oklab, white, black)) {
  :root {
    --in-oklab: in oklab;
    --in-oklch: in oklch;
  }
}

/* Dark Aurora Glass (Default) */
body[data-theme="dark"] {
  --bg-base: #060b19;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --glass-bg: rgba(15, 23, 42, 0.56);
  --glass-bg-elevated: rgba(17, 26, 48, 0.72);
  --glass-sub: rgba(255, 255, 255, 0.065);
  --glass-sub-hover: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-highlight: rgba(255, 255, 255, 0.28);
  --glass-shadow:
    0 12px 36px rgba(2, 6, 23, 0.55),
    0 2px 8px rgba(2, 6, 23, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --input-bg: rgba(2, 6, 23, 0.45);
  --input-border: rgba(255, 255, 255, 0.22);
  --backdrop-dim: rgba(2, 6, 23, 0.68);
  --progress-track: rgba(255, 255, 255, 0.14);
}

/* Light Frosted Crystal Glass */
body[data-theme="light"] {
  --bg-base: #dbeafe;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-bg-elevated: rgba(255, 255, 255, 0.8);
  --glass-sub: rgba(255, 255, 255, 0.52);
  --glass-sub-hover: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.78);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --glass-shadow:
    0 14px 36px rgba(30, 58, 138, 0.14),
    0 2px 10px rgba(30, 58, 138, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --input-bg: rgba(255, 255, 255, 0.72);
  --input-border: rgba(15, 23, 42, 0.22);
  --backdrop-dim: rgba(15, 23, 42, 0.46);
  --progress-track: rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-block-size: 100dvh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.min-w-0 {
  min-inline-size: 0;
}

.text-right {
  text-align: end;
}

/* Aurora Canvas */
.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1100px 680px at 10% -10%, rgba(56, 189, 248, 0.28), transparent 65%),
    radial-gradient(900px 620px at 92% 8%, rgba(99, 102, 241, 0.3), transparent 60%),
    radial-gradient(950px 700px at 50% 105%, rgba(20, 184, 166, 0.24), transparent 65%),
    linear-gradient(155deg var(--in-oklab), var(--bg-base), #0b1630 55%, #0e1e38);
}

body[data-theme="light"] .aurora-bg {
  background:
    radial-gradient(1000px 620px at 8% -5%, rgba(56, 189, 248, 0.42), transparent 62%),
    radial-gradient(900px 600px at 94% 6%, rgba(129, 140, 248, 0.36), transparent 62%),
    radial-gradient(900px 680px at 55% 105%, rgba(45, 212, 191, 0.34), transparent 65%),
    linear-gradient(155deg var(--in-oklab), #e0f2fe, #eef2ff 55%, #dbeafe);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.48;
  will-change: transform;
}

.orb-1 {
  inline-size: 420px;
  block-size: 420px;
  inset-block-start: -90px;
  inset-inline-start: -80px;
  background: #0ea5e9;
}

.orb-2 {
  inline-size: 380px;
  block-size: 380px;
  inset-block-start: 18%;
  inset-inline-end: -70px;
  background: #6366f1;
}

.orb-3 {
  inline-size: 440px;
  block-size: 440px;
  inset-block-end: -140px;
  inset-inline-start: 35%;
  background: #14b8a6;
}

/* Glass Surface Primitives */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
}

.glass-subcard {
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}

@supports not (backdrop-filter: blur(1px)) {
  .glass-panel {
    background: var(--glass-bg-elevated);
  }
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  min-block-size: 100dvh;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

.app-shell.is-locked {
  filter: blur(14px) saturate(120%);
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

dialog.glass-dialog.is-mandatory::backdrop {
  background-color: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sidebar {
  border-radius: var(--radius-xl);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  inset-block-start: 1rem;
  block-size: calc(100dvh - 2rem);
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block-end: 0.5rem;
  border-block-end: 1px solid var(--glass-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  inline-size: 42px;
  block-size: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg var(--in-oklch), #0ea5e9, #6366f1);
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.35);
}

.brand-icon svg {
  inline-size: 22px;
  block-size: 22px;
}

.brand-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-label {
  margin: 0.75rem 0.5rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-btn {
  inline-size: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: start;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.nav-btn svg {
  inline-size: 18px;
  block-size: 18px;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--glass-sub-hover);
  color: var(--text-primary);
}

.nav-btn.is-active {
  background: linear-gradient(135deg var(--in-oklab), rgba(56, 189, 248, 0.26), rgba(99, 102, 241, 0.22));
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-accent {
  border-color: rgba(45, 212, 191, 0.3);
  background: rgba(45, 212, 191, 0.09);
}

.storage-widget {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.storage-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.storage-label {
  font-size: 0.82rem;
  font-weight: 700;
}

.storage-path {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
}

.storage-metrics {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Native Progress Styling (modern-web-guidance: progress) */
progress.glass-progress {
  appearance: none;
  border: 0 solid;
  overflow: clip;
  inline-size: 100%;
  block-size: 8px;
  border-radius: 1e5px;
  background: var(--progress-track);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.18);
  container-type: inline-size;
  --progress-bar-radius: 1e5px;
  --progress-bar-fill: linear-gradient(90deg var(--in-oklab), #38bdf8, #6366f1);
  --progress-bar-indeterminate-size: 32%;
  --progress-bar-indeterminate-animation-duration: 1.5s;
}

@media (prefers-reduced-motion: reduce) {
  progress.glass-progress {
    --progress-bar-indeterminate-animation-duration: 10s;
  }
}

progress.glass-progress:indeterminate {
  --progress-bar-animation: progress-bar-indeterminate var(--progress-bar-indeterminate-animation-duration) infinite linear;
}

progress.glass-progress::-webkit-progress-bar {
  background: transparent;
}

progress.glass-progress::-webkit-progress-value {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.25s ease;
  animation: var(--progress-bar-animation, revert-rule);
}

progress.glass-progress::-moz-progress-bar {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.25s ease;
  animation: var(--progress-bar-animation, revert-rule);
}

@keyframes progress-bar-indeterminate {
  from, to {
    inline-size: var(--progress-bar-indeterminate-size);
    margin-right: auto;
  }
  from {
    translate: -100%;
  }
  to {
    translate: 100cqi;
  }
}

.upload-bar {
  block-size: 10px;
}

/* Main Column */
.main-column {
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topbar {
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1 1 280px;
  min-inline-size: 0;
}

.search-box {
  position: relative;
  flex: 1;
  min-inline-size: 0;
}

.search-icon {
  position: absolute;
  inset-inline-start: 0.9rem;
  inset-block-start: 50%;
  transform: translateY(-50%);
  inline-size: 17px;
  block-size: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  inline-size: 100%;
  min-block-size: 44px;
  padding: 0.55rem 0.95rem 0.55rem 2.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font: inherit;
  font-size: max(1rem, 0.94em);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Glass Buttons & Chips */
.glass-btn,
.glass-chip,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  min-block-size: 42px;
  padding: 0.5rem 0.9rem;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.14s ease;
}

.glass-btn svg,
.icon-btn svg {
  inline-size: 17px;
  block-size: 17px;
  flex-shrink: 0;
}

.icon-btn {
  inline-size: 42px;
  padding: 0;
}

.glass-chip {
  min-block-size: 38px;
  padding: 0.35rem 0.78rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.glass-btn:hover,
.glass-chip:hover,
.icon-btn:hover {
  background: var(--glass-sub-hover);
  border-color: var(--glass-highlight);
}

.glass-btn:active,
.icon-btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg var(--in-oklch), #0284c7, #4f46e5);
  border-color: rgba(125, 211, 252, 0.55);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.32);
}

.btn-primary:hover {
  background: linear-gradient(135deg var(--in-oklch), #0ea5e9, #6366f1);
}

.btn-primary-soft {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-sky {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.42);
}

.btn-rose {
  background: rgba(251, 113, 133, 0.18);
  border-color: rgba(251, 113, 133, 0.42);
}

.btn-teal {
  background: rgba(45, 212, 191, 0.18);
  border-color: rgba(45, 212, 191, 0.42);
}

.btn-whatsapp {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.42);
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.48);
}

.btn-danger {
  background: linear-gradient(135deg var(--in-oklab), #dc2626, #be123c);
  border-color: rgba(252, 165, 165, 0.5);
  color: #ffffff;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
}

.avatar-pill {
  inline-size: 26px;
  block-size: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg var(--in-oklab), #0ea5e9, #6366f1);
}

.status-dot {
  inline-size: 9px;
  block-size: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.status-dot.is-offline {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

/* Content Area */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-block-end: 2rem;
}

.setup-banner {
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-color: rgba(56, 189, 248, 0.48);
  background: linear-gradient(135deg var(--in-oklab), rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.14));
}

.setup-banner-text h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.setup-banner-text p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.toolbar-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.view-switcher {
  display: inline-flex;
  padding: 0.2rem;
  gap: 0.2rem;
  border-radius: var(--radius-md);
}

.view-btn {
  display: grid;
  place-items: center;
  inline-size: 36px;
  block-size: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.view-btn svg {
  inline-size: 17px;
  block-size: 17px;
}

.view-btn.is-active {
  background: var(--glass-sub-hover);
  color: var(--text-primary);
}

/* Drop Zone */
.drop-zone {
  border-radius: var(--radius-xl);
  padding: 1.65rem 1.25rem;
  text-align: center;
  border-style: dashed;
  border-width: 1.5px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  transform: translateY(-1px);
}

.drop-icon {
  inline-size: 56px;
  block-size: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.drop-icon svg {
  inline-size: 28px;
  block-size: 28px;
}

.drop-zone h2 {
  margin: 0 0 0.3rem;
  font-size: 1.08rem;
}

.drop-zone p {
  margin: 0 0 0.9rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.drop-badges {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.glass-pill {
  padding: 0.3rem 0.72rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
}

.upload-progress-card {
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.progress-head h2 {
  margin: 0;
  font-size: 0.96rem;
}

.progress-head p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* File Table & Grid */
.files-panel {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.file-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 104px 145px 92px 140px;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-block-end: 1px solid var(--glass-border);
  background: var(--glass-sub);
}

.file-list-body {
  display: flex;
  flex-direction: column;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 104px 145px 92px 140px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1.15rem;
  border-block-end: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.15s ease;
}

body[data-theme="light"] .file-row {
  border-block-end-color: rgba(15, 23, 42, 0.08);
}

.file-row:hover {
  background: var(--glass-sub);
}

.file-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-inline-size: 0;
}

.file-thumb-box {
  inline-size: 42px;
  block-size: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: var(--glass-sub);
  cursor: pointer;
}

.file-thumb-box img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.file-thumb-box svg {
  inline-size: 20px;
  block-size: 20px;
}

.file-name-btn {
  display: block;
  max-inline-size: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  text-align: start;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name-btn:hover {
  color: var(--accent);
}

.file-subline {
  margin: 0.18rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-cell {
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.file-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.file-actions .icon-btn {
  inline-size: 36px;
  block-size: 36px;
  min-block-size: 36px;
  border-radius: 10px;
}

/* Grid View */
.file-grid-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
  padding: 1rem;
}

.file-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: var(--radius-lg);
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.file-card:hover {
  transform: translateY(-2px);
  background: var(--glass-sub-hover);
}

.file-card-preview {
  aspect-ratio: 16 / 10;
  inline-size: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.25);
  border: 1px solid var(--glass-border);
  cursor: pointer;
}

.file-card-preview img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.file-card-preview svg {
  inline-size: 34px;
  block-size: 34px;
}

.file-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-card-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.access-btn {
  --badge-bg: #475569;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-block-size: 32px;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background-color: var(--badge-bg);
  color: #ffffff;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, filter 0.15s ease;
}

.access-btn svg {
  inline-size: 13px;
  block-size: 13px;
  flex-shrink: 0;
}

.access-btn.is-public {
  --badge-bg: #059669;
}

.access-btn.is-private {
  --badge-bg: #475569;
}

.access-btn:hover:not(:disabled) {
  filter: brightness(1.12);
}

.access-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

@supports (color: contrast-color(red)) {
  .access-btn {
    color: contrast-color(var(--badge-bg));
  }
}

/* Dynamic Contrast Badges (modern-web-guidance: contrast-color) */
.badge {
  --badge-bg: #0284c7;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.58rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  background-color: var(--badge-bg);
  color: #ffffff;
}

@supports (color: contrast-color(red)) {
  .badge {
    color: contrast-color(var(--badge-bg));
  }
}

.badge-images { --badge-bg: #0284c7; }
.badge-pdf { --badge-bg: #e11d48; }
.badge-video { --badge-bg: #0d9488; }
.badge-documents { --badge-bg: #4f46e5; }
.badge-others { --badge-bg: #475569; }
.badge-live { --badge-bg: #15803d; }
.badge-off { --badge-bg: #991b1b; }

.empty-state,
.empty-mini {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Native Modal Dialogs (modern-web-guidance: dialog & prevent-page-scroll-under-modal-dialog) */
dialog.glass-dialog {
  margin: auto;
  padding: 1.35rem;
  inline-size: min(94vw, 520px);
  max-block-size: 90dvh;
  border-radius: var(--radius-xl);
  background: var(--glass-bg-elevated);
  border: 1px solid var(--glass-highlight);
  color: var(--text-primary);
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(26px) saturate(175%);
  -webkit-backdrop-filter: blur(26px) saturate(175%);
}

dialog.glass-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

dialog.dialog-wide {
  inline-size: min(95vw, 760px);
}

dialog.dialog-preview {
  inline-size: min(96vw, 960px);
}

dialog.dialog-sm {
  inline-size: min(92vw, 420px);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: var(--backdrop-dim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
}

.dialog-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.dialog-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-inline-end: 0.25rem;
  overscroll-behavior: contain;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group input,
.field-group select {
  font: inherit;
  font-size: max(1rem, 0.94em);
  min-block-size: 46px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  inline-size: 100%;
  padding-inline-end: 3rem;
}

.pw-eye {
  position: absolute;
  inset-inline-end: 0.3rem;
  border: 0;
  background: transparent;
}

.form-error {
  margin: 0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(225, 29, 72, 0.2);
  border: 1px solid rgba(251, 113, 133, 0.5);
  font-size: 0.84rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* API Key UI */
.api-create-box,
.settings-card,
.key-reveal-box {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.section-mini-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
}

.api-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.scope-fieldset {
  margin: 0;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.scope-fieldset legend {
  padding: 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  cursor: pointer;
}

.check-pill input,
.toggle-row input {
  accent-color: var(--accent);
  inline-size: 18px;
  block-size: 18px;
}

.key-reveal-box {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
}

.reveal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.reveal-header h2 {
  margin: 0;
  font-size: 0.98rem;
}

.reveal-header p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.key-code-block {
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: #f8fafc;
  word-break: break-all;
}

.snippets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
}

.snippet-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-inline-size: 0;
}

.snippet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.snippet-card pre {
  margin: 0;
  padding: 0.7rem;
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, 0.55);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-x: auto;
}

.apikey-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.apikey-item {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.apikey-item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-inline-size: 0;
}

.apikey-item-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-weight: 700;
}

.apikey-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.apikey-item-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.rescan-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.muted-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Preview Stage */
.preview-head-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-block-size: 280px;
  max-block-size: 72dvh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid var(--glass-border);
  padding: 0.75rem;
}

.preview-stage img,
.preview-stage video {
  max-inline-size: 100%;
  max-block-size: 66dvh;
  border-radius: var(--radius-md);
  display: block;
}

.preview-stage iframe {
  inline-size: 100%;
  block-size: 66dvh;
  border: 0;
  border-radius: var(--radius-md);
  background: #fff;
}

.confirm-body {
  margin: 0;
  line-height: 1.5;
}

/* Toasts */
.toast-region {
  position: fixed;
  inset-block-end: 1rem;
  inset-inline-end: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-inline-size: min(92vw, 360px);
  pointer-events: none;
}

.toast-item {
  padding: 0.78rem 1rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg-elevated);
  border: 1px solid var(--glass-highlight);
  color: var(--text-primary);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 0.86rem;
  font-weight: 500;
  pointer-events: auto;
}

/* Focus Visibility (modern-web-guidance: accessibility / forms) */
:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

.mobile-only {
  display: none;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
}

.reveal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.user-create-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.users-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--glass-subtle);
  border: 1px solid var(--border-subtle);
}

.user-item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 260px;
}

.user-item-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.94rem;
}

.user-item-sub {
  font-size: 0.79rem;
  color: var(--text-muted);
  word-break: break-word;
}

.user-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.badge-sky {
  background: rgba(56, 189, 248, 0.16);
  color: var(--sky-text, #7dd3fc);
  border: 1px solid rgba(56, 189, 248, 0.32);
}

.badge-amber {
  background: rgba(251, 191, 36, 0.16);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.32);
}

.delete-choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.25rem;
}

.delete-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  width: 100%;
  min-height: 44px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-primary);
  background: var(--glass-sub);
  border: 1px solid var(--glass-border);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.delete-choice-btn:hover,
.delete-choice-btn:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.choice-permanent {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.45);
}

.choice-permanent:hover,
.choice-permanent:focus-visible {
  background: rgba(251, 113, 133, 0.24);
  border-color: rgba(251, 113, 133, 0.75);
}

.choice-soft {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.42);
}

.choice-soft:hover,
.choice-soft:focus-visible {
  background: rgba(251, 191, 36, 0.22);
  border-color: rgba(251, 191, 36, 0.72);
}

.choice-title {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-primary);
}

.choice-desc {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

body[data-theme="light"] .badge-sky {
  background: rgba(14, 165, 233, 0.14);
  color: #0369a1;
}

body[data-theme="light"] .badge-amber {
  background: rgba(217, 119, 6, 0.14);
  color: #92400e;
}

body[data-theme="light"] .choice-permanent {
  background: rgba(244, 63, 94, 0.1);
}

body[data-theme="light"] .choice-soft {
  background: rgba(217, 119, 6, 0.1);
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.65rem;
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset-block: 0.65rem;
    inset-inline-start: 0.65rem;
    inline-size: min(84vw, 300px);
    block-size: calc(100dvh - 1.3rem);
    z-index: 40;
    transform: translateX(-115%);
    transition: transform 0.24s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .file-table-head,
  .file-row {
    grid-template-columns: minmax(0, 1fr) 92px 124px;
  }

  .hide-md,
  .file-table-head .hide-sm,
  .file-row .hide-sm {
    display: none;
  }
}

@media (max-width: 600px) {
  .hide-sm {
    display: none;
  }

  .file-table-head {
    grid-template-columns: minmax(0, 1fr) 86px 118px;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr) 86px 118px;
    padding: 0.75rem 0.75rem;
    gap: 0.45rem;
  }

  .upload-actions {
    inline-size: 100%;
  }

  .upload-actions > .glass-btn {
    flex: 1 1 45%;
  }

  .user-form-grid {
    grid-template-columns: 1fr;
  }
}
