/* CloudBox appearance controls. app.css is the original daytime palette. */
.theme-switcher {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-subtle);
}
.theme-option {
  min-height: 31px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s;
}
.theme-option .ui-icon { width: 15px; height: 15px; }
.theme-option:hover { color: var(--primary); background: var(--primary-soft); }
.theme-option[aria-pressed="true"] {
  color: var(--primary);
  border-color: var(--line);
  background: var(--surface-solid);
  box-shadow: var(--shadow-xs);
}
.theme-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.public-theme-control { position: fixed; top: 16px; right: 18px; z-index: 100; }
.theme-default-setting {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-subtle);
}
.theme-default-setting .settings-toggle-copy { flex: 1 1 auto; }
.theme-default-field { min-width: 175px; flex: 0 0 175px; font-size: 11px; }
.theme-default-field select { margin-top: 5px; }

/* Midnight navy / blue/cyan design based on the supplied reference. */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #071126;
  --bg-soft: #0b1832;
  --surface: #0c1933;
  --surface-solid: #0e1d3a;
  --surface-subtle: #101f3d;
  --text: #eff5ff;
  --text-2: #ccdbf4;
  --muted: #9db3d8;
  --muted-2: #708bb7;
  --line: rgba(82, 130, 211, .19);
  --line-strong: rgba(82, 130, 211, .32);
  --primary: #4292ff;
  --primary-hover: #65b5ff;
  --primary-soft: rgba(44, 126, 255, .16);
  --success: #26d2aa;
  --success-soft: rgba(38, 210, 170, .14);
  --warning: #ffbb66;
  --warning-soft: rgba(255, 187, 102, .14);
  --danger: #ff7c88;
  --danger-soft: rgba(255, 124, 136, .15);
  --info: #53c7fa;
  --shadow-xs: 0 1px 5px rgba(0, 7, 23, .20);
  --shadow-sm: 0 10px 30px rgba(0, 5, 23, .20);
  --shadow-md: 0 16px 45px rgba(0, 5, 23, .36);
  --shadow-lg: 0 25px 65px rgba(0, 5, 23, .60);
}
html[data-theme="dark"] body {
  color: var(--text);
  background:
    radial-gradient(ellipse at 76% -16%, rgba(20, 77, 159, .15), transparent 42rem),
    linear-gradient(145deg, #08142b 0%, #071127 62%, #050e20 100%);
}
html[data-theme="dark"] body::before { opacity: .09; background-image: radial-gradient(#5397fb .6px, transparent .6px); }
html[data-theme="dark"] .glass-panel,
html[data-theme="dark"] .storage-card,
html[data-theme="dark"] .quick-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .table-panel,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .admin-tabs {
  border-color: var(--line);
  background: linear-gradient(150deg, #101f3e, #0a1730);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(134, 176, 242, .035);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
@media (min-width: 1101px) {
  html[data-theme="dark"] { --sidebar-width: 236px; }
  html[data-theme="dark"] .sidebar { inset: 0 auto 0 0; }
  html[data-theme="dark"] .sidebar-inner {
    height: 100vh;
    min-height: 0;
    padding: 19px 12px;
    border-radius: 0;
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
  }
  html[data-theme="dark"] .main-area { margin-left: var(--sidebar-width); padding: 0 18px 28px; }
  html[data-theme="dark"] .topbar {
    top: 0;
    height: 68px;
    margin: 0 -18px;
    padding-inline: 22px;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}
html[data-theme="dark"] .sidebar-inner { background: #091630; }
html[data-theme="dark"] .topbar { background: #091630; }
html[data-theme="dark"] .content-area { padding-top: 24px; }
html[data-theme="dark"] .brand-copy strong { color: var(--text); }
html[data-theme="dark"] .brand-mark:not(.brand-mark-image) {
  background: linear-gradient(140deg, #3182ff, #22c5ea);
  box-shadow: 0 8px 18px rgba(29, 120, 238, .20);
}
html[data-theme="dark"] .primary-nav a { color: #a8bddd; }
html[data-theme="dark"] .primary-nav a:hover { color: var(--text); background: #12284a; }
html[data-theme="dark"] .primary-nav a.active {
  color: #e7f5ff;
  border-color: rgba(42, 135, 250, .19);
  background: linear-gradient(100deg, #17365e, #0e3659);
  box-shadow: inset 3px 0 0 #378bff, 0 5px 14px rgba(0, 4, 16, .15);
}
html[data-theme="dark"] .primary-nav a.active::before { display: none; }
html[data-theme="dark"] .nav-section-label { color: #7895c1; }
html[data-theme="dark"] .mini-usage { border-color: var(--line); background: #0e203f; }
html[data-theme="dark"] .progress-track { background: #1b3155; }
html[data-theme="dark"] .progress-track span,
html[data-theme="dark"] .upload-progress span { background: linear-gradient(90deg, #397cff, #1fc4e9); }
html[data-theme="dark"] .avatar {
  color: #d4e9ff; border-color: #214779;
  background: linear-gradient(145deg, #1a4276, #15305b);
}
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .row-action-icon { color: #9db7df; }
html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .row-action-icon:hover { color: #66b8ff; border-color: var(--line-strong); background: #152b4e; }
html[data-theme="dark"] .theme-switcher { background: #0b1b36; border-color: #20375d; }
html[data-theme="dark"] .theme-option { color: #92afd8; }
html[data-theme="dark"] .theme-option:hover { color: #ddf1ff; background: #14345e; }
html[data-theme="dark"] .theme-option[aria-pressed="true"] {
  color: #e8f5ff; border-color: #285293; background: #193c6f;
  box-shadow: inset 0 1px 0 rgba(113, 182, 255, .15);
}
html[data-theme="dark"] .system-pill { color: #a7d5ef; border-color: var(--line); background: #102344; }
html[data-theme="dark"] .status-dot { box-shadow: 0 0 0 4px rgba(38, 210, 170, .12); }
html[data-theme="dark"] .page-hero {
  border-color: #1c3966;
  background:
    radial-gradient(ellipse at 83% 22%, rgba(43, 100, 202, .21), transparent 47%),
    linear-gradient(115deg, #102243 0%, #0d2348 57%, #091932 100%);
  box-shadow: var(--shadow-sm);
}
html[data-theme="dark"] .page-hero::after { background: linear-gradient(145deg, rgba(44, 126, 255, .12), transparent); }
html[data-theme="dark"] .hero-kicker { color: #68aeff; }
html[data-theme="dark"] .hero-copy h2 { color: #f2f7ff; }
html[data-theme="dark"] .alert { color: var(--text-2); background: #112441; }
html[data-theme="dark"] .btn { color: #c9def9; border-color: #29426c; background: #122745; box-shadow: none; }
html[data-theme="dark"] .btn:hover { color: #fff; border-color: #3774bf; background: #1a3b63; box-shadow: 0 6px 18px rgba(0, 6, 23, .24); }
html[data-theme="dark"] .btn.primary { color: #fff; border-color: #2b9cfc; background: linear-gradient(120deg, #337aff, #20bfe3); box-shadow: 0 7px 20px rgba(27, 115, 241, .22); }
html[data-theme="dark"] .btn.primary:hover { color: #fff; background: linear-gradient(120deg, #4c90ff, #36ceee); }
html[data-theme="dark"] .btn.ghost { background: transparent; }
html[data-theme="dark"] .btn.subtle { background: #122a4b; }
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .input-shell,
html[data-theme="dark"] .unit-input { color: var(--text); border-color: #29426c; background: #0a1933; }
html[data-theme="dark"] .search-box input { color: var(--text); }
html[data-theme="dark"] .breadcrumbs a,
html[data-theme="dark"] .breadcrumbs span.current { color: #b5c8e6; }
html[data-theme="dark"] .breadcrumb-separator { color: #6b86af; }
html[data-theme="dark"] .bulk-bar {
  color: #a5d6ff; border-color: #264c83;
  background: linear-gradient(100deg, #112950, #0b1d39);
}
html[data-theme="dark"] .file-head { color: #9ab7e2; background: #172842; }
html[data-theme="dark"] .file-row:not(.file-head):hover { background: #122747; }
html[data-theme="dark"] .file-row.selected { background: #143456; box-shadow: inset 3px 0 0 #378bff; }
html[data-theme="dark"] .file-title { color: #ecf4ff; }
html[data-theme="dark"] .file-title:hover { color: #70bbff; }
html[data-theme="dark"] .file-icon,
html[data-theme="dark"] .file-icon.folder,
html[data-theme="dark"] .file-icon.image,
html[data-theme="dark"] .file-icon.video,
html[data-theme="dark"] .file-icon.audio,
html[data-theme="dark"] .file-icon.pdf,
html[data-theme="dark"] .file-icon.text,
html[data-theme="dark"] .file-icon.document,
html[data-theme="dark"] .file-icon.spreadsheet,
html[data-theme="dark"] .file-icon.file {
  color: #66aeff; background: #17365a; border-color: #234879;
}
html[data-theme="dark"] .file-icon.folder { color: #ffca81; background: #3a2c30; border-color: #715039; }
html[data-theme="dark"] .file-icon.image { color: #61e6cb; background: #0d3740; }
html[data-theme="dark"] .file-icon.video { color: #ff96be; background: #3d203e; }
html[data-theme="dark"] .file-icon.audio { color: #cbb0ff; background: #2d2854; }
html[data-theme="dark"] .file-icon.pdf { color: #ff9a9b; background: #402338; }
html[data-theme="dark"] .file-icon.spreadsheet { color: #73e9aa; background: #153b35; }
html[data-theme="dark"] .badge.preview { color: #9ccbff; }
html[data-theme="dark"] .badge.success { color: #67e0ba; }
html[data-theme="dark"] .badge.muted { color: #acbfd9; }
html[data-theme="dark"] .badge.warning { color: #ffd096; }
html[data-theme="dark"] .row-actions a,
html[data-theme="dark"] .row-actions button { color: #aec4e5; }
html[data-theme="dark"] .row-actions a:hover,
html[data-theme="dark"] .row-actions button:hover { color: #66bcff; border-color: #244877; background: #142e51; }
html[data-theme="dark"] .empty-icon { color: #8ac5ff; border-color: #294a7e; background: #17345f; }
html[data-theme="dark"] .copy-line button { color: var(--text-2); border-color: var(--line-strong); background: #15284a; }
html[data-theme="dark"] .share-expiry-cell strong { color: var(--text-2); }
html[data-theme="dark"] .modal-card {
  color: var(--text); border-color: #29466f; background: #0d1c38;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(137, 175, 239, .045);
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color: #e9f3ff;
  border-color: #29446d;
  background-color: #0c1b37;
  box-shadow: inset 0 1px 2px rgba(0, 4, 15, .15);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .input-shell:focus-within {
  border-color: #448de3;
  background-color: #11264a;
  box-shadow: 0 0 0 4px rgba(44, 126, 255, .15);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #7794bf; }
html[data-theme="dark"] select {
  background-image: linear-gradient(45deg, transparent 50%, #9bb7d8 50%), linear-gradient(135deg, #9bb7d8 50%, transparent 50%);
}
html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] { accent-color: #388cff; }
html[data-theme="dark"] .divider { color: var(--text); }
html[data-theme="dark"] .drop-zone {
  border-color: #31568a;
  background: linear-gradient(145deg, #0e2544, #101b3a);
}
html[data-theme="dark"] .drop-zone:hover,
html[data-theme="dark"] .drop-zone.dragging { background: #17385b; border-color: var(--primary); }
html[data-theme="dark"] .drop-zone-icon { color: #7abaff; background: #173f6c; }
html[data-theme="dark"] .upload-preview-support { border-color: var(--line); background: #10264a; }
html[data-theme="dark"] .upload-preview-support > span { color: #87baff; }
html[data-theme="dark"] .upload-preview-support b { color: #b8d6ff; background: #1e3b68; }
html[data-theme="dark"] .upload-item { background: #102440; }
html[data-theme="dark"] .upload-item.is-uploading { background: #132c50; }
html[data-theme="dark"] .upload-item.failed { background: #3d2539; }
html[data-theme="dark"] .upload-progress { background: #20385c; }
html[data-theme="dark"] .auth-bg,
html[data-theme="dark"] .share-page {
  background:
    radial-gradient(ellipse at 23% 6%, rgba(41, 121, 222, .17), transparent 38rem),
    radial-gradient(ellipse at 93% 93%, rgba(15, 152, 202, .09), transparent 36rem),
    linear-gradient(145deg, #071227, #08172e);
}
html[data-theme="dark"] .auth-bg::before,
html[data-theme="dark"] .share-page::before { background: none; }
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .share-card { border-color: #234169; background: #0d1d3b; box-shadow: var(--shadow-lg); }
html[data-theme="dark"] .auth-switch a { color: #79bbff; }
html[data-theme="dark"] .preview-box { background: #071327; }
html[data-theme="dark"] .preview-placeholder { background: #122846; }
html[data-theme="dark"] .admin-tabs a:hover { color: var(--text); background: #183356; }
html[data-theme="dark"] .admin-tabs a.active { color: #cce6ff; background: #1b3c68; box-shadow: inset 0 0 0 1px #295184; }
html[data-theme="dark"] .share-tabs a.active .tab-count { color: #bddaff; background: #244a7b; }
html[data-theme="dark"] .stat-card::after { background: rgba(47, 129, 250, .11); }
html[data-theme="dark"] .stat-icon,
html[data-theme="dark"] .activity-icon { color: #7bbcff; }
html[data-theme="dark"] .ranking-value { color: #b1c6e6; }
html[data-theme="dark"] .detail-item { background: #112543; }
html[data-theme="dark"] .branding-setting,
html[data-theme="dark"] .settings-toggle-row,
html[data-theme="dark"] .theme-default-setting {
  border-color: #2b456d;
  background: linear-gradient(135deg, #142949, #101d38);
  box-shadow: none;
}
html[data-theme="dark"] .branding-logo-preview { background: #192f53; box-shadow: inset 0 0 0 1px var(--line); }
html[data-theme="dark"] .branding-file-field input[type="file"] { background: #102442; }
html[data-theme="dark"] .branding-file-field input[type="file"]::file-selector-button { color: #a5d0ff; background: #1b3960; }
html[data-theme="dark"] .switch-track { border-color: #2c476d; background: #385172; }
html[data-theme="dark"] .switch-control input:checked + .switch-track { background: linear-gradient(135deg, #3277f6, #16b9de); border-color: #468eda; }
html[data-theme="dark"] .switch-status-on { color: #8ac2ff; }
html[data-theme="dark"] .unit-suffix { color: var(--muted); background: #142849; }
html[data-theme="dark"] .theme-default-field select { border-color: #2e4f7e; }

@media (max-width: 760px) {
  .theme-switcher { gap: 1px; padding: 3px; }
  .theme-option { padding: 0 8px; min-height: 32px; }
  .theme-option span { display: none; }
  .theme-default-setting { flex-direction: column; align-items: stretch; }
  .theme-default-field { flex: none; width: 100%; }
  .public-theme-control { top: 8px; right: 10px; }
  html[data-theme="dark"] .file-row,
  html[data-theme="dark"] .shares-table .file-row,
  html[data-theme="dark"] .trash-table .file-row,
  html[data-theme="dark"] .admin-users .file-row,
  html[data-theme="dark"] .audit-table .file-row {
    border-color: #23416a;
    background: #10203d;
    box-shadow: var(--shadow-sm);
  }
  html[data-theme="dark"] .file-row:not(.file-head):hover { background: #162c4c; }
  html[data-theme="dark"] .file-row.selected { background: #143255; box-shadow: inset 3px 0 0 #3c8dff, var(--shadow-sm); }
}
@media (max-width: 390px) {
  .theme-option { padding: 0 6px; }
  .topbar-actions { gap: 4px; }
}
