:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #66727e;
  --line: #d9e0e6;
  --surface: #ffffff;
  --wash: #f3f6f8;
  --accent: #1769aa;
  --accent-dark: #0d4d80;
  --selected: #e4f0fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--wash); }
button, input { font: inherit; }
button, .button { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; padding: .45rem .75rem; font-size: .88rem; text-decoration: none; }
button:hover, .button:hover { border-color: var(--accent); }
button:focus-visible, .button:focus-visible, input:focus-visible { outline: 3px solid #76b7e8; outline-offset: 1px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { color: white; background: var(--accent); border-color: var(--accent); }
.primary:hover { background: var(--accent-dark); color: white; }
.muted { color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: #eef2f5; }
.login-panel { width: min(100%, 29rem); padding: 2.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 45px #102a4320; }
.login-panel h1 { margin-bottom: .75rem; font-size: 1.55rem; }
.login-panel .message { margin-bottom: 1rem; }
.product-name { margin-bottom: 1.75rem; color: var(--accent-dark); font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }

.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; background: #102a43; color: white; }
.brand { display: flex; align-items: baseline; gap: .8rem; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.25rem; }
.topbar .muted { color: #c7d5e2; }
.auth-controls { display: flex; align-items: center; gap: .65rem; }
.auth-controls #logout-button { color: white; border-color: #8296a8; background: transparent; }
.refresh-spinner { width: 1.6rem; height: 1.6rem; animation: refresh-spin 2.0s linear infinite; filter: brightness(0) invert(1); }
@keyframes refresh-spin { to { transform: rotate(360deg); } }

main { --sidebar-width: 280px; --inspector-width: 320px; height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(220px, var(--sidebar-width)) 8px minmax(360px, 1fr) 8px minmax(320px, var(--inspector-width)); }
.sidebar { padding: 1.1rem .75rem; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.sidebar h2 { margin: 0 .5rem .75rem; font-size: .78rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.tree .directory-name { width: 100%; border: 0; background: transparent; text-align: left; padding: .2rem .5rem; overflow: hidden; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.tree .directory-name:hover, .tree .directory-name.selected { background: var(--selected); }
.tree ul { list-style: none; padding-left: 1rem; margin: .1rem 0; }
.tree > ul { padding-left: 1rem; }
.tree li { position: relative; }
.tree .directory-row, .root-row { display: grid; grid-template-columns: 1.45rem minmax(0, 1fr); align-items: center; font-size: .88rem; }
.tree .disclosure, .root-row .disclosure { width: 2.4rem; padding: 0.3rem 0 0 0; border: 0; background: transparent; color: var(--muted); }
.tree .disclosure-icon, .root-row .disclosure-icon { width: 1.0rem; height: 1.0rem; }
.resize-handle { position: relative; z-index: 3; cursor: col-resize; touch-action: none; }
.resize-handle::after { position: absolute; inset: 0 3px; content: ""; background: var(--line); }
.resize-handle:hover, .resize-handle:focus-visible { background: var(--selected); outline: none; }
body.resizing-panels { cursor: col-resize; user-select: none; }
.inspector { min-width: 0; border-left: 1px solid var(--line); background: var(--surface); overflow: auto; }
.inspector-toolbar { position: sticky; top: 0; z-index: 2; min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: .55rem .75rem .55rem 1rem; border-bottom: 1px solid var(--line); background: #ffffffeb; backdrop-filter: blur(8px); }
.inspector-toolbar h2 { margin: 0; font-size: .78rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

.inspector-toggle { width: 2rem; height: 2rem; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; }
.inspector-content { padding: 1rem; }
.inspector-empty { padding: 4rem 1rem; text-align: center; font-size: 0.88rem; }
.inspector-empty h2 { margin-bottom: .5rem; font-size: 0.88rem; }
.inspector-loading { min-height: 12rem; display: grid; place-items: center; }
.detail-spinner { width: 1.6rem; height: 1.6rem; animation: refresh-spin 2s linear infinite; opacity: .65; }
main.inspector-collapsed { grid-template-columns: minmax(220px, var(--sidebar-width)) 8px minmax(360px, 1fr) 8px 44px; }
.inspector-collapsed .inspector-content, .inspector-collapsed .inspector-toolbar h2 { display: none; }
.inspector-collapsed .inspector-toolbar { justify-content: center; padding-inline: 0; }

.browser { min-width: 0; overflow: auto; background: var(--wash); }
.browser-toolbar { position: sticky; top: 0; z-index: 2; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); background: #ffffffeb; backdrop-filter: blur(8px); }
.breadcrumbs { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.breadcrumbs button { flex: 0 1 auto; min-width: 0; padding: .3rem .0rem; border: 0; background: transparent; font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs button:not(:last-child)::after { content: "/"; margin: 0 0.2rem 0 0.2rem; color: #9aa6b2; font-size: .88rem; }
.message { margin: 0rem; padding: .75rem 1rem; border: 1px solid #e4b64d; border-radius: 6px; background: #fff8df; }
.message.error { border-color: #d66; background: #fff0f0; color: #8d2020; }
.file-list-panel { margin: 0.rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.file-list-table { --file-name-width: 48.75%; --file-size-width: 18%; --file-modified-width: 28%; --file-actions-width: 5.25%; width: 100%; border-collapse: collapse; table-layout: fixed; }
.file-list-table col.file-column-name { width: var(--file-name-width); }
.file-list-table col.file-column-size { width: var(--file-size-width); }
.file-list-table col.file-column-modified { width: var(--file-modified-width); }
.file-list-table col.file-column-actions { width: var(--file-actions-width); }
.file-list-table th { position: relative; padding: .55rem .8rem; border-bottom: 1px solid var(--line); background: #f7f9fb; color: var(--muted); font-size: .88rem; font-weight: 600; text-align: left; }
.file-column-resize-handle { position: absolute; top: 0; right: 0; width: 7px; height: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: col-resize; }
.file-column-resize-handle::after { position: absolute; top: 20%; right: 3px; bottom: 20%; width: 1px; content: ""; background: var(--line); }
.file-column-resize-handle:hover, .file-column-resize-handle:focus-visible { background: var(--selected); outline: none; }
.file-column-resize-handle:hover::after, .file-column-resize-handle:focus-visible::after { background: var(--accent); }
.file-list-table th:nth-child(2), .file-list-table td:nth-child(2) {
  text-align: right;
}
.file-list-table th:last-child, .file-list-table td:last-child { padding-inline: .35rem; text-align: center; }
.file-list-table td { height: 1.2rem; padding: .15rem .8rem; border-bottom: 1px solid #edf0f2; color: var(--muted); font-size: .88rem; }
.file-list-table tr:last-child td { border-bottom: 0; }
.file-list-table tbody tr:hover, .file-list-table tbody tr.selected { background: var(--selected); }
.entry-button { width: 100%; border: 0; background: transparent; padding: .25rem 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-button::before { content: ""; display: inline-block; width: .85rem; height: 0.9rem; margin: 0 0.3rem 0 0; border: 1px solid white; border-radius: 2px; background: white; vertical-align: -3px; }
/* .entry-button.directory-entry::before { height: .65rem; margin: 0 0.3rem 0.2rem 0;border: 0; background: #75a9d2; } */
.entry-button.directory-entry::before { height: 0.9rem; border: 0; -webkit-mask-image: url('icons/folder-solid-full.svg');
  mask-image: url('icons/folder-solid-full.svg');
  mask-size: contain;
  mask-repeat: no-repeat;
  color: #75a9d2;
  background-color: currentColor;
}
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .1rem; }
.row-link-button, .row-copy-button, .row-download-button, .row-delete-button { width: 2rem; height: 1.2rem; display: grid; place-items: center; padding: 0; border: 0; background: transparent; line-height: 1; }
.row-actions img { display: block; width: 1rem; height: 1rem; opacity: .72; }
.row-link-button:hover, .row-copy-button:hover, .row-download-button:hover { border: 0; background: #d7e9f7; }
.row-delete-button:hover { border: 0; background: #f7dddd; }
.row-link-button:hover img, .row-copy-button:hover img, .row-download-button:hover img, .row-delete-button:hover img { opacity: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.empty-folder { padding: 4rem 1rem; color: var(--muted); text-align: center; }

.detail { min-width: 0; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .35rem; font-size: 0.88rem; }
.detail h3 { font-size: 0.88rem; }
.detail-heading h2 { margin-bottom: 0; font-size: 0.88rem; overflow-wrap: anywhere; }
.detail-heading .button { flex: none; }
.eyebrow { margin-bottom: .2rem; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.metadata { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; margin: 1.25rem 0; }
.metadata dl { margin: 0; padding: .35rem; border: 1px solid var(--line); border-radius: 5px; background: var(--wash); }
.metadata dt { color: var(--muted); font-size: .67rem; }
.metadata dd { display: flex; align-items: flex-start; gap: .5rem; margin: .25rem 0 0; font-size: .88rem; }

.metadata-value { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.copy-metadata-button { flex: none; width: 1.5rem; height: 1.5rem; display: grid; place-items: center; padding: .15rem; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.copy-metadata-button img { display: block; width: .9rem; height: .9rem; opacity: .68; }
.copy-metadata-button:hover { border: 0; background: #d7e9f7; }
.copy-metadata-button[data-copied="true"] img { opacity: 1; }
.viewer-section { margin: 1.5rem 0; }
.viewer { min-height: 5rem; padding: .75rem; border: 1px solid var(--line); border-radius: 5px; background: var(--wash); overflow: auto; }
.viewer img, .viewer video, .viewer audio { display: block; max-width: 100%; max-height: 45vh; margin: auto; }
.viewer iframe { width: 100%; min-height: 45vh; border: 0; }
.viewer pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.history { overflow-x: auto; }
.history table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.history th, .history td { padding: .5rem; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.history th { background: #e9eef2; font-size: .75rem; }

.upload-dialog { width: min(calc(100% - 2rem), 34rem); padding: 0; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px #102a4340; }
.upload-dialog::backdrop { background: #102a4370; backdrop-filter: blur(2px); }
.upload-dialog form { padding: 1.4rem; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin-bottom: 1rem; }
.icon-button { border: 0; padding: .1rem .4rem; background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; }
.upload-dialog label { display: block; margin: .85rem 0; font-size: .85rem; font-weight: 600; }
.upload-dialog input { display: block; width: 100%; margin-top: .3rem; padding: .55rem; border: 1px solid var(--line); border-radius: 5px; }
.upload-dialog progress { display: block; width: 100%; margin-top: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.upload-destination { font-size: 0.85rem; }
.upload-destination-path {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

@media (max-width: 1000px) {
  .resize-handle { display: none; }
  main, main.inspector-collapsed { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); }
  .inspector { position: fixed; z-index: 4; top: 68px; right: 0; bottom: 0; width: min(380px, calc(100vw - 180px)); box-shadow: -8px 0 24px #102a4324; }
  .inspector-collapsed .inspector { width: 44px; }
}


@media (max-width: 700px) {
  .brand .muted, #identity { display: none; }
  .topbar { padding: .7rem; }
  main, main.inspector-collapsed { grid-template-columns: 150px minmax(0, 1fr); }
  .sidebar { padding-inline: .35rem; }
  .inspector { width: min(380px, calc(100vw - 150px)); }
  .file-list-panel { margin: .65rem; }
  .file-list-table th:nth-child(2), .file-list-table td:nth-child(2) { display: none; }
  .file-list-table th:first-child { width: auto; }
}

@media (max-width: 480px) {
  .brand h1 { font-size: 1rem; }
  .auth-controls { gap: .35rem; }
  .auth-controls button { padding-inline: .5rem; }
  main, main.inspector-collapsed { grid-template-columns: 115px minmax(0, 1fr); }
  .inspector { width: min(380px, calc(100vw - 115px)); }
  .file-list-table th:nth-child(3), .file-list-table td:nth-child(3) { display: none; }
  .file-list-table th:first-child { width: auto; }
}
