:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --text: #1D2129;
  --muted: #5F6673;
  --line: #CDD1D8;
  --control-border: #878D99;
  --hover: #EDEFF3;
  --accent: #4F3FA6;
  --on-accent: #FFFFFF;
  --accent-soft: #E3DFF6;
  --danger: #B3261E;
  --on-danger: #FFFFFF;
  --danger-soft: #FBE9E7;
  --on-tab: #FFFFFF;
  --type-pdf: #C0362C;
  --type-pdf-soft: #FCE8E6;
  --type-img: #1F63B5;
  --type-other: #5F6673;
  --on-type: #FFFFFF;
  --tab-kraft: #9C7143;
  --tab-sage: #5A8B69;
  --tab-slate: #5F7FB0;
  --tab-rose: #B0617B;
  --tab-teal: #23868E;
  --tab-plum: #8D569B;
  --tab-ochre: #9E7C00;
  --tab-olive: #6C7F22;
  --viewer: #D5D8DE;
  --scrim: rgba(20, 22, 27, 0.45);
  --info-bg: #FFF4D6;
  --on-info: #5C4400;
  --fs-xs: 0.833rem;
  --fs-1: 1rem;
  --fs-2: 1.2rem;
  --fs-3: 1.44rem;
  --fs-4: 1.728rem;
  --font: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161B;
    --surface: #1D2027;
    --text: #E8EAEE;
    --muted: #9AA1AD;
    --line: #3A3F4A;
    --control-border: #6C7380;
    --hover: #272B34;
    --accent: #A99BF2;
    --on-accent: #14161B;
    --accent-soft: #322D4E;
    --danger: #F2B8B5;
    --on-danger: #3A0F0D;
    --danger-soft: #3A2321;
    --on-tab: #14161B;
    --type-pdf: #F28B82;
    --type-pdf-soft: #3B2422;
    --type-img: #8AB4F8;
    --type-other: #9AA1AD;
    --on-type: #14161B;
    --tab-kraft: #C49A6B;
    --tab-sage: #7FB08D;
    --tab-slate: #8AA6D6;
    --tab-rose: #D98BA3;
    --tab-teal: #4DB5BD;
    --tab-plum: #BE8CCB;
    --tab-ochre: #CDA62E;
    --tab-olive: #9DB650;
    --viewer: #0E1014;
    --scrim: rgba(0, 0, 0, 0.6);
    --info-bg: #3A3115;
    --on-info: #F3DC9B;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14161B;
  --surface: #1D2027;
  --text: #E8EAEE;
  --muted: #9AA1AD;
  --line: #3A3F4A;
  --control-border: #6C7380;
  --hover: #272B34;
  --accent: #A99BF2;
  --on-accent: #14161B;
  --accent-soft: #322D4E;
  --danger: #F2B8B5;
  --on-danger: #3A0F0D;
  --danger-soft: #3A2321;
  --on-tab: #14161B;
  --type-pdf: #F28B82;
  --type-pdf-soft: #3B2422;
  --type-img: #8AB4F8;
  --type-other: #9AA1AD;
  --on-type: #14161B;
  --tab-kraft: #C49A6B;
  --tab-sage: #7FB08D;
  --tab-slate: #8AA6D6;
  --tab-rose: #D98BA3;
  --tab-teal: #4DB5BD;
  --tab-plum: #BE8CCB;
  --tab-ochre: #CDA62E;
  --tab-olive: #9DB650;
  --viewer: #0E1014;
  --scrim: rgba(0, 0, 0, 0.6);
  --info-bg: #3A3115;
  --on-info: #F3DC9B;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-1);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

@supports (font: -apple-system-body) {
  body {
    font: -apple-system-body;
    font-family: var(--font);
    line-height: 1.45;
  }
}

.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: var(--fs-4);
  font-weight: 600;
}

.mark {
  width: 2rem;
  height: 2rem;
  color: var(--accent);
}

.soon {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-2);
}

/* sign in, PIN re-entry and the signed-in placeholder */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}
.auth-col {
  width: 100%;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-lead { color: var(--muted); }
.title {
  font-size: var(--fs-4);
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.field-label { font-weight: 600; }
.input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--text);
}

.err { color: var(--danger); font-weight: 600; }
.err:focus { outline: none; } /* focused only to scroll it into view after a re-render */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0 1rem;
  border-radius: 0.65rem;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  border-radius: 999px;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-quiet { border-color: transparent; background: none; }
.btn-block { width: 100%; }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  background: none;
  border: 0;
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
}

.pinrow { position: relative; display: flex; gap: 0.5rem; }
.pinbox {
  flex: 1;
  min-width: 0;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--control-border);
  background: var(--surface);
  border-radius: 0.65rem;
  font-size: var(--fs-3);
  font-weight: 600;
}
.pinrow:focus-within .pinbox.is-cur {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pin-real {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 1rem;
  cursor: pointer;
}

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.pad-key {
  min-height: 4rem;
  border-radius: 0.75rem;
  border: 1px solid var(--control-border);
  background: var(--surface);
  font-size: var(--fs-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pad-key:hover { background: var(--hover); }
.pad-key:disabled { opacity: 0.45; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Browse and view (M3), ported from docs/mockups/index.html ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
mark { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-radius: 3px; padding: 0 1px; }

.ic { flex: none; display: inline-block; }
.s14 { width: 0.875rem; height: 0.875rem; }
.s18 { width: 1.125rem; height: 1.125rem; }
.s20 { width: 1.25rem; height: 1.25rem; }
.s22 { width: 1.375rem; height: 1.375rem; }
.s24 { width: 1.5rem; height: 1.5rem; }
.s30 { width: 1.875rem; height: 1.875rem; }
.s32 { width: 2rem; height: 2rem; }

/* Person colours: eight muted hues, each at least 3:1 on the surface in both themes */
.c-kraft { color: var(--tab-kraft); }
.c-sage { color: var(--tab-sage); }
.c-slate { color: var(--tab-slate); }
.c-rose { color: var(--tab-rose); }
.c-teal { color: var(--tab-teal); }
.c-plum { color: var(--tab-plum); }
.c-ochre { color: var(--tab-ochre); }
.c-olive { color: var(--tab-olive); }
.tabmark { flex: none; width: 1.25rem; height: 0.875rem; display: inline-block; }
.glyph { flex: none; display: block; width: 2rem; height: 1.7rem; }
.glyph.sm { width: 1.75rem; height: 1.4875rem; }
.glyph-i { fill: var(--on-tab); font-family: var(--font); font-weight: 600; font-size: 14px; }

/* Shell */
.app, .shell {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(16px, env(safe-area-inset-top, 0px));
}
.shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 1440px; }
.sidebar, .details { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); max-width: 44rem; }
.page { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page.narrow { max-width: 48rem; }
.page-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.title:focus { outline: none; }
.section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.section-title { font-size: var(--fs-2); font-weight: 600; }
/* Phone-only and desktop-only pieces. These rules only hide, and they are
   !important so a component's own display cannot undo them. Shown pieces
   keep their own display. */
@media (max-width: 1023.98px) {
  .only-desk, .vis-desk { display: none !important; }
}

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab { flex: 1; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; color: var(--muted); text-decoration: none; }
.tab-label { white-space: nowrap; font-size: min(var(--fs-xs), 15px); line-height: 1.2; }
.tab.is-active { color: var(--accent); font-weight: 600; }

@media (min-width: 1024px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); gap: 32px; }
  .shell.has-details { grid-template-columns: 240px minmax(0, 1fr) 320px; }
  .main { max-width: none; padding-bottom: 32px; }
  .sidebar { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 16px; align-self: start; }
  .details { display: block; position: sticky; top: 16px; align-self: start; }
  .tabbar { display: none; }
  .show-phone, .vis-phone { display: none !important; }
}

/* Sidebar */
.side-brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-2); font-weight: 600; min-height: 44px; }
.brandmark { display: inline-flex; align-items: flex-end; gap: 3px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-title { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding-left: 12px; padding-bottom: 4px; }
.navitem { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-decoration: none; }
.navitem:hover { background: var(--hover); }
.navitem.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Groups and rows. Hover is a grey fill; selected is a tinted fill plus an accent bar. */
.group { background: var(--surface); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 4px; min-height: 52px; }
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: var(--hover); }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 52px; text-decoration: none; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { display: block; overflow-wrap: anywhere; }
.row-sub { display: block; color: var(--muted); font-size: var(--fs-xs); }
.row-end { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted); }
.row-more { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 10px; color: var(--muted); margin-right: 6px; }
.row-more:hover { background: var(--line); }
.pathc { display: flex; align-items: center; gap: 6px; min-width: 0; }
.note-line { font-style: normal; }
.ficon { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); }
.sub-ic { flex: none; display: inline-flex; }

/* File type: colour plus an extension label, so PDF, JPG and the rest are told apart at a glance */
.ftype { position: relative; flex: none; display: inline-flex; }
.ftype-big { display: flex; width: 100%; }
.fi-pdf { background: var(--type-pdf-soft); color: var(--type-pdf); }
.fi-image { color: var(--type-img); }
.fi-other { color: var(--type-other); }
.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 8px; background: var(--bg); }
.fbadge { position: absolute; right: -0.3rem; bottom: -0.2rem; padding: 0.0625rem 0.25rem; border-radius: 4px; font-size: 0.625rem; font-weight: 600; line-height: 1.3; letter-spacing: 0.02em; color: var(--on-type); }
.fb-pdf { background: var(--type-pdf); }
.fb-image { background: var(--type-img); }
.fb-other { background: var(--type-other); }
.ftype-big .fbadge { right: 0.4rem; bottom: 0.4rem; font-size: 0.75rem; padding: 0.125rem 0.375rem; }
.noprev { display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; padding: 2.5rem 1.5rem; }
.noprev .ftype { width: 6rem; }

/* Buttons and fields */
a.btn, a.iconbtn { text-decoration: none; }
.btn-primary:hover { color: var(--on-accent); }
.iconbtn { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 10px; color: var(--text); }
.iconbtn:hover { background: var(--hover); }
.iconbtn[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.searchfield { position: relative; display: flex; align-items: center; }
.searchfield .sf-icon { position: absolute; left: 0.75rem; color: var(--muted); display: inline-flex; pointer-events: none; }
.sf-input { padding-left: 2.75rem; }
.chiprow { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.chipgrp { display: flex; align-items: center; gap: 8px; flex: none; }
.chip-sep { flex: none; width: 1px; height: 1.75rem; background: var(--line); }
.chip { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--control-border); background: var(--surface); color: var(--text); text-decoration: none; }
.chip:hover { background: var(--hover); }
.chip[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 8px 12px; }
.toolbar-sort { margin-left: auto; min-width: 0; }
.toolbar-views { display: flex; gap: 2px; }
#pane-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Folder header and breadcrumbs */
.fhead { display: flex; flex-direction: column; min-width: 0; }
.fhead-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.fhead-row .title { flex: 1 1 6rem; min-width: 0; overflow-wrap: break-word; }
.plink { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--text); font-size: var(--fs-xs); font-weight: 600; }
.plink:hover, .crumb:hover { text-decoration: underline; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.crumb-item { display: inline-flex; align-items: center; }
.crumb { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; color: var(--text); font-weight: 600; text-decoration: none; }
.crumb-here { color: var(--muted); }
.crumb-sep { display: inline-flex; color: var(--muted); }

/* Tiles (grid view and recent) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 12px; }
.tile, .rtile { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 12px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.tile { width: 100%; }
.tile:hover, .rtile:hover { background: var(--hover); }
.tile-name { overflow-wrap: anywhere; min-width: 0; }
.tile .ficon-big, .rtile .ficon-big { width: 100%; height: 5.5rem; border-radius: 8px; }
.tile .thumb, .rtile .thumb { border-radius: 8px; }
.tile .sub-ic { height: 5.5rem; align-items: center; }
.recent { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.rtile { flex: none; width: 9.5rem; scroll-snap-align: start; }

/* File table (desktop) */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 12px; }
.ftable { border-collapse: collapse; width: 100%; }
.ftable th, .ftable td { padding: 0 12px; text-align: left; white-space: nowrap; }
.ftable th { height: 2.75rem; padding: 0 4px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; border-bottom: 1px solid var(--line); }
.ftable td { height: 3.25rem; border-bottom: 1px solid var(--line); }
.ftable .trow:last-child td { border-bottom: 0; }
.ftable .col-name { width: 100%; max-width: 0; }
.ftable .col-folder { max-width: 14rem; }
.ftable .col-act { width: 3.5rem; padding: 0 6px 0 0; }
.ftable .ficon { width: 2rem; height: 2rem; border-radius: 6px; }
.ftable .thumb { border-radius: 6px; }
.thbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 8px; border-radius: 8px; color: inherit; font-weight: 600; text-decoration: none; }
.thbtn:hover { background: var(--hover); }
.trow { cursor: default; }
.trow:hover { background: var(--hover); }
.trow.is-sel { background: var(--accent-soft); }
.trow.is-sel .col-name { box-shadow: inset 3px 0 0 var(--accent); }
.trow:focus-visible { outline-offset: -2px; }
.cn { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cn-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cn-link { text-decoration: none; }
.cn-link:hover { text-decoration: underline; }
.cn-stack { display: flex; flex-direction: column; min-width: 0; }
.cn-note { overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 1279px) {
  .has-details .ftable .col-by, .has-details .ftable .col-size { display: none; }
}

/* Panels */
.panel { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; background: var(--surface); border-radius: 12px; }
.panel-title { font-size: var(--fs-2); font-weight: 600; }
.panel-icon { color: var(--muted); display: inline-flex; }

/* Details */
.detail { display: flex; flex-direction: column; gap: 16px; padding: 20px; background: var(--surface); border-radius: 12px; min-width: 0; }
.sheet .detail { padding: 0; }
.detail-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.detail-name { font-size: var(--fs-2); font-weight: 600; overflow-wrap: anywhere; }
.detail-path { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.facts { display: flex; flex-direction: column; gap: 10px; }
.fact { display: flex; flex-direction: column; }
.fact-k { font-size: var(--fs-xs); color: var(--muted); }
.fact-v { overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-empty { padding: 20px; background: var(--surface); border-radius: 12px; color: var(--muted); }

/* Sheets: popovers, a bottom sheet on phones and a card from 640 px */
.sheet { color: var(--text); background: var(--surface); }
.sheet.pop, .vdetails:popover-open {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 88vh; overflow-y: auto;
  border: 0; border-radius: 12px 12px 0 0;
  padding: 16px max(16px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px));
}
.sheet.pop:popover-open, .vdetails:popover-open { display: flex; flex-direction: column; gap: 14px; }
.sheet.pop::backdrop, .vdetails::backdrop { background: var(--scrim); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sheet-title { font-size: var(--fs-2); font-weight: 600; overflow-wrap: anywhere; padding-top: 0.5rem; }
.menuitem { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; width: 100%; padding: 0 12px; background: none; border: 0; border-radius: 10px; text-align: left; text-decoration: none; color: var(--text); }
.menuitem:hover { background: var(--hover); }
.menuitem[aria-current="true"] { color: var(--accent); font-weight: 600; }
@media (min-width: 640px) {
  .sheet.pop { inset: 0; margin: auto; width: min(28rem, calc(100% - 32px)); height: fit-content; border-radius: 12px; padding-bottom: 20px; }
}

/* Viewer */
.vpage { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--viewer); }
.viewer-bar { display: flex; align-items: center; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--line); padding: max(8px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.viewer-name { flex: 1; min-width: 0; font-size: var(--fs-1); font-weight: 600; overflow-wrap: anywhere; }
.vmain { flex: 1; min-height: 0; display: flex; }
.viewer-body { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px max(16px, env(safe-area-inset-left, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)); }
.pdfframe { flex: 1; width: 100%; min-height: 60vh; border: 0; border-radius: 4px; background: var(--surface); }
.viewer-foot { display: flex; justify-content: center; }
.viewer-img { display: flex; justify-content: center; }
.viewimg { max-width: 100%; height: auto; border-radius: 4px; background: var(--surface); }
.paper { background: var(--surface); width: min(100%, 38rem); margin: 0 auto; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; border-radius: 4px; }
.vdetails { color: var(--text); background: var(--surface); }
.vdetails:popover-open .detail { padding: 0; }
.vdetails .sheet-head .iconbtn { margin-right: -8px; }
@media (min-width: 1024px) {
  .vdetails { display: block; position: static; inset: auto; margin: 0; height: auto; max-height: none; flex: none; width: 320px; overflow-y: auto; padding: 16px; background: var(--bg); border: 0; border-left: 1px solid var(--line); border-radius: 0; }
  .vdetails .sheet-head { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* M4: uploads, trash and file actions */
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn-danger-solid:hover { background: var(--danger); filter: brightness(1.08); }
.menuitem.is-danger { color: var(--danger); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wrap-row { display: flex; flex-wrap: wrap; gap: 8px; }
.row-block { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.trash-main { padding: 0; }
.textarea { min-height: 5.5rem; padding: 10px 12px; resize: vertical; }
.pgroup { display: flex; align-items: center; gap: 8px; font-size: var(--fs-1); font-weight: 600; }
.filein { padding: 8px 12px; }
progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: 4px; background: var(--line); overflow: hidden; color: var(--accent); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }

/* The message bar after an action: same look as the prototype's toast, but it stays until closed. */
.msgbar { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 2px 4px 2px 16px; background: var(--text); color: var(--bg); border-radius: 12px; max-width: 100%; }
.msgbar.is-err { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.msgbar-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.msgbar form { display: inline-flex; }
.msgbar-undo { min-height: 44px; padding: 0 12px; background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; }
.msgbar-x { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: inherit; }
.vpage > .msgbar { margin: 8px max(16px, env(safe-area-inset-left, 0px)) 0; }

/* M5: admin pages (Users, a user, Security), the permissions grid and My devices */
.chip[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.admin-tabs { padding-bottom: 2px; }
.admin-panel { align-items: stretch; }
.admin-panel form, .admin-panel .stack { width: 100%; }
.badge { display: inline-flex; align-items: center; padding: 0 8px; min-height: 1.5rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.badge.is-warn { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.banner { padding: 12px 16px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-weight: 600; display: flex; flex-direction: column; gap: 8px; }
.banner .btn { color: var(--text); }
.row-form { flex: none; display: inline-flex; padding-right: 8px; }
.choice { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.choice-opt { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.choice-opt input, .chk input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
.pin-shown { align-items: center; text-align: center; }
.pin-digits { font-size: 2.6rem; font-weight: 600; letter-spacing: 0.3em; padding-left: 0.3em; font-variant-numeric: tabular-nums; }
.gtable tbody th { height: 3.25rem; padding: 0 12px; color: var(--text); font-size: var(--fs-1); font-weight: 400; text-align: left; border-bottom: 1px solid var(--line); }
.gtable thead th { padding: 0 12px; }
.gtable .col-chk { text-align: center; line-height: 1.2; }
.gtable .trow:last-child th { border-bottom: 0; }
.chk { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
.from { display: block; color: var(--muted); font-size: var(--fs-xs); }
.ind-0 { padding-left: 12px; }
.ind-1 { padding-left: 28px; }
.ind-2 { padding-left: 44px; }
.ind-3 { padding-left: 60px; }
.ind-4 { padding-left: 76px; }
.ind-5 { padding-left: 92px; }
.ind-6 { padding-left: 108px; }
.gtable tbody th.ind-1 { padding-left: 28px; }
.gtable tbody th.ind-2 { padding-left: 44px; }
.gtable tbody th.ind-3 { padding-left: 60px; }
.gtable tbody th.ind-4 { padding-left: 76px; }
.gtable tbody th.ind-5 { padding-left: 92px; }
.gtable tbody th.ind-6 { padding-left: 108px; }
.event.is-warn { background: var(--danger-soft); color: var(--danger); }
.event .ic { vertical-align: -3px; margin-right: 4px; }
.event a { color: inherit; }

/* M8: polish */
.skip-link { position: absolute; left: 8px; top: 8px; z-index: 100; padding: 0 16px; min-height: 44px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.main:focus { outline: none; }

.btn-sm { min-height: 2.25rem; padding: 0 0.875rem; }
.install-hint { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); }
.install-icon { border-radius: 9px; }
.install-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.install-title { font-weight: 600; }
.install-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.steps { list-style: decimal; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 4px; }
.steps li { padding-left: 4px; }
@media (display-mode: standalone) {
  .install-section, .install-hint { display: none !important; }
}

.errpage { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 34rem; padding-block: 48px; min-width: 0; }
.auth > .errpage { width: 100%; padding-inline: 0; }
.errpage p { color: var(--muted); }
.errpage-glyph { width: 48px; height: 48px; color: var(--muted); }
.errpage-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.info { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); color: var(--on-info); }

/* Phone: folder header wraps, and long names never push the page wider */
@media (max-width: 1023.98px) {
  .fhead-row { flex-wrap: wrap; }
  .fhead-row .title { overflow-wrap: anywhere; min-width: 0; }
  .fhead-row .head-end { flex: 1 1 100%; flex-wrap: wrap; margin-left: 0; }
  .fhead-row .head-end > * { order: 2; }
  .fhead-row .head-end > .btn-primary { order: 1; }
  .fhead-row .head-end > #pane-toggle { order: 3; }
  .page-head { flex-wrap: wrap; }
}
.page-head .title, .detail-name, .fact-v, .row-sub, .cn-t, .tile-name { min-width: 0; overflow-wrap: anywhere; }
.row-block .row-title, .row-block .row-sub, .err { overflow-wrap: anywhere; min-width: 0; }
