:root {
  /* Karparts360 yellow and charcoal. --link is the yellow made readable as text; --ring is the keyboard-focus outline. */
  --bg: #f3f4f6; --card: #fff; --text: #1b1f27; --muted: #5f6674; --line: #e5e7eb; --field-line: #cdd2da;
  --accent: #FDB81A; --accent-dark: #F0A800; --on-accent: #222222; --link: #8a5a00; --focus: #fde3a3; --ring: #b97c00;
  --bar: #222222; --bar-text: #f4f4f5; --bar-muted: #a8acb4; --bar-line: #222222; --bar-hover: rgba(255, 255, 255, .08);
  --danger: #c3362b; --danger-solid: #cf3a2e; --danger-line: #efc3bf; --danger-bg: #fdf0ef; --ok: #1f8a4c; --warn: #b26a00;
  --err-bg: #fdecea; --err-text: #8c2018; --ok-bg: #e7f6ed; --ok-text: #135c33; --info-bg: #eaf0fd; --info-text: #183f9e;
  --warn-bg: #fff4e0; --admin-bg: #fff4d6; --row-hover: #f8f9fb; --row-sel: #fff7de; --drop-bg: #fffaeb;
  --face-bg: #fde7a8; --face-text: #6b4a00;
  --icon-page: #fff; --icon-line: #b4bac4; --folder-back: #e5a000; --folder-front: #FDB81A;
  --shadow: 0 1px 2px rgba(16, 20, 28, .05); --shadow-pop: 0 12px 36px rgba(16, 20, 28, .18);
  --radius: 12px; --radius-sm: 8px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.45;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* Dark colours: used when the computer is in dark mode, unless the person picked Light (theme.js). */
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { color-scheme: dark;
  --bg: #14161b; --card: #1c1f26; --text: #e7e9ee; --muted: #9aa1ad; --line: #2c3039; --field-line: #3a3f4a;
  --accent-dark: #FFC93D; --link: #FDB81A; --focus: #5a4610; --ring: #FDB81A;
  --bar: #0d0f13; --bar-text: #eceef2; --bar-muted: #9298a3; --bar-line: #262a31; --bar-hover: rgba(255, 255, 255, .06);
  --danger: #ff8f85; --danger-solid: #d8453a; --danger-line: #5c302c; --danger-bg: #2c1c1b; --ok: #62d394; --warn: #f0b45a;
  --err-bg: #35201e; --err-text: #ffb4ab; --ok-bg: #16301f; --ok-text: #8be0ad; --info-bg: #1b2540; --info-text: #a9c1ff;
  --warn-bg: #33270f; --admin-bg: #3a3016; --row-hover: #21252d; --row-sel: #2e2914; --drop-bg: #2b2614;
  --face-bg: #4a3a14; --face-text: #fdb81a;
  --icon-page: #262a33; --icon-line: #4d5360; --folder-back: #c48a00; --folder-front: #f2b11c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-pop: 0 14px 40px rgba(0, 0, 0, .5); } }
:root[data-theme=dark] { color-scheme: dark;
  --bg: #14161b; --card: #1c1f26; --text: #e7e9ee; --muted: #9aa1ad; --line: #2c3039; --field-line: #3a3f4a;
  --accent-dark: #FFC93D; --link: #FDB81A; --focus: #5a4610; --ring: #FDB81A;
  --bar: #0d0f13; --bar-text: #eceef2; --bar-muted: #9298a3; --bar-line: #262a31; --bar-hover: rgba(255, 255, 255, .06);
  --danger: #ff8f85; --danger-solid: #d8453a; --danger-line: #5c302c; --danger-bg: #2c1c1b; --ok: #62d394; --warn: #f0b45a;
  --err-bg: #35201e; --err-text: #ffb4ab; --ok-bg: #16301f; --ok-text: #8be0ad; --info-bg: #1b2540; --info-text: #a9c1ff;
  --warn-bg: #33270f; --admin-bg: #3a3016; --row-hover: #21252d; --row-sel: #2e2914; --drop-bg: #2b2614;
  --face-bg: #4a3a14; --face-text: #fdb81a;
  --icon-page: #262a33; --icon-line: #4d5360; --folder-back: #c48a00; --folder-front: #f2b11c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-pop: 0 14px 40px rgba(0, 0, 0, .5); }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--link); text-underline-offset: 2px; }
h2, h3 { letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- top bar: charcoal, like the logo ---------- */
header.top { background: var(--bar); color: var(--bar-text); border-bottom: 1px solid var(--bar-line); padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 24px; position: relative; z-index: 30; }
header.top :focus-visible { outline-color: var(--accent); }
header.top .brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--bar-text); text-decoration: none; display: flex; align-items: center; gap: 9px; }
header.top .brand .logo { width: 28px; height: 28px; background: url(/logo.svg) center / contain no-repeat; flex: none; }
header.top nav { display: flex; gap: 2px; flex: 1; align-self: stretch; }
header.top nav a { text-decoration: none; color: var(--bar-muted); padding: 0 14px; display: flex; align-items: center; font-weight: 500; font-size: 14.5px;
  box-shadow: inset 0 -3px 0 transparent; transition: color .15s, box-shadow .15s; }
header.top nav a:hover { color: var(--bar-text); background: var(--bar-hover); }
header.top nav a.on { color: var(--bar-text); box-shadow: inset 0 -3px 0 var(--accent); }
.profile { position: relative; }
.avatar { width: 34px; height: 34px; min-height: 0; border-radius: 50%; padding: 0; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 700; letter-spacing: .02em; box-shadow: none; }
.avatar:hover, .avatar.on { background: var(--accent-dark); box-shadow: 0 0 0 3px rgba(253, 184, 26, .35); }
.profile-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 250px; background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; }
.profile-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.profile-who span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.profile-menu a, .profile-menu .menu-item { display: block; width: 100%; min-height: 0; text-align: left; padding: 9px 10px; border-radius: 6px; color: var(--text); text-decoration: none; background: none; font-weight: 500; font-size: 14px; border: 0; box-shadow: none; }
.profile-menu a:hover, .profile-menu .menu-item:hover { background: var(--bg); }
.theme-pick { display: flex; gap: 2px; margin: 4px 6px; padding: 3px; background: var(--bg); border-radius: var(--radius-sm); }
.theme-pick button { flex: 1; min-height: 0; padding: 5px 0; background: none; color: var(--muted); font-size: 13px; font-weight: 500; border-radius: 6px; box-shadow: none; }
.theme-pick button:hover { background: none; color: var(--text); }
.theme-pick button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

/* ---------- page and cards ---------- */
main { max-width: 1080px; margin: 28px auto; padding: 0 20px; }
main.narrow { max-width: 440px; margin-top: 0; padding-top: 44px; }
/* Sign-in style pages: a charcoal band behind the logo, the form card resting on it */
body:has(> main.narrow) { background: linear-gradient(var(--bar) 0 200px, var(--bg) 200px); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
main.narrow .card { box-shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 12px 32px rgba(16, 20, 28, .10); }
main.narrow > p.muted { color: var(--bar-muted); }
.card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.card p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; max-width: 72ch; }
.center-brand { text-align: center; margin-bottom: 26px; font-size: 24px; font-weight: 700; letter-spacing: -.015em; color: var(--bar-text);
  display: flex; justify-content: center; align-items: center; gap: 10px; }
.center-brand .logo { width: 38px; height: 38px; background: url(/logo.svg) center / contain no-repeat; flex: none; }

/* ---------- form fields ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--field-line); border-radius: var(--radius-sm); font: inherit; background: var(--card); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox] { accent-color: var(--accent-dark); width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; }
input.code { font-size: 24px; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; border: 1px solid transparent; border-radius: var(--radius-sm); min-height: 40px; padding: 0 16px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .14); transition: background-color .15s, border-color .15s, color .15s; }
button:hover, .btn:hover { background: var(--accent-dark); }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }
button.full { width: 100%; margin-top: 22px; min-height: 44px; }
button.ghost, .btn.ghost { background: var(--card); color: var(--text); border-color: var(--field-line); box-shadow: var(--shadow); }
button.ghost:hover, .btn.ghost:hover { background: var(--bg); border-color: var(--muted); }
button.danger { background: var(--card); color: var(--danger); border-color: var(--danger-line); box-shadow: none; }
button.danger:hover { background: var(--danger-bg); }
button.small { min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 500; }

.cmd { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px 10px; background: #1d2230; border-radius: var(--radius-sm); }
.cmd code { flex: 1; color: #fdd77a; font: 13px ui-monospace, Menlo, monospace; overflow-x: auto; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.msg { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-top: 14px; }
.msg.error { background: var(--err-bg); color: var(--err-text); }
.msg.ok { background: var(--ok-bg); color: var(--ok-text); }
.msg > div { margin-top: 6px; } /* extra lines under a message */
.card p.hint { max-width: 72ch; }
.msg.info { background: var(--info-bg); color: var(--info-text); }
.muted { color: var(--muted); font-size: 14px; }
div.small, .muted.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--bg); color: var(--muted); margin: 1px 2px 1px 0; white-space: nowrap; }
.pill.admin { background: var(--admin-bg); color: var(--link); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--err-bg); color: var(--danger); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.qr { display: flex; gap: 20px; align-items: center; margin: 12px 0; }
.qr svg { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: #fff; flex: none; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; background: var(--bg); padding: 6px 8px; border-radius: 6px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; background: var(--bg); padding: 14px 18px; border-radius: var(--radius-sm); margin: 14px 0; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps span.on { background: var(--accent); }

/* ---------- tab bar (admin) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; color: var(--muted); border: 0; border-radius: 0; min-height: 44px; padding: 0 14px; white-space: nowrap; font-weight: 600;
  box-shadow: inset 0 -2px 0 transparent; flex: none; }
.tabs button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tabs button:hover { background: none; color: var(--text); }
.tabs button:focus-visible { outline-offset: -2px; }
/* When a bar scrolls sideways, fade the edge that has more (classes set in app.js). */
.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.fade-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px); mask-image: linear-gradient(to right, transparent, #000 48px); }
.fade-l.fade-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); }

/* ---------- dialogs ---------- */
dialog { background: var(--card); color: var(--text); border: 0; border-radius: 14px; padding: 24px; width: min(520px, 92vw); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(14, 16, 20, .5); }
dialog h3 { margin-top: 0; font-size: 18px; }
dialog.wide { width: min(760px, 94vw); }

/* Preview: full-screen viewer */
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border-radius: 0; background: #0b0c0f; color: #f1f2f4; box-shadow: none; overflow: hidden; }
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: #0b0c0f; }
.v-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px) 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(0, 0, 0, .55); z-index: 2; }
.v-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.v-name strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-name span { font-size: 12px; color: #a8acb4; }
.v-btn { background: rgba(255, 255, 255, .1); color: #f1f2f4; border: 0; border-radius: 8px; height: 40px; padding: 0 14px; font-size: 14px; font-weight: 500; box-shadow: none; }
.v-btn:hover { background: rgba(255, 255, 255, .18); }
.v-x { width: 40px; padding: 0; font-size: 16px; }
.v-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; touch-action: pan-y pinch-zoom; }
.v-stage img, .v-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.v-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.v-stage audio { width: min(520px, 90vw); }
.v-stage .v-msg { text-align: center; color: #c9ccd2; padding: 24px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.v-stage .v-msg .icon svg { width: 56px; height: 56px; }
.v-stage .v-msg a.btn { text-decoration: none; }
.v-stage.loading::after { content: ''; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--brand, #f5b301); animation: v-spin .8s linear infinite; position: absolute; }
@keyframes v-spin { to { transform: rotate(360deg); } }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 10px; background: rgba(0, 0, 0, .45); color: #fff; font-size: 34px; line-height: 1; padding: 0; box-shadow: none; z-index: 2; }
.v-nav:hover { background: rgba(0, 0, 0, .7); }
.v-nav:disabled { display: none; }
.v-prev { left: 12px; } .v-next { right: 12px; }
@media (max-width: 640px), (pointer: coarse) {
  .v-nav { width: 40px; height: 52px; font-size: 28px; background: rgba(0, 0, 0, .35); }
  .v-prev { left: 4px; } .v-next { right: 4px; }
  #v-dl { padding: 0 12px; }
}
.dlg-list { max-height: min(55vh, 460px); overflow: auto; margin: 0 -4px; }
.dlg-list table td, .dlg-list table th { padding: 7px 8px; }
.dlg-list .acts { white-space: nowrap; text-align: right; }
.dlg-list .path { word-break: break-all; }
.checks { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 6px 0; }
/* Groups: members as a few faces and a count (one button), and the members panel it opens. */
.face { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--face-bg); color: var(--face-text); font-size: 11px; font-weight: 700; letter-spacing: 0; line-height: 1; }
.mem-sum { display: inline-flex; align-items: center; gap: 10px; padding: 0 12px 0 4px; white-space: nowrap; }
.mem-sum .faces { display: inline-flex; }
.mem-sum .face { box-shadow: 0 0 0 2px var(--card); }
.mem-sum .face + .face { margin-left: -4px; }
.mem-sum:hover .face { box-shadow: 0 0 0 2px var(--bg); }
.mem-add { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--field-line); color: var(--muted); font-size: 17px; font-weight: 500; line-height: 1; box-sizing: border-box; }
.mem-count { margin: 10px 2px 6px; font-size: 13px; min-height: 1.4em; }
.mem-list { max-height: min(50vh, 400px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mem-row { display: flex; align-items: center; gap: 12px; margin: 0; padding: 8px 12px; min-height: 52px; font-weight: 400; cursor: pointer; }
.mem-row + .mem-row { border-top: 1px solid var(--line); }
.mem-row:hover { background: var(--row-hover); }
.mem-sep { position: sticky; top: 0; z-index: 1; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mem-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mem-who strong, .mem-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-who strong { font-size: 14px; font-weight: 600; }
.mem-who span { font-size: 13px; color: var(--muted); }
.mem-row input[type=checkbox] { width: 20px; height: 20px; }
.mem-none { padding: 18px 12px; text-align: center; }
/* Groups list: one row per group (name and buckets | members | desktop settings | Rename/Delete stacked). */
.grp-list > .grp:first-child { padding-top: 0; }
.grp-list > .grp:last-child { padding-bottom: 0; }
.grp { display: grid; grid-template-columns: minmax(0, 1fr) 200px 400px auto; grid-template-areas: "main mem set acts";
  gap: 12px 24px; align-items: center; padding: 18px 0; }
.grp + .grp { border-top: 1px solid var(--line); }
.grp-main { grid-area: main; min-width: 0; }
.grp-name { margin: 0 0 6px; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.grp-buckets { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; }
.grp-buckets .muted { font-size: 13px; }
.grp-b { margin: 0; display: inline-flex; gap: 6px; color: var(--text); }
.grp-acc { color: var(--muted); font-weight: 400; }
.grp-acc::before { content: '·'; margin-right: 6px; }
button.linkish { background: none; border: 0; box-shadow: none; min-height: 0; padding: 0; color: var(--link); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
button.linkish:hover { background: none; }
.grp-mem { grid-area: mem; }
.grp-mem .mem-sum { width: 100%; }
.mem-go { margin-left: auto; padding-left: 4px; color: var(--muted); font-size: 18px; font-weight: 400; line-height: 1; }
.grp-set { grid-area: set; display: grid; gap: 8px; }
/* Computers: labels in one column, lists lined up in the next. */
.grp-set:not(.folded) { grid-template-columns: max-content minmax(0, 1fr); align-items: center; column-gap: 12px; }
.grp-set label { display: contents; margin: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.grp-hint { grid-column: 1 / -1; }
.grp-set select { width: 100%; }
.grp-sync-sum { display: none; font-size: 13px; }
.grp-sync-sum .muted { font-size: 13px; }
.grp-set.folded > :not(.grp-sync-sum) { display: none; }
.grp-set.folded .grp-sync-sum { display: block; }
.grp-hint { margin: 0; font-size: 12px; }
.grp-acts { grid-area: acts; display: flex; flex-direction: column; gap: 12px; }
.grp-acts button { width: 100%; min-width: 84px; }
.grp-acts button.danger { border-color: var(--line); }
.grp-acts button.danger:hover { border-color: var(--danger-line); }
@media (max-width: 1000px) {
  .grp { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main acts" "mem acts" "set set"; align-items: start; }
  .grp-mem .mem-sum { width: auto; }
  .grp-set:not(.folded) { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grp-set label { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .grp-hint { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .grp-set:not(.folded) { grid-template-columns: 1fr; }
  .grp-buckets button.linkish, .grp-sync-sum button.linkish { display: inline-block; padding: 12px 0; margin: -12px 0; }
  .grp-acts button { min-width: 72px; padding-inline: 12px; }
}
.linkbox { display: flex; gap: 8px; margin-top: 10px; }
.linkbox input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.grant-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.grant-row select { min-width: 0; }
.grant-row button { white-space: nowrap; }
.access-help { margin: 0 0 8px; font-size: 12.5px; }
#usage-bars .bar.on span { outline: 2px solid var(--text); outline-offset: 1px; }
.grants-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
td.when { white-space: nowrap; width: 1%; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---------- usage ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.stat-v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-v .muted { font-size: 13px; font-weight: 400; letter-spacing: 0; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 72px; padding-top: 4px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar span { display: block; width: 100%; background: var(--accent, #f5b92e); border-radius: 3px 3px 0 0; opacity: .8; }
.bar:hover span { opacity: 1; }
.bucket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.bucket-head > .btn, .bucket-head > button { flex: none; }
/* How long Backblaze keeps deleted files (Admin > Buckets) */
.keep { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 14px; padding: 8px 12px; border-radius: 8px; font-size: 13px; background: var(--hover, rgba(0,0,0,.04)); }
.keep.warn { background: color-mix(in srgb, #f0a000 14%, transparent); }
.keep .grow { flex: 1; min-width: 200px; }
.keep .grow > div { margin-top: 2px; }
@media (max-width: 640px) { .keep { flex-direction: column; align-items: flex-start; } }
.warn-line { margin-top: 8px; padding: 8px 10px; border-radius: 6px; font-weight: 600; background: color-mix(in srgb, #f0a000 14%, transparent); }
/* Recycle bin: files Backblaze already removed */
.rtable tr.gone td { color: var(--muted); }
.rtable .gone-note { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.rtable .gone-dash { display: inline-block; width: 16px; text-align: center; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }
@media (max-width: 640px) { .qr { flex-direction: column; } }
.card ol { padding-left: 20px; line-height: 1.7; margin: 0; }

/* ---------- files ---------- */
main.wide { max-width: 1200px; }
.files-card { padding: 20px 24px 12px; }
.files-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.files-top select { width: auto; min-width: 180px; font-weight: 600; }
.files-top .inline-label { margin: 0 -2px 0 0; color: var(--muted); font-weight: 500; font-size: 13.5px; }
.files-top .grow { flex: 1; }
.files-top #write-tools { gap: 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 17px; margin: 0 5px 6px; } /* text lines up with the tabs */
.crumbs a { text-decoration: none; padding: 4px 7px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.crumbs a:hover { background: var(--bg); color: var(--text); }
.crumbs span { color: var(--muted); opacity: .7; }
.crumbs strong { padding: 4px 7px; font-weight: 600; }
table.files { margin-top: 4px; }
table.files th { padding: 10px; }
table.files td { padding: 9px 10px; }
table.files .ck { width: 36px; }
table.files .num { text-align: right; white-space: nowrap; }
table.files td:nth-child(4) { white-space: nowrap; }
table.files tr:hover td { background: var(--row-hover); }
table.files tr:has([data-sel]:checked) td { background: var(--row-sel); }
table.files .name a { text-decoration: none; color: var(--text); display: inline-flex; gap: 12px; align-items: center; font-weight: 500; }
table.files .name a:hover .t { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
table.files .acts { white-space: nowrap; text-align: right; }
table.files .by { white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { table.files .by { display: none; } }
/* Row buttons stay quiet until you point at the row */
table.files .acts button.small { margin-left: 2px; background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
table.files tr:hover .acts button.small, table.files tr:focus-within .acts button.small { color: var(--text); }
table.files .acts button.small:hover { background: var(--card); border-color: var(--field-line); }
table.files .acts button.danger.small { color: var(--muted); }
table.files tr:hover .acts button.danger.small, table.files tr:focus-within .acts button.danger.small { color: var(--danger); }
table.files .acts button.danger.small:hover { background: var(--danger-bg); border-color: var(--danger-line); }
.icon { width: 24px; text-align: center; flex: none; display: inline-flex; justify-content: center; }

/* File-type icons (made in files.js) */
.ficon { display: block; width: 24px; height: 24px; overflow: visible; }
.ficon .page { fill: var(--icon-page); stroke: var(--icon-line); stroke-width: 1.3; stroke-linejoin: round; }
.ficon .fold { fill: none; stroke: var(--icon-line); stroke-width: 1.3; stroke-linejoin: round; }
.ficon .tag { fill: var(--k); }
.ficon text { fill: #fff; font: 700 5.4px -apple-system, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: .02em; }
.ficon.folder .back { fill: var(--folder-back); }
.ficon.folder .front { fill: var(--folder-front); }
.k-pdf { --k: #d63a2f; } .k-sheet { --k: #1e8a4a; } .k-doc { --k: #2d6be0; } .k-slides { --k: #dc6511; } .k-image { --k: #8b4fd6; }
.k-video { --k: #d2336d; } .k-audio { --k: #0d8f86; } .k-archive { --k: #8a6b3b; } .k-other { --k: #6b7280; }

.drop-zone { position: relative; min-height: 120px; border-radius: 10px; }
.drop-hint { display: none; }
.drop-zone.over { outline: 2px dashed var(--accent-dark); outline-offset: 2px; background: var(--drop-bg); }
.drop-zone.over .drop-hint { display: grid; place-items: center; position: absolute; inset: 0; font-weight: 600; font-size: 16px; color: var(--link); pointer-events: none; }
/* Empty folder */
.empty-folder { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 44px 20px 40px; }
.empty-folder::before { content: ''; width: 52px; height: 52px; margin-bottom: 10px; background: var(--icon-line);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M2.5 7A2.5 2.5 0 0 1 5 4.5h3.8c.7 0 1.3.3 1.8.8l1.4 1.5H19A2.5 2.5 0 0 1 21.5 9.3v8.2A2.5 2.5 0 0 1 19 20H5a2.5 2.5 0 0 1-2.5-2.5z'/%3E%3Cpath d='M12 10.5v6M9 13.5h6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M2.5 7A2.5 2.5 0 0 1 5 4.5h3.8c.7 0 1.3.3 1.8.8l1.4 1.5H19A2.5 2.5 0 0 1 21.5 9.3v8.2A2.5 2.5 0 0 1 19 20H5a2.5 2.5 0 0 1-2.5-2.5z'/%3E%3Cpath d='M12 10.5v6M9 13.5h6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.empty-folder strong { color: var(--text); font-size: 16px; font-weight: 600; }
.ro .empty-folder::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M2.5 7A2.5 2.5 0 0 1 5 4.5h3.8c.7 0 1.3.3 1.8.8l1.4 1.5H19A2.5 2.5 0 0 1 21.5 9.3v8.2A2.5 2.5 0 0 1 19 20H5a2.5 2.5 0 0 1-2.5-2.5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M2.5 7A2.5 2.5 0 0 1 5 4.5h3.8c.7 0 1.3.3 1.8.8l1.4 1.5H19A2.5 2.5 0 0 1 21.5 9.3v8.2A2.5 2.5 0 0 1 19 20H5a2.5 2.5 0 0 1-2.5-2.5z'/%3E%3C/svg%3E"); }
.on-phone { display: none; }
/* Selection bar: charcoal, like the top bar, so it reads as "you're choosing files" */
.sel-bar { display: flex; gap: 8px; align-items: center; background: var(--bar); color: var(--bar-text); border-radius: 10px; padding: 6px 6px 6px 16px; margin: 4px 0 8px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-pop); }
.sel-bar .grow { flex: 1; }
.sel-bar button.danger { background: var(--danger-solid); color: #fff; border-color: transparent; }
.sel-bar button.danger:hover { background: var(--danger); }
.sel-bar button.ghost { background: transparent; color: var(--bar-text); border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.sel-bar button.ghost:hover { background: var(--bar-hover); }
.sel-bar :focus-visible { outline-color: var(--accent); }
/* Upload list */
.up { display: grid; grid-template-columns: minmax(0, 1fr) 140px 80px; gap: 6px 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.up:last-child { border-bottom: 0; }
.up > div:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up strong { font-weight: 500; }
.up .bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.up .bar span { display: block; height: 100%; background: var(--accent); width: 0; border-radius: 6px; opacity: 1; transition: width .2s; }
.up.done .bar span { background: var(--ok); }
.up.failed .bar span { background: var(--danger); }
.up .st { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.up.done .st { color: var(--ok); }
.up.failed .st { color: var(--danger); font-weight: 600; }
.up .err { grid-column: 1 / -1; color: var(--danger); font-size: 13px; }
.ro .w-only { display: none !important; }
label.btn { margin: 0; font-size: 14px; }

/* ---------- tablets ---------- */
header.top nav a, header.top .brand { white-space: nowrap; }

/* "Select all" in the selection bar: phones only (computers have the tick box in the table header). */
.sel-bar .sel-all { display: none; }

/* Download as zip */
.zipbar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 14px; }
.zipbar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 8px; transition: width .2s; }
#zip-sub { font-variant-numeric: tabular-nums; word-break: break-word; }

/* Search box */
.files-top .search { flex: 0 1 260px; min-width: 160px; }
.files-top .search input { width: 100%; padding-left: 34px; background: var(--card) no-repeat 11px 50% / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a909c' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.files-top .search input::-webkit-search-cancel-button { cursor: pointer; }

/* All files / Starred / Recent */
.views-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; border-bottom: 1px solid var(--line); }
.views { display: flex; gap: 4px; flex: 1; min-width: 0; }
/* Recycle bin: a quiet link at the end of the tabs row (on phones it's in the + menu). */
.bin-link { background: none; border: 0; box-shadow: none; min-height: 38px; padding: 0 0 0 8px; color: var(--muted); font-weight: 500; font-size: 14px; gap: 6px; }
.bin-link:hover { background: none; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.views button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); font-weight: 600; font-size: 14px;
  height: 38px; padding: 0 12px; margin-bottom: -1px; box-shadow: none; }
.views button:hover { color: var(--text); background: none; }
.views button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.crumbs.views-off { display: none !important; }
/* Stars: shown when set; on computers the empty ☆ appears when you point at the row */
.star { background: none; border: 0; box-shadow: none; padding: 0; width: 30px; height: 30px; min-height: 0; border-radius: 50%; font-size: 17px; line-height: 1;
  color: var(--muted); cursor: pointer; vertical-align: middle; margin-left: 4px; }
.star:hover { background: var(--bg); color: var(--text); }
.star.on { color: var(--accent-dark); }
table.files td.name .star:not(.on) { opacity: 0; }
table.files tr:hover td.name .star, table.files td.name .star:focus-visible { opacity: 1; }
table.files td.name a { vertical-align: middle; }
/* Starred and Recent lists */
.alt-sec { margin: 6px 0 18px; }
.alt-sec h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.alist { list-style: none; margin: 0; padding: 0; }
.alist li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.alist li:hover { background: var(--row-hover); }
.alist .arow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 9px 6px; color: var(--text); text-decoration: none; }
.alist .icon { width: 28px; flex: none; }
.alist .nm { display: flex; flex-direction: column; min-width: 0; }
.alist .nm .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alist .nm .meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alist .more { display: inline-flex; width: 36px; height: 36px; min-height: 0; align-items: center; justify-content: center; padding: 0; border: 0;
  background: none; color: var(--muted); font-size: 20px; border-radius: 50%; cursor: pointer; box-shadow: none; flex: none; }
.alist .more:hover { background: var(--bg); }
.alt .empty strong { color: var(--text); }
.alt-loading { padding: 10px 6px; }

/* The ⋮ button on each row, and the phones' action sheet */
table.files td.acts .more { display: inline-flex; width: 36px; height: 40px; min-height: 0; align-items: center; justify-content: center; padding: 0; border: 0;
  background: none; color: var(--muted); font-size: 22px; border-radius: 50%; cursor: pointer; box-shadow: none; }
table.files td.acts .more:hover { background: var(--bg); }
table.files .nm .meta { display: none; }
.fab { display: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 6px 6px 14px; border-bottom: 1px solid var(--line); }
.sheet-head .icon { width: 36px; }
.sheet-head .ficon { width: 34px; height: 34px; }
.sheet-head strong { display: block; word-break: break-word; line-height: 1.3; }
.sheet-act { display: block; width: 100%; min-height: 52px; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 16px; font-weight: 500;
  padding: 0 10px; border-bottom: 1px solid var(--line); border-radius: 0; cursor: pointer; box-shadow: none; }
.sheet-act:last-child { border-bottom: 0; }
.sheet-act:hover, .sheet-act:focus-visible { background: var(--bg); }
.sheet-act:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--accent); }
.sheet-act.danger-text { color: var(--danger); }
dialog.sheet:focus { outline: none; }
.sheet-cancel { width: 100%; margin-top: 10px; min-height: 48px; }

/* ---------- phones and small screens (and phones turned sideways) ---------- */
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  /* Header: one row. The logo stands in for the word "Kdrive"; the menu scrolls sideways if it ever doesn't fit. */
  header.top { height: 52px; padding: 0 10px 0 12px; gap: 6px; }
  header.top .brand { font-size: 0; gap: 0; }
  header.top .brand .logo { width: 30px; height: 30px; }
  header.top nav { overflow-x: auto; scrollbar-width: none; }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { white-space: nowrap; padding: 0 10px; font-size: 15px; }
  .avatar { width: 38px; height: 38px; font-size: 12.5px; }

  main { margin: 12px auto; padding: 0 10px; }
  main.narrow { padding-top: 28px; }
  body:has(> main.narrow) { background: linear-gradient(var(--bar) 0 170px, var(--bg) 170px); }
  .card { padding: 18px 16px; border-radius: 14px; }
  .bucket-head { flex-wrap: wrap; align-items: flex-start; }
  .tabs { margin: 0 -10px 14px; padding: 0 6px; }
  .tabs button { padding: 0 11px; }
  /* Bigger targets for fingers, and 16px text so phones don't zoom into fields. */
  input, select, textarea { font-size: 16px !important; min-height: 44px; }
  button.small { min-height: 36px; padding: 0 12px; }

  /* Tables become a list of small cards; each value is labelled with its column name (set in app.js). */
  table:not(.files), table:not(.files) tbody, table:not(.files) tr, table:not(.files) td { display: block; width: 100%; }
  table:not(.files) tr:has(> th) { display: none; }
  table:not(.files) tr { border-bottom: 1px solid var(--line); padding: 12px 0; }
  table:not(.files) tr:last-child { border-bottom: 0; }
  table:not(.files) td { border: 0; padding: 3px 0; }
  /* Label and value on one line; the first column is the card's title. */
  table:not(.files) td { display: flex; align-items: baseline; gap: 10px; }
  table:not(.files) td[data-label]:not([data-label=""])::before {
    content: attr(data-label); flex: none; width: 96px; font-size: 12.5px; color: var(--muted); font-weight: 500;
  }
  table:not(.files) td.num { text-align: left; }
  table:not(.files) td:first-child { font-size: 15px; }
  table:not(.files) td:first-child::before { display: none !important; }
  table:not(.files) td:first-child { display: block; padding-bottom: 6px; }
  table:not(.files) td:empty { display: none; }
  table:not(.files) td:last-child:has(> button), table:not(.files) td:last-child:has(> .grp-acts) { padding-top: 8px; }

  /* Files: one line per file (icon, name, size · date) with a ⋯ menu; + button for adding. */
  .files-top .search { flex: 1 1 100%; min-width: 0; order: 1; }
  .views-row { margin: 2px -4px 8px; }
  .views button { flex: 1; padding: 0 6px; }
  table.files td.name { display: flex; align-items: center; }
  table.files td.name a { flex: 1; }
  table.files td.name .star:not(.on) { display: none; }
  table.files td.name .star.on { opacity: 1; flex: none; }
  .alist .star:not(.on) { display: none; }
  .alist .arow { padding: 10px 2px; }
  .files-card { padding: 12px 12px 4px; }
  .files-top { gap: 8px; margin-bottom: 4px; }
  .files-top .inline-label, .files-top #write-tools, #recycle { display: none !important; }
  .files-top select { flex: 1 1 100%; width: 100%; min-width: 0; }
  .files-top .grow { display: none; }
  .crumbs { font-size: 16px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; scrollbar-width: none; margin: 0 -4px 2px; }
  table.files thead { display: none; }
  table.files, table.files tbody { display: block; }
  table.files tr { display: grid; grid-template-columns: 0 1fr 40px; align-items: center; min-height: 60px; border-bottom: 1px solid var(--line); }
  table.files tr:last-child { border-bottom: 0; }
  body.selecting table.files tr { grid-template-columns: 34px 1fr 40px; }
  table.files td { border: 0; padding: 0; }
  table.files td.ck { overflow: hidden; width: auto; }
  body:not(.selecting) table.files td.ck input { visibility: hidden; }
  table.files td.num, table.files td.muted:not(.acts), table.files td.by { display: none; }
  table.files td.name { min-width: 0; }
  table.files td.name a { display: flex; align-items: center; gap: 12px; padding: 8px 0; min-width: 0; }
  table.files td.name .icon { width: 32px; }
  table.files td.name .ficon { width: 30px; height: 30px; }
  table.files .nm { display: flex; flex-direction: column; min-width: 0; }
  table.files .nm .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; line-height: 1.3; }
  table.files .name a:hover .t { color: inherit; text-decoration: none; }
  table.files .nm .meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
  table.files td.acts { text-align: right; }
  table.files td.acts button:not(.more) { display: none; }
  table.files td.acts .more { display: inline-flex; }
  table.files tr:hover td { background: none; }
  table.files tr:has([data-sel]:checked) { background: var(--row-sel); margin: 0 -12px; padding: 0 12px; }
  table.files tr:has([data-sel]:checked) td { background: none; }
  .on-big { display: none; }
  .on-phone { display: inline; }
  .empty-folder { padding: 40px 16px 44px; }
  .fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; min-height: 0; border-radius: 18px;
    font-size: 30px; font-weight: 500; line-height: 1; padding: 0; display: grid; place-items: center; z-index: 20;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 22px rgba(0, 0, 0, .22); }
  .fab.hidden { display: none; }
  main.wide { padding-bottom: 84px; } /* room for the + button */
  .sel-bar { position: sticky; top: 8px; z-index: 5; }

  /* Action sheet slides up from the bottom */
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); }
  dialog.sheet::before { content: ''; display: block; width: 38px; height: 5px; border-radius: 5px; background: var(--field-line); margin: 0 auto 10px; }
  dialog.sheet { border-top: 1px solid var(--line); } /* its edge stays visible in dark mode */
  /* Dialogs sit near the top, so the on-screen keyboard doesn't cover their buttons. */
  dialog:not(.sheet):not(.viewer) { margin: 64px auto auto; max-height: calc(100dvh - 76px); overflow: auto; }
  /* The + button would cover row menus while choosing files; the selection bar has the actions. */
  body:has(#sel-bar:not(.hidden)) .fab { display: none; }
  /* Usage numbers two per row. */
  .stat-row { grid-template-columns: 1fr 1fr; }
  /* Selection bar: wraps instead of running off small screens; bigger buttons; Select all. */
  .sel-bar { flex-wrap: wrap; row-gap: 6px; padding: 6px 6px 6px 14px; }
  #sel-count { white-space: nowrap; }
  .sel-bar .sel-all { display: inline-flex; }
  .sel-bar button { min-height: 40px; padding: 0 12px; }
  /* Recycle bin: one row per file, the whole row ticks it. */
  table.rtable tr:has(> th) { display: flex; align-items: center; padding: 4px 0 12px; }
  table.rtable th { border: 0; padding: 0; }
  table.rtable tr:has(> th) th:not(.ck) { display: none; }
  table.rtable tr:has(> th) th.ck { display: flex; align-items: center; color: var(--text); font-size: 14px; }
  table.rtable tr:has(> th) th.ck::after { content: 'Select all'; font-weight: 600; margin-left: 12px; }
  html:lang(zh) table.rtable tr:has(> th) th.ck::after { content: '全選'; }
  table.rtable tr:not(:has(> th)) { position: relative; padding-left: 34px; cursor: pointer; }
  table.rtable td.ck { position: absolute; left: 0; top: 12px; padding: 0; }
  table.rtable td::before { display: none !important; }
  /* Size · Deleted by · When on one small line under the name. */
  table.rtable td:not(.ck):not(.path) { display: inline; padding: 0; font-size: 13px; }
  table.rtable td:not(.ck):not(.path):not(:last-child)::after { content: ' · '; }
  table.rtable td.path { display: block; font-size: 15px; font-weight: 500; word-break: break-word; padding: 0 0 3px; }
  table.rtable input[type=checkbox] { width: 22px; height: 22px; }
  /* The desktop app is for computers: no "Get the app" in the phone menu (the page still works). */
  header.top nav a.desktop-only:not(.on) { display: none; }
  /* Admin tabs wrap into rows of chips, so every tab is visible. */
  .tabs { flex-wrap: wrap; gap: 6px; overflow: visible; border-bottom: 0; margin-bottom: 14px; -webkit-mask-image: none !important; mask-image: none !important; }
  .tabs button { min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
  .tabs button.on { background: var(--bar); color: var(--bar-text); border-color: var(--bar); box-shadow: none; }
  /* Bucket access: one bordered card per person or group, with access and Remove side by side. */
  .grant-row { grid-template-columns: minmax(0, 1fr) auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; gap: 8px; }
  .grant-row select[name=who] { grid-column: 1 / -1; }
  .grant-row button { min-height: 40px; }
  /* Bigger tap targets */
  .crumbs a { padding: 9px 8px; }
  .up { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name st" "bar bar"; }
  .up > div:first-child { grid-area: name; }
  .up .bar { grid-area: bar; }
  .up .st { grid-area: st; }
  .linkbox { flex-wrap: wrap; }
  .codes { grid-template-columns: 1fr; }
}
@media (max-width: 640px) and (prefers-reduced-motion: no-preference), (pointer: coarse) and (max-height: 500px) and (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); }
  @keyframes sheet-up { from { transform: translateY(40%); opacity: .4; } }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Admin: file types */
.ext-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.linkish { background: none; border: 0; padding: 0 0 0 4px; color: inherit; cursor: pointer; font: inherit; min-height: 0; height: auto; box-shadow: none; display: inline; }
.linkish:hover { color: var(--danger); background: none; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 18px; }
.check-line input { width: auto; margin: 0; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.dim { opacity: .5; }

/* "Link copied" note */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  width: max-content; max-width: min(92vw, 420px); padding: 10px 14px; border-radius: 10px; background: var(--bar); color: var(--bar-text);
  font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
/* The file a link pointed to */
table.files tr.hl, table.files tr.hl td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
table.files tr.hl td { background: transparent; }
table.files tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
@media (min-width: 641px) and (max-width: 1100px) { table.files th.by, table.files td.by { display: none; } }
#err { margin: 0 0 12px; }
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) { .toast { bottom: calc(88px + env(safe-area-inset-bottom)); } }

/* Computers: the ⋯ menu (and right-click) as a small vertical list */
table.files td.acts { width: 52px; }
.pmenu { position: fixed; z-index: 55; min-width: 190px; padding: 5px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-pop); }
.pmenu button { display: block; width: 100%; min-height: 32px; padding: 0 14px 0 12px; border: 0; border-radius: 6px; background: none;
  box-shadow: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; }
.pmenu button:hover, .pmenu button:focus-visible { background: var(--bg); outline: none; }
.pmenu button.danger-text { color: var(--danger); }
.pmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
table.files td.acts .more[aria-expanded="true"] { background: var(--bg); color: var(--text); }
table.files td.acts .more:focus-visible, .alist .more:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .pmenu { border-color: color-mix(in srgb, var(--line) 60%, #fff); } }
:root[data-theme="dark"] .pmenu { border-color: color-mix(in srgb, var(--line) 60%, #fff); }

/* Chinese: Taiwan system fonts; the page stays hidden for the moment it is still in English (i18n.js). */
:lang(zh-Hant-TW) body { font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", Roboto, sans-serif; }
.i18n-wait body { visibility: hidden; }

/* Admin Activity: search, kind of event and Search in one toolbar above the list; "Load more" below it. */
.act-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.act-search { flex: 1 1 280px; min-width: 0; }
.act-search input { padding-left: 34px; background: var(--card) no-repeat 11px 50% / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a909c' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.act-search input::-webkit-search-cancel-button { cursor: pointer; }
.act-bar select { flex: 0 0 auto; width: auto; min-width: 150px; }
.act-bar button { flex: none; }
#activity[aria-busy=true] { opacity: .55; transition: opacity .15s; }
#activity .empty .linkish { margin-left: 6px; }
.act-err { margin: 0; color: var(--danger); }
/* Under the list: "Showing N events" over a centred Load more (hidden when there's nothing to show). */
.act-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.act-foot:not(:has(> :not([hidden]):not(:empty))) { display: none; }
.act-foot #activity-status:focus { outline: none; }
.act-foot #activity-status:empty { display: none; }
.act-foot button { min-width: 180px; }
.act-foot [hidden] { display: none !important; }
.act-foot button[aria-disabled=true] { opacity: .55; cursor: default; }
/* Fixed column widths on computers, so the columns don't jump as more rows load or the search changes. */
@media (min-width: 641px) {
  table.act-list { table-layout: fixed; }
  table.act-list th:nth-child(1) { width: 150px; }
  table.act-list th:nth-child(2) { width: 18%; }
  table.act-list th:nth-child(3) { width: 22%; }
  table.act-list td { overflow-wrap: anywhere; }
}
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  /* Search box + Search on the first row, the two dropdowns side by side on the second. */
  .act-search { flex: 1 1 calc(100% - 96px); order: 1; }
  .act-bar button { min-height: 44px; width: 88px; padding: 0 8px; order: 2; }
  .act-search input { min-height: 44px; }
  .act-bar select, .act-bar #activity-when { flex: 1 1 calc(50% - 4px); min-width: 0; order: 3; }
  .act-foot { align-items: stretch; }
  .act-foot button { width: 100%; min-height: 44px; }
}
