/* ============================================================
   PhysicsNP — App list pages (Home · Courses · Papers)
   Single markup, mobile-first; desktop from 900px.
   ============================================================ */
.pg { padding: .9rem .9rem calc(var(--tabbar-h, 70px) + 1.5rem); display: flex; flex-direction: column; gap: 1.35rem; }
.pg > .alert { margin: 0; }
.pg-sec { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.pg-sec-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.pg-sec-hd h2 { font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.pg-sec-hd a { font-size: .78rem; font-weight: 700; color: var(--brand); text-decoration: none; white-space: nowrap; }
.pg-sec-hd a:hover { text-decoration: underline; }
.pg-sec-hd small { font-size: .76rem; color: var(--ink-faint); font-weight: 600; }

/* Page header (courses / papers) */
.pg-head { display: flex; flex-direction: column; gap: .2rem; }
.pg-head h1 { font-family: 'Sora', 'Inter', sans-serif; font-size: 1.35rem; font-weight: 700; letter-spacing: -.03em; display: none; }
.pg-head p { font-size: .8rem; color: var(--ink-faint); font-weight: 500; }

/* Toolbar: search + filters */
.pg-tools { display: flex; flex-direction: column; gap: .65rem; }
.pg-search { position: relative; display: flex; align-items: center; }
.pg-search i { position: absolute; left: .95rem; color: var(--ink-faint); font-size: .85rem; pointer-events: none; }
.pg-search input {
  width: 100%; height: 44px; padding: 0 2.6rem 0 2.5rem; border-radius: var(--r-pill);
  background: var(--surface); border: 1.5px solid var(--glass-border); color: var(--ink);
  font: inherit; font-size: .88rem; outline: none; transition: border-color .2s, box-shadow .2s;
}
.pg-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow); }
.pg-search input::-webkit-search-cancel-button { display: none; }
.pg-search .clear { position: absolute; right: .55rem; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-faint); text-decoration: none; }
.pg-search .clear:hover { background: var(--surface-2); color: var(--ink); }
.pg-chips { display: flex; gap: .45rem; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.pg-chips::-webkit-scrollbar { display: none; }
.pg-chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  background: var(--surface); color: var(--ink-soft); border: 1.5px solid var(--glass-border); transition: all .15s;
}
.pg-chip:hover { border-color: var(--brand); color: var(--brand); }
.pg-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pg-chip em { font-style: normal; font-size: .68rem; opacity: .75; }
.pg-chip-sep { flex-shrink: 0; width: 1px; background: var(--glass-border); margin: .3rem .15rem; }
.pg-select {
  flex-shrink: 0; height: 34px; padding: 0 2rem 0 .85rem; border-radius: var(--r-pill); font: inherit; font-size: .78rem; font-weight: 700;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right .8rem center;
  border: 1.5px solid var(--glass-border); color: var(--ink-soft); appearance: none; cursor: pointer;
}
.pg-select.on { border-color: var(--brand); color: var(--brand); }
.pg-result { display: flex; align-items: center; justify-content: space-between; font-size: .76rem; color: var(--ink-faint); font-weight: 600; }
.pg-result a { color: var(--brand); text-decoration: none; font-weight: 700; }

/* Empty state */
.pg-empty { text-align: center; padding: 2.5rem 1.25rem; background: var(--surface); border: 1px dashed var(--glass-border); border-radius: var(--r-lg); }
.pg-empty > i { font-size: 1.9rem; color: var(--ink-faint); opacity: .6; }
.pg-empty h3 { font-size: .98rem; font-weight: 800; margin: .7rem 0 .25rem; }
.pg-empty p { font-size: .82rem; color: var(--ink-soft); margin-bottom: 1rem; }

/* Tones */
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); } .tone-brand { color: var(--brand); }
.tone-bg-ok { background: var(--ok); } .tone-bg-brand { background: var(--brand); }

/* ── Course card ───────────────────────────────────────── */
.cc-grid { display: grid; grid-template-columns: 1fr; gap: .7rem; }
.cc {
  display: flex; text-decoration: none; color: inherit; min-width: 0;
  background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.cc:hover { border-color: rgba(99,102,241,.3); box-shadow: var(--shadow-sm); }
.cc:active { transform: scale(.985); }
.cc-media { position: relative; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; color: var(--brand); background: linear-gradient(135deg, rgba(99,102,241,.16), rgba(14,165,233,.08)); }
.cc-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cc-media > i { font-size: 1.6rem; opacity: .75; }
.cc-level { position: absolute; left: .5rem; top: .5rem; font-size: .6rem; font-weight: 800; padding: .18rem .5rem; border-radius: var(--r-pill); background: rgba(15,23,42,.62); color: #fff; backdrop-filter: blur(6px); }
.cc-flag { position: absolute; right: .5rem; top: .5rem; display: inline-flex; align-items: center; gap: .25rem; font-size: .6rem; font-weight: 800; padding: .18rem .5rem; border-radius: var(--r-pill); color: #fff; }
.cc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; padding: .85rem .95rem; }
.cc-title { font-size: .92rem; font-weight: 800; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-meta { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .7rem; color: var(--ink-faint); font-weight: 600; }
.cc-meta i { margin-right: .3rem; }
.cc-desc { font-size: .78rem; color: var(--ink-soft); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-progress { display: flex; align-items: center; gap: .55rem; margin-top: .15rem; }
.cc-progress b { font-size: .7rem; font-weight: 800; color: var(--brand); min-width: 2.2em; text-align: right; }
.bar { flex: 1; height: 5px; border-radius: 5px; background: var(--surface-3); overflow: hidden; display: block; }
.bar > span { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--brand), var(--brand-light)); }
.bar.done > span { background: linear-gradient(90deg, var(--ok), #6ee7b7); }
.cc-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; padding-top: .25rem; font-size: .7rem; font-weight: 700; }
.cc-foot > span:first-child { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-cta { color: var(--brand); white-space: nowrap; }
.cc-cta i { font-size: .62rem; transition: transform .2s; }
.cc:hover .cc-cta i { transform: translateX(3px); }

/* Card variant: banner on top */
.cc-card { flex-direction: column; }
.cc-card .cc-media { aspect-ratio: 16 / 8; }
/* Row variant: thumbnail at the side */
.cc-row .cc-media { width: 92px; min-height: 92px; }
.cc-row .cc-level { display: none; }
.cc-row .cc-flag { left: .35rem; right: auto; top: auto; bottom: .35rem; }
.cc-row .cc-body { padding: .75rem .85rem; }
.cc-row .cc-title { font-size: .86rem; }

/* Phone: grid cards become rows for density */
@media (max-width: 599.98px) {
  .cc-grid .cc-card { flex-direction: row; }
  .cc-grid .cc-card .cc-media { width: 96px; aspect-ratio: auto; min-height: 104px; }
  .cc-grid .cc-card .cc-level { display: none; }
  .cc-grid .cc-card .cc-flag { left: .35rem; right: auto; top: auto; bottom: .35rem; }
  .cc-grid .cc-card .cc-desc { display: none; }
}

/* ── Paper card ────────────────────────────────────────── */
.pc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.pc {
  display: flex; flex-direction: column; text-decoration: none; color: inherit; min-width: 0;
  background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs); overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.pc:hover { border-color: rgba(245,158,11,.4); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.pc-media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, rgba(245,158,11,.14), rgba(251,191,36,.06)); }
.pc-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.pc-ph { font-size: 1.8rem; color: var(--accent); opacity: .55; }
.pc-year { position: absolute; left: .45rem; top: .45rem; font-size: .66rem; font-weight: 800; padding: .15rem .5rem; border-radius: var(--r-pill); background: var(--accent); color: #fff; box-shadow: 0 2px 8px var(--accent-glow); }
.pc-sol { position: absolute; right: .45rem; bottom: .45rem; font-size: .6rem; font-weight: 800; padding: .15rem .45rem; border-radius: var(--r-pill); background: var(--ok); color: #fff; }
.pc-body { display: flex; flex-direction: column; gap: .3rem; padding: .65rem .75rem .75rem; }
.pc-title { font-size: .8rem; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { display: flex; flex-wrap: wrap; gap: .25rem; }
.pc-meta span { font-size: .62rem; font-weight: 700; padding: .1rem .45rem; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-soft); }
.pc-meta span:first-child { background: rgba(99,102,241,.1); color: var(--brand); }

/* Horizontal rail on phones (home) */
.rail-x { display: grid; grid-auto-flow: column; grid-auto-columns: 72%; gap: .7rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -.9rem; padding: 2px .9rem 4px; }
.rail-x::-webkit-scrollbar { display: none; }
.rail-x > * { scroll-snap-align: start; }
.rail-x.papers { grid-auto-columns: 44%; }
.rail-x .cc-card { flex-direction: column; }
.rail-x .cc-card .cc-media { width: auto; aspect-ratio: 16 / 8; min-height: 0; }
.rail-x .cc-desc { display: none; }

/* Pager */
.pg-pager { display: flex; align-items: center; justify-content: center; gap: .4rem; flex-wrap: wrap; }
.pg-pager a, .pg-pager span { min-width: 38px; height: 38px; padding: 0 .75rem; display: inline-grid; place-items: center; border-radius: var(--r-pill); font-size: .8rem; font-weight: 700; text-decoration: none; border: 1.5px solid var(--glass-border); background: var(--surface); color: var(--ink-soft); }
.pg-pager a:hover { border-color: var(--brand); color: var(--brand); }
.pg-pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pg-pager .gap { border: 0; background: none; min-width: 0; padding: 0 .1rem; }

/* ── Home ──────────────────────────────────────────────── */
.hm-hero {
  position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 1.3rem 1.2rem; color: #fff;
  background:
    radial-gradient(circle at 105% -20%, rgba(255,255,255,.22) 0 28%, transparent 29%),
    radial-gradient(circle at -10% 130%, rgba(255,255,255,.14) 0 30%, transparent 31%),
    linear-gradient(125deg, var(--brand-dark), var(--brand) 50%, var(--teal));
  box-shadow: 0 12px 32px var(--brand-glow);
}
[data-theme="dark"] .hm-hero { background: radial-gradient(circle at 105% -20%, rgba(255,255,255,.12) 0 28%, transparent 29%), linear-gradient(125deg, #3730a3, #4f46e5 55%, #0369a1); }
.hm-kicker { font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.hm-hero h1 { font-family: 'Sora', 'Inter', sans-serif; font-size: 1.35rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.25; margin: .3rem 0 .35rem; }
.hm-hero p { font-size: .84rem; opacity: .88; line-height: 1.55; max-width: 34rem; }
.hm-stats { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.hm-stat { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border-radius: var(--r-pill); background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.2); font-size: .76rem; font-weight: 600; backdrop-filter: blur(8px); }
.hm-stat b { font-weight: 800; }
.hm-cta { display: flex; gap: .5rem; margin-top: 1.1rem; flex-wrap: wrap; }
.hm-cta .btn-white { background: #fff; color: var(--brand-dark); border: 0; }
.hm-cta .btn-white:hover { background: #eef2ff; }
.hm-cta .btn-glass { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); }

.hm-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.hm-tile {
  display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .85rem .4rem; text-align: center;
  background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--r-md); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-xs); transition: border-color .15s, transform .15s;
}
.hm-tile:hover { border-color: rgba(99,102,241,.3); transform: translateY(-2px); }
.hm-tile i { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1rem; }
.hm-tile b { font-size: .76rem; font-weight: 700; }
.hm-tile small { display: none; font-size: .68rem; color: var(--ink-faint); }
.ic-brand { background: rgba(99,102,241,.12); color: var(--brand); }
.ic-accent { background: rgba(245,158,11,.14); color: var(--accent-dark); }
.ic-teal { background: rgba(14,165,233,.12); color: var(--teal); }
.ic-ok { background: rgba(16,185,129,.12); color: var(--ok); }
.ic-red { background: rgba(239,68,68,.1); color: #ef4444; }
.ic-purple { background: rgba(168,85,247,.12); color: #a855f7; }

.hm-support { text-decoration: none; color: inherit; display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--glass-border); box-shadow: var(--shadow-xs); }
.hm-support > i:first-child { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #25d366; color: #fff; font-size: 1.15rem; flex-shrink: 0; }
.hm-support div { flex: 1; min-width: 0; }
.hm-support b { display: block; font-size: .84rem; }
.hm-support span { font-size: .74rem; color: var(--ink-faint); }

/* Home order on single-column layouts: continue first, support last */
.hm-grid { display: flex; flex-direction: column; gap: 1.35rem; }
.hm-grid > div { display: contents; }
.hm-o-continue { order: 1; } .hm-o-tiles { order: 2; } .hm-o-explore { order: 3; } .hm-o-papers { order: 4; } .hm-o-guest { order: 5; } .hm-o-support { order: 6; }

/* ── Tablet ────────────────────────────────────────────── */
@media (min-width: 600px) {
  .cc-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
  .pc-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
  .hm-tiles { grid-template-columns: repeat(6, 1fr); }
  .rail-x { grid-auto-columns: 42%; }
  .rail-x.papers { grid-auto-columns: 28%; }
}

/* ── Desktop ───────────────────────────────────────────── */
@media (min-width: 900px) {
  .pg { padding: 1.75rem 2rem 3rem; max-width: 1240px; margin: 0 auto; gap: 1.75rem; }
  .pg-head h1 { display: block; }
  .pg-tools { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; }
  .pg-search { width: 320px; flex-shrink: 0; order: 2; }
  .pg-chips { flex-wrap: wrap; overflow: visible; }
  .hm-hero { padding: 2rem 2.2rem; }
  .hm-hero h1 { font-size: 1.75rem; }
  .hm-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
  .hm-grid > div { display: flex; flex-direction: column; gap: 1.75rem; min-width: 0; }
  .hm-grid > div > * { order: 0; }
  .hm-tile { flex-direction: row; text-align: left; padding: .85rem 1rem; gap: .75rem; }
  .hm-tile small { display: block; }
  .hm-tiles { grid-template-columns: repeat(3, 1fr); }
  .rail-x { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; margin: 0; padding: 0; gap: 1rem; }
  .rail-x.papers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hm-side .cc-row .cc-media { width: 84px; }
}
@media (min-width: 900px) and (max-width: 1099.98px) {
  .hm-grid { display: flex; }
  .hm-grid > div { display: contents; }
  .hm-grid .hm-o-continue { order: 1; } .hm-grid .hm-o-tiles { order: 2; } .hm-grid .hm-o-explore { order: 3; } .hm-grid .hm-o-papers { order: 4; } .hm-grid .hm-o-support { order: 6; }
}
@media (prefers-reduced-motion: reduce) { .cc, .pc, .hm-tile { transition: none; } }
