/* ============================================================
   Kiste - application stylesheet (app.css)
   Server rendered HTML only: no inline styles, no inline scripts.
   Light palette by default, dark via [data-theme="dark"] or
   prefers-color-scheme. All sizing uses rem and is mobile first.
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceef1;
  --text: #1c2230;
  --text-dim: #5b6472;
  --text-faint: #8a93a2;
  --line: #d8dce2;
  --line-strong: #b9c0ca;
  --accent: #2f6df6;
  --accent-strong: #2458cc;
  --accent-contrast: #ffffff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --fail: #d64545;
  --shadow: 0 1px 2px rgba(20, 24, 33, .08), 0 4px 16px rgba(20, 24, 33, .06);
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #14171d;
  --bg-elevated: #1d2129;
  --bg-sunken: #10131a;
  --text: #e8ebf1;
  --text-dim: #a7afbd;
  --text-faint: #6f7885;
  --line: #2b313c;
  --line-strong: #3a414e;
  --accent: #5b8bff;
  --accent-strong: #7aa2ff;
  --accent-contrast: #10131a;
  --ok: #3fbf78;
  --warn: #e0a94a;
  --fail: #ef6a6a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171d; --bg-elevated: #1d2129; --bg-sunken: #10131a;
    --text: #e8ebf1; --text-dim: #a7afbd; --text-faint: #6f7885;
    --line: #2b313c; --line-strong: #3a414e; --accent: #5b8bff;
    --accent-strong: #7aa2ff; --accent-contrast: #10131a;
    --ok: #3fbf78; --warn: #e0a94a; --fail: #ef6a6a;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-contrast);
  padding: .5rem .9rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .9rem;
  padding: .55rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; }
.brand-name { font-size: 1.05rem; letter-spacing: .2px; }

.mainnav { display: flex; gap: .15rem; margin-right: auto; }
.mainnav a {
  color: var(--text-dim); padding: .4rem .7rem;
  border-radius: var(--radius-sm); font-weight: 550;
}
.mainnav a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--bg-sunken); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.topbar-right { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

.lang { display: flex; align-items: center; gap: .25rem; font-size: .8rem; font-weight: 600; }
.lang a { color: var(--text-dim); padding: .15rem .3rem; border-radius: 4px; }
.lang a.active { color: var(--accent); }
.lang-sep { color: var(--text-faint); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-sunken); color: var(--text-dim);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

.userbox { display: flex; align-items: center; gap: .4rem; margin-left: .3rem; }
.userbox-name { font-weight: 600; font-size: .9rem; }

/* ---------- donut ---------- */
.donut { position: relative; display: inline-grid; place-items: center; cursor: default; }
.donut svg { display: block; }
.donut-track { fill: none; stroke: var(--line); stroke-width: 3.4; }
.donut-fill {
  fill: none; stroke: var(--accent); stroke-width: 3.4; stroke-linecap: round;
  stroke-dasharray: 0 100; transition: stroke-dasharray .9s ease, stroke .3s ease;
  transform: rotate(-90deg); transform-origin: center;
}
.donut.is-critical .donut-fill { stroke: var(--fail); }
.donut-text {
  fill: var(--text-dim); font-size: 6px; font-weight: 700; font-family: var(--mono);
}

/* ---------- main / layout ---------- */
.main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.1rem 1rem 2.5rem; }
main.main { display: block; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--text-faint);
  background: var(--bg-elevated);
}
.footer-hint { color: var(--text-faint); }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.panel + .panel { margin-top: 1rem; }
.panel.narrow { max-width: 560px; }

.hint { color: var(--text-dim); font-size: .86rem; }
.code-cell { font-family: var(--mono); font-size: .86rem; overflow-wrap: anywhere; }

/* ---------- buttons ---------- */
.button {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-weight: 550; color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .42rem .8rem; cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.button:hover { background: var(--bg); border-color: var(--line-strong); color: var(--text); text-decoration: none; }
.button:focus-visible, .input:focus-visible, .search-input:focus-visible, .two-factor-input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-contrast); }
.button-danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.button-danger:hover { background: var(--fail); filter: brightness(.94); }
.button-quiet { background: transparent; border-color: transparent; color: var(--text-dim); }
.button-quiet:hover { background: var(--bg-sunken); color: var(--text); border-color: var(--line); }
.button-wide { width: 100%; justify-content: center; margin-top: .6rem; }
.linkbtn { background: none; border: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.linkbtn:hover { color: var(--accent); }
.linkbtn::after { content: ""; }

/* ---------- forms ---------- */
form label, .form-grid label { display: block; margin: .55rem 0 0; }
form label span, label .hint { font-weight: 400; }
.input,
:where(form, .searchbar, .newfolder, .dialog-form, .install) input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}
:where(form, .searchbar, .newfolder, .dialog-form, .install) input::placeholder { color: var(--text-faint); }
select { width: auto; min-width: 120px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.check-inline { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }
.radio-row { display: flex; align-items: center; gap: .45rem; margin: .5rem 0; }
.radio-row input[type="number"] { width: 5rem; }
.rule { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

.warn-box {
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
}
.error-inline { color: var(--fail); font-weight: 550; margin: .5rem 0; }
.warn-inline { color: var(--warn); font-weight: 550; }

/* ---------- flash ---------- */
.flash {
  position: fixed; left: 50%; bottom: 1.1rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: .7rem;
  max-width: min(94vw, 560px);
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .6rem .8rem .6rem 1rem; z-index: 60;
  font-size: .92rem;
}
.flash::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; flex: none; }
.flash-ok::before { background: var(--ok); }
.flash-error::before { background: var(--fail); }
.flash-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; color: var(--text-faint); padding: 0 .3rem;
}
.flash-close:hover { color: var(--text); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elevated); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .5rem .7rem; vertical-align: middle; }
/* row dividers: one clear line under the header, one continuous hairline per row */
.table thead th {
  position: sticky; top: 0; background: var(--bg-elevated);
  color: var(--text-dim); font-weight: 600; font-size: .8rem; letter-spacing: .3px;
  border-bottom: 1px solid var(--line-strong);
  z-index: 1;
}
.table tbody tr { box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--line) 60%, var(--bg-elevated)); }
.table tbody tr:last-child { box-shadow: none; }
.table tbody tr { position: relative; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.items-table tr.is-selected,
.items-table tr.is-selected:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.grid-item.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: .86rem; }

.install-steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; }
.install-step {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 20px;
  color: var(--text-dim); font-size: .88rem; background: var(--bg-elevated);
}
.install-step-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--bg-sunken); font-weight: 700; font-size: .8rem;
}
.install-step.active { border-color: var(--accent); color: var(--text); }
.install-step.active .install-step-num { background: var(--accent); color: var(--accent-contrast); }
.install-step.done { color: var(--text); }
.install-step.done .install-step-num { background: var(--ok); color: #fff; }

/* ---------- auth ---------- */
.card {
  max-width: 420px; margin: 8vh auto 0;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.3rem;
}
.auth-title { font-size: 1.3rem; }
.auth-sub { color: var(--text-dim); margin-bottom: .6rem; }
.two-factor-input { letter-spacing: .35em; font-family: var(--mono); font-size: 1.2rem; text-align: center; }
.auth-back { margin-top: .9rem; }
.card .form-actions { display: flex; gap: .5rem; }

/* ---------- files head ---------- */
.page-title { margin-bottom: .6rem; }
.files-head { margin-bottom: .8rem; }
/* breadcrumb path – Plesk style: every level is a clear link, chevron separators */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: .65rem; font-size: .98rem; }
.breadcrumbs a {
  color: var(--accent); font-weight: 600; text-decoration: none;
  padding: .1rem .3rem; border-radius: 6px;
}
.breadcrumbs a:hover { text-decoration: underline; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.breadcrumbs a:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.crumb-sep { color: var(--text-faint); display: inline-grid; place-items: center; padding: 0 .1rem; }
.crumb-current { color: var(--text); font-weight: 700; padding: .1rem .3rem; }

.results-count { color: var(--text-dim); font-size: .88rem; margin: .2rem 0 .5rem; }

.files-toolbar {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  padding: .4rem 0; border-bottom: 1px solid var(--line); margin-bottom: .6rem;
}
.sort-link { color: var(--text-dim); font-weight: 600; font-size: .85rem; padding: .2rem .45rem; border-radius: 4px; }
.sort-link:hover { color: var(--text); background: var(--bg-sunken); text-decoration: none; }
.sort-link.active { color: var(--accent); }
.view-toggle { display: inline-flex; gap: .15rem; margin-left: .3rem; }
.view-link {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: 5px; color: var(--text-dim);
}
.view-link:hover { color: var(--text); border-color: var(--line-strong); text-decoration: none; }
/* search field on the right end of the toolbar - Google style:
   one clean box, subtle border, no focus glow */
.toolbar-search {
  margin-left: auto; position: relative;
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 .9rem 0 2.35rem;
  height: 34px;
  min-width: 170px; width: auto; max-width: none; flex: 1 1 auto;
  transition: border-color .12s ease, background-color .12s ease;
}
.toolbar-search:hover { border-color: var(--line-strong); }
.toolbar-search:focus-within { border-color: var(--accent); background: var(--bg-elevated); }
.toolbar-search-icon { color: var(--text-faint); display: inline-grid; place-items: center; flex: none; position: absolute; left: .75rem; pointer-events: none; }
/* higher specificity on purpose: the generic form-input rule would otherwise win */
.files-toolbar .toolbar-search input[type="search"] {
  flex: 1; min-width: 0; width: 100%; height: 100%;
  padding: 0; margin: 0; border: 0; border-radius: 0;
  background: transparent; font-size: .92rem; line-height: normal;
  color: var(--text); box-shadow: none; outline: none;
  appearance: none; -webkit-appearance: none;
}
.files-toolbar .toolbar-search input[type="search"]::-webkit-search-decoration,
.files-toolbar .toolbar-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.files-toolbar .toolbar-search input[type="search"]::placeholder { color: var(--text-faint); }
.toolbar-search-clear {
  flex: none; display: inline-grid; place-items: center;
  color: var(--text-faint); border-radius: 50%;
  width: 22px; height: 22px;
}
.toolbar-search-clear:hover { color: var(--text); background: color-mix(in srgb, var(--text-faint) 18%, transparent); }
/* predictive search dropdown (filled by app.js) */
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: 12px; padding: .3rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .08);
  z-index: 60; max-height: 340px; overflow: auto;
}
.search-dropdown[hidden] { display: none; }
.search-result {
  display: flex; flex-wrap: wrap; align-items: center; row-gap: 2px;
  padding: .42rem .6rem; border-radius: 8px; cursor: pointer;
  font-size: .86rem; line-height: 1.45;
}
.search-result:hover, .search-result.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sug-crumb { color: var(--text-dim); text-decoration: none; padding: 0 .12rem; border-radius: 4px; }
.sug-crumb:hover { color: var(--accent); text-decoration: underline; }
.sug-crumb mark { background: transparent; color: inherit; font-weight: 700; }
.sug-crumb.sug-last { color: var(--text); font-weight: 600; }
.sug-sep { color: var(--text-faint); margin: 0 .2rem; user-select: none; }
.search-none { padding: .55rem .7rem; font-size: .82rem; color: var(--text-dim); pointer-events: none; }
@media (max-width: 760px) {
  .toolbar-search { width: 100%; max-width: none; min-width: 0; }
}
/* search result location line */
.result-path {
  font-size: .76rem; line-height: 1.35; color: var(--text-faint);
  margin-top: .15rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 460px;
}
.quota-line { color: var(--text-dim); font-size: .82rem; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .quota-line { width: 100%; }
}

/* items table */
.items-form { margin: 0; }
.items-table { min-width: 560px; }
.items-table .col-check { width: 34px; }
.items-table .col-size, .items-table .col-mod { width: 140px; }
.items-table .col-mod { white-space: nowrap; }
.items-table .col-actions { width: 44px; }
.item-name { display: flex; align-items: center; gap: .55rem; overflow: hidden; }
.item-icon { flex: none; color: var(--text-dim); display: inline-grid; place-items: center; width: 24px; }
.item-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; }
.item-link:hover { color: var(--accent); }
.ficon { display: block; }
.ficon-dir { color: var(--accent); }

.empty-list { padding: 2.2rem 1rem; text-align: center; color: var(--text-faint); }

/* item context menu (details/summary, no JS required) */
.item-menu { position: relative; display: inline-block; }
.item-menu summary {
  list-style: none; cursor: pointer; border-radius: 5px;
  display: inline-grid; place-items: center; width: 28px; height: 28px; color: var(--text-dim);
}
.item-menu summary::-webkit-details-marker { display: none; }
.item-menu summary:hover { background: var(--bg-sunken); color: var(--text); }
.item-menu-list {
  position: absolute; right: 0; top: 100%; z-index: 30;
  width: max-content; max-width: 230px;
  display: none; flex-direction: column;
  background: var(--bg-elevated); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .3rem;
}
.item-menu[open] .item-menu-list { display: flex; animation: menu-in .12s ease; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-3px); } }
.menu-item {
  text-align: left; background: none; border: none; font: inherit; font-size: .92rem; font-weight: 500;
  color: var(--text); padding: .45rem .6rem; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-item:hover { background: var(--bg-sunken); color: var(--text); }
.menu-danger, .menu-danger:hover { color: var(--fail); background: color-mix(in srgb, var(--fail) 10%, transparent); }

/* share dialog: user grants */
.dialog-sub {
  font-size: .78rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 .4rem;
}
.user-share-add .dialog-actions { margin-top: .8rem; }
.user-share-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.user-share-list li {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.user-share-list li:last-child { border-bottom: none; }
.user-share-who { font-weight: 600; }
.user-share-perm { flex-basis: 100%; order: 5; }
.user-share-actions { margin-left: auto; display: inline-flex; gap: .25rem; }
.inline-form { display: inline; margin: 0; }
.inline-form .button { padding: .18rem .55rem; font-size: .82rem; }
.button-quiet-danger:hover { color: var(--fail); background: color-mix(in srgb, var(--fail) 10%, transparent); }

/* bulk bar */
.bulkbar {
  display: none; align-items: center; gap: .8rem; flex-wrap: wrap;
  margin-top: .5rem; padding: .5rem .7rem;
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius);
}
.bulkbar.visible { display: flex; }
.bulk-count { font-weight: 650; color: var(--text-dim); }
.bulk-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- grid view ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.grid-item {
  position: relative;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .65rem;
  display: flex; flex-direction: column; gap: .3rem; min-height: 140px;
}
.grid-item:hover { border-color: var(--line-strong); }
.grid-check { position: absolute; top: .45rem; left: .45rem; z-index: 2; }
.grid-check input { width: 16px; height: 16px; }
.grid-thumb {
  display: grid; place-items: center; height: 64px; color: var(--text-dim);
}
.grid-thumb img { max-width: 100%; max-height: 64px; border-radius: 4px; object-fit: contain; }
.grid-name {
  font-weight: 600; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; text-align: center;
}
.grid-name:hover { color: var(--accent); }
.grid-size { text-align: center; color: var(--text-faint); font-size: .78rem; }
.grid-item .item-menu { position: static; }
.grid-item .item-menu summary { position: absolute; top: .3rem; right: .35rem; background: var(--bg-elevated); border-radius: 50%; width: 26px; height: 26px; }
.grid-item .item-menu-list { right: .45rem; }

/* ---------- upload zone ---------- */
.uploadzone { margin-top: 1.1rem; }
.uploadzone-inner {
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg-elevated); padding: 1.2rem; text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.uploadzone.dropzone.dragover .uploadzone-inner {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-elevated));
}
.uploadzone-title { font-weight: 650; margin: 0 0 .7rem; }
.uploadzone-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.uploadzone .hint { margin-top: .6rem; }
.uploadzone[data-blocked="1"] .uploadzone-actions { display: none; }
.uploadzone-readonly .uploadzone-inner { border-style: solid; border-width: 1px; }

.pending-uploads { margin-top: .9rem; text-align: left; border-top: 1px solid var(--line); padding-top: .7rem; }
.pending-title { font-weight: 650; margin-bottom: .3rem; }
.pending-item {
  display: flex; align-items: center; gap: .6rem; justify-content: space-between;
  padding: .4rem 0; border-bottom: 1px solid var(--line);
}
.pending-item:last-child { border-bottom: none; }
.pending-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-actions { display: flex; gap: .35rem; flex: none; }

.upload-queue { margin: 0; padding-left: 1.1rem; }
.upload-queue:empty { display: none; }
.upload-queue li { margin: .5rem 0; }
.uq-row {
  text-align: left; background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .55rem .7rem;
}
.uq-top { display: flex; align-items: baseline; gap: .6rem; }
.uq-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uq-size { color: var(--text-faint); font-size: .8rem; flex: none; }
.uq-speed { color: var(--text-dim); font-size: .8rem; flex: none; font-variant-numeric: tabular-nums; }
.uq-bar { height: 8px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; margin: .45rem 0 .3rem; }
.uq-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width .2s ease; }
.uq-row[data-state="done"] .uq-fill { background: var(--ok); }
.uq-row[data-state="failed"] .uq-fill { background: var(--fail); }
.uq-foot { display: flex; align-items: center; gap: .6rem; }
.uq-state { font-size: .84rem; color: var(--text-dim); flex: 1; }
.uq-state.done { color: var(--ok); }
.uq-state.failed { color: var(--fail); }
.uq-actions { display: flex; gap: .35rem; }

.classic-upload { margin-top: .8rem; text-align: left; }
.classic-upload summary { cursor: pointer; color: var(--text-dim); font-size: .9rem; }
.classic-upload form { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.classic-upload form input[type="file"] { flex: 1; }

/* ---------- share panel ---------- */
.share-panel { margin-bottom: .9rem; }
.share-panel-title { font-weight: 700; margin-bottom: .2rem; }
.share-url-row { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.share-url {
  flex: 1; font-family: var(--mono); font-size: .85rem;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .45rem .6rem; overflow-wrap: anywhere;
}

/* ---------- preview ---------- */
.back-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-dim); font-weight: 600; }
.preview-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.preview-title { margin: 0; font-size: 1.25rem; flex: 1; min-width: 200px; }
.preview-actions { display: flex; gap: .4rem; }
.preview-body { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview-image { display: grid; place-items: center; padding: 1rem; }
.preview-image img { max-width: 100%; max-height: 74vh; border-radius: var(--radius-sm); }
.preview-pdf iframe { width: 100%; height: 74vh; border: 0; display: block; background: #fff; }
.preview-video video { width: 100%; max-height: 74vh; display: block; background: #000; }
.preview-none { padding: 2rem; text-align: center; display: grid; gap: .7rem; justify-items: center; }
.text-preview {
  margin: 0; padding: 1rem; font-family: var(--mono); font-size: .85rem;
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 74vh; overflow: auto;
}

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .9rem; }
.admin-tabs a {
  padding: .4rem .8rem; border-radius: 20px; border: 1px solid var(--line);
  color: var(--text-dim); font-weight: 600; font-size: .9rem; background: var(--bg-elevated);
}
.admin-tabs a:hover { color: var(--text); text-decoration: none; }
.admin-tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 20px;
  font-size: .76rem; font-weight: 650; line-height: 1.4;
}
.badge-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge-fail { background: color-mix(in srgb, var(--fail) 16%, transparent); color: var(--fail); }
.badge + .badge { margin-left: .25rem; }

.row-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.inline-form { display: inline-flex; }

.filterbar { display: flex; gap: .35rem; margin-bottom: .7rem; }
.filterbar a { padding: .3rem .7rem; border-radius: 18px; border: 1px solid var(--line); color: var(--text-dim); font-weight: 600; font-size: .86rem; background: var(--bg-elevated); }
.filterbar a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.filterbar a:hover { color: var(--text); text-decoration: none; }

.log-table .log-detail { font-family: var(--mono); font-size: .78rem; color: var(--text-dim); overflow-wrap: anywhere; max-width: 380px; }

.backup-codes { font-family: var(--mono); line-height: 2; list-style: none; margin: .5rem 0; padding: 0; columns: 2; column-gap: 1.4rem; break-inside: avoid; }
.backup-codes code { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 4px; padding: .1rem .45rem; }

/* ---------- totp / qr ---------- */
.totp-setup { text-align: center; }
.totp-setup .qr-box { margin: .8rem 0; }
.qr-box { display: inline-grid; place-items: center; background: #fff; padding: .6rem; border-radius: var(--radius); border: 1px solid var(--line); }
.qr-box svg { display: block; width: min(240px, 66vw); height: auto; image-rendering: pixelated; }
.secret-code { font-family: var(--mono); word-break: break-all; background: var(--bg-sunken); padding: .2rem .5rem; border-radius: 4px; }
.card-auth .qr-box, .panel .qr-box { margin: .8rem auto; }
.enroll-skip { margin-top: .35rem; }
.totp-remove { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.totp-remove .two-factor-input { width: 160px; font-size: 1rem; letter-spacing: .18em; }
.card-auth .auth-back form { display: inline; }

/* one-time display of a freshly created initial password */
.pw-once { max-width: 560px; margin-top: .25rem; margin-bottom: .9rem; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pw-once-row { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; flex-wrap: wrap; }
.pw-once-row .secret-code { font-size: 1.15rem; letter-spacing: .05em; padding: .5rem .8rem; }

/* ---------- status ---------- */
.status-section { margin-bottom: 1rem; }
.status-table th[scope="row"] { color: var(--text-dim); width: 42%; }
.status-ok { color: var(--ok); font-weight: 700; }
.status-warn { color: var(--warn); font-weight: 700; }
.status-fail { color: var(--fail); font-weight: 700; }
.ext { display: inline-block; border-radius: 4px; padding: .05rem .45rem; margin: .1rem .15rem .1rem 0; font-size: .8rem; font-family: var(--mono); }
.ext-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.ext-miss { background: var(--bg-sunken); color: var(--text-faint); border: 1px dashed var(--line-strong); }
.ext-required { color: var(--fail); border-color: var(--fail); }
.storage-flex { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.status-storage .table { margin-top: .6rem; }

/* ---------- storage trend chart ---------- */
.storage-chart { display: block; width: 100%; height: auto; margin-top: .4rem; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-quota { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 4; opacity: .8; }
.chart-label { fill: var(--text-faint); font-size: 10px; font-family: var(--mono); }
.chart-area { fill: var(--accent); opacity: .12; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); opacity: .55; }
.chart-dot:hover { opacity: 1; }
.chart-dot-last { fill: var(--accent); opacity: 1; stroke: var(--bg-elevated); stroke-width: 1.5; }

/* ---------- share (public) pages ---------- */
body-share .main { max-width: 720px; padding-top: 2rem; }
.share-main { display: block; }
.share-card { margin-top: 4vh; }
.share-logo { display: block; margin: 0 auto .7rem; }
.share-name { text-align: center; word-break: break-word; }
.share-panel .button { margin-top: .6rem; }
.share-files-table { min-width: 480px; }

/* ---------- error pages ---------- */
body-center { display: grid; place-items: center; }
.error-box { max-width: 460px; text-align: center; margin: 6vh auto; }
.error-code { font-family: var(--mono); font-size: 3rem; font-weight: 700; color: var(--accent); margin: 0; }
.error-title { margin-bottom: .4rem; }
.error-message { color: var(--text-dim); }
.error-detail { text-align: left; font-family: var(--mono); font-size: .78rem; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: .7rem; overflow: auto; max-height: 200px; }
.error-actions { margin-top: 1rem; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: .9rem; flex-wrap: wrap; }
.pagination a, .pagination .page-current {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .5rem;
  border: 1px solid var(--line); border-radius: 5px; background: var(--bg-elevated);
  color: var(--text-dim); font-weight: 600;
}
.pagination a:hover { color: var(--text); border-color: var(--line-strong); text-decoration: none; }
.pagination .page-current { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg-elevated); color: var(--text);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem; width: min(94vw, 460px);
}
dialog::backdrop { background: rgba(10, 12, 16, .5); }
.dialog-title { font-size: 1.15rem; }
.dialog-form label { margin-top: .55rem; }
.dialog-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.dialog-standalone { max-width: 480px; margin: 6vh auto; }

/* ---------- misc ---------- */
.install { max-width: 720px; }
.totp-confirm { margin: .8rem 0; display: grid; gap: .2rem; }
.totp-confirm input { max-width: 220px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="radio"] { accent-color: var(--accent); }

@media (max-width: 560px) {
  .mainnav { display: none; }
  .topbar { flex-wrap: wrap; }
  .table .col-mod { display: none; }
  .items-table .col-mod { display: none; }
}
