/* App Depot: one card per app, newest build up front. */
:root {
  --ground: #f4f4f7; --surface: #ffffff; --surface-2: #ececf2; --ink: #17181d; --muted: #5f6170; --line: #dddde5;
  --accent: #3b4fd8; --accent-ink: #ffffff; --accent-soft: #e6e9fc; --accent-text: #3346c9;
  --release: #0f7a4a; --release-soft: #e1f3ea; --test: #8a5a00; --test-soft: #fbf0d9; --danger: #b42318;
  --shadow: 0 1px 2px rgba(20, 22, 40, .05), 0 6px 18px rgba(20, 22, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #111216; --surface: #191a20; --surface-2: #22242c; --ink: #e7e8ee; --muted: #9a9cab; --line: #2b2d36;
    --accent: #8796ff; --accent-ink: #0f1330; --accent-soft: #23284a; --accent-text: #a3afff;
    --release: #5fd39a; --release-soft: #173326; --test: #f1bd5d; --test-soft: #352a14; --danger: #f88a80; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #111216; --surface: #191a20; --surface-2: #22242c; --ink: #e7e8ee; --muted: #9a9cab; --line: #2b2d36;
  --accent: #8796ff; --accent-ink: #0f1330; --accent-soft: #23284a; --accent-text: #a3afff;
  --release: #5fd39a; --release-soft: #173326; --test: #f1bd5d; --test-soft: #352a14; --danger: #f88a80; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--ground); color: var(--ink); font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }

.btn { min-height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 18px;
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); }
.btn svg { width: 18px; height: 18px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%;
  color: var(--ink); list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }

/* sign in */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(390px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card .brand { font-size: 22px; } .login-card .brand img { width: 38px; height: 38px; }
.sub { margin: -4px 0 6px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { border: 1px solid var(--line); background: var(--ground); border-radius: 10px; padding: 11px 12px; font-size: 16px; }
.login-card input[name=code] { letter-spacing: .3em; font-size: 18px; }
.login-card label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; }
.login-card label.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* shell */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.top .brand { flex: 1; }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: 46px; width: min(280px, calc(100vw - 32px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14); }
.menu-panel p { margin: 0; font-size: 14px; color: var(--muted); }
.main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.apps { display: grid; gap: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; margin: 0; background: var(--surface); border: 1px dashed var(--line); border-radius: 16px; }

/* app card */
.app-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.app-head { display: flex; align-items: center; gap: 12px; }
.app-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-size: 20px;
  background: var(--accent-soft); color: var(--accent-text); flex: none; text-transform: uppercase; }
.app-title h2 { margin: 0; font-size: 18px; line-height: 1.25; text-transform: capitalize; }
.app-sub { margin: 0; font-size: 13px; color: var(--muted); }

.build { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.latest .build { background: var(--surface-2); border-radius: 14px; padding: 12px 12px 12px 14px; }
.build-name { font-weight: 650; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; }
.tag.release { background: var(--release-soft); color: var(--release); }
.tag.test { background: var(--test-soft); color: var(--test); }
.build-meta { grid-column: 1; font-size: 12.5px; color: var(--muted); }
.build .btn { grid-column: 2; grid-row: 1 / span 2; }
.build-notes { grid-column: 1 / -1; margin: 2px 0 0; font-size: 13.5px; }
.build-sha { grid-column: 1 / -1; font: 11px/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.latest { display: grid; gap: 10px; }

.older summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent-text); list-style: none; min-height: 32px;
  display: flex; align-items: center; gap: 6px; }
.older summary::-webkit-details-marker { display: none; }
.older summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); }
.older[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.older-list { display: grid; }
.older-list .build { padding: 10px 0; border-top: 1px solid var(--line); }

.help { color: var(--muted); font-size: 13.5px; padding: 0 4px; }
.help h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; }
.help p { margin: 0 0 8px; }

@media (max-width: 420px) {
  .build { grid-template-columns: 1fr; }
  .build .btn { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 6px; }
}
