/* One dark theme, no assets: the box art is the only image the app loads. */
:root {
  --bg: #11151c;
  --panel: #182029;
  --panel-2: #1e2732;
  --line: #2a3440;
  --ink: #e8eef5;
  --ink-dim: #93a4b8;
  --accent: #37b98a;
  --accent-ink: #05130d;
  --warn: #e0a44a;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* The scrollbars are part of the theme too: the platform's own are light, and a white
   track down the side menu of a dark window looks like a mistake. */
* {
  scrollbar-width: thin;
  scrollbar-color: #33414f transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #33414f;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #46586b; background-clip: content-box; }

/* An explicit `display` beats the browser's own [hidden] rule, and most of the
   regions here have one — the gate's store picker showed as an empty stub because
   of exactly that. This makes `hidden` mean hidden everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- shell: the side menu and everything else --------------------------- */
.shell {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;   /* so the collapsed menu is clipped rather than scrolled to */
}
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.side {
  --side-width: 244px;
  width: var(--side-width);
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  /* The menu itself does not scroll: the category list does. Letting the whole
     column scroll made the bottom block — pinned there with margin-top: auto —
     sit on top of the overflowing categories. */
  overflow: hidden;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: margin-left .16s ease-out;
}
body.nav-closed .side { margin-left: calc(-1 * var(--side-width)); }

.side-block { display: flex; flex-direction: column; gap: 6px; flex: none; }
.side-cats { flex: 1; min-height: 0; }
.side-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  gap: 8px;
  flex-direction: row;
  align-items: center;
}
/* The icons sit at the end of the footer row, away from the log toggle. */
.side-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.side-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 2px 4px;
}
.btn-wide { width: 100%; text-align: left; }

.nav-toggle {
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--ink-dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.nav-toggle:hover { color: var(--ink); border-color: #3a4757; }

/*
 * Store switcher: one row per store on this machine, the open one marked.
 *
 * The row is a wrapper holding two buttons — open, and remove — rather than being a
 * button itself: a button inside a button is invalid markup, and the inner click would
 * reach the outer handler anyway. So the framing lives on the wrapper and the padding
 * on the part that is actually clicked, or the click target would be smaller than the
 * thing it looks like.
 */
.store-list { display: flex; flex-direction: column; gap: 4px; }
.store-row {
  display: flex;
  align-items: stretch;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}
.store-row:hover { background: var(--panel-2); }
.store-row.is-active {
  background: var(--panel-2);
  border-color: #2f5a49;
}
.store-row-open {
  flex: 1;
  min-width: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 8px 0 0 8px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.store-row .store-row-name { font-weight: 600; }
.store-row .store-row-id {
  font-size: 11px;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/*
 * Remove appears on hover or focus only. It is destructive, and it sits in a list
 * whose ordinary use is switching stores — it should not be under the pointer of
 * every routine click. :focus-within is what keeps it reachable by keyboard.
 */
.store-row-remove {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border: none;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms, color 120ms;
}
.store-row:hover .store-row-remove,
.store-row:focus-within .store-row-remove { opacity: 1; }
.store-row-remove:hover { color: var(--warn); }
.store-row-open:disabled { opacity: .55; cursor: default; }
.store-row-remove:disabled { opacity: 0; cursor: default; }
.icon-trash { width: 14px; height: 14px; }

/* Categories: what the catalog is filtered down to. */
.cats { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.cat {
  font: inherit;
  text-align: left;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cat:hover { background: var(--panel-2); color: var(--ink); }
.cat.is-active { background: var(--panel-2); color: var(--ink); font-weight: 600; }
.cat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; }
.cat-group {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #6b7d92;
  padding: 8px 10px 2px;
}

/*
 * An icon-only control: a square the size of its glyph, quiet until pointed at.
 * `position: relative` is what lets the language picker put its <select> on top.
 */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.icon-btn:active:not(:disabled) { transform: scale(.94); }
.icon-btn:disabled { opacity: .4; cursor: default; }
/* The select swallows focus, so the ring has to be drawn on the label around it. */
.icon-btn:focus-visible,
.icon-btn:focus-within { color: var(--ink); border-color: var(--accent); outline: none; }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }

/*
 * The real <select>, stretched over the icon and invisible. It keeps the native
 * dropdown — and its keyboard and screen-reader behaviour — while only the glyph shows.
 */
.locale-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  appearance: none;
  font: inherit;
}

/* --- top bar ------------------------------------------------------------ */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.bar-title { display: flex; align-items: baseline; gap: 10px; font-weight: 700; margin-right: auto; }
.logo { color: var(--accent); font-size: 18px; }
.store-id {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.bar-actions { display: flex; align-items: center; gap: 8px; }
.progress { color: var(--ink-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

/* --- controls ----------------------------------------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover:not(:disabled) { background: #26313e; border-color: #3a4757; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: #45cd9b; }
.btn-ghost { background: transparent; color: var(--ink-dim); }
/*
 * The second-choice button: present and pressable, but not the one the eye lands on.
 * Used where a card offers signing in rather than installing, and beside the typed
 * catalog address — both are real actions that are not the primary one.
 */
.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--panel-2); border-color: #3a4757; }
.btn-tiny { padding: 3px 9px; font-size: 12px; font-weight: 500; }
.select {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* --- gate (no store yet) ---------------------------------- */
.gate {
  margin: auto;
  max-width: 520px;
  padding: 28px;
  text-align: center;
}
.gate h1 { font-size: 20px; margin: 0 0 10px; }
.gate p { color: var(--ink-dim); white-space: pre-line; margin: 0 0 20px; word-break: break-all; }
.gate-actions { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.gate-choice { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-dim); font-size: 13px; }

/* --- signing in --------------------------------------------------------- */
/*
 * The code, while somebody carries it to a browser. A band across the top of the
 * content rather than a screen of its own: the sign-in is happening elsewhere, and
 * there is no reason the catalog should stop being readable while it does.
 */
.signin {
  margin: 18px 18px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
}
.signin h2 { margin: 0 0 6px; font-size: 16px; }
.signin p { margin: 0 0 10px; color: var(--ink-dim); font-size: 13px; }
/* The one thing on screen somebody has to copy by eye, so: large, spaced, and
   selectable — a code that cannot be highlighted is a code that has to be retyped. */
.signin-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px;
  letter-spacing: 0.22em;
  color: var(--ink);
  user-select: text;
}
.signin-waiting { font-size: 12px; }
.signin-actions { display: flex; gap: 10px; justify-content: center; }

/* --- the grid ----------------------------------------------------------- */
.grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  /* Narrower than it was: the side menu takes 244px off the window, and at 260px
     a 1040px window had room for only two columns. */
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  padding: 18px;
  /* Content-sized rows, spelled out. Left to `auto` the implicit rows split the
     grid's height evenly — every card came out 94px tall with its box art
     collapsed to nothing and its buttons clipped away, which is how the grid
     looked before this was measured. */
  grid-auto-rows: max-content;
  align-content: start;
}
.empty { margin: auto; color: var(--ink-dim); }
/* A title somebody has not bought is not a broken one: the dimming and the dashed
   border belong to what this *machine* cannot do, and there is nothing wrong with
   the machine here. */
.card.is-purchasable { opacity: 1; }
.side-quiet-text { color: var(--ink-dim); font-size: 12px; margin: 0 0 8px; }

/* --- the gate's typed-address row ---------------------------------------- */
.gate-custom {
  margin: 22px auto 0;
  max-width: 460px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: left;
}
.gate-custom-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.gate-custom-row { display: flex; gap: 8px; }
.gate-custom-row .input { flex: 1; min-width: 0; }
.gate-custom-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.5;
}
.input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate { overflow-y: auto; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.is-installed { border-color: #2f5a49; }
/* Listed, but not for this machine: dimmed rather than hidden, and it says why. */
.card.is-unavailable { opacity: .55; }
.card.is-unavailable:hover { opacity: .8; }
.card.is-unavailable .art { filter: grayscale(1); }
.badge-unavailable { color: var(--ink-dim); border-color: var(--line); border-style: dashed; }
.actions-note { font-size: 12px; color: var(--ink-dim); margin-top: auto; }

.art {
  /* One height for every card, art or not, so the titles and the buttons line up
     across a row. The images are cropped anyway (object-fit: cover). */
  height: 148px;
  flex: none;
  background: #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.art img { width: 100%; height: 100%; object-fit: cover; }
.art-glyph { font-size: 44px; font-weight: 700; color: #263341; }

.body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.body h2 { font-size: 15px; margin: 0; }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.badge-app { color: var(--accent); border-color: #2f5a49; }
.badge-web { color: var(--warn); border-color: #5a4a2f; }
/* A price reads as a fact rather than a warning: same weight as the mode badges,
   filled rather than outlined, so it is findable while scanning a row of cards. */
.badge-price {
  color: var(--ink);
  background: var(--panel-2);
  border-color: var(--line);
}
.badge-owned { color: var(--accent); border-color: #2f5a49; }
.version { font-size: 12px; color: var(--ink-dim); margin-left: auto; }
.desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.actions { display: flex; gap: 8px; margin-top: auto; }

/* --- the card's actions menu -------------------------------------------- */
/*
 * A <details> holding the two actions that are not the card's headline. The card is the
 * positioning context, and the panel is pinned to the button's right edge so it opens
 * inward rather than off the side of the grid.
 */
.menu { position: relative; margin-left: auto; }
.menu-toggle { list-style: none; }
/* Safari and Chrome each draw their own marker on a summary; both have to go. */
.menu-toggle::-webkit-details-marker { display: none; }
.menu-toggle::marker { content: ''; }
.menu[open] .menu-toggle { color: var(--ink); background: var(--panel-2); border-color: var(--line); }

.menu-items {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  min-width: 148px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgb(0 0 0 / .45);
}
.menu-item {
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover:not(:disabled) { background: #2b3746; }
.menu-item:disabled { color: var(--ink-dim); opacity: .5; cursor: default; }

.icon-dots { fill: currentColor; stroke: none; }

/* An installed version with a newer one behind it: the arrow carries the news, so the
   colour only has to make it findable in a grid. */
.version.has-update { color: var(--accent); font-weight: 600; }


/* --- log ----------------------------------------------------------------
   No permanent footer: the panel is in the flow only while it is open, and the
   switch for it sits in the side menu with everything else that is not a title. */
.log-panel {
  flex: none;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 18px 10px;
}
.side-quiet {
  font: inherit;
  font-size: 12px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  margin-left: -6px;
  text-align: left;
  cursor: pointer;
}
.side-quiet:hover { color: var(--ink); background: var(--panel-2); }
.side-quiet.is-active { color: var(--accent); }
.log-lines {
  max-height: 150px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--ink-dim);
  background: #0d1117;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.log-line { white-space: pre-wrap; word-break: break-all; }
.log-paths { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.paths-line {
  font-size: 11.5px;
  color: var(--ink-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}
