/* nodedrive - Ledger.
 *
 * Token values are lifted verbatim from NIGHT/DAY in "Nodedrive Ledger.dc.html", which the
 * handoff names as the source of truth. Nothing is hardcoded per component: if a colour
 * appears below that is not a var(), it is either the shared danger colour or a mistake.
 */

/* ---------------------------------------------------------------- fonts */

/* Both are variable fonts, latin subset, served from this folder. Self-hosted rather than
 * linked: a private drive that fetches from fonts.googleapis.com tells Google every time it
 * is opened, and stops rendering correctly the moment the NAS has no route out. */
@font-face {
  font-family: 'Instrument Sans';
  src: url('fonts/instrument-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------- tokens */

:root,
:root[data-theme='night'] {
  --bg: #0E1113;
  --fg: #E8EDEC;
  --fg-soft: #C4CCCA;
  --fg2: #8A9694;
  --fg3: #6C7876;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .04);
  --line-hard: rgba(255, 255, 255, .12);
  --hover: rgba(255, 255, 255, .035);
  --field: rgba(255, 255, 255, .05);
  --seg: rgba(255, 255, 255, .05);
  --seg-on: rgba(255, 255, 255, .1);
  --seg-shadow: none;
  --raised: rgba(255, 255, 255, .05);
  --raised-shadow: none;
  --track: rgba(255, 255, 255, .08);
  --accent: #2E9E8F;
  --accent-fg: #08100E;
  --accent-text: #5FC7B6;
  --accent-bg: rgba(46, 158, 143, .12);
  --accent-line: rgba(46, 158, 143, .24);
  --accent-fill: rgba(46, 158, 143, .2);
  --indigo: #5B5BD6;
  --indigo-bg: rgba(91, 91, 214, .14);
  --indigo-fg: #A6A6F2;
  --bar: #1C2225;
  --bar-line: rgba(255, 255, 255, .12);
  --bar-fg: #fff;
  --bar-fg2: #C4CCCA;
  --bar-hover: rgba(255, 255, 255, .08);
  --bar-shadow: rgba(0, 0, 0, .55);
}

:root[data-theme='day'] {
  --bg: #FBFAF7;
  --fg: #14181A;
  --fg-soft: #3A4240;
  /* Two-step ramp on purpose: --fg2 and --fg3 are the same value. A third, lighter tier
   * failed 4.5:1 against this ground. Do not reintroduce one. */
  --fg2: #6B7472;
  --fg3: #6B7472;
  --line: rgba(0, 0, 0, .08);
  --line2: rgba(0, 0, 0, .05);
  --line-hard: rgba(0, 0, 0, .11);
  --hover: rgba(0, 0, 0, .025);
  --field: #fff;
  --seg: rgba(0, 0, 0, .05);
  --seg-on: #fff;
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, .09);
  --raised: #fff;
  --raised-shadow: 0 1px 2px rgba(0, 0, 0, .07);
  --track: rgba(0, 0, 0, .08);
  --accent: #1F7F73;
  --accent-fg: #fff;
  --accent-text: #1F7F73;
  --accent-bg: rgba(31, 127, 115, .1);
  --accent-line: rgba(31, 127, 115, .22);
  --accent-fill: rgba(31, 127, 115, .16);
  --indigo: #4F4FC4;
  --indigo-bg: rgba(79, 79, 196, .09);
  --indigo-fg: #4A4AB8;
  /* The floating bar is dark in BOTH themes, so it reads as an overlay rather than as part
   * of the table it sits on. */
  --bar: #14181A;
  --bar-line: rgba(255, 255, 255, .14);
  --bar-fg: #fff;
  --bar-fg2: #D4DAD8;
  --bar-hover: rgba(255, 255, 255, .1);
  --bar-shadow: rgba(0, 0, 0, .28);
}

:root {
  --danger: #F08D7A;
  --danger-bg: rgba(240, 141, 122, .12);
  --danger-hover: rgba(240, 141, 122, .13);
  --ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  /* The icon-canvas inset matches the 18px horizontal padding used by the header, the
   * filter bar and the list rows. */
  --inset: 18px;
}

/* Row and tile metrics come from SIZES in the design file, not from guesses. */
[data-size='regular'] {
  --row-h: 46px;
  --row-icon: 29px;
  --row-glyph: 15px;
  --row-ext: 8.5px;
  --row-name: 13.5px;
  --cell-w: 128px;
  --cell-h: 136px;
  --tile-w: 100px;
  --tile-h: 112px;
  --chip: 52px;
  --glyph: 27px;
  --ext-sz: 10px;
  --name-sz: 11.5px;
}
[data-size='large'] {
  --row-h: 60px;
  --row-icon: 38px;
  --row-glyph: 20px;
  --row-ext: 10px;
  --row-name: 15px;
  --cell-w: 166px;
  --cell-h: 180px;
  --tile-w: 138px;
  --tile-h: 140px;
  --chip: 76px;
  --glyph: 40px;
  --ext-sz: 13px;
  --name-sz: 13px;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 13px/1.4 var(--ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: background .2s ease, color .2s ease;
}
#app.boot { visibility: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; flex: none; }

.mono { font-family: var(--mono); }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1; }

/* A label that must never wrap or spill its box. Used for every filename. */
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* The segmented-track pattern: view toggle, theme toggle, size toggle. */
.seg {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 8px;
  background: var(--seg);
  flex: none;
}
.seg > button {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--fg3);
  transition: background .12s ease, color .12s ease;
}
.seg > button[aria-pressed='true'] {
  background: var(--seg-on);
  box-shadow: var(--seg-shadow);
  color: var(--fg);
}
.seg.view > button, .seg.theme > button { height: 24px; }
.seg.view > button { width: 26px; }
.seg.theme > button { width: 28px; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line-hard);
  font: 400 11.5px/1 var(--ui);
  color: var(--fg2);
  white-space: nowrap;
  transition: color .12s ease;
}
.chip:hover { color: var(--fg); }
.chip.on {
  background: var(--seg-on);
  border-color: transparent;
  font-weight: 500;
  color: var(--fg);
}

/* ---------------------------------------------------------------- login */

.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.login-top {
  display: flex;
  justify-content: flex-end;
  padding: 16px 18px;
  flex: none;
}
.login-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 64px;
  min-height: 0;
  overflow: auto;
}
.login-card { width: 100%; max-width: 352px; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
.mark {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  flex: none;
  width: 30px;
  height: 30px;
}
.wordmark {
  font: 700 17px/1 var(--ui);
  letter-spacing: -.02em;
  color: var(--fg);
}

.login h1 {
  margin: 0 0 9px;
  font: 600 25px/1.2 var(--ui);
  letter-spacing: -.025em;
  color: var(--fg);
}
.login .sub {
  margin: 0 0 26px;
  font: 400 13px/1.55 var(--ui);
  color: var(--fg2);
}

.field { margin-bottom: 13px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font: 600 9.5px/1 var(--mono);
  letter-spacing: .11em;
  color: var(--fg3);
}
.field input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line-hard);
  background: var(--field);
  font: 400 13.5px/1 var(--ui);
  outline: none;
  transition: border-color .12s ease;
}
.field input:focus { border-color: var(--accent); }
.field input[type='password'] {
  font-family: var(--mono);
  letter-spacing: .14em;
}

.trust {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  cursor: pointer;
  user-select: none;
}
.box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line-hard);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background .12s ease, border-color .12s ease;
}
.trust.on .box { background: var(--accent); border-color: var(--accent); }
.trust .box svg { display: none; }
.trust.on .box svg { display: block; }
.trust span { font: 400 12.5px/1 var(--ui); color: var(--fg-soft); }

.primary {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  font: 600 13px/1 var(--ui);
  background: var(--accent);
  color: var(--accent-fg);
  /* The border is not decoration. Without it the disabled state is invisible against the
   * day theme's off-white ground, so it is declared on both states and only recoloured. */
  border: 1px solid var(--accent);
}
.primary[disabled] {
  background: var(--seg);
  border-color: var(--line-hard);
  color: var(--fg2);
  cursor: default;
}
.primary[disabled] svg { opacity: .55; }

.err {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font: 400 12px/1.45 var(--ui);
  color: var(--danger);
  background: var(--danger-bg);
}

.login-foot {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 11px/1 var(--mono);
  color: var(--fg3);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---------------------------------------------------------------- header */

.head {
  height: 54px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.head .brand { margin: 0; gap: 9px; flex: none; }
.head .mark { width: 22px; height: 22px; border-radius: 6px; }
.head .wordmark { font-size: 13.5px; letter-spacing: -.01em; }
.vline { width: 1px; height: 20px; background: var(--line-hard); flex: none; }

/* The breadcrumb is the only thing here allowed to shrink to nothing, and it must clip from
 * the LEFT so the folder you are actually in stays readable. direction:rtl on the clipper
 * puts the ellipsis at the start; the inner run is switched back to ltr so the text itself
 * is not reordered. */
.crumbs {
  flex: 1 1 auto;
  min-width: 44px;
  display: flex;
  align-items: center;
  font: 400 12px/1 var(--mono);
  color: var(--fg3);
  white-space: nowrap;
}
.crumb-lead {
  direction: rtl;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.crumb-lead > span { direction: ltr; unicode-bidi: embed; }
.crumb-lead b { font-weight: 400; color: var(--fg3); cursor: pointer; }
.crumb-lead b:hover { color: var(--fg2); }
.crumb-here { flex: none; color: var(--fg); font-weight: 500; }

.badge {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  border-radius: 7px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  font: 500 11px/1 var(--mono);
  color: var(--accent-text);
  white-space: nowrap;
}
.badge .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .badge .spin { animation: none; } }

.search {
  flex: 0 1 208px;
  min-width: 104px;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 31px;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--field);
  border: 1px solid var(--line-hard);
  transition: border-color .12s ease;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font: 400 12px/1 var(--ui);
}
.search input::placeholder { color: var(--fg3); }

.avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--indigo));
  color: var(--accent-fg);
  font: 600 10.5px/1 var(--ui);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ---------------------------------------------------------------- body split */

.body { flex: 1; display: flex; min-height: 0; }

.side {
  width: 238px;
  flex: none;
  border-right: 1px solid var(--line);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}
.side-row { display: flex; gap: 7px; margin-bottom: 18px; flex: none; }
.side-row .primary { height: 33px; border-radius: 7px; font-size: 12px; gap: 7px; }
.icon-btn {
  width: 33px;
  height: 33px;
  border-radius: 7px;
  border: 1px solid var(--line-hard);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--fg2);
  transition: background .12s ease;
}
.icon-btn:hover { background: var(--hover); }

.side h2 {
  margin: 0 0 8px;
  font: 600 9.5px/1 var(--mono);
  letter-spacing: .11em;
  color: var(--fg3);
  text-transform: uppercase;
}
.side section { margin-bottom: 16px; }

.server {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--raised);
  box-shadow: var(--raised-shadow);
  /* A <button> shrink-wraps even as a flex container, so without this the row was a narrow
   * pill two thirds of the way across the sidebar and ONLINE never reached the right edge. */
  width: 100%;
  text-align: left;
}
.server .nm { font: 600 12.5px/1 var(--ui); color: var(--fg); flex: 1; }
.server .on { font: 500 9.5px/1 var(--mono); color: var(--accent-text); letter-spacing: .06em; }

.tree {
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line-hard);
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  width: 100%;
  text-align: left;
  transition: background .12s ease;
}
.row:hover { background: var(--hover); }
.row .nm { font: 400 12.5px/1 var(--ui); color: var(--fg-soft); flex: 1; min-width: 0; }
.row .ct { font: 400 9.5px/1 var(--mono); color: var(--fg3); flex: none; }
.row svg { color: var(--fg3); }
.row.on { background: var(--accent-bg); }
.row.on .nm { color: var(--fg); font-weight: 600; }
.row.on .ct { color: var(--accent-text); }
.row.on svg { color: var(--accent); fill: var(--accent-fill); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--line-hard);
  font: 500 11px/1 var(--ui);
  color: var(--fg-soft);
}
.tag i { width: 6px; height: 6px; border-radius: 50%; background: var(--indigo); flex: none; }
.tag.on { background: var(--accent-bg); border-color: var(--accent-line); color: var(--fg); }

.pool {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--raised);
  border: 1px solid var(--line);
  flex: none;
}
.pool-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.pool-head .l { font: 600 9.5px/1 var(--mono); letter-spacing: .09em; color: var(--fg2); }
.pool-head .r { font: 500 10px/1 var(--mono); color: var(--accent-text); }
.track { height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pool-foot { margin-top: 8px; font: 400 11px/1.5 var(--mono); color: var(--fg2); }

/* ---------------------------------------------------------------- main column */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* min-height, never height: when these controls wrap, a fixed height spills them over the
 * border and onto the content below. */
.filters {
  min-height: 47px;
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
}
/* margin-left:auto rather than a flex:1 spacer, so the right-hand cluster stays right
 * aligned on the line it lands on after a wrap. */
.filters .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* The three filter chips carry a chevron, so they open a menu. The wrapper is the
 * positioning context; the menu hangs below its own chip rather than from the bar, so it
 * stays attached to the right control after the bar wraps. */
.chipwrap { position: relative; display: flex; }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 35;
  min-width: 152px;
  padding: 4px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line-hard);
  box-shadow: 0 12px 28px var(--bar-shadow);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.menu button {
  text-align: left;
  padding: 7px 10px;
  border-radius: 5px;
  font: 400 12px/1 var(--ui);
  color: var(--fg-soft);
  white-space: nowrap;
  transition: background .1s ease, color .1s ease;
}
.menu button:hover { background: var(--hover); color: var(--fg); }
.menu button.on { background: var(--accent-bg); color: var(--fg); font-weight: 500; }

.hint {
  margin: 0;
  font: 400 11.5px/1.5 var(--ui);
  color: var(--fg3);
}
.seg.size > button { padding: 4px 9px; border-radius: 5px; font: 500 11px/1 var(--ui); }
.seg.size { border-radius: 7px; }
.count { font: 400 11px/1 var(--mono); color: var(--fg3); white-space: nowrap; }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--fg3);
  font: 400 12.5px/1.5 var(--ui);
  padding: 40px 20px;
  text-align: center;
}

/* ---------------------------------------------------------------- list view */

.list { flex: 1; overflow: auto; min-height: 0; }
.lhead, .lrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 96px 128px;
  gap: 12px;
  padding: 0 18px;
  align-items: center;
}
.lhead {
  height: 30px;
  border-bottom: 1px solid var(--line);
  font: 600 9.5px/1 var(--mono);
  letter-spacing: .09em;
  color: var(--fg3);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.lhead .r, .lrow .sz, .lrow .md { text-align: right; }
/* text-align:left is not redundant. A <button> centres its label by default, so NAME and TAG
 * sat in the middle of their columns - NAME floated 340px right of the filenames it labels -
 * while SIZE and MODIFIED looked fine because .r already overrode it. The effect is a header
 * row that reads as slightly wrong without it being obvious why. */
.lhead button {
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  width: 100%;
  padding: 0;
}
.lhead button.r { text-align: right; }
.lhead button:hover { color: var(--fg2); }

.lrow {
  height: var(--row-h);
  border-bottom: 1px solid var(--line2);
  cursor: default;
  width: 100%;
  text-align: left;
  transition: background .12s ease;
}
.lrow:hover { background: var(--hover); }
.lrow.sel { background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); }

.lname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ibox {
  width: var(--row-icon);
  height: var(--row-icon);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--seg);
  color: var(--fg2);
  font: 600 var(--row-ext) / 1 var(--mono);
  letter-spacing: .03em;
}
.ibox.dir { background: var(--accent-bg); color: var(--accent); }
.ibox.media { background: var(--indigo-bg); color: var(--indigo-fg); }
.lrow.sel .ibox { background: var(--accent-fill); color: var(--accent-text); }

.ltext { min-width: 0; }
.ltext .n {
  font: 400 var(--row-name) / 1.25 var(--ui);
  color: var(--fg);
}
.lrow.dir .ltext .n { font-weight: 500; }
.lrow.sel .ltext .n { font-weight: 500; }
.ltext .m { margin-top: 2px; font: 400 10.5px/1 var(--mono); color: var(--fg3); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--indigo-bg);
  font: 500 10.5px/1 var(--ui);
  color: var(--indigo-fg);
  max-width: 100%;
}
.pill i { width: 5px; height: 5px; border-radius: 50%; background: var(--indigo); flex: none; }

.lrow .sz { font: 400 11.5px/1 var(--mono); color: var(--fg-soft); }
.lrow.dir .sz { color: var(--fg3); }
.lrow .md { font: 400 11.5px/1 var(--mono); color: var(--fg2); }
.lrow.sel .sz { font-weight: 500; }

.blocked { opacity: .45; }

/* ---------------------------------------------------------------- icon view */

/* No padding here. Absolutely positioned children ignore a padding box, so the 18px inset
 * is baked into the layout coordinates instead - see INSET in app.js. */
.canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  min-height: 0;
}
.tile {
  position: absolute;
  width: var(--tile-w);
  /* Width only - no height. The design sets none either, and that is not an omission: the
   * tile is a fixed-height flex column the moment you add one, and flexbox then SHRINKS the
   * name pill to make the contents fit, which silently clips the descenders on anything
   * like "backups". --tile-h still exists, but it belongs to the layout maths in app.js -
   * the drag clamp and the scroll extent - not to the box. The tile sizes to its content
   * (~118px regular) and still sits comfortably inside the 136px cell. */
  padding: 10px 6px 9px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background .12s ease;
}
.tile:hover { background: var(--seg); }
.tile.drag {
  box-shadow: 0 12px 28px var(--bar-shadow);
  z-index: 20;
  opacity: .92;
  cursor: grabbing;
  transition: none;
}
.chip-ico {
  width: var(--chip);
  height: var(--chip);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--seg);
  color: var(--fg2);
  font: 600 var(--ext-sz) / 1 var(--mono);
  letter-spacing: .03em;
}
.chip-ico.dir { background: var(--accent-bg); color: var(--accent); }
.chip-ico.media { background: var(--indigo-bg); color: var(--indigo-fg); }
/* The ring wins over hover, and sits on the chip rather than filling the whole tile. */
.tile.sel .chip-ico { box-shadow: inset 0 0 0 2px var(--accent); }

.tname {
  max-width: 100%;
  /* Belt and braces against the squeeze above: even inside a constrained column these two
   * keep their full line box rather than giving it up. */
  flex: none;
  /* border-box is required. Without it the padding pushes the pill past the tile and two
   * adjacent selected labels merge into one continuous bar. */
  box-sizing: border-box;
  padding: 2px 7px;
  border-radius: 6px;
  font: 500 var(--name-sz) / 1.35 var(--ui);
  color: var(--fg);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile.sel .tname { background: var(--accent); color: var(--accent-fg); }
.tmeta { font: 400 9.5px/1 var(--mono); color: var(--fg3); flex: none; }
.tile.sel .tmeta { color: var(--fg2); }

/* ---------------------------------------------------------------- inline rename
 *
 * The input takes the exact metrics of the name it replaces, so the row does not shift by a
 * pixel when editing starts. That is the whole point of editing in place rather than in a
 * dialog - if the row jumps, you may as well have opened a dialog. */

.rename-input {
  width: 100%;
  min-width: 0;
  height: calc(var(--row-name) + 10px);
  padding: 0 5px;
  margin: -1px 0;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--field);
  color: var(--fg);
  font: 500 var(--row-name) / 1.25 var(--ui);
  outline: none;
}
.tile-rename {
  max-width: 100%;
  height: auto;
  padding: 2px 5px;
  margin: 0;
  border-radius: 6px;
  font: 500 var(--name-sz) / 1.35 var(--ui);
  text-align: center;
  flex: none;
}

/* ---------------------------------------------------------------- panels (trash, shared) */

/* Column labels differ per panel, so they are not buttons that sort - just headings that
 * happen to sit in the same grid, which is what keeps these reading as the same table. */
.lhead.panel button { cursor: default; }
.lhead.panel button:hover { color: var(--fg3); }

.choices { display: flex; flex-wrap: wrap; gap: 7px; }
.choices .chip { padding: 7px 12px; font-size: 12px; cursor: pointer; }

.linkbox { display: flex; gap: 7px; align-items: stretch; }
.linkbox input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid var(--line-hard);
  background: var(--field);
  font: 400 11.5px/1 var(--mono);
  color: var(--fg-soft);
  outline: none;
}
.linkbox input:focus { border-color: var(--accent); }
.linkbox .ghost { display: flex; align-items: center; gap: 6px; }

.dialog .sub { color: var(--fg2); line-height: 1.5; }

/* The code sits on its own white plate in BOTH themes. Scanners are built for dark-on-light,
 * and inverting it on the night theme costs reliability for nothing — this is one of the few
 * places where matching the surrounding palette would be the wrong call. */
.qr-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line-hard);
}
.qr { display: block; width: 232px; height: 232px; max-width: 100%; }

/* ---------------------------------------------------------------- inspector panel
 *
 * Metrics from the quick-look inspector in the Explorations file (option 1d): 4/3 preview at
 * radius 9, name at 600 14px, a Mono key/value fact list, tags, then stacked actions pinned
 * to the bottom. Same tokens as everything else - it reads as part of the same app rather
 * than a panel bolted on. */

.insp {
  width: 300px;
  flex: none;
  border-left: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
}

.insp-preview {
  aspect-ratio: 4 / 3;
  border-radius: 9px;
  border: 1px solid var(--line-hard);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
  /* The design's placeholder hatch, so an un-previewable file still reads as a preview slot
   * rather than an empty box. */
  background: repeating-linear-gradient(135deg, var(--seg) 0 7px, transparent 7px 14px);
}
.insp-preview .ph {
  font: 600 10px/1 var(--mono);
  letter-spacing: .11em;
  color: var(--fg2);
}
.insp-preview.has-img { background: var(--seg); }
.insp-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }

.insp-name {
  font: 600 14px/1.3 var(--ui);
  color: var(--fg);
  margin-bottom: 4px;
  word-break: break-word;
}
.insp-meta {
  font: 400 11px/1.4 var(--mono);
  color: var(--fg3);
  margin-bottom: 16px;
}

.insp-block {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  flex: none;
}
.insp-block.facts { display: flex; flex-direction: column; gap: 9px; }

.fact { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fact .k {
  font: 600 9.5px/1 var(--mono);
  letter-spacing: .07em;
  color: var(--fg2);
  flex: none;
}
.fact .v {
  font: 400 11px/1.4 var(--mono);
  color: var(--fg-soft);
  text-align: right;
  min-width: 0;
  word-break: break-word;
}

.insp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; flex: none; }
.addtag {
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px dashed var(--line-hard);
  font: 400 10.5px/1 var(--ui);
  color: var(--fg3);
}
.addtag:hover { color: var(--fg); border-color: var(--accent); }

.insp-acts { display: flex; flex-direction: column; gap: 7px; flex: none; }
.insp-acts .primary { height: 36px; border-radius: 8px; font-size: 12px; }
.insp-acts .two { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.insp-acts .ghost {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font: 500 11.5px/1 var(--ui);
  color: var(--fg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.insp-acts .ghost[disabled] { opacity: .4; cursor: default; }
.insp-acts .ghost[disabled]:hover { background: none; color: var(--fg-soft); }
.insp-acts .ghost.danger { color: var(--danger); border-color: rgba(240, 141, 122, .28); }
.insp-acts .ghost.danger:hover { background: var(--danger-hover); color: var(--danger); }

.insp-note {
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--seg);
  font: 400 10.5px/1.45 var(--mono);
  color: var(--fg3);
}
.insp-empty {
  font: 400 12px/1.6 var(--ui);
  color: var(--fg3);
  padding: 8px 0;
}

/* --- transfers, from the design's TRANSFERS block */

.insp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 11px;
}
.insp-head .k { font: 600 9.5px/1 var(--mono); letter-spacing: .11em; color: var(--fg2); }
.insp-head .rate { font: 500 10px/1 var(--mono); color: var(--accent-text); }

.xfer + .xfer { margin-top: 12px; }
.xfer-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.xfer-top .nm { font: 400 12px/1 var(--ui); color: var(--fg); min-width: 0; }
.xfer-top .pct { font: 500 10px/1 var(--mono); color: var(--accent-text); flex: none; }
.xfer-track {
  height: 3px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
  margin-bottom: 8px;
}
.xfer-track i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .2s ease;
}
.xfer-detail { font: 400 10px/1.4 var(--mono); color: var(--fg3); }

.info-toggle { width: 28px; height: 28px; border-radius: 7px; }
.info-toggle.on { background: var(--seg-on); color: var(--fg); border-color: transparent; }

/* ---------------------------------------------------------------- selection bar */

.selbar {
  position: sticky;
  bottom: 22px;
  z-index: 30;
  margin: 0 auto;
  max-width: calc(100% - 36px);
  width: max-content;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 8px 7px 14px;
  border-radius: 11px;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  box-shadow: 0 12px 34px var(--bar-shadow);
}
.selbar .n { font: 600 11.5px/1 var(--ui); color: var(--bar-fg); white-space: nowrap; }
.selbar .b { font: 400 10.5px/1 var(--mono); color: var(--bar-fg2); margin-right: 6px; white-space: nowrap; }
.selbar button {
  padding: 6px 11px;
  border-radius: 7px;
  font: 500 11.5px/1 var(--ui);
  color: var(--bar-fg2);
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.selbar button:hover { background: var(--bar-hover); color: var(--bar-fg); }
.selbar button.del { color: var(--danger); }
.selbar button.del:hover { background: var(--danger-hover); color: var(--danger); }
.selbar .vline { background: var(--bar-line); height: 18px; margin: 0 4px; }
.selbar .x {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

/* ---------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 74px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - 36px);
}
.toast {
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  box-shadow: 0 12px 34px var(--bar-shadow);
  font: 500 12px/1.4 var(--ui);
  color: var(--bar-fg);
  text-align: center;
}
.toast.bad { color: var(--danger); }

/* ---------------------------------------------------------------- overlay (rename, mkdir) */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog {
  width: 100%;
  max-width: 352px;
  padding: 18px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line-hard);
  box-shadow: 0 24px 60px var(--bar-shadow);
}
.dialog h3 {
  margin: 0 0 14px;
  font: 600 15px/1.2 var(--ui);
  letter-spacing: -.01em;
}
.dialog .acts { display: flex; gap: 8px; margin-top: 16px; }
.dialog .acts .primary { height: 36px; border-radius: 7px; font-size: 12.5px; }
.ghost {
  height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--line-hard);
  font: 500 12.5px/1 var(--ui);
  color: var(--fg2);
  flex: none;
}
.ghost:hover { color: var(--fg); background: var(--hover); }

/* ---------------------------------------------------------------- drop target */

.dropping::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 12px;
  border: 2px dashed var(--accent);
  background: var(--accent-bg);
  pointer-events: none;
  z-index: 40;
}
.main { position: relative; }

/* ---------------------------------------------------------------- responsive
 *
 * All three breakpoints matter equally. Nothing here is allowed to overflow: the header,
 * the filter bar and the selection bar wrap, the breadcrumb collapses from the left, and
 * the search field gives up its width before the path does. */

/* The inspector is the first thing to go when space runs short: the file list is the
 * point of the page, and a 300px panel on a 1000px window leaves it cramped. */
@media (max-width: 1180px) {
  .insp { display: none; }
  .info-toggle { display: none; }
}

@media (max-width: 1000px) {
  .side { width: 200px; }
  .lhead, .lrow { grid-template-columns: minmax(0, 1fr) 92px 84px; }
  .lhead .md, .lrow .md { display: none; }
}

@media (max-width: 760px) {
  .head { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .crumbs { order: 3; flex: 1 0 100%; }
  .search { flex: 1 1 140px; }
  .badge { order: 4; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: 260px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: 0 0 40px var(--bar-shadow);
  }
  .side.open { transform: none; }
  .body.side-open::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 44;
    background: rgba(0, 0, 0, .45);
  }
  .burger { display: flex !important; }
  .lhead, .lrow { grid-template-columns: minmax(0, 1fr) 84px; padding: 0 14px; }
  .lhead .tg, .lrow .tg { display: none; }
  .filters { padding: 9px 14px; }
}

.burger { display: none; }

@media (max-width: 480px) {
  .login-mid { padding: 16px 16px 48px; }
  .head { padding: 10px 12px; }
  .filters { padding: 8px 12px; gap: 6px; }
  .lhead, .lrow { padding: 0 12px; }
  .selbar { padding: 7px 8px; gap: 3px; }
  .selbar button { padding: 6px 9px; }
  /* Free placement is a desktop affordance. On a phone the same toggle gives a tidy
   * scrolling grid instead, so a tile can never be dragged somewhere unreachable. */
  .canvas.flow {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
    gap: 4px;
    padding: 12px;
    align-content: start;
  }
  .canvas.flow .tile { position: static !important; width: auto; cursor: default; }
  .canvas.flow .spacer-y { display: none; }
}
