:root {
  --bg: #0b0e14; --panel: #151a23; --border: #232a37; --text: #eef1f6; --muted: #8892a0;
  --accent: #7c3aed; --accent-2: #c026d3;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f4f5f9; --panel: #ffffff; --border: #e3e6ee; --text: #14171f; --muted: #656e7d; }
}
:root[data-theme="light"] { --bg: #f4f5f9; --panel: #ffffff; --border: #e3e6ee; --text: #14171f; --muted: #656e7d; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input { outline: none; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.brandcol { flex: 1; }
.topbar h1 {
  font-size: 1.25rem; margin: 0; line-height: 1.1;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brandsub { font-size: .7rem; color: var(--muted); font-weight: 600; }
.topbtn { font-size: 1.25rem; padding: 6px; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 80px; }

/* ---------- featured spotlight ---------- */
.featured {
  border-radius: 20px; padding: 16px; color: #fff; cursor: pointer;
  box-shadow: 0 10px 30px rgba(124, 58, 237, .25); margin-bottom: 16px;
  transition: background .6s ease;
}
.featbadge { font-size: .68rem; font-weight: 800; letter-spacing: .06em; opacity: .9; margin-bottom: 10px; }
.featrow { display: flex; align-items: center; gap: 12px; }
.featicon {
  width: 54px; height: 54px; border-radius: 15px; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-size: 1.7rem; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.featmeta { flex: 1; min-width: 0; }
.featname { font-weight: 800; font-size: 1.05rem; }
.feattag { font-size: .78rem; opacity: .92; }
.featopen {
  background: #fff; color: #111; font-weight: 800; border-radius: 20px; padding: 9px 18px; font-size: .85rem;
  flex-shrink: 0;
}
.featopen:active { transform: scale(.95); }

/* ---------- search ---------- */
.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 14px; margin-bottom: 12px;
}
.searchbar input { flex: 1; background: none; border: none; font-size: .95rem; }
.searchbar input::placeholder { color: var(--muted); }

/* ---------- category chips ---------- */
.catchips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.catchips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; background: var(--panel); color: var(--muted);
  border: 1px solid var(--border); border-radius: 20px; padding: 8px 15px;
  font-size: .82rem; font-weight: 600; transition: all .15s ease;
}
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }

/* ---------- recently opened ---------- */
.secttitle { font-size: .95rem; margin: 10px 0 10px; }
.recentrow { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.recentrow::-webkit-scrollbar { display: none; }
.recentitem {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 600; color: var(--text); flex-shrink: 0; width: 64px;
}
.recenticon {
  width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.recentitem:active .recenticon { transform: scale(.92); }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 20px 12px 16px; color: var(--text);
  transition: transform .12s ease, border-color .15s ease, box-shadow .2s ease;
}
.tile:active { transform: scale(.96); }
.tile:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(124, 58, 237, .15); }
.tileicon {
  width: 58px; height: 58px; border-radius: 17px; display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; box-shadow: 0 6px 16px rgba(0,0,0,.25);
}
.tilename { font-weight: 700; font-size: .92rem; }
.tiletagline { font-size: .72rem; color: var(--muted); line-height: 1.35; min-height: 2em; }
.tileopen { font-size: .75rem; font-weight: 700; color: var(--accent-2); }

.empty { color: var(--muted); text-align: center; margin-top: 30px; }

/* ---------- detail sheet ---------- */
.sheetwrap {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); border: 1px solid var(--border); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheethead { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.sheeticon {
  width: 64px; height: 64px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; flex-shrink: 0; box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.sheetmeta h3 { margin: 0 0 3px; font-size: 1.15rem; }
.sheettag { font-size: .8rem; color: var(--muted); }
.sheetdesc { font-size: .88rem; line-height: 1.55; color: var(--text); margin: 0 0 16px; }
.sheetbtns { display: flex; gap: 10px; }
.sheetbtns .btn { flex: 1; text-align: center; text-decoration: none; }

/* ---------- shared ---------- */
.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border-radius: 12px; padding: 12px 18px; font-weight: 700; display: inline-block;
}
.btn.small { padding: 8px 14px; font-size: .85rem; }
.btn.ghost { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.linkbtn { color: var(--muted); font-weight: 600; padding: 10px; display: block; margin: 6px auto 0; }
.row { display: flex; gap: 8px; flex-shrink: 0; }

.install {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  max-width: 560px; margin: 0 auto;
}

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 10px 18px; font-size: .85rem; box-shadow: 0 4px 16px rgba(0,0,0,.35);
  white-space: nowrap;
}
