/* HCG Casebooks. The look is CancerOS's (canceros-chat-runtime,
   ui/styles/app.css): a warm cream rail, a white working canvas, cream
   cards and hairlines, one blue accent. The base, motion, controls, cards,
   tables, dialogs and sign-in rules below are taken from there, so the two
   read as one family; the folder, case header and upload rules at the end
   are this app's own, written the same way. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--text-body);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-500); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); color: var(--text-strong); letter-spacing: var(--ls-tight); }
h1 { font-size: var(--fs-h1); font-weight: 600; line-height: var(--lh-snug); }
h2 { font-size: var(--fs-h2); font-weight: 600; line-height: var(--lh-snug); }
h3 { font-size: var(--fs-h3); font-weight: 600; }
p { margin: 0 0 var(--space-2); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.overline { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: var(--fs-body-sm); }
.caption { font-size: var(--fs-caption); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---- motion ------------------------------------------------------------ */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
/* Things arrive by rising and settling, and leave by sinking and fading, a
   little faster than they came. Dialogs scale from just under full size so
   the glass reads as a sheet lifting off the page. */
@keyframes sink { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.975); } to { opacity: 1; transform: none; } }
@keyframes sheet-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scrim-out { from { opacity: 1; } to { opacity: 0; } }
.overlay { animation: scrim-in var(--dur-base) var(--ease-out) both; }
.overlay .modal { animation: sheet-in var(--dur-slow) var(--ease-out) both; }
.overlay.leaving { animation: scrim-out var(--dur-base) ease-in both; }
.overlay.leaving .modal { animation: sheet-out var(--dur-base) ease-in both; }
.toast.leaving { animation: sink var(--dur-base) ease-in both; }

/* ---- motion primitives (core/motion.ts) --------------------------------
   After ibelick's motion-primitives, as classes. Text Effect: a word
   arriving, inline so the text wraps as it did. Animated Group: an item
   arriving, with a delay per item in --mp-delay. Transition Panel: the old
   panel is lifted out of the flow and sinks away while the new one takes
   its room. Text Shimmer: a sheen along a line still being worked on. */
@keyframes mp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mp-blur { from { opacity: 0; filter: blur(8px); } to { opacity: 1; filter: blur(0); } }
@keyframes mp-blur-slide { from { opacity: 0; filter: blur(8px); transform: translateY(10px); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes mp-slide { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes mp-scale { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes mp-word { from { opacity: 0; filter: blur(5px); } to { opacity: 1; filter: blur(0); } }
@keyframes mp-out { to { opacity: 0; transform: translateY(6px); filter: blur(3px); } }
.mp-w { animation: mp-word 360ms var(--ease-out) both; }
.mp-w.mp-fade { animation-name: mp-fade; }
.mp-in { animation: mp-fade var(--dur-slow) var(--ease-out) both; animation-delay: var(--mp-delay, 0ms); }
.mp-in.mp-blur { animation-name: mp-blur; }
.mp-in.mp-blur-slide { animation-name: mp-blur-slide; }
.mp-in.mp-slide { animation-name: mp-slide; }
.mp-in.mp-scale { animation-name: mp-scale; }
.mp-host { position: relative; }
.mp-out { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; animation: mp-out var(--dur-base) ease-in both; }
@keyframes mp-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.mp-shimmer { display: inline-block; color: transparent;
  background: linear-gradient(90deg, var(--text-muted) 40%, var(--text-strong) 50%, var(--text-muted) 60%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; animation: mp-shimmer 2.2s linear infinite; }
/* Border Trail: a light runs round the edge of a box that is being worked
   on. The mask keeps only the border of the box; the streak follows the
   box's own rectangle (offset-path rect). core/motion.ts borderTrail(). */
.mp-trail { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; border: 1.5px solid transparent;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude; }
.mp-trail i { position: absolute; height: 6px; display: block; offset-rotate: auto; offset-anchor: 100% 50%;
  background: linear-gradient(90deg, transparent 0%, rgba(47, 86, 230, 0.35) 35%, rgba(47, 86, 230, 0.7) 60%, transparent 100%);
  animation: mp-trail 6s linear infinite; }
@keyframes mp-trail { from { offset-distance: 0%; } to { offset-distance: 100%; } }
/* Animated Background: one highlight slides to the chosen item, instead of
   each item painting its own. core/motion.ts animatedBackground(). */
.mp-bg-host { position: relative; }
.mp-bg-host > :not(.mp-bg) { position: relative; z-index: 1; }
.mp-bg { position: absolute; top: 0; left: 0; z-index: 0; opacity: 0; pointer-events: none;
  transition: transform var(--dur-slow) var(--ease-out), width var(--dur-slow) var(--ease-out), height var(--dur-slow) var(--ease-out), opacity var(--dur-base); }
/* Animated Number: figures of one width, so a changing count does not jiggle. */
.mp-num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .mp-shimmer { color: inherit; background: none; } .mp-trail { display: none; } }

/* ---- shell ------------------------------------------------------------- */

.app { display: grid; grid-template-columns: 248px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; }
/* Gradient mesh keyframes. One background-position list per keyframe, one
   entry per blob; the entries move at different rates and directions so
   the blobs cross rather than slide together. The base layer stays put. */
@keyframes railmesh {
  0%   { background-position: 100% 0%, 0% 100%, 50% 60%, 0% 0%, 100% 100%, 0 0; }
  33%  { background-position: 40% 40%, 60% 60%, 100% 0%, 80% 100%, 0% 30%, 0 0; }
  66%  { background-position: 0% 100%, 100% 0%, 20% 100%, 100% 30%, 50% 0%, 0 0; }
  100% { background-position: 80% 100%, 100% 20%, 0% 30%, 20% 60%, 90% 80%, 0 0; }
}
.rail {
  /* The cream rail, with the brand mesh kept as a faint tint: blobs drift
     slowly over the cream-to-paper fade. Each layer's background-size is
     larger than the element and its position sweeps, so the blobs move
     without the gradients ever being repainted. */
  position: relative; isolation: isolate;
  background-color: var(--cream-50);
  background-image:
    radial-gradient(900px 900px at 50% 50%, rgba(117, 141, 250, 0.10) 0%, rgba(117, 141, 250, 0) 70%),
    radial-gradient(1100px 1100px at 50% 50%, rgba(117, 231, 239, 0.08) 0%, rgba(117, 231, 239, 0) 70%),
    radial-gradient(800px 800px at 50% 50%, rgba(107, 180, 247, 0.07) 0%, rgba(107, 180, 247, 0) 70%),
    radial-gradient(760px 760px at 50% 50%, rgba(168, 121, 250, 0.06) 0%, rgba(168, 121, 250, 0) 70%),
    radial-gradient(1000px 1000px at 50% 50%, rgb(var(--glass-rgb) / 0.40) 0%, rgb(var(--glass-rgb) / 0) 70%),
    linear-gradient(180deg, var(--cream-100) 0%, var(--cream-50) 100%);
  background-size: 400% 400%, 400% 400%, 400% 400%, 400% 400%, 400% 400%, 100% 100%;
  background-repeat: no-repeat;
  animation: railmesh 40s ease-in-out infinite alternate;
  border-right: 1px solid var(--cream-border);
  color: var(--ink-700);
  display: flex; flex-direction: column;
  padding: var(--space-4) var(--space-4);
  gap: 4px;
  min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .mark { padding: 4px 4px 18px 10px; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; border-radius: var(--radius-sm); }
.rail .mark img { height: 28px; width: 28px; display: block; flex: none; }
/* The name in two lines: what this is, and whose. */
.brand { display: grid; min-width: 0; line-height: 1.15; }
.brand .wordmark { font-size: 16px; letter-spacing: -0.2px; }
/* The cross between the two names: lighter than either. */
.wordmark .cross { margin: 0 0.3em; font-weight: 400; color: var(--text-subtle); }
.brand .byline { font-size: 11px; font-weight: 500; color: var(--text-subtle); letter-spacing: .02em; margin-top: 2px; }
.rail .mark:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.wordmark { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -0.3px; color: var(--ink-900); white-space: nowrap; }
.wordmark b { font-weight: 600; color: var(--accent-600); }
.rail .rail-group { display: flex; flex-direction: column; gap: 3px; margin-bottom: var(--space-5); }
.rail .rail-group-label { font-size: 12px; color: var(--ink-600); padding: 0 10px 8px; white-space: nowrap; }
.rail .rail-recent { flex: 1 1 auto; min-height: 0; margin-bottom: var(--space-2); overflow: hidden; }
.rail .recent-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
.rail .recent-list::-webkit-scrollbar { display: none; }
.rail .navbtn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; color: var(--ink-900);
  min-height: 38px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 15.5px; font-weight: 400; text-align: left;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.rail .navbtn svg { width: 18px; height: 18px; flex: none; color: var(--ink-700); }
.rail .navbtn:hover { background: var(--cream-300); }
.rail .navbtn.active { background: var(--cream-300); font-weight: 500; }
.rail .navbtn.active svg { color: var(--accent-600); }
.rail .navbtn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.rail .navbtn.recent { min-height: 32px; padding: 5px 10px; gap: 10px; font-size: 13.5px; color: var(--ink-700); }
.rail .navbtn.recent svg { width: 15px; height: 15px; color: var(--ink-500); }
.rail .navbtn.recent .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-family: var(--font-mono); }
.rail .navbtn.recent.active { color: var(--ink-900); }
.rail .foot { margin: auto calc(-1 * var(--space-3)) 0; padding: var(--space-2) var(--space-3) 0; border-top: 1px solid var(--cream-border); display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 14px; }
.rail .foot .who { flex: 1; min-width: 0; display: grid; }
.rail .foot .who b { color: var(--ink-900); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .foot .who span { font-size: 12px; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .foot .rail-av { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--avatar-0); color: var(--blue-850); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.rail .sign-out svg { transform: scaleX(-1); }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wash-soft); }
.content { flex: 1; overflow-y: auto; padding: var(--space-8) var(--space-8) 80px; min-height: 0; }
.content > * { animation: rise var(--dur-slow) var(--ease-out) both; }
.page { max-width: 1200px; margin: 0 auto; }
.page.narrow { max-width: 920px; }
.page-head { display: flex; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-head h1 { margin-bottom: 4px; }
.page-head .lead { color: var(--text-muted); font-size: var(--fs-body); }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---- controls ---------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--white); color: var(--text-strong);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(0.98); background: var(--surface-pressed); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn:disabled { color: var(--text-subtle); background: var(--surface-sunken); border-color: var(--cream-border); cursor: not-allowed; }
/* Two fills only: .primary for the one verb a screen exists for, and the
   plain bordered button for every other command. */
.btn.primary { background: var(--accent-600); border-color: var(--accent-600); color: var(--on-bold); }
.btn.primary:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn.primary:active { background: var(--blue-850); }
.btn.primary:disabled { background: var(--accent-300); border-color: var(--accent-300); color: var(--on-bold); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-body); }
.btn.ghost:hover { background: var(--accent-50); color: var(--accent-700); }
.btn.danger { color: var(--danger-600); }
.btn.danger:hover { background: var(--danger-100); }
.btn.danger.primary { background: var(--danger-500); border-color: var(--danger-500); color: var(--on-bold); }
.btn.danger.primary:hover { background: var(--danger-600); border-color: var(--danger-600); }
.btn.sm { padding: 6px 11px; font-size: 13px; }

.iconbtn {
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; flex: none;
}
.iconbtn svg { width: 18px; height: 18px; display: block; }
.iconbtn:hover { background: rgba(60, 50, 30, .08); border-color: rgba(60, 50, 30, .14); color: var(--text-strong); }
.iconbtn:active { background: rgba(60, 50, 30, .14); }
/* Destructive icons are grey at rest and only turn red under the pointer,
   so a row of controls does not shout delete. */
.iconbtn.danger:hover { background: var(--danger-100); border-color: var(--danger-200); color: var(--danger-600); }
.iconbtn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.linkbtn { border: 0; background: transparent; padding: 0; color: var(--accent-600); font-weight: 500; cursor: pointer; border-radius: 4px; }
.linkbtn:hover { color: var(--accent-700); text-decoration: underline; }
.linkbtn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.linkbtn:disabled { color: var(--text-subtle); cursor: default; text-decoration: none; }

input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], select {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  background: var(--white); outline: none; color: var(--text-strong);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input::placeholder { color: var(--text-muted); }
input:hover, select:hover { background: var(--surface-faint); }
input:focus-visible, select:focus-visible { background: var(--white); border-color: var(--accent-600); box-shadow: var(--ring-focus); }
/* .field-label is the same label for a group of controls that is not one
   input (the Sex choice), where a <label> has nothing to point at. */
label, .field-label { display: block; font-size: var(--fs-caption); color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: var(--space-4); min-width: 0; }
.field .hint { margin: 6px 0 0; font-size: var(--fs-caption); color: var(--text-subtle); }
/* A field whose answer is a few characters: the box is as wide as that. */
.field.short input { max-width: 160px; }
.err { color: var(--danger-600); font-size: 14px; margin: 0 0 12px; }
.err:empty { display: none; }

/* A choice of a few: a cream track with one white pill that slides to the
   chosen option (Animated Background). The options are real radio buttons,
   so the arrow keys move between them. */
/* The track is a warm tint rather than a cream, so it shows on the white
   page and on a dialog's cream glass alike. */
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: rgba(60, 50, 30, 0.07); gap: 2px; max-width: 100%; }
.seg label { margin: 0; padding: 6px 14px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 400; cursor: pointer; color: var(--ink-700); white-space: nowrap; transition: color var(--dur-fast); min-width: 0; }
.seg label[data-checked="true"] { color: var(--ink-900); font-weight: 500; }
.seg label:has(input:focus-visible) { box-shadow: var(--ring-focus); }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.seg .mp-bg { background: var(--white); border-radius: var(--radius-pill); box-shadow: var(--shadow-xs); }
.seg.wide { display: flex; }
.seg.wide label { flex: 1; text-align: center; }

/* ---- cards and data ---------------------------------------------------- */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-6);
}
/* Cards stacked down a page are spaced; cards in a grid use the grid's gap. */
.page > .card + .card { margin-top: var(--space-4); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); }
.card-head h3 { margin: 0; }
.card-head .sub { color: var(--text-subtle); font-size: var(--fs-caption); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--text-muted); font-size: 13px; }
/* A table wider than its card scrolls inside it rather than spilling out. */
.table-host { overflow-x: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  background: var(--cream-200); color: var(--ink-700); border: 1px solid transparent;
  white-space: nowrap; max-width: 100%; min-width: 0;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
/* Status lozenges: a faint fill, the status colour for the text, a subtle
   edge. The text names the status; colour is reinforcement. */
.badge.accent { background: var(--accent-50); color: var(--accent-700); border-color: var(--accent-100); }
.badge.success { background: var(--success-200); color: var(--success-600); border-color: var(--success-300); }
.badge.warning { background: var(--warning-200); color: var(--warning-600); border-color: var(--warning-300); }
/* A cancer is a fact, not a status: a tint of its own colour with no edge.
   Outside the semantic scale on purpose, so it is never read as good or bad. */
.badge.cancer { background: rgba(var(--cancer-rgb), 0.10); color: var(--cancer); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .name { font-weight: 600; color: var(--text-strong); }
td .meta { color: var(--text-subtle); font-size: var(--fs-caption); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.acts { width: 1%; white-space: nowrap; text-align: right; }
td.acts > * { display: inline-grid; vertical-align: middle; }
tr.off td { color: var(--text-subtle); }
tr.off td .name { color: var(--text-muted); font-weight: 500; }

.progress { height: 6px; border-radius: 3px; background: var(--cream-200); overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-gradient); transition: width var(--dur-base) linear; }
.spin { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--accent-200); border-top-color: var(--accent-600); animation: spin 0.8s linear infinite; display: inline-block; }
.spin.big { width: 28px; height: 28px; border-width: 3px; }

.empty { text-align: center; padding: 72px 24px; color: var(--text-muted); }
.empty h2 { font-weight: 500; margin-bottom: 8px; }
.empty .sub { max-width: 46ch; margin: 0 auto 20px; }
.empty .empty-ic { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; background: var(--accent-50); color: var(--accent-600); display: grid; place-items: center; }
.empty .empty-ic svg { width: 26px; height: 26px; }
.empty.slim { padding: 32px 24px; }
.loading { display: grid; place-items: center; padding: 96px 24px; }

/* ---- dialogs and toasts ------------------------------------------------ */

.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(17, 19, 21, 0.32); backdrop-filter: var(--scrim-blur); -webkit-backdrop-filter: var(--scrim-blur); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--acrylic-light-strong); backdrop-filter: var(--acrylic-blur); -webkit-backdrop-filter: var(--acrylic-blur); border-radius: var(--radius-lg); padding: 22px 24px; width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--acrylic-shadow), var(--acrylic-edge); }
.modal:focus { outline: none; }
.modal-text { margin-bottom: 16px; }
.modal-text h2 { font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.modal-text p { color: var(--text-muted); font-size: 14px; margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; top: 20px; left: 50%; translate: -50% 0; z-index: 120; background: var(--acrylic-dark); backdrop-filter: var(--acrylic-blur); -webkit-backdrop-filter: var(--acrylic-blur); color: #fff; padding: 11px 16px; border-radius: var(--radius-md); box-shadow: var(--acrylic-shadow), inset 0 1px 0 rgb(var(--glass-rgb) / 0.18); font-size: 14px; max-width: min(460px, calc(100vw - 32px)); animation: rise var(--dur-base) var(--ease-out) both; }
.toast.error { background: linear-gradient(135deg, rgba(211, 47, 47, 0.88) 0%, rgba(114, 19, 16, 0.88) 100%); }

/* A quiet note beside a control: an icon and a sentence. */
.note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--text-body); font-size: 13px; line-height: 1.45; }
.note > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--text-muted); }
.note.warn { background: var(--warning-100); color: var(--warning-600); }
.note.warn > svg { color: var(--warning-600); }
.note b { font-weight: 600; }

/* ---- sign-in -----------------------------------------------------------
   CancerOS's sign-in: one viewport in the app's cream with the rail's mesh
   drifting over it, a 1080px column, the pitch on the left and the card
   (400px) on the right. The card is white with a wide soft shadow, radius
   20; fields 44px, the button 46px. */
.login { display: flex; flex-direction: column; color: var(--ink-900); background: var(--cream-50); }
.login-body { min-height: 100vh; min-height: 100dvh; width: 100%; padding: 64px 48px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center;
  position: relative; isolation: isolate;
  background-color: var(--cream-50);
  background-image:
    radial-gradient(900px 900px at 50% 50%, rgba(117, 141, 250, 0.14) 0%, rgba(117, 141, 250, 0) 70%),
    radial-gradient(1100px 1100px at 50% 50%, rgba(117, 231, 239, 0.10) 0%, rgba(117, 231, 239, 0) 70%),
    radial-gradient(800px 800px at 50% 50%, rgba(107, 180, 247, 0.10) 0%, rgba(107, 180, 247, 0) 70%),
    radial-gradient(760px 760px at 50% 50%, rgba(168, 121, 250, 0.08) 0%, rgba(168, 121, 250, 0) 70%),
    radial-gradient(1000px 1000px at 50% 50%, rgb(var(--glass-rgb) / 0.45) 0%, rgb(var(--glass-rgb) / 0) 70%),
    linear-gradient(180deg, var(--cream-100) 0%, var(--cream-50) 100%);
  background-size: 400% 400%, 400% 400%, 400% 400%, 400% 400%, 400% 400%, 100% 100%;
  background-repeat: no-repeat;
  animation: railmesh 40s ease-in-out infinite alternate; }
.login-body > * { width: 100%; max-width: 1080px; margin-left: auto; margin-right: auto; }
/* The logo row does not animate in. If everything on a freshly loaded page
   starts transparent, the browser has nothing to paint, holds the first
   frame for half a second waiting for something, and drops clicks
   meanwhile. One thing drawn at once lets the rest arrive on time. */
.login-logo-row { margin-bottom: 36px; display: flex; align-items: center; gap: 12px; }
.login-logo-row .brand-mark { display: block; height: 44px; width: 44px; flex: none; }
.login-logo-row .wordmark { font-size: 26px; letter-spacing: -0.5px; }
.login-logo-row .byline { font-size: 13px; margin-top: 3px; }
.login-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 48px; }
.login-row > * { min-width: 0; animation: rise var(--dur-slow) var(--ease-out) both; }
.login-pitch { width: 520px; max-width: 100%; }
.login-pitch .login-eyebrow { margin-bottom: 14px; }
.login-pitch h1 { margin: 0 0 12px; font-family: var(--font-display); font-size: 2rem; font-weight: 500; line-height: 1.15; letter-spacing: -0.5px; color: var(--ink-900); }
.login-pitch h1 em { font-style: normal; color: var(--accent-600); }
.login-lead { margin: 0 0 28px; max-width: 460px; font-size: 1rem; line-height: 1.5; letter-spacing: -0.2px; color: var(--ink-700); text-wrap: pretty; }
.login-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.login-points li { display: flex; align-items: center; gap: 12px; font-size: 1rem; color: var(--ink-900); }
.login-point-ic { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-50); color: var(--accent-700); display: grid; place-items: center; flex: none; }
.login-point-ic svg { width: 15px; height: 15px; }
.login-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-700); }
.login-eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-600); }
.login-access { width: 400px; max-width: 100%; flex: none; animation-delay: 80ms; }
.login-card { background: var(--white); border: 1px solid var(--cream-border); border-radius: 20px; padding: 28px 32px 32px; box-shadow: var(--shadow-md), 0 12px 40px rgba(60, 50, 30, 0.08); }
.login-card .seg { margin-bottom: 24px; }
.login-card h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 1.5rem; font-weight: 500; line-height: 1.25; letter-spacing: -0.3px; color: var(--ink-900); }
.login-card .login-sub { margin: 0 0 20px; font-size: 0.875rem; line-height: 1.5; color: var(--ink-600); overflow-wrap: anywhere; }
.login-card .err { margin: 0 0 14px; }
.login-label { display: block; margin: 0 0 6px; font-size: 0.8125rem; font-weight: 500; line-height: 1.6; letter-spacing: 0.5px; text-transform: uppercase; color: var(--ink-500); }
.login-input + .login-label { margin-top: 16px; }
.login-input { display: flex; align-items: center; gap: 10px; border: 1px solid var(--cream-border-input); border-radius: var(--radius-sm); padding: 0 12px; height: 44px; background: var(--white); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.login-input svg { width: 18px; height: 18px; flex: none; color: var(--ink-500); }
.login-input:hover { border-color: var(--ink-200); }
.login-input:focus-within { border-color: var(--accent-600); box-shadow: var(--ring-focus); }
.login-input input { flex: 1; min-width: 0; width: auto; border: 0; outline: none; background: transparent; font-size: 1rem; color: var(--ink-900); padding: 0; box-shadow: none; border-radius: 0; }
.login-input input:hover, .login-input input:focus-visible { background: transparent; box-shadow: none; }
.login-input input::placeholder { color: var(--ink-300); }
.login-input input.code { font-family: var(--font-mono); font-size: 1.25rem; letter-spacing: 0.3em; }
.login-submit { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 20px; height: 46px; border: 0; border-radius: var(--radius-sm); background: var(--accent-600); color: var(--on-bold); font-size: 1rem; font-weight: 500; cursor: pointer; transition: background var(--dur-fast), transform var(--dur-fast); }
.login-submit svg { width: 16px; height: 16px; }
.login-submit:hover { background: var(--accent-700); }
.login-submit:active { background: var(--blue-850); transform: translateY(1px); }
.login-submit:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.login-submit:disabled { background: var(--accent-300); cursor: default; }
.login-submit .spin { border-color: rgb(255 255 255 / 0.4); border-top-color: #fff; }
.login-foot-note { margin: 20px 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--ink-500); text-align: center; }
.login-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; font-size: 0.875rem; }
/* The trust line under the card: two facts, side by side when there is
   room and one under the other when there is not. */
.login-badges { display: flex; align-items: center; justify-content: center; gap: 6px 18px; flex-wrap: wrap; margin: 16px 0 0; font-size: 0.8125rem; color: var(--ink-700); }
.login-badges span { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.login-badges svg { width: 16px; height: 16px; color: var(--ink-500); }
.login-notice { margin-bottom: 20px; }

/* ---- folders -----------------------------------------------------------
   A folder card, after CancerOS's casebook card: the code where a name
   would be, the cancer as a tinted fact, the counts along the foot. */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.pcard { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; text-align: left; font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--border-subtle); transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
  background: radial-gradient(90% 90% at 100% 100%, var(--cream-200) 0%, transparent 70%), var(--surface-card); }
.pcard:hover { border-color: var(--accent-300); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pcard:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.pcard-head { display: flex; align-items: center; gap: 12px; }
.pcard-head .name { font-family: var(--font-mono); font-weight: 500; font-size: 15px; line-height: 1.25; color: var(--text-strong); letter-spacing: 0.02em; }
.pcard-head .meta { font-size: var(--fs-case-note); color: var(--text-muted); line-height: 1.35; margin-top: 2px; }
.pcard-dx { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; font-size: 14px; color: var(--ink-800); min-height: 24px; line-height: 1.35; }
.pcard-foot { display: flex; align-items: center; gap: 12px; padding-top: 8px; border-top: 1px solid var(--cream-border-soft); font-size: 12px; color: var(--ink-500); }
.pcard-foot svg { width: 14px; height: 14px; }
.pcard-foot .count { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-700); font-weight: 500; }
.pcard-foot .when { margin-left: auto; }
/* The folder's tile: the cancer's colour as a pale wash behind a folder
   glyph. Grey when the cancer is not recorded. */
.tile { --cancer: var(--ink-500); --cancer-rgb: 96, 100, 105; width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: rgba(var(--cancer-rgb), 0.12); color: var(--cancer); }
.tile svg { width: 20px; height: 20px; }
.tile.big { width: 52px; height: 52px; border-radius: 16px; }
.tile.big svg { width: 26px; height: 26px; }

/* ---- one folder -------------------------------------------------------- */

.backlink { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 var(--space-4) -6px; padding: 4px 8px 4px 4px; border: 0; background: transparent; color: var(--text-muted); font-size: 14px; cursor: pointer; border-radius: var(--radius-xs); }
.backlink svg { width: 16px; height: 16px; }
.backlink:hover { color: var(--accent-700); background: var(--accent-50); }
.backlink:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.case-head { background: var(--wash-hero); }
.case-top { display: flex; align-items: center; gap: var(--space-4); }
.case-code-row { display: flex; align-items: center; gap: 6px; }
.case-code { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: 0.04em; color: var(--text-strong); line-height: 1.2; white-space: nowrap; }
.case-top .actions { margin-left: auto; }
/* The basics, in a row of labelled facts with hairlines between. */
.case-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: var(--space-4); border-top: 1px solid var(--cream-border); }
.case-facts > div { padding: 12px 16px 2px 0; border-right: 1px solid var(--cream-border); min-width: 0; }
.case-facts > div + div { padding-left: 16px; }
.case-facts > div:last-child { border-right: 0; }
.case-facts dt { font-size: var(--fs-case-micro); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-subtle); margin-bottom: 4px; }
.case-facts dd { margin: 0; font-size: var(--fs-case-value); font-weight: 500; color: var(--text-strong); min-height: 24px; display: flex; align-items: center; }
.case-facts dd.none { color: var(--text-subtle); font-weight: 400; }
dl.case-facts { margin-bottom: 0; }
.case-note { margin: var(--space-4) 0 0; }

/* The drop zone, and the list of files on their way in. */
.drop { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; border: 1.5px dashed var(--ink-200); border-radius: var(--radius-md); padding: 14px 18px; text-align: left; color: var(--text-muted); transition: all var(--dur-fast); background: var(--white); }
.drop.over { border-color: var(--accent-400); background: var(--accent-50); color: var(--accent-700); }
.drop strong { color: var(--text-strong); font-weight: 600; }
.drop .drop-ic { grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-50); color: var(--accent-600); display: grid; place-items: center; }
.drop .drop-ic svg { width: 20px; height: 20px; }
.drop .drop-sub { grid-column: 2; margin: 2px 0 0; font-size: 13px; color: var(--text-subtle); }
.drop.busy { border-color: transparent; }
.add-card .note { margin-top: var(--space-3); }
.uploads { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: 8px; }
.uploads:empty { display: none; }
.up { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--white); }
.up .up-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--cream-200); color: var(--ink-600); grid-row: span 2; }
.up .up-ic svg { width: 17px; height: 17px; }
.up .up-name { font-size: 14px; font-weight: 500; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .up-status { font-size: 13px; color: var(--text-muted); grid-column: 2; }
.up .up-acts { grid-row: span 2; grid-column: 3; display: flex; align-items: center; gap: 4px; }
.up .progress { grid-column: 1 / -1; margin-top: 4px; }
.up[data-state="added"] { border-color: var(--success-300); background: var(--success-100); }
.up[data-state="added"] .up-ic { background: var(--success-200); color: var(--success-600); }
.up[data-state="added"] .up-status { color: var(--success-600); }
.up[data-state="failed"] { border-color: var(--danger-300); background: var(--danger-100); }
.up[data-state="failed"] .up-ic { background: var(--danger-200); color: var(--danger-600); }
.up[data-state="failed"] .up-status { color: var(--danger-600); }
.up[data-state="added"] .progress, .up[data-state="failed"] .progress, .up[data-state="waiting"] .progress { display: none; }

/* The icon and name sit in a box inside the cell: a cell that is itself a
   flex box stops being a table cell, and its rule no longer lines up. */
.docs .doc { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.docs .doc-ic { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--danger-100); color: var(--danger-600); }
.docs .doc-ic svg { width: 17px; height: 17px; }
.docs .doc a { font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.docs .doc a:hover { color: var(--accent-700); }
.docs tr.fresh td { background: var(--accent-50); transition: background 1.2s ease-out; }

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 900px) {
  /* The rail becomes a bar along the top: the mark, the two ways in as
     icons (their names stay as tooltips and for screen readers), and who
     is signed in as initials. */
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .rail { flex-direction: row; align-items: center; gap: 4px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--cream-border); overflow: visible; }
  .rail .mark { padding: 4px 6px; }
  .rail .brand { display: none; }
  .rail .rail-group { margin: 0; flex-direction: row; gap: 2px; }
  .rail .rail-recent { display: none; }
  .rail .navbtn { width: auto; padding: 8px 10px; }
  .rail .navbtn .label { display: none; }
  .rail .foot { margin: 0 0 0 auto; padding: 0; border-top: 0; }
  .rail .foot .who { display: none; }
  .content { padding: var(--space-5) var(--space-4) 64px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-head .actions { margin-left: 0; }
  .case-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-facts > div:nth-child(2) { border-right: 0; }
  .case-facts > div:nth-child(3) { padding-left: 0; }
  .case-code { font-size: 22px; }
  .login-body { padding: 40px 20px; justify-content: flex-start; }
  .login-row { flex-direction: column; gap: 32px; }
  .login-access { width: 100%; }
  .login-pitch { width: 100%; }
}
@media (max-width: 560px) {
  .seg.wide label { padding-left: 6px; padding-right: 6px; }
  .card { padding: var(--space-4); }
  /* The code keeps its own line; the button drops under it, full width. */
  .case-top { flex-wrap: wrap; }
  .case-top .actions { width: 100%; margin-left: 0; }
  .case-top .actions .btn { width: 100%; justify-content: center; }
  .docs th.hide-sm, .docs td.hide-sm { display: none; }
  .docs .doc { min-width: 0; }
  .login-card { padding: 22px 20px 24px; }
}

/* ---- the files in a folder ----------------------------------------------- */

/* After CancerOS's files section (canceros-chat-runtime, ui/styles/app.css):
   one compact line per file, or its first page as a tile, with the same
   bar over them to find, group, sort and choose the view. */

/* The find box and the two pickers are labels; a form label's bottom
   margin would sit them higher than the view switch beside them. */
.files-bar > label { margin: 0; }
.files-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: var(--space-3); color: var(--text-muted); font-size: 13px; }
.files-find { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; flex: 0 1 220px; min-width: 120px; border: 1px solid var(--cream-border); border-radius: var(--radius-sm); background: var(--white); color: var(--ink-500); cursor: text; }
.files-find:focus-within { border-color: var(--accent-400); box-shadow: var(--ring-focus); }
.files-find svg { width: 16px; height: 16px; flex: none; }
.files-find input, .files-find input:focus-visible { flex: 1; min-width: 0; height: 30px; padding: 0; border: 0; outline: none; background: transparent; box-shadow: none; font: inherit; font-size: 14px; color: var(--ink-900); }
.tb-pick { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 2px 0 10px; border: 1px solid var(--cream-border); border-radius: var(--radius-sm); background: var(--white); color: var(--ink-600); cursor: pointer; }
.tb-pick:hover { border-color: var(--cream-border-input); }
.tb-pick:focus-within { border-color: var(--accent-400); box-shadow: var(--ring-focus); }
.tb-pick svg { width: 16px; height: 16px; flex: none; }
.tb-label { font-size: 13.5px; color: var(--ink-500); white-space: nowrap; }
.tb-pick select.sm, .tb-pick select.sm:hover, .tb-pick select.sm:focus-visible { width: auto; height: 32px; padding: 0 22px 0 0; border: 0; background-color: transparent; box-shadow: none; font-size: 13.5px; color: var(--ink-900); cursor: pointer; }
/* How much the folder holds, in quiet words beside the tabs. */
.docs-card .card-head { flex-wrap: wrap; row-gap: 8px; }
.card-head .files-total { gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.files-total .sep { color: var(--text-subtle); }
.files-total .btn { margin-left: 10px; }
/* A button that is a link: the archive downloads. */
a.btn { text-decoration: none; }
.view-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--cream-100); flex: none; }
.view-btn { display: grid; place-items: center; width: 30px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-600); cursor: pointer; }
.view-btn svg { width: 16px; height: 16px; }
.view-btn:hover { color: var(--ink-900); }
.view-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.view-btn.on { background: var(--white); color: var(--accent-700); box-shadow: var(--shadow-xs); }

/* Groups: a quiet heading, then the files. */
.doc-groups { display: grid; gap: 14px; }
.doc-group-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 6px; }
.doc-group-head h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.doc-group-count { font-size: 12.5px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.doc-group.unsorted .doc-group-head h4 { color: var(--warning-600); }
.fsection-ic { width: 22px; height: 22px; flex: none; border-radius: 7px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent-700); }
.fsection-ic svg { width: 14px; height: 14px; }
.doc-group.unsorted .fsection-ic { background: var(--warning-200); color: var(--warning-600); }

/* The list: one line per file. */
.frows { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--white); overflow: hidden; }
.fr { display: grid; grid-template-columns: 20px minmax(0, 1fr) minmax(0, 184px) 68px 92px auto; align-items: center; gap: 12px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border-subtle); transition: background var(--dur-fast); }
.fr:last-child { border-bottom: 0; }
.fr:hover, .fr:focus-within { background: var(--surface-faint); }
.fr.fresh { background: var(--accent-50); }
.fr-ic { display: grid; place-items: center; color: var(--ink-500); }
.fr-ic svg { width: 18px; height: 18px; }
.fr-body { min-width: 0; }
.fr-name { display: block; max-width: 100%; padding: 0; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 500; line-height: 1.3; color: var(--text-strong); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-name:hover { color: var(--accent-700); }
.fr-name:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: 4px; }
.fr-line2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 1px; font-size: 12px; color: var(--text-subtle); }
.fr-line2 .chip { padding: 0 6px; font-size: 11px; line-height: 17px; }
.fr-line2 .chip svg { width: 11px; height: 11px; }
.fr-fact.narrow { display: none; margin-left: -2px; }
.fr-size, .fr-when { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.fr-section { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.row-actions a.iconbtn { display: inline-grid; place-items: center; line-height: 0; text-decoration: none; }
.iconbtn.xs { width: 26px; height: 26px; }
.iconbtn.xs svg { width: 15px; height: 15px; }
/* The actions wait quietly until the pointer or the keyboard is on the row. */
.fr .row-actions { opacity: 0.4; transition: opacity var(--dur-fast); }
.fr:hover .row-actions, .fr:focus-within .row-actions { opacity: 1; }
/* Nothing hovers on a touch screen: there the actions are always plain. */
@media (hover: none) { .fr .row-actions { opacity: 1; } }

/* The section a file is in, as a control that looks like words until used. */
.fsel { min-width: 0; height: 30px; padding: 0 26px 0 8px; font-size: 12.5px; border-radius: var(--radius-sm); text-overflow: ellipsis; }
.fsel.quiet { width: 100%; height: 26px; padding: 0 22px 0 6px; border-color: transparent; background-color: transparent; color: var(--text-muted); cursor: pointer; -webkit-appearance: none; appearance: none; }
.fsel.quiet:hover, .fsel.quiet:focus-visible { border-color: var(--border-input); background-color: var(--white); color: var(--text-strong); -webkit-appearance: menulist; appearance: auto; }
/* Where nothing can hover, the arrow is the only sign that it is a control. */
@media (hover: none) { .fsel.quiet { -webkit-appearance: menulist; appearance: auto; } }
/* Under a section's own heading, saying the section again on every line is noise. */
.frows.by-section .fr-section { visibility: hidden; }

/* The small marks on a file. */
.fchips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 500; background: var(--cream-200); color: var(--ink-700); white-space: nowrap; }
.chip svg { width: 12px; height: 12px; }
.chip .spin { width: 10px; height: 10px; border-width: 1.5px; }
.chip.busy { background: var(--accent-50); color: var(--accent-700); }
.chip.warn { background: var(--warning-200); color: var(--warning-600); }
.chip.ok { background: var(--success-200); color: var(--success-600); }
.chip.dup { background: var(--c-violet-fill); color: var(--c-violet); }

/* The first page of a file, beside its name in the list. */
.fprev-note { position: fixed; z-index: 90; display: flex; flex-direction: column; gap: 6px; max-width: 262px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-card); border: 1px solid var(--cream-border); box-shadow: var(--shadow-lg); pointer-events: none; animation: rise var(--dur-fast) var(--ease-out) both; }
.fprev-frame { position: relative; width: 244px; height: 300px; }
.fprev-frame .fprev-img { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; display: block; object-fit: contain; border-radius: var(--radius-xs); background: var(--white); border: 1px solid var(--cream-border); opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.fprev-frame.loaded .fprev-img { opacity: 1; }
.fprev-frame .fprev-load { position: absolute; inset: 0; border-radius: var(--radius-xs); border: 1px solid var(--cream-border); background: linear-gradient(100deg, var(--cream-100) 30%, var(--white) 50%, var(--cream-100) 70%); background-size: 300% 100%; animation: fprev-load 1.2s linear infinite; }
.fprev-frame.loaded .fprev-load { display: none; }
@keyframes fprev-load { from { background-position: 100% 0; } to { background-position: 0 0; } }
.fprev-name { font-size: 12px; font-weight: 500; color: var(--text-strong); overflow-wrap: anywhere; line-height: 1.35; padding: 0 2px; }
.fprev-sub { font-size: 12px; color: var(--text-muted); padding: 0 2px; }

/* The grid: each file is its first page. */
.ftiles { display: grid; gap: 12px; }
.ftiles.lg { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.ftiles.sm { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.ftile { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--cream-border); border-radius: var(--radius-md); background: var(--white); overflow: hidden; transition: box-shadow var(--dur-fast), border-color var(--dur-fast); }
.ftile:hover { border-color: var(--accent-300); box-shadow: var(--shadow-sm); }
.ftile.fresh { border-color: var(--accent-400); box-shadow: 0 0 0 3px var(--accent-50); }
.ftile-stage { position: relative; min-width: 0; }
.ftile-pic { display: grid; place-items: center; aspect-ratio: 3 / 4; width: 100%; padding: 0; border: 0; background: var(--cream-50); cursor: pointer; overflow: hidden; }
.ftile-pic:focus-visible { outline: none; box-shadow: inset var(--ring-focus); }
.ftile-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.ftile-ic { display: grid; place-items: center; }
.ftile-ic svg { width: 34px; height: 34px; color: var(--ink-400); }
.ftiles.sm .ftile-ic svg { width: 26px; height: 26px; }
/* The name and its line sit over the foot of the picture, behind a blur
   that deepens toward the edge (four layers, each masked to a band) and a
   dark scrim, so the tile is the picture's height and the words still read. */
.ftile-blur { position: absolute; left: 0; right: 0; bottom: 0; height: 62%; pointer-events: none; overflow: hidden; }
.ftile-blur > div { position: absolute; inset: 0; }
.ftile-blur .l1 { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 20%, #000 40%, transparent 60%); mask-image: linear-gradient(to bottom, transparent 0%, #000 20%, #000 40%, transparent 60%); }
.ftile-blur .l2 { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); -webkit-mask-image: linear-gradient(to bottom, transparent 20%, #000 40%, #000 60%, transparent 80%); mask-image: linear-gradient(to bottom, transparent 20%, #000 40%, #000 60%, transparent 80%); }
.ftile-blur .l3 { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); -webkit-mask-image: linear-gradient(to bottom, transparent 40%, #000 60%, #000 80%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 40%, #000 60%, #000 80%, transparent 100%); }
.ftile-blur .l4 { backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); -webkit-mask-image: linear-gradient(to bottom, transparent 60%, #000 80%, #000 100%); mask-image: linear-gradient(to bottom, transparent 60%, #000 80%, #000 100%); }
.ftile-blur::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(11, 12, 14, 0) 0%, rgba(11, 12, 14, 0.35) 40%, rgba(11, 12, 14, 0.78) 75%, rgba(11, 12, 14, 0.9) 100%); }
.ftiles.sm .ftile-blur { height: 70%; }
.ftile-body { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 9px; min-width: 0; pointer-events: none; }
.ftiles.sm .ftile-body { padding: 8px 8px 7px; }
.ftile-name { font-size: 13px; font-weight: 500; line-height: 1.3; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ftiles.sm .ftile-name { font-size: 12px; }
.name-end { display: inline-block; overflow-wrap: normal; white-space: nowrap; }
.ftile-meta { font-size: 12px; color: rgba(255, 255, 255, 0.78); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftiles.sm .ftile-meta { display: none; }
/* What needs attention, as a dot each in the corner of the tile. */
.tile-flags { position: absolute; top: 6px; right: 6px; z-index: 2; display: flex; gap: 4px; pointer-events: none; }
.flag { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(11, 12, 14, 0.62); color: #fff; pointer-events: auto; }
.flag svg { width: 12px; height: 12px; }
.flag .spin { width: 10px; height: 10px; border-width: 1.5px; }
.flag.warn { background: var(--warning-500); }
.flag.dup { background: var(--c-violet); }

/* Rest on a tile and it grows into this card: the page at a readable
   size, the file's facts, and everything that can be done with it. */
.morph-card { position: fixed; z-index: 95; display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-md); background: var(--surface-card); border: 1px solid var(--cream-border); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.12); transition: left 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.24s; }
.morph-card.morph-start { box-shadow: none; }
.morph-card .morph-pic { display: block; flex: none; width: 100%; height: 100%; padding: 0; border: 0; background: var(--cream-50); cursor: pointer; overflow: hidden; transition: height 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
.morph-card .morph-pic img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.morph-card .morph-ic { width: 100%; height: 100%; }
.morph-card .morph-ic svg { width: 56px; height: 56px; }
.morph-card .morph-body { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 10px; min-width: 0; opacity: 1; transition: opacity 0.18s 0.1s; }
.morph-card.morph-start .morph-body { opacity: 0; transition: opacity 0.08s; }
.morph-card .morph-name { font-size: 14px; font-weight: 600; color: var(--text-strong); line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.morph-card .morph-meta { margin-top: -6px; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.morph-card .morph-foot { display: flex; align-items: center; gap: 6px; }
.morph-card .morph-foot .fsel, .morph-card .morph-foot .fr-section { flex: 1; min-width: 0; }
.ftile.morphing .ftile-stage { visibility: hidden; }

/* How much of a file's line fits depends on the width of the files
   themselves, not of the window: the rail takes its share on a laptop. */
.files-pane { container: files / inline-size; }
@container files (max-width: 900px) {
  .tb-label { display: none; }
}
@container files (max-width: 760px) {
  .fr { grid-template-columns: 20px minmax(0, 1fr) minmax(0, 150px) auto; }
  .fr-size, .fr-when { display: none; }
  .fr-fact.narrow { display: inline; }
}
@container files (max-width: 520px) {
  .files-find { flex: 1 1 100%; }
  /* The name gets the whole line; its facts and what can be done share the next. */
  .fr { grid-template-columns: 20px minmax(0, 1fr) auto; row-gap: 0; }
  .fr-body { display: contents; }
  .fr-ic { grid-row: 1 / span 2; }
  .fr-name { grid-column: 2 / -1; }
  .fr-line2 { grid-column: 2; grid-row: 2; margin-top: 0; }
  .fr .row-actions { grid-column: 3; grid-row: 2; }
  .fr > .fsel, .fr > .fr-section { display: none; }
  .ftiles.lg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ftiles.sm { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
}

/* The viewer's stand-in for a file with nothing to show: its kind, large. */
.kind-tile { display: grid; place-items: center; gap: 6px; width: 84px; height: 84px; border-radius: 18px; background: var(--c-slate-fill); color: var(--c-slate); align-content: center; }
.kind-tile svg { width: 26px; height: 26px; }
.kind-tile span { font-size: 11px; font-weight: 600; letter-spacing: .04em; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind-tile[data-group="document"] { background: var(--danger-100); color: var(--danger-600); }
.kind-tile[data-group="image"] { background: var(--c-blue-fill); color: var(--c-blue); }
.kind-tile[data-group="omics"] { background: var(--c-teal-fill); color: var(--c-teal); }
.kind-tile[data-group="other"] { background: var(--c-amber-fill); color: var(--c-amber); }

/* ---- the file viewer ----------------------------------------------------- */

.viewer { display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(1440px, 100%); height: calc(100dvh - 32px); background: var(--surface-card); border-radius: var(--radius-lg); box-shadow: var(--acrylic-shadow), var(--acrylic-edge); overflow: hidden; animation: rise var(--dur-base) var(--ease-out) both; }
.viewer:focus { outline: none; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--border-subtle); }
.viewer-title { min-width: 0; flex: 1; }
.viewer-name { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-meta { font-size: 12px; color: var(--text-subtle); }
.viewer-pager, .viewer-files { display: flex; align-items: center; gap: 2px; flex: none; }
.viewer-where { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.viewer-files { padding-left: 10px; border-left: 1px solid var(--border-subtle); }
.viewer-main { display: grid; grid-template-columns: auto minmax(0, 1fr) 304px; min-height: 0; }
/* The page thumbnails of a PDF, down the left. */
.viewer-strip { display: flex; flex-direction: column; gap: 8px; width: 124px; padding: 12px 10px; overflow-y: auto; border-right: 1px solid var(--border-subtle); background: var(--surface-faint); }
.pthumb { display: grid; gap: 3px; justify-items: center; padding: 4px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; color: var(--text-subtle); font-size: 11px; }
.pthumb img { width: 92px; min-height: 60px; height: auto; display: block; border: 1px solid var(--border-subtle); border-radius: 4px; background: var(--white); }
.pthumb:hover { background: var(--surface-hover); }
.pthumb.on { background: var(--accent-50); color: var(--accent-700); }
.pthumb.on img { border-color: var(--accent-400); box-shadow: 0 0 0 2px var(--accent-100); }
.pthumb:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.viewer-stage { display: grid; place-items: start center; overflow: auto; padding: 20px; background: var(--surface-sunken); min-height: 0; }
.viewer-stage:focus { outline: none; }
.viewer-stage > .spin { align-self: center; }
.viewer-page { max-width: 100%; height: auto; background: var(--white); box-shadow: var(--shadow-md); border-radius: 2px; }
.viewer-textbox { width: min(1000px, 100%); display: grid; gap: 12px; }
.viewer-text { margin: 0; padding: 16px 18px; background: var(--white); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; color: var(--text-body); white-space: pre; overflow-x: auto; tab-size: 4; }
.viewer-none { align-self: center; display: grid; justify-items: center; gap: 14px; max-width: 44ch; text-align: center; color: var(--text-muted); font-size: 14px; }
.viewer-none p { margin: 0; }
.viewer-facts { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; overflow-y: auto; border-left: 1px solid var(--border-subtle); }
.viewer-dl { display: grid; gap: 12px; margin: 0; }
.viewer-dl dt { font-size: var(--fs-case-micro); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-subtle); margin-bottom: 3px; }
.viewer-dl dd { margin: 0; font-size: 14px; color: var(--text-strong); overflow-wrap: anywhere; }
.viewer-dl .fsel { width: 100%; height: 34px; font-size: 13.5px; }
.viewer-sum { display: flex; align-items: flex-start; gap: 4px; }
.viewer-sum code { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; color: var(--text-body); word-break: break-all; }

/* ---- sticky notes at the top of a folder --------------------------------- */

.stickies { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--space-4); }
.sticky { display: flex; flex-direction: column; gap: 8px; width: 216px; min-height: 96px; padding: 10px 12px 8px; border-radius: 3px 3px 12px 3px; background: var(--warning-100); border: 1px solid var(--warning-200); box-shadow: var(--shadow-xs); color: var(--ink-800); font-size: 13.5px; line-height: 1.4; }
/* An operator's note is a different colour, so the doctor sees whose it is. */
.sticky.operator { background: var(--accent-50); border-color: var(--accent-100); }
.sticky-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; flex: 1; }
.sticky-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sticky-by { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticky .iconbtn { width: 24px; height: 24px; flex: none; }
.sticky .iconbtn svg { width: 13px; height: 13px; }
.sticky.add { align-items: center; justify-content: center; flex-direction: row; gap: 8px; width: 148px; background: transparent; border: 1.5px dashed var(--ink-200); box-shadow: none; color: var(--text-muted); font: inherit; font-size: 13.5px; cursor: pointer; transition: all var(--dur-fast); }
.sticky.add:hover { border-color: var(--accent-400); color: var(--accent-700); background: var(--accent-50); }
.sticky.add:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.sticky.add svg { width: 18px; height: 18px; }
.sticky.writing { width: 264px; }
.sticky-input { width: 100%; min-height: 64px; padding: 6px 8px; border: 1px solid var(--warning-300); border-radius: var(--radius-xs); background: var(--white); font: inherit; font-size: 13.5px; resize: vertical; }
.sticky-input:focus { outline: none; box-shadow: var(--ring-focus); }
.sticky.writing .sticky-foot { justify-content: flex-end; }

/* ---- a folder's three views ----------------------------------------------- */

.docs-card .card-head .seg label { display: inline-flex; align-items: center; gap: 6px; }
.tab-count { padding: 0 6px; min-width: 18px; justify-content: center; font-size: 11px; line-height: 16px; }
.badge.operator { background: var(--accent-50); color: var(--accent-700); border-color: var(--accent-100); }
.badge.doctor { background: var(--success-200); color: var(--success-600); border-color: var(--success-300); }
.badge svg { width: 13px; height: 13px; }
.viewer-acts { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* The messages between a folder's doctor and the operators. */
.thread-panel { display: grid; gap: var(--space-3); }
.thread { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 10px; max-height: 56dvh; overflow-y: auto; }
.msg { max-width: min(680px, 88%); padding: 10px 14px; border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--border-subtle); justify-self: start; }
.msg.mine { justify-self: end; background: var(--accent-50); border-color: var(--accent-100); }
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; color: var(--text-strong); }
.msg-head .badge { padding: 1px 8px; font-size: 11px; }
.msg-when { margin-left: auto; padding-left: 12px; font-size: 12px; color: var(--text-subtle); white-space: nowrap; }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; color: var(--text-body); }
.thread-empty { list-style: none; padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }
.thread-write { display: flex; align-items: flex-end; gap: 10px; padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.thread-input { flex: 1; min-height: 44px; max-height: 200px; padding: 10px 12px; border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--white); font: inherit; font-size: 14px; line-height: 1.45; resize: vertical; }
.thread-input:focus { outline: none; border-color: var(--accent-400); box-shadow: var(--ring-focus); }

/* A folder's history: who did what, newest first. */
.trail-panel { display: grid; gap: var(--space-3); justify-items: start; }
.trail-filter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.trail { list-style: none; margin: 0; padding: 0; width: 100%; }
.trail-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); font-size: 14px; }
.trail-row:last-child { border-bottom: 0; }
.trail-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--cream-200); color: var(--ink-600); }
.trail-ic svg { width: 15px; height: 15px; }
.trail-row.system .trail-ic { background: var(--accent-50); color: var(--accent-600); }
.trail-words { color: var(--text-body); overflow-wrap: anywhere; }
.trail-words b { font-weight: 600; color: var(--text-strong); }
.trail-when { font-size: 12.5px; color: var(--text-subtle); white-space: nowrap; }

/* Renaming: the part that can change, then the ending that cannot. */
.rename-row { display: flex; align-items: center; gap: 8px; }
.rename-row input { flex: 1; min-width: 0; }
.rename-ending { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .viewer { height: calc(100dvh - 16px); }
  .viewer-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .viewer-strip { display: none; }
  .viewer-facts { border-left: 0; border-top: 1px solid var(--border-subtle); max-height: 38dvh; }
  .viewer-bar { flex-wrap: wrap; row-gap: 6px; }
  .viewer-title { flex-basis: 100%; }
}
@media (max-width: 560px) {
  .viewer-stage { padding: 10px; }
}
