/* =====================================================================
   Veylora – design system v6
   Colours from the Veylora design manual: Deep Nordic #142C3B, Nordic Teal #268F86,
   Ice Green #A4D9CD, Snow White #F4F5F2, Midnight #111B22.
   Text and buttons use slightly darker teal (#1F7A72) to meet WCAG AA contrast.
   Mobile first. Desktop (>= 1024 px) gets a sidebar, a file table and a details panel.
   ===================================================================== */
:root {
  --olive: #1F7A72; --olive-2: #19675F; --on-olive: #FFFFFF; --olive-soft: #DDEFEA; --accent: #268F86;
  --green: #142C3B; --brand: #F4F5F2;
  --bg: #F4F5F2; --surface: #FFFFFF; --surface-2: #F8F9F7; --fg: #142C3B; --muted: #5A6B75; --faint: #8A98A1;
  --line: #E1E6E4; --line-2: #D0D8D6; --hover: #ECF1EF; --sel: #E0F0EB;
  --input: #FFFFFF; --input-line: #CBD4D2;
  --err: #B03A2E; --err-soft: #F8E6E3; --ok: #1F7A72; --ok-soft: #DDEFEA; --info: #2F5D86; --info-soft: #E3ECF4;
  --warn: #8A5A00; --warn-soft: #FBF0D9;
  --sidebar: #142C3B; --sidebar-fg: #F4F5F2; --sidebar-muted: rgba(244,245,242,.6); --sidebar-hover: rgba(255,255,255,.07); --sidebar-sel: #A4D9CD; --sidebar-sel-fg: #142C3B;
  --shadow-1: 0 1px 2px rgba(17,27,34,.05), 0 1px 1px rgba(17,27,34,.03);
  --shadow-2: 0 8px 24px rgba(17,27,34,.10), 0 2px 6px rgba(17,27,34,.06);
  --shadow-3: 0 24px 64px rgba(17,27,34,.24);
  --backdrop: rgba(17,27,34,.45);
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --olive: #A4D9CD; --olive-2: #B9E4DA; --on-olive: #111B22; --olive-soft: #1B3836; --accent: #A4D9CD;
  --green: #0D161C; --brand: #DCE6E3;
  --bg: #111B22; --surface: #17242D; --surface-2: #1B2A33; --fg: #E8EEEC; --muted: #93A3AC; --faint: #6C7C85;
  --line: #23333D; --line-2: #2D3F4A; --hover: #1E2E38; --sel: #1C3837;
  --input: #121D24; --input-line: #33464F;
  --err: #F2A096; --err-soft: #3A2220; --ok: #A4D9CD; --ok-soft: #1B3836; --info: #A9C3E6; --info-soft: #1E2C3F;
  --warn: #E8C070; --warn-soft: #362C13;
  --sidebar: #0D161C; --sidebar-fg: #DCE6E3; --sidebar-muted: rgba(220,230,227,.55); --sidebar-hover: rgba(255,255,255,.05); --sidebar-sel: rgba(164,217,205,.16); --sidebar-sel-fg: #A4D9CD;
  --shadow-1: none; --shadow-2: 0 8px 24px rgba(0,0,0,.45); --shadow-3: 0 24px 64px rgba(0,0,0,.6);
  --backdrop: rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --olive: #A4D9CD; --olive-2: #B9E4DA; --on-olive: #111B22; --olive-soft: #1B3836; --accent: #A4D9CD;
    --green: #0D161C; --brand: #DCE6E3;
    --bg: #111B22; --surface: #17242D; --surface-2: #1B2A33; --fg: #E8EEEC; --muted: #93A3AC; --faint: #6C7C85;
    --line: #23333D; --line-2: #2D3F4A; --hover: #1E2E38; --sel: #1C3837;
    --input: #121D24; --input-line: #33464F;
    --err: #F2A096; --err-soft: #3A2220; --ok: #A4D9CD; --ok-soft: #1B3836; --info: #A9C3E6; --info-soft: #1E2C3F;
    --warn: #E8C070; --warn-soft: #362C13;
    --sidebar: #0D161C; --sidebar-fg: #DCE6E3; --sidebar-muted: rgba(220,230,227,.55); --sidebar-hover: rgba(255,255,255,.05); --sidebar-sel: rgba(164,217,205,.16); --sidebar-sel-fg: #A4D9CD;
    --shadow-1: none; --shadow-2: 0 8px 24px rgba(0,0,0,.45); --shadow-3: 0 24px 64px rgba(0,0,0,.6);
    --backdrop: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

/* ---------- Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--fg); background: var(--bg); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--olive); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.012em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.msg { min-height: 0; margin: 10px 0 0; font-size: .92rem; }
.msg:empty { display: none; }
.msg.err { color: var(--err); } .msg.ok { color: var(--ok); }
.oktext { color: var(--ok); font-weight: 600; display: flex; align-items: center; gap: 6px; }
kbd { font: 600 .7rem var(--font); color: var(--faint); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Icons */
.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sm .ic, .ic.sm { width: 17px; height: 17px; }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r);
  font: 600 .92rem var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  background: var(--surface); color: var(--fg); border-color: var(--line-2); box-shadow: var(--shadow-1);
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--olive); color: var(--on-olive); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: var(--olive-2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { background: var(--err-soft); color: var(--err); border-color: transparent; box-shadow: none; }
.btn.danger:hover:not(:disabled) { filter: brightness(.97); }
.btn.sm { height: 34px; padding: 0 12px; font-size: .86rem; }
.btn.block { width: 100%; }
.iconbtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--r);
  background: transparent; color: inherit; cursor: pointer; transition: background .15s;
}
.iconbtn:hover { background: var(--hover); }
.iconbtn.sm { width: 30px; height: 30px; }

/* ---------- Forms */
label { display: block; font-weight: 600; font-size: .86rem; color: var(--fg); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; height: 42px; padding: 0 12px;
  font: 400 .95rem var(--font); color: var(--fg); background: var(--input);
  border: 1px solid var(--input-line); border-radius: var(--r); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; }
select { padding-right: 30px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
form > label { margin-bottom: 14px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.formgrid.three { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.formfoot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { margin: 0; flex: 1 1 200px; width: auto; }

/* ---------- Sign-in */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1100px 560px at 50% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.authcard { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow-2); }
.authcard h1 { font-size: 1.45rem; font-weight: 750; margin: 18px 0 6px; }
.authcard .muted { margin: 0 0 16px; font-size: .92rem; }
.authcard form > label:first-of-type { margin-top: 18px; }
.authcard .btn.block + .btn.block { margin-top: 8px; }
.mark { flex: 0 0 auto; width: 34px; height: 34px; }
.wordmark { font-weight: 600; letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.wordmark b { font-weight: 600; color: var(--fg); }
.wordmark i { font-style: normal; font-weight: 600; color: var(--accent); }
:root:not([data-theme="dark"]) .wordmark i { color: #16756E; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .wordmark i { color: #A4D9CD; } }
.authbrand { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 0 4px; }
.authbrand .mark { width: 58px; height: 58px; }
.authbrand .wm { display: flex; flex-direction: column; gap: 6px; }
.authbrand .wordmark { font-size: 2.05rem; }
.authbrand small { font-size: .62rem; font-weight: 600; letter-spacing: .26em; color: var(--muted); }
.sidebrand { display: flex; align-items: center; gap: 10px; }
.sidebrand .wordmark { font-size: 1.3rem; }
.sidebrand .wordmark b { color: var(--sidebar-fg); }
.sidebrand .wordmark i { color: #A4D9CD !important; }
.pitch { list-style: none; margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.pitch li { position: relative; padding-left: 22px; font-size: .86rem; color: var(--muted); }
.pitch li::before { content: ''; position: absolute; left: 2px; top: .45em; width: 9px; height: 9px; border-radius: 2px; background: var(--accent); transform: rotate(45deg) scale(.8); }
.authfoot { margin: 18px 0 0; text-align: center; font-size: .74rem; letter-spacing: .08em; color: var(--faint); }

/* ---------- Shell: mobile first */
.shell { min-height: 100vh; min-height: 100dvh; }
.side, .detail { display: none; }
.mtop { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.mtop .mark { width: 30px; height: 30px; }
.mtop h1 { flex: 1; font-size: 1.05rem; font-weight: 700; }
.content { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.pc { display: none !important; }
.adminonly, .adminonly-flex { display: none !important; }
body.is-admin .adminonly:not(.pc) { display: block !important; }
body.is-admin .adminonly-flex { display: flex !important; }

/* Bottom bar */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: stretch; justify-content: space-around;
  padding: 6px 6px max(6px, env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--line); }
.bottombar button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px;
  border: 0; background: none; color: var(--faint); font: 600 .7rem var(--font); cursor: pointer; border-radius: var(--r); }
.bottombar button .ic { width: 23px; height: 23px; }
.bottombar button.active { color: var(--olive); }
.bottombar .fab { flex: 0 0 auto; width: 54px; height: 54px; margin: -18px 6px 0; border-radius: 18px; background: var(--olive); color: var(--on-olive);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--olive) 40%, transparent); justify-content: center; }
.bottombar .fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Pages */
.pagetitle { font-size: 1.35rem; font-weight: 750; margin: 4px 0 14px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.pagehead .pagetitle { margin-bottom: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-1); }
.panel.flush { padding: 0; overflow: hidden; }
.panel h3 { font-size: .98rem; font-weight: 700; margin-bottom: 12px; }
.panel > .muted.small { margin: -6px 0 12px; }
.dangerzone { border-color: color-mix(in srgb, var(--err) 30%, var(--line)); }
.dangerzone h3 { color: var(--err); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 14px; }
.mobileonly { margin-top: 6px; }

/* ---------- Folders (mobile: horizontal row) */
.mfolders { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -14px 4px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.mfolders::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--fg); font: 600 .88rem var(--font); cursor: pointer; white-space: nowrap; }
.chip .ic { width: 17px; height: 17px; color: var(--muted); }
.chip.active { background: var(--olive); border-color: transparent; color: var(--on-olive); }
.chip.active .ic { color: var(--on-olive); }
.chip .cnt { font-weight: 500; opacity: .6; font-size: .8rem; }
.chip.add { border-style: dashed; color: var(--muted); }
.badge-new { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--olive); color: var(--on-olive); font: 700 .68rem var(--font); }

/* Folder header */
.filehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 10px; }
.titleblock h2 { font-size: 1.3rem; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.titleblock p { margin: 2px 0 0; font-size: .86rem; }
.headactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar select { width: auto; margin: 0; height: 36px; font-size: .86rem; }
.toolbar #fileCount { margin-left: auto; }
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox > span:first-child { position: absolute; left: 11px; display: grid; color: var(--faint); pointer-events: none; }
.searchbox input { margin: 0; padding-left: 38px; }
.searchbox kbd { position: absolute; right: 9px; }
.searchbox.big input { height: 48px; font-size: 1rem; border-radius: var(--r-lg); }
.searchbox.big > span:first-child { left: 14px; }
.searchbox.big input { padding-left: 44px; }

/* ---------- File cards (mobile) */
.cards { display: flex; flex-direction: column; gap: 8px; }
.fcard { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  cursor: pointer; transition: background .15s, border-color .15s; box-shadow: var(--shadow-1); text-align: left; width: 100%; font: inherit; color: inherit; }
.fcard:active { background: var(--hover); }
.fcard .meta { flex: 1; min-width: 0; }
.fcard .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard .sub { color: var(--muted); font-size: .8rem; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard .snip { color: var(--muted); font-size: .8rem; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.fcard .snip mark, .snip mark { background: color-mix(in srgb, var(--olive) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.fcard > .ic { color: var(--faint); }

/* File type tile */
.ftile { flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--r); display: grid; place-items: center;
  font: 800 .62rem var(--font); letter-spacing: .03em; background: var(--hover); color: var(--muted); }
.ftile.sm { width: 30px; height: 30px; border-radius: 8px; font-size: .55rem; }
.ftile.lg { width: 52px; height: 52px; border-radius: 12px; font-size: .75rem; }
.ft-pdf { background: var(--err-soft); color: var(--err); }
.ft-csv, .ft-xlsx { background: var(--ok-soft); color: var(--ok); }
.ft-docx, .ft-json, .ft-xml { background: var(--info-soft); color: var(--info); }
.ft-txt { background: var(--olive-soft); color: var(--olive); }
.ft-zip { background: var(--warn-soft); color: var(--warn); }

.pill { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--hover); color: var(--fg); font-weight: 600; font-size: .74rem; line-height: 1.6; }
.pill.gone { font-style: italic; opacity: .75; }
.pill.new { background: var(--olive); color: var(--on-olive); }

/* Empty states */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; stroke-width: 1.4; color: var(--faint); margin-bottom: 8px; }
.empty strong { display: block; color: var(--fg); font-size: 1rem; margin-bottom: 4px; }
.skeleton { height: 64px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface) 0, var(--hover) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin-bottom: 8px; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Rows (users, trash etc.) */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .meta { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row .sub { color: var(--muted); font-size: .82rem; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.avatar { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 700 .82rem var(--font);
  background: var(--olive-soft); color: var(--olive); }
.role { display: inline-block; padding: 0 7px; border-radius: 6px; font: 700 .66rem var(--font); letter-spacing: .05em; line-height: 1.7; background: var(--hover); color: var(--muted); }
.role.admin { background: var(--olive); color: var(--on-olive); }

/* ---------- Admin hub (mobile) */
.hubgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hub { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow-1); }
.hub .ic { width: 26px; height: 26px; color: var(--olive); margin-bottom: 6px; }
.hub small { color: var(--muted); }

/* ---------- Overview */
.statcards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow-1); }
.stat .num { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .lbl { font-weight: 600; font-size: .86rem; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: .76rem; }
.stat.alert .num { color: var(--err); }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 64px 1fr 36px; gap: 10px; align-items: center; font-size: .86rem; }
.btrack { height: 8px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.bfill { display: block; height: 100%; border-radius: 4px; background: var(--olive); transition: width .5s var(--ease); }
.bfill.ft-pdf { background: var(--err); } .bfill.ft-csv, .bfill.ft-xlsx { background: var(--ok); }
.bfill.ft-docx, .bfill.ft-json, .bfill.ft-xml { background: var(--info); } .bfill.ft-zip { background: var(--warn); }
.bval { text-align: right; font-weight: 600; }

/* ---------- Tables */
.tablewrap { overflow: auto; border-radius: var(--r); }
.tablewrap.tall { max-height: calc(100vh - 220px); }
.table { border-collapse: collapse; width: 100%; font-size: .86rem; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 650; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover td { background: var(--hover); }
.table tr.warn td { background: color-mix(in srgb, var(--err-soft) 60%, transparent); }
.table.csv td { white-space: nowrap; }

/* ---------- Dialog (mobile: bottom sheet, desktop: centred) */
dialog { padding: 0; border: 0; color: var(--fg); background: var(--surface); box-shadow: var(--shadow-3);
  width: 100%; max-width: 100%; max-height: 88vh; max-height: 88dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
dialog[open] { animation: sheetUp .26s var(--ease); }
dialog::backdrop { background: var(--backdrop); animation: fadeIn .2s; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } }
@keyframes fadeIn { from { opacity: 0; } }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 10px 10px 18px; border-bottom: 1px solid var(--line); position: relative; }
.dlg-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
.dlg-head h3 { font-size: 1.02rem; overflow-wrap: anywhere; padding-top: 6px; }
.dlg-body { padding: 16px 18px; overflow: auto; max-height: calc(88dvh - 130px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
dialog.wide .dlg-body { max-height: calc(88dvh - 130px); }

/* Action list (in sheets and details) */
.actlist { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.act { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 10px; border: 0; border-radius: var(--r); background: none; color: var(--fg);
  font: 500 .95rem var(--font); text-align: left; cursor: pointer; text-decoration: none !important; }
.act:hover { background: var(--hover); }
.act .ic { color: var(--muted); }
.act.danger { color: var(--err); } .act.danger .ic { color: var(--err); }
.act small { margin-left: auto; color: var(--faint); font-size: .8rem; }
.sep { height: 1px; background: var(--line); margin: 6px 8px; }

/* Details */
.dhead { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.dhead .name { font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; line-height: 1.3; }
.dhead .sub { color: var(--muted); font-size: .82rem; }
.dbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .86rem; margin: 0 0 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.dsec { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 16px 0 6px; }
.vers { display: flex; flex-direction: column; }
.ver { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.ver:last-child { border-bottom: 0; }
.ver .meta { flex: 1; min-width: 0; }
.ver .meta small { color: var(--muted); display: block; }

/* Editor, PDF, QR */
dialog.wide { width: 100%; }
.editwrap { display: flex; flex-direction: column; gap: 10px; }
.editwrap .inline input { margin: 0; }
textarea.editor { min-height: 50vh; resize: vertical; font: .92rem/1.55 var(--mono); }
.pdfframe { width: 100%; height: 75vh; border: 0; border-radius: var(--r); background: var(--hover); }
.qrwrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.qrbox { display: inline-block; line-height: 0; border-radius: 10px; overflow: hidden; margin-top: 8px; border: 1px solid var(--line); }
.qrbox svg { max-width: 100%; height: auto; }
.qrurl { font: .76rem var(--mono); color: var(--muted); word-break: break-all; }
pre.code { margin: 0; white-space: pre-wrap; word-break: break-word; font: .84rem/1.5 var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: var(--r); }
.steps { padding-left: 20px; } .steps li { margin-bottom: 10px; }
code.secret { font: 600 .95rem var(--mono); background: var(--hover); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* ---------- Toasts */
.toasts { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; border-radius: var(--r-lg);
  background: #142C3B; color: #F4F5F2; box-shadow: var(--shadow-2); font-size: .9rem; animation: toastIn .25s var(--ease); }
:root[data-theme="dark"] .toast { background: #23363F; }
.toast .ic { color: #A4D9CD; }
.toast.err .ic { color: #F0907E; }
.toast .tmsg { flex: 1; min-width: 0; }
.toast .tmsg small { display: block; opacity: .7; }
.toast button { border: 0; background: rgba(255,255,255,.1); color: inherit; font: 700 .84rem var(--font); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.toast button:hover { background: rgba(255,255,255,.18); }
.toast.out { animation: toastOut .2s forwards; }
.tprog { height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 6px; }
.tprog span { display: block; height: 100%; width: 0; background: #A4D9CD; transition: width .2s; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }

/* Offline */
.offline { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: .88rem; }

/* Context menu (desktop) */
.ctxmenu { position: fixed; z-index: 200; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); animation: fadeIn .1s; }
.ctxmenu .act { padding: 8px 10px; font-size: .9rem; }
.ctxmenu .act kbd { margin-left: auto; }

/* Drag and drop (desktop) */
.dropwrap { position: relative; }
.dropzone { display: none; }

/* =====================================================================
   Desktop layout
   ===================================================================== */
@media (min-width: 1024px) {
  body { font-size: 14px; }
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr) auto; height: 100vh; overflow: hidden; }
  .mtop, .bottombar, .mfolders, .mobileonly, #page-search, #page-admin { display: none !important; }
  .pc { display: flex !important; }
  select.pc { display: block !important; }
  body.is-admin .pc.adminonly { display: block !important; }

  /* Sidebar */
  .side { display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-fg); padding: 18px 12px 12px; overflow: hidden; }
  .sidebrand { padding: 0 6px 18px; }
  .sidenav { display: flex; flex-direction: column; gap: 2px; }
  .snav { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none;
    color: var(--sidebar-fg); font: 500 .9rem var(--font); cursor: pointer; text-align: left; width: 100%; }
  .snav .ic { width: 18px; height: 18px; opacity: .8; }
  .snav:hover { background: var(--sidebar-hover); }
  .snav.active { background: var(--sidebar-sel); color: var(--sidebar-sel-fg); font-weight: 650; }
  .snav .badge-new { margin-left: auto; }
  .snav .cnt { margin-left: auto; font-size: .78rem; opacity: .55; }
  .slabel { font: 700 .68rem var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-muted); padding: 16px 10px 6px; }
  .sidehead { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px 4px 10px; font: 700 .68rem var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-muted); }
  .sidehead .iconbtn { color: var(--sidebar-fg); }
  .sidehead .iconbtn:hover { background: var(--sidebar-hover); }
  .sidefolders { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; padding: 0 4px; }
  .sidefolders .snav .owner { font-size: .74rem; opacity: .55; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidefolders .snav span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidefolders .snav.dropover { background: var(--sidebar-sel); outline: 2px dashed var(--sidebar-muted); }
  .sidefoot { display: flex; align-items: center; gap: 4px; padding-top: 10px; border-top: 1px solid var(--sidebar-hover); margin-top: 8px; }
  .sidefoot .iconbtn { color: var(--sidebar-fg); }
  .sidefoot .iconbtn:hover { background: var(--sidebar-hover); }
  .userchip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px; border: 0; border-radius: 8px; background: none; color: var(--sidebar-fg); cursor: pointer; text-align: left; font: inherit; }
  .userchip:hover { background: var(--sidebar-hover); }
  .userchip .avatar { width: 30px; height: 30px; font-size: .72rem; background: var(--sidebar-sel); color: var(--sidebar-fg); }
  .userchip .who { min-width: 0; line-height: 1.2; }
  .userchip .who b { display: block; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .userchip .who small { font-size: .72rem; opacity: .6; }

  /* Content */
  .content { max-width: none; margin: 0; padding: 22px 28px 40px; overflow-y: auto; height: 100vh; }
  .page { max-width: 1200px; }
  .filehead { margin: 0 0 14px; }
  .titleblock h2 { font-size: 1.45rem; }
  .toolbar { gap: 8px; }
  .toolbar .searchbox { flex: 1 1 280px; max-width: 420px; }
  .toolbar .searchbox input { height: 36px; }
  .toolbar #sort { display: none; }
  .statcards { grid-template-columns: repeat(4, 1fr); }
  .offline { position: fixed; top: 0; left: 248px; right: 0; }

  /* Compact file table */
  .ftable { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
  .ftable th { text-align: left; font: 650 .72rem var(--font); text-transform: uppercase; letter-spacing: .05em; color: var(--faint);
    padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; }
  .ftable th.sorted { color: var(--fg); }
  .ftable td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; font-size: .88rem; }
  .ftable tr:last-child td { border-bottom: 0; }
  .ftable tbody tr { cursor: default; }
  .ftable tbody tr:hover td { background: var(--hover); }
  .ftable tbody tr.sel td { background: var(--sel); }
  .ftable .nm { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .ftable .nm > div { min-width: 0; }
  .ftable .nm b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
  .ftable .nm small { display: block; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
  .ftable td.num { color: var(--muted); text-align: right; }
  .ftable td.dim { color: var(--muted); }
  .ftable td.acol { width: 44px; text-align: right; padding: 4px 8px; }
  .ftable .rowbtn { opacity: 0; }
  .ftable tr:hover .rowbtn, .ftable tr.sel .rowbtn { opacity: 1; }

  /* Drag and drop */
  .dropzone { display: grid; place-items: center; position: absolute; inset: -6px; z-index: 5; border-radius: var(--r-lg);
    border: 2px dashed var(--olive); background: color-mix(in srgb, var(--olive) 10%, var(--bg)); opacity: 0; pointer-events: none; transition: opacity .15s; }
  .dropzone > div { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--olive); text-align: center; }
  .dropzone .ic { width: 36px; height: 36px; }
  .dropzone span#dropTarget { color: var(--muted); font-size: .86rem; }
  .dropwrap.dragging .dropzone { opacity: 1; }
  .dropwrap { min-height: 260px; }
  .emptydrop { border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface); }

  /* Details panel */
  .detail { display: block; width: 360px; border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; height: 100vh; padding: 18px 18px 30px; animation: slideIn .2s var(--ease); }
  .detail[hidden] { display: none !important; }
  .detail .dtop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .detail .dtop span { font: 700 .72rem var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
  @keyframes slideIn { from { transform: translateX(16px); opacity: 0; } }

  /* Centred dialog */
  dialog { width: min(560px, 92vw); max-height: 86vh; margin: auto; border-radius: var(--r-lg); }
  dialog[open] { animation: popIn .18s var(--ease); }
  dialog.wide { width: min(1000px, 94vw); }
  .dlg-head::before { display: none; }
  .dlg-head h3 { padding-top: 0; }
  .dlg-foot { padding-bottom: 12px; }
  @keyframes popIn { from { transform: scale(.97); opacity: 0; } }

  .toasts { bottom: 22px; left: calc(248px + 28px); right: auto; transform: none; width: 400px; }
}

/* ---------- iPhone install guide */
.ioshint { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60; display: flex; gap: 10px; align-items: flex-start;
  background: #142C3B; color: #F4F5F2; border-radius: var(--r-lg); padding: 14px 10px 14px 16px; box-shadow: var(--shadow-2); }
.ioshint[hidden] { display: none; }
.ioshint-body { flex: 1; font-size: .9rem; }
.ioshint strong { display: block; margin-bottom: 6px; font-weight: 600; }
.ioshint ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.ioshint b { font-weight: 600; color: #A4D9CD; }
.ioshint .ioshare svg { width: 16px; height: 16px; vertical-align: -3px; }
.ioshint .iconbtn { color: #F4F5F2; }
#view-app:not([hidden]) ~ .ioshint { bottom: calc(76px + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) { .ioshint { display: none !important; } }
