:root {
  color-scheme: light;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b2732;
  background: #f0f1ed;
  --ink: #1b2732;
  --muted: #526170;
  --border: #b6c1c9;
  --blue: #263d55;
  --blue-light: #e6edf1;
  --surface: #fff;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100dvh; }
button, input { font: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 36px;
  padding: .36rem .7rem;
  border: 1px solid #8092a1;
  border-radius: 3px;
  background: #f7f9fa;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.25;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--blue-light); border-color: #597085; }
button:active, .button:active { background: #d9e3e9; }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #0c69b4; outline-offset: 2px; }
a { color: #174e7c; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.error { color: #9a2020 !important; }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--blue); color: #fff; border-bottom: 2px solid #14283c; }
.topbar-inner { max-width: 1180px; margin: auto; min-height: 56px; padding: .55rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.app-title { font-size: 1.13rem; letter-spacing: .01em; }
.account-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; min-width: 0; }
#username { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e3ebef; margin-right: .2rem; }
.topbar button { background: #f7f9fa; }
.workspace { width: min(100%, 1180px); margin: 0 auto; padding: 1rem 1rem 2rem; }
.location-bar { display: flex; align-items: center; gap: .45rem; min-width: 0; min-height: 38px; }
#up-button { flex: none; }
#breadcrumbs { display: flex; align-items: center; gap: .2rem; overflow-x: auto; white-space: nowrap; min-width: 0; scrollbar-width: thin; }
#breadcrumbs button { border: 0; background: none; color: #174e7c; padding: .35rem .25rem; text-decoration: underline; text-underline-offset: 2px; }
#breadcrumbs button:hover { background: var(--blue-light); }
#breadcrumbs span { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .45rem; padding: .8rem 0; }
#status, #admin-status { min-height: 1.4em; margin: 0 0 .6rem; color: var(--muted); }
.file-panel, .admin-table-wrap { background: var(--surface); border: 1px solid var(--border); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--blue-light); color: #25394b; font-weight: 600; text-align: left; }
th, td { padding: .62rem .7rem; border-bottom: 1px solid #d8e0e5; vertical-align: middle; }
tbody tr:nth-child(even) { background: #f8fafb; }
tbody tr:last-child td { border-bottom: 0; }
.file-row { cursor: pointer; }
.file-row:hover { background: #edf3f6; }
.file-row:focus-visible { outline: 2px solid #0c69b4; outline-offset: -2px; }
.file-table th:nth-child(2), .file-table th:nth-child(3), .file-table td:nth-child(2), .file-table td:nth-child(3) { width: 120px; white-space: nowrap; color: var(--muted); }
.file-table th:last-child, .file-table td:last-child { text-align: right; width: 325px; }
.file-name { color: #174e7c; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 2px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .35rem; }
.row-actions button, .row-actions .button { min-height: 32px; padding: .27rem .5rem; }

.login { width: min(100% - 2rem, 390px); margin: max(7vh, 2rem) auto; padding: 1.25rem; border: 1px solid var(--border); background: var(--surface); }
.login h1 { margin: 0 0 1rem; font-size: 1.3rem; padding-bottom: .65rem; border-bottom: 1px solid var(--border); }
form label { display: block; margin: .7rem 0; font-weight: 500; }
form input { display: block; width: 100%; min-height: 42px; margin-top: .3rem; padding: .45rem .55rem; border: 1px solid #8b9ca9; border-radius: 3px; background: #fff; color: var(--ink); }
.login form button { width: 100%; margin-top: .4rem; }

dialog { width: min(94vw, 960px); max-height: min(92dvh, 900px); padding: 0; border: 1px solid #8295a4; border-radius: 4px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 35px #12233533; }
dialog::backdrop { background: #15253699; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .9rem; background: var(--blue-light); border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#preview-body { min-height: 100px; max-height: calc(92dvh - 135px); overflow: auto; padding: .7rem .9rem; }
#preview-body iframe { display: block; width: 100%; height: min(65dvh, 700px); border: 1px solid var(--border); }
#preview-body img, #preview-body video { display: block; max-width: 100%; max-height: 65dvh; margin: auto; }
#preview-body audio { width: min(100%, 480px); }
#preview-body pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.5 ui-monospace, monospace; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .45rem; padding: .7rem .9rem; border-top: 1px solid var(--border); }
#admin-dialog { width: min(94vw, 1020px); }
#add-user-form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; padding: .65rem .9rem .85rem; }
#add-user-form label { flex: 1 1 180px; margin: 0; }
#admin-status { padding: 0 .9rem; }
.admin-table th:last-child { width: 430px; }
.admin-table td:last-child { text-align: right; }
.admin-table .row-actions { justify-content: flex-end; }
#action-dialog { width: min(94vw, 430px); }
#action-form h2 { margin: 0; padding: .8rem .9rem; background: var(--blue-light); border-bottom: 1px solid var(--border); font-size: 1.1rem; }
#action-label { margin: .9rem; }
#action-form .dialog-actions { margin-top: 1rem; }

@media (max-width: 700px) {
  button, .button { min-height: 44px; }
  .topbar-inner { min-height: 54px; padding: .45rem .75rem; gap: .4rem; }
  .app-title { font-size: 1rem; }
  #username { display: none; }
  .account-actions { gap: .3rem; }
  .topbar button { padding: .35rem .55rem; }
  .workspace { padding: .7rem .65rem calc(86px + env(safe-area-inset-bottom)); }
  .location-bar { margin-bottom: .5rem; }
  .toolbar { position: fixed; z-index: 9; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .55rem .65rem calc(.55rem + env(safe-area-inset-bottom)); margin: 0; border-top: 1px solid var(--border); background: #edf1f3; box-shadow: 0 -3px 12px #1b273214; }
  .toolbar button, .toolbar .button { width: 100%; }
  .file-panel { border: 0; background: transparent; overflow: visible; }
  .file-table, .file-table tbody { display: block; }
  .file-table thead { display: none; }
  .file-table tr { display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; margin-bottom: .5rem; padding: .55rem .65rem; border: 1px solid var(--border); background: var(--surface) !important; }
  .file-table td { display: block; width: auto !important; padding: 0; border: 0; }
  .file-table td:first-child { grid-column: 1 / -1; min-width: 0; }
  .file-table td:nth-child(2), .file-table td:nth-child(3) { font-size: .82rem; }
  .file-table td:nth-child(3) { text-align: right; }
  .file-table td:last-child { grid-column: 1 / -1; margin-top: .45rem; padding-top: .48rem; border-top: 1px solid #dce3e7; }
  .file-name { display: block; padding: .35rem 0; font-weight: 600; }
  .file-table tr.file-row:hover { background: #edf3f6 !important; }
  .row-actions { justify-content: flex-start; }
  .row-actions button, .row-actions .button { min-height: 40px; }
  dialog { width: 100vw !important; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .dialog-head { padding: calc(.7rem + env(safe-area-inset-top)) .75rem .7rem; }
  #preview-dialog { display: flex; flex-direction: column; }
  #preview-dialog:not([open]) { display: none; }
  #preview-body { flex: 1; max-height: none; min-height: 0; padding: .7rem; }
  #preview-body iframe { height: calc(100dvh - 175px - env(safe-area-inset-bottom)); }
  .dialog-actions { padding: .65rem .75rem calc(.65rem + env(safe-area-inset-bottom)); }
  #admin-dialog { overflow-y: auto; }
  #add-user-form { display: block; }
  #add-user-form label { margin: .7rem 0; }
  #add-user-form button { width: 100%; }
  .admin-table-wrap { border: 0; overflow: visible; padding: 0 .65rem 1rem; }
  .admin-table, .admin-table tbody { display: block; }
  .admin-table thead { display: none; }
  .admin-table tr { display: block; margin-bottom: .5rem; padding: .6rem; border: 1px solid var(--border); }
  .admin-table td { display: block; padding: .15rem 0; border: 0; text-align: left !important; }
  .admin-table td:first-child { font-weight: 600; }
  .admin-table td:nth-child(2) { color: var(--muted); }
  .admin-table .row-actions { justify-content: flex-start; margin-top: .45rem; }
  #action-dialog { width: min(100vw - 1rem, 430px) !important; max-width: min(100vw - 1rem, 430px); height: auto !important; max-height: 90dvh; top: 50%; bottom: auto; transform: translateY(-50%); margin: auto; border: 1px solid var(--border); border-radius: 4px; }
}
