/* The mobile viewer's chrome, as the Android app draws it: a dark ground, the
   card top left, the toolbar top right, the dock at the foot, the triad in the
   corner, a drawer from the left for the parts and centred dialogs for the
   rest. The accent is the app's (#6750A4), the dialogs' ground the store's
   (#212429). */
:root {
  --ground: #212429;
  --accent: #6750a4;
  --surface: #2e3238;
  --outline: #6b7178;
  --muted: #b8bdc4;
  --scrim: rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #212429; color: #fff; font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; }
#viewport { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* The card. */
.card { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; display: flex; gap: 10px; align-items: center; padding: 10px 14px 10px 10px; background: rgba(0, 0, 0, 0.72); border-radius: 14px; max-width: min(70vw, 440px); cursor: pointer; }
.card-mark { width: 40px; height: 40px; object-fit: contain; opacity: 0.9; }
.card-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-line { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#card-line1 { white-space: normal; }
.card-line:empty { display: none; }
.card-text { min-width: 0; }
.card .bar { margin-top: 6px; }

/* A phone held upright has no room for the card beside the toolbar: the card
   goes under it. */
@media (max-width: 640px) {
  .card { top: calc(max(12px, env(safe-area-inset-top)) + 60px); max-width: calc(100vw - 24px); }
}

/* The toolbar. */
.toolbar { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, 0.72); border-radius: 14px; }
.tool { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; }
.tool svg { width: 24px; height: 24px; fill: currentColor; }
.tool:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.tool:disabled { opacity: 0.35; cursor: default; }

/* The dock. */
.dock { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, 0.72); border-radius: 999px; }
.layer { border: 0; border-radius: 999px; padding: 8px 16px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.layer.on { background: var(--accent); color: #fff; }
.layer:disabled { opacity: 0.3; cursor: default; }

/* The triad. */
#triad { position: fixed; left: 8px; bottom: max(8px, env(safe-area-inset-bottom)); width: 104px; height: 104px; touch-action: none; }

/* The drawer. */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(76vw, 420px); background: rgba(22, 24, 28, 0.94); color: #fff; display: flex; flex-direction: column; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4); }
.drawer-page { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; gap: 4px; padding: max(6px, env(safe-area-inset-top)) 4px 6px 16px; }
.drawer-title { flex: 1; font-weight: 600; font-size: 16px; }
.details-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.icon-button { width: 40px; height: 40px; border: 0; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; border-radius: 10px; }
.icon-button svg { width: 22px; height: 22px; fill: currentColor; }
.icon-button:hover { background: rgba(255, 255, 255, 0.08); }
.text-button { border: 0; background: transparent; color: #fff; cursor: pointer; padding: 8px 12px; border-radius: 10px; font-weight: 600; }
.text-button:hover { background: rgba(255, 255, 255, 0.08); }
.text-button.on { color: #d0bcff; }
.filter { padding: 0 12px 6px; }
.filter input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--outline); background: rgba(255, 255, 255, 0.06); color: #fff; font: inherit; }
.filter-error { color: #ffb4ab; font-size: 12px; padding: 4px 2px 0; }
.tree { flex: 1; overflow-y: auto; padding: 0 4px 12px; }
.tree-row { display: flex; align-items: center; height: 36px; gap: 2px; cursor: pointer; border-radius: 8px; padding-right: 2px; }
.tree-row:hover { background: rgba(255, 255, 255, 0.06); }
.tree-row.selected { background: rgba(103, 80, 164, 0.35); }
.tree-row.greyed .tree-name, .tree-row.greyed .tree-count { opacity: 0.4; }
.tree-row.match .tree-name { color: #d0bcff; }
.chev { width: 28px; height: 28px; flex: none; display: grid; place-items: center; color: var(--muted); }
.chev svg { width: 18px; height: 18px; fill: currentColor; transition: transform 120ms; }
.chev.open svg { transform: rotate(90deg); }
.chev.leaf { visibility: hidden; }
.tree-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-count { font-size: 12px; color: var(--muted); padding: 0 4px; }
.tree-row .icon-button { width: 32px; height: 32px; }
.tree-row .icon-button svg { width: 18px; height: 18px; }
.details-path { padding: 4px 16px 8px; font-size: 12px; color: var(--muted); }
.details-body { flex: 1; overflow-y: auto; padding: 0 16px 12px; }
.section { font-weight: 600; margin: 12px 0 4px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 2px 10px; font-size: 13px; padding: 3px 0; }
.kv .k { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv .v { word-break: break-word; }
.details-foot { display: flex; gap: 8px; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }

/* Dialogs. */
.dialog-scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; }
.dialog { width: min(100%, 520px); max-height: 90vh; background: var(--ground); border-radius: 24px; display: flex; flex-direction: column; overflow: hidden; }
.dialog-head { display: flex; align-items: center; padding: 12px 8px 4px 24px; }
.dialog-title { flex: 1; font-size: 22px; }
.dialog-body { overflow-y: auto; padding: 8px 24px 24px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.row-text { flex: 1; }
.row-title { font-size: 16px; }
.row-sub { font-size: 12px; color: var(--muted); }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--surface); border: 1px solid var(--outline); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: left 120ms, background 120ms; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 23px; background: #fff; }
.choice { display: flex; gap: 4px; }
.choice button { border: 0; border-radius: 8px; padding: 6px 10px; background: var(--surface); color: #fff; cursor: pointer; font-size: 13px; }
.choice button.on { background: var(--accent); }
.tabs { display: flex; border-bottom: 1px solid var(--outline); margin-top: 8px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px 0; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: #fff; border-bottom-color: var(--accent); }
.presets { display: flex; gap: 10px; padding: 12px 0 4px; }
.preset { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); cursor: pointer; }
.presets.disabled .preset { opacity: 0.35; pointer-events: none; }
input[type="color"] { width: 48px; height: 32px; border: 0; background: transparent; cursor: pointer; }
.about { align-items: center; padding: 24px; position: relative; text-align: center; gap: 10px; }
.about-close { position: absolute; top: 6px; right: 6px; }
.lockup { height: 190px; }
.about-version { font-size: 12px; color: rgba(255, 255, 255, 0.6); }
.about-copy { color: rgba(255, 255, 255, 0.85); }
.about-device { display: grid; grid-template-columns: 92px 1fr; gap: 2px 8px; text-align: left; font-size: 12px; width: 100%; }
.about-device .k { color: rgba(255, 255, 255, 0.55); }
.about-device .v { color: rgba(255, 255, 255, 0.85); word-break: break-all; }
.outlined { border: 1px solid var(--outline); border-radius: 999px; padding: 8px 20px; color: #fff; text-decoration: none; }

/* A file over the page. */
.drop-hint { position: fixed; inset: 0; background: rgba(103, 80, 164, 0.25); display: grid; place-items: center; z-index: 9; pointer-events: none; outline: 3px dashed var(--accent); outline-offset: -12px; }
.drop-box { background: var(--ground); border-radius: 16px; padding: 16px 28px; font-size: 18px; font-weight: 600; }

/* No WebGPU. */
.loading { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 10; }
.loading-box { background: var(--ground); border-radius: 16px; padding: 20px 24px; min-width: 260px; max-width: 90vw; }
.bar { height: 4px; border-radius: 2px; background: var(--surface); overflow: hidden; }
#card-bar { height: 100%; width: 0; background: var(--accent); transition: width 120ms; }
