:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
  font-synthesis: none;
  --background: #f5f5f4;
  --surface: #ffffff;
  --surface-secondary: #fafaf9;
  --surface-hover: #f3f3f1;
  --surface-selected: #fff2e7;
  --border: #e5e5e2;
  --text: #171717;
  --text-muted: #6b6b69;
  --accent: #f4770b;
  --accent-hover: #ff8b31;
  --accent-text: #ad4700;
  --accent-contrast: #171717;
  --danger: #b83232;
  --danger-contrast: #ffffff;
  --danger-soft: #fff0ee;
  --success: #32805c;
  --radius: 8px;
  --shadow: 0 12px 32px #20202016;
  background: var(--background);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --background: #171819;
    --surface: #202123;
    --surface-secondary: #252729;
    --surface-hover: #2c2e30;
    --surface-selected: #412b1c;
    --border: #37393a;
    --text: #f3f3f1;
    --text-muted: #aaaead;
    --accent: #ff821b;
    --accent-hover: #ff9b47;
    --accent-text: #ff9b47;
    --accent-contrast: #161616;
    --danger: #f18a83;
    --danger-contrast: #171819;
    --danger-soft: #442a2a;
    --success: #81c9a4;
    --shadow: 0 14px 36px #0006;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #171819;
  --surface: #202123;
  --surface-secondary: #252729;
  --surface-hover: #2c2e30;
  --surface-selected: #412b1c;
  --border: #37393a;
  --text: #f3f3f1;
  --text-muted: #aaaead;
  --accent: #ff821b;
  --accent-hover: #ff9b47;
  --accent-text: #ff9b47;
  --accent-contrast: #161616;
  --danger: #f18a83;
  --danger-contrast: #171819;
  --danger-soft: #442a2a;
  --success: #81c9a4;
  --shadow: 0 14px 36px #0006;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; padding: 21px 13px 18px; border-right: 1px solid var(--border); background: var(--surface-secondary); }
.sidebar-header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 11px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 650; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; overflow: hidden; flex: none; }
.brand-mark img { display: block; width: 180%; max-width: none; height: auto; }
.brand-mark.small { width: 36px; height: 36px; }
.side-nav { margin-top: 34px; }
.side-link { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-muted); text-align: left; font-weight: 550; transition: background 150ms, color 150ms; }
.side-link:hover { background: var(--surface-hover); color: var(--text); }
.side-link.active { background: var(--surface-selected); color: var(--accent-text); }
.side-link.active::before { content: ""; width: 3px; height: 18px; margin-left: -12px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-link.active svg { margin-left: -3px; }
.sidebar-bottom { margin-top: auto; }
.storage-card { padding: 15px 12px 23px; }
.storage-title { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-size: 12px; font-weight: 650; }
.storage-title span:last-child { color: var(--text-muted); font-weight: 500; }
.progress-track { height: 5px; overflow: hidden; border-radius: 3px; background: var(--border); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 180ms; }
.storage-caption { margin-top: 9px; color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.workspace { min-width: 0; }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 72px; display: grid; grid-template-columns: minmax(150px, 1fr) minmax(190px, 360px) auto; align-items: center; gap: 20px; padding: 12px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 3px; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.breadcrumbs button { max-width: 230px; min-height: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font-weight: 550; }
.breadcrumbs button:hover { background: var(--surface-hover); color: var(--text); }
.breadcrumbs button:last-child { color: var(--text); }
.breadcrumbs .separator { padding: 0 1px; color: var(--text-muted); }
.breadcrumbs .current { padding: 0 6px; color: var(--text); font-weight: 550; }
.search-wrap { min-width: 0; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-secondary); color: var(--text-muted); transition: border-color 150ms, background 150ms; }
.search-wrap:focus-within { border-color: var(--accent); background: var(--surface); }
.search-wrap svg { width: 17px; height: 17px; }
.search-wrap input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-wrap input::placeholder { color: var(--text-muted); }
.search-wrap input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1; }
.search-clear:hover { background: var(--surface-hover); color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 13px; border: 1px solid transparent; border-radius: var(--radius); white-space: nowrap; font-size: 13px; font-weight: 600; text-decoration: none; transition: background 150ms, border-color 150ms, color 150ms; }
.button svg { width: 17px; height: 17px; }
.button.primary { background: var(--accent); color: var(--accent-contrast); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button.secondary:hover { background: var(--surface-hover); }
.button.danger { background: var(--danger); color: var(--danger-contrast); }
.button.danger:hover { filter: brightness(.9); }
.upload-button { cursor: pointer; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-muted); font-size: 23px; line-height: 1; }
.icon-button:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-open, .sidebar-close { display: none; }

.main-content { max-width: 1600px; margin: 0 auto; padding: 31px 30px 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; font-size: 26px; font-weight: 630; letter-spacing: -.025em; line-height: 1.2; }
.page-heading p { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }
.mobile-storage { display: none; color: var(--text-muted); font-size: 12px; text-align: right; }
.file-toolbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.file-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-select { min-height: 35px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-muted); font-size: 12px; }
.filter-select select { max-width: 165px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.view-switch { display: flex; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.view-switch button { width: 34px; height: 29px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1; }
.view-switch button[aria-pressed="true"] { background: var(--surface-selected); color: var(--accent-text); }
.notice { margin-bottom: 14px; padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.notice.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.file-panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.file-head, .file-row { display: grid; grid-template-columns: minmax(0, 1fr) 105px 145px 46px; align-items: center; gap: 12px; }
.file-head { min-height: 38px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--surface-secondary); color: var(--text-muted); font-size: 12px; }
.file-row { position: relative; min-height: 48px; padding: 0 12px; border-bottom: 1px solid var(--border); transition: background 130ms; }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--surface-hover); }
.file-row:focus-within { background: var(--surface-selected); box-shadow: inset 3px 0 var(--accent); }
.file-name { min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; font-weight: 500; }
.file-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { width: 25px; height: 25px; flex: none; display: grid; place-items: center; color: var(--text-muted); }
.file-icon.folder { color: var(--accent-text); }
.file-icon svg { width: 21px; height: 21px; }
.file-meta { min-width: 0; color: var(--text-muted); font-size: 12px; }
.file-meta.mobile-meta { display: none; }
.row-menu { position: relative; justify-self: end; }
.row-menu summary { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 6px; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { background: var(--surface-selected); color: var(--accent-text); }
.row-menu-items { position: absolute; z-index: 20; top: 39px; right: 0; width: 172px; padding: 5px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.row-menu-items button { width: 100%; min-height: 35px; display: block; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text); text-align: left; font-size: 13px; }
.row-menu-items button:hover { background: var(--surface-hover); }
.row-menu-items .menu-separator { height: 1px; margin: 4px 0; background: var(--border); }
.row-menu-items button.danger { color: var(--danger); }
.empty { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px 20px; color: var(--text-muted); text-align: center; }
.empty svg { width: 28px; height: 28px; margin-bottom: 5px; color: var(--text-muted); }
.empty strong { color: var(--text); font-size: 15px; font-weight: 600; }
.empty .button { margin-top: 10px; }

.file-list.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 11px; padding: 12px; }
.file-list.grid-view .file-row { min-height: 154px; display: grid; grid-template-columns: minmax(0, 1fr) 38px; grid-template-rows: 1fr auto; gap: 3px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.file-list.grid-view .file-row:hover { background: var(--surface-hover); }
.file-list.grid-view .file-row:focus-within { background: var(--surface-selected); }
.file-list.grid-view .file-name { grid-column: 1 / -1; grid-row: 1; align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 9px; min-height: 0; }
.file-list.grid-view .file-name-text { max-width: 100%; }
.file-list.grid-view .file-icon { width: 38px; height: 38px; }
.file-list.grid-view .file-icon svg { width: 31px; height: 31px; }
.file-list.grid-view .file-meta:not(.mobile-meta) { display: none; }
.file-list.grid-view .mobile-meta { grid-column: 1; grid-row: 2; display: block; align-self: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list.grid-view .row-menu { grid-column: 2; grid-row: 2; }
.file-list.grid-view .empty { grid-column: 1 / -1; }

.upload-panel { margin-bottom: 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.upload-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.upload-panel-head strong { font-size: 14px; font-weight: 600; }
.upload-summary { margin: 7px 0 10px; color: var(--text-muted); font-size: 12px; }
.upload-overall-progress { height: 7px; margin-bottom: 11px; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.upload-item:first-child { border-top: 0; }
.upload-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.upload-status { color: var(--text-muted); font-size: 12px; text-align: right; }
.upload-status.success { color: var(--success); }
.upload-status.error { color: var(--danger); }
.upload-item .progress-track { grid-column: 1 / 3; grid-row: 2; }
.upload-item .upload-control { grid-column: 3; grid-row: 1 / 3; min-width: 65px; padding: 5px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 12px; }
.upload-item .upload-control:hover { background: var(--surface-hover); color: var(--text); }
.upload-more { padding: 10px 0 2px; color: var(--text-muted); font-size: 12px; }
.drop-overlay { position: fixed; z-index: 40; inset: 12px; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 10px; background: var(--surface); }
.drop-overlay > div { display: grid; gap: 8px; text-align: center; }
.drop-overlay strong { font-size: 18px; }
.drop-overlay span { color: var(--text-muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-theme { position: absolute; top: 20px; right: 24px; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; }
.login-card { width: min(100%, 380px); padding: 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.login-mark { width: 52px; height: 52px; }
.login-card h1 { margin: 18px 0 3px; font-size: 27px; font-weight: 650; letter-spacing: -.025em; }
.login-card p { margin: 0 0 27px; color: var(--text-muted); font-size: 13px; }
.login-card label, .action-dialog label, .token-form label { display: block; margin: 15px 0 7px; font-size: 13px; font-weight: 600; }
.login-card input, .action-dialog input, .token-form input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--border); border-radius: var(--radius); outline: 0; background: var(--surface); color: var(--text); }
.login-card input:focus, .action-dialog input:focus, .token-form input:focus { border-color: var(--accent); }
.wide { width: 100%; margin-top: 22px; }
.error { min-height: 16px; margin-top: 10px; color: var(--danger); font-size: 12px; }
.theme-select { min-height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.modal { width: min(92vw, 500px); max-height: min(90vh, 750px); padding: 24px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: #0f1111a6; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 630; }
.dialog-description { margin: 12px 0 18px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.eyebrow { margin-bottom: 6px; color: var(--text-muted); font-size: 10px; font-weight: 700; letter-spacing: .11em; }
.dav-address { display: grid; gap: 5px; padding: 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text-muted); font-size: 12px; }
.dav-address code, .new-token code { overflow-wrap: anywhere; color: var(--text); }
.token-form { margin: 20px 0; }
.token-form > div { display: flex; gap: 8px; }
.token-form input { flex: 1; min-width: 0; }
.new-token { display: grid; gap: 11px; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-secondary); font-size: 12px; }
.new-token .button { justify-self: start; }
.token-section-title { margin-top: 20px; font-size: 13px; font-weight: 600; }
.token-list { margin-top: 7px; border-top: 1px solid var(--border); }
.token-item { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.token-item button { min-height: 34px; padding: 0 7px; border: 0; border-radius: 5px; background: transparent; color: var(--danger); }
.token-item button:hover { background: var(--danger-soft); }
.settings-footer { margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--border); }
.settings-footer label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.sidebar-backdrop { display: none; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: minmax(110px, 1fr) minmax(160px, 280px) auto; gap: 12px; padding: 12px 20px; }
  .main-content { padding-inline: 22px; }
}
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 51; inset: 0 auto 0 0; width: 242px; max-width: calc(100vw - 48px); transform: translateX(-100%); transition: transform 180ms; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop:not([hidden]) { position: fixed; z-index: 50; inset: 0; display: block; background: #0f11118a; }
  .sidebar-open, .sidebar-close { display: grid; }
  .topbar { grid-template-columns: 38px minmax(130px, 1fr) minmax(160px, 300px) auto; }
}
@media (max-width: 700px) {
  .topbar { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 7px; padding: 9px 14px; }
  .breadcrumbs { grid-column: 2; grid-row: 1; }
  .top-actions { grid-column: 3; grid-row: 1; }
  .top-actions .button { width: 38px; min-width: 38px; padding: 0; }
  .top-actions .button span { display: none; }
  .search-wrap { grid-column: 1 / -1; grid-row: 2; margin-top: 3px; }
  .main-content { padding: 23px 16px 50px; }
  .page-heading { align-items: start; margin-bottom: 18px; }
  .page-heading h1 { font-size: 23px; }
  .mobile-storage { display: block; }
  .file-head { display: none; }
  .file-row { grid-template-columns: minmax(0, 1fr) 42px; grid-template-rows: auto auto; gap: 0 5px; min-height: 63px; padding: 6px 8px; }
  .file-name { grid-column: 1; grid-row: 1; min-height: 30px; }
  .file-meta:not(.mobile-meta) { display: none; }
  .file-meta.mobile-meta { grid-column: 1; grid-row: 2; display: block; padding-left: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row-menu { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .row-menu summary { width: 42px; height: 44px; }
  .file-list.grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-list.grid-view .file-row { min-height: 144px; }
  .file-list.grid-view .mobile-meta { padding-left: 0; }
}
@media (max-width: 420px) {
  .page-heading { display: block; }
  .mobile-storage { margin-top: 8px; text-align: left; }
  .file-toolbar { align-items: stretch; }
  .file-filters { gap: 5px; }
  .filter-select { gap: 4px; padding: 0 6px; }
  .filter-select select { max-width: 93px; }
  .view-switch button { width: 29px; }
  .upload-item { grid-template-columns: minmax(0, 1fr) 65px; gap: 5px; }
  .upload-item .upload-status { grid-column: 1; grid-row: 2; text-align: left; }
  .upload-item .progress-track { grid-column: 1 / -1; grid-row: 3; }
  .upload-item .upload-control { grid-column: 2; grid-row: 1 / 3; }
  .modal { padding: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
