/* Colours. Change --accent to restyle buttons and links. */
:root {
  --accent: #2b5fd9;
  --accent-hover: #234fb8;
  --on-accent: #ffffff;

  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f2f0eb;
  --border: #e3e0d9;
  --border-strong: #cfcbc2;
  --text: #1d1c1a;
  --text-2: #4d4a45;
  --muted: #7a766f;
  --focus: #2b5fd9;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #7ea2f2;
    --accent-hover: #9ab6f5;
    --on-accent: #10131a;
    --bg: #171614;
    --surface: #1e1d1a;
    --surface-2: #262420;
    --border: #33312c;
    --border-strong: #46433d;
    --text: #ece9e3;
    --text-2: #bdb8af;
    --muted: #8e897f;
    --focus: #7ea2f2;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --accent: #7ea2f2;
  --accent-hover: #9ab6f5;
  --on-accent: #10131a;
  --bg: #171614;
  --surface: #1e1d1a;
  --surface-2: #262420;
  --border: #33312c;
  --border-strong: #46433d;
  --text: #ece9e3;
  --text-2: #bdb8af;
  --muted: #8e897f;
  --focus: #7ea2f2;
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 16px/1.6 var(--font);
  color: var(--text);
  background: var(--bg);
}
main { flex: 1; width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 600; margin-right: auto; min-width: 0; }
.brand:hover { color: var(--text); }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplinks { display: flex; gap: 18px; }
.toplinks a { color: var(--text-2); font-size: 15px; text-decoration: none; }
.toplinks a:hover { color: var(--text); text-decoration: underline; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font-size: 18px; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.i-moon { display: none; }
:root[data-theme="light"] .i-sun, :root:not([data-theme]) .i-sun { display: none; }
:root[data-theme="light"] .i-moon, :root:not([data-theme]) .i-moon { display: block; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .i-sun { display: block; }
  :root:not([data-theme]) .i-moon { display: none; }
}

/* Intro */
.intro { padding: 44px 0 28px; }
.intro h1 { margin: 0; font-size: clamp(28px, 4.5vw, 36px); line-height: 1.15; letter-spacing: -.015em; font-weight: 700; }
.tagline { margin: 8px 0 0; max-width: 34em; color: var(--text-2); font-size: 17px; }

/* Search + filters */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 220px; max-width: 320px;
  height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: text;
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.search svg { font-size: 17px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; color: var(--text); font-size: 15px; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 14px; cursor: pointer;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.chip .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.device-hint { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.device-hint strong { color: var(--text-2); font-weight: 600; }
.status { color: var(--muted); margin: 20px 0; }
.status:empty { display: none; }
.status .link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; padding: 0; }

/* Resource list: one row per resource. */
.list { padding-bottom: 56px; }
.item {
  display: grid; grid-template-columns: 56px 1fr; gap: 6px 18px;
  padding: 24px 0; border-bottom: 1px solid var(--border);
}
.item > .app-icon { grid-row: span 2; }
.item-main { min-width: 0; }
.item-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.item-title h2 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 650; }
.item-title h2 a { color: var(--text); text-decoration: none; }
.item-title h2 a:hover { text-decoration: underline; }
.meta { margin: 0; font-size: 13.5px; color: var(--muted); }
.summary { margin: 6px 0 0; color: var(--text-2); max-width: 40em; }
.platforms { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.platform { display: inline-flex; align-items: center; gap: 5px; }
.platform svg { font-size: 15px; }
.platform.match { color: var(--text); font-weight: 550; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 6px; }
.item-actions .more { font-size: 14px; color: var(--text-2); text-decoration: none; }
.item-actions .more:hover { color: var(--text); text-decoration: underline; }
.label-featured { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 6px; line-height: 20px; }

@media (min-width: 720px) {
  .item { grid-template-columns: 56px 1fr auto; }
  .item > .app-icon { grid-row: auto; }
  .item-actions { flex-direction: column; align-items: flex-end; margin-top: 0; }
}

.app-icon {
  width: 56px; height: 56px; border-radius: 12px; flex: none; object-fit: cover;
  display: grid; place-items: center; font-weight: 700; font-size: 22px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
}
img.app-icon { border: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 1px 8px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 6px;
  font-size: 15px; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--on-accent); }
.btn .label { overflow: hidden; text-overflow: ellipsis; }
.btn .size { font-weight: 400; opacity: .8; font-size: 13px; }
.btn .size:empty { display: none; }
.btn svg { font-size: 17px; }

/* Detail dialog */
dialog {
  width: min(640px, calc(100% - 24px)); max-height: calc(100% - 48px);
  padding: 0; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 18, 15, .5); }
@media (max-width: 560px) {
  dialog { width: 100%; max-width: 100%; max-height: 92%; margin: auto 0 0; border-radius: 10px 10px 0 0; }
}

.sheet { padding: 22px; display: flex; flex-direction: column; gap: 22px; }
@media (min-width: 640px) { .sheet { padding: 28px; } }
.sheet-head { display: flex; gap: 14px; align-items: center; }
.sheet-head .app-icon { width: 60px; height: 60px; border-radius: 13px; }
.sheet-head h2 { margin: 0; font-size: 22px; line-height: 1.25; }
.sheet-head .close { margin-left: auto; align-self: flex-start; }
.desc p { margin: 0 0 10px; color: var(--text-2); }
.desc p:last-child { margin-bottom: 0; }
.section-title { margin: 0 0 10px; font-size: 15px; font-weight: 650; }

.dl-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; }
.dl { display: grid; gap: 8px; padding: 14px 16px; }
.dl + .dl { border-top: 1px solid var(--border); }
.dl-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dl-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; margin-right: auto; }
.dl-name svg { font-size: 18px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 500; color: var(--muted); }
.badge::before { content: "· "; }
.dl-info { margin: 0; font-size: 14px; color: var(--text-2); display: grid; gap: 6px; }
.dl-info .note { color: var(--text-2); background: var(--surface-2); padding: 6px 10px; border-radius: 6px; }
.hash { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hash code { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.copy { flex: none; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 4px; font-size: 12px; padding: 1px 7px; cursor: pointer; color: var(--text-2); }
.copy:hover { color: var(--text); }

.link-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Loading placeholder + footer */
.skeleton { height: 120px; border-bottom: 1px solid var(--border); position: relative; }
.skeleton::before, .skeleton::after { content: ""; position: absolute; background: var(--surface-2); border-radius: 4px; }
.skeleton::before { left: 0; top: 24px; width: 56px; height: 56px; border-radius: 12px; }
.skeleton::after { left: 74px; top: 28px; width: min(320px, 60%); height: 16px; }

.footer { border-top: 1px solid var(--border); padding: 20px 0 28px; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; }
