/* =========================================================
   Portfolio v2 — shared styles (front page + admin manager)
   ========================================================= */
/* Design: warm paper canvas + hairline white cards (Notion), iridescent sphere & museum
   labels (OFF+BRAND), soft radii, pastel tiles and a dark pill CTA (Genie). */
:root {
  --bg: #f6f5f4;
  --surface: #ffffff;
  --surface-2: #f9f8f6;
  --ink: #1b1b1a;
  --ink-2: #4f4b47;
  --muted: #8a847e;
  --line: #e8e5e0;
  --line-2: #f0eeea;
  --accent: #0075de;
  --accent-2: #0a62bb;
  --accent-soft: #e6f3fe;
  --cta: #181d27;
  --cta-ink: #ffffff;
  --gold: #b7791f;
  --gold-soft: #fff2be;
  --green: #0f7b55;
  --green-soft: #d3f6e3;
  --red: #d1402c;
  --red-soft: #fde7e2;
  --lav: #f1e6ff; --lav-ink: #6b3fb8;
  --mint: #d3f6e3; --mint-ink: #0f7b55;
  --powder: #cce7ff; --powder-ink: #0a62bb;
  --solar: #fff2be; --solar-ink: #8a5a00;
  --peach: #ffe3d3; --peach-ink: #b4461f;
  --grid: #efede9;
  --iris: linear-gradient(255deg, #facb0e, #f06ba8 30%, #78bae6 65%, #ffffff);
  --stage: #141414;
  --shadow-1: none;
  --shadow-2: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.08);
  --shadow-3: 0 24px 60px rgba(10, 12, 20, .25);
  --r-sm: 10px; --r: 16px; --r-lg: 24px;
  --head-h: 60px;
  --ease: cubic-bezier(.2,.7,.2,1);
  --font-body: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Anuphan', 'IBM Plex Sans Thai', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #232320; --ink: #efede9; --ink-2: #cbc6bf; --muted: #918b84;
    --line: #2f2e2b; --line-2: #282725; --accent: #4ea1f3; --accent-2: #7ab8f6; --accent-soft: #15283b; --cta: #efede9; --cta-ink: #141413;
    --gold: #f0b54a; --gold-soft: #3a2f17; --green: #4cc79a; --green-soft: #15302a; --red: #ff7a66; --red-soft: #3b1d19;
    --lav: #2a2238; --lav-ink: #c9a8ff; --mint: #15302a; --mint-ink: #6fd9ad; --powder: #15283b; --powder-ink: #7ab8f6;
    --solar: #332b12; --solar-ink: #f3cd63; --peach: #3a2219; --peach-ink: #ffab85; --grid: #262523;
    --stage: #0b0b0a; --shadow-2: 0 8px 24px rgba(0,0,0,.5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.25; margin: 0; color: var(--ink); letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 28px; } }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.uil { line-height: 1; }

/* ---------- Buttons / chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 15px; cursor: pointer; transition: background .2s, border-color .2s, transform .1s, box-shadow .2s, color .2s; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn .uil { font-size: 18px; }
.btn-primary { background: var(--cta); border-color: var(--cta); color: var(--cta-ink); box-shadow: 0 1px 2px rgba(10,13,18,.5), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: color-mix(in srgb, var(--cta) 86%, var(--accent)); border-color: transparent; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-soft:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 14px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; color: var(--ink); flex: none; }
.icon-btn .uil { font-size: 20px; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 32px; height: 32px; } .icon-btn.sm .uil { font-size: 17px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: all .15s; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { font-weight: 500; opacity: .65; font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge-draft { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.tag { font-size: 12px; color: var(--muted); }
.tag-color-default { background: var(--surface-2); color: var(--ink-2); }
.tag-color-blue { background: #dbeafe; color: #1d4ed8; } .tag-color-green { background: #d1fae5; color: #065f46; }
.tag-color-red { background: #fee2e2; color: #991b1b; } .tag-color-yellow { background: #fef3c7; color: #92400e; }
.tag-color-indigo { background: #e0e7ff; color: #3730a3; } .tag-color-purple { background: #f3e8ff; color: #6b21a8; }
.tag-color-pink { background: #fce7f3; color: #9d174d; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }

/* ---------- Header ---------- */
.site-head { position: sticky; top: 0; z-index: 40; height: var(--head-h); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid transparent; transition: border-color .2s, transform .25s; }
.site-head.scrolled { border-bottom-color: var(--line); }
.site-head .wrap { height: 100%; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--font-head); font-weight: 700; font-size: 19px; min-width: 0; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-nav { display: none; margin-left: auto; gap: 2px; }
.top-nav a { color: var(--muted); font-weight: 500; font-size: 15px; padding: 7px 12px; border-radius: 999px; transition: background .15s, color .15s; }
.top-nav a:hover { color: var(--ink); }
.top-nav a.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
@media (min-width: 1024px) { .top-nav { display: flex; } .head-actions { margin-left: 8px; } }

/* ---------- Hero (iridescent sphere + concentric rings) ---------- */
.hero { padding: 16px 0 4px; }
.hero-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; overflow: hidden; isolation: isolate; }
.hero-top { display: flex; gap: 16px; align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-family: var(--font-body); }
.eyebrow::before { content: ""; width: 18px; height: 1px; background: currentColor; }
.hero-kicker { display: inline-block; margin-top: 2px; color: var(--ink-2); font-weight: 500; font-size: 15px; }
.hero h1 { font-size: clamp(26px, 5vw, 56px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.12; margin-top: 6px; }
.hl { display: inline-block; padding: 0 .32em; margin: 0 .04em; border-radius: 999px; background: var(--peach); color: var(--peach-ink); line-height: 1.15; }
.hl:nth-of-type(2n) { background: var(--powder); color: var(--powder-ink); }
.hero p.lead { color: var(--ink-2); margin: 12px 0 0; font-size: 16px; max-width: 58ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; position: relative; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; position: relative; margin-top: 18px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 10px 12px; border-radius: var(--r); color: var(--ink); transition: transform .2s var(--ease); min-width: 0; }
.stat:nth-child(1) { background: var(--solar); } .stat:nth-child(2) { background: var(--peach); } .stat:nth-child(3) { background: var(--lav); } .stat:nth-child(4) { background: var(--mint); }
.stat:hover { transform: translateY(-2px); }
.stat b { font-family: var(--font-head); font-weight: 500; font-size: 26px; line-height: 1.1; letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat .uil { font-size: 17px; opacity: .7; }
@media (max-width: 520px) { .hero-cta .btn { height: 38px; padding: 0 14px; font-size: 14px; } }
@media (max-width: 420px) { .stat { padding: 8px 9px; } .stat b { font-size: 21px; } .stat span { font-size: 12px; } }
.hero-side { display: none; position: relative; justify-self: center; width: 100%; max-width: 380px; }
@media (min-width: 900px) {
  .hero { padding-top: 24px; }
  .hero-card { grid-template-columns: minmax(0, 1fr) 380px; padding: 44px 48px; gap: 40px; align-items: center; }
  .hero-side { display: block; }
  .hero p.lead { font-size: 18px; }
  .stats { margin-top: 28px; }
}
/* ---------- Sections ---------- */
.sec { padding: 22px 0 6px; }
@media (min-width: 768px) { .sec { padding: 34px 0 10px; } }
.sec-head { display: flex; align-items: center; gap: 10px 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head .sec-title { flex: 1 1 230px; }
.sec-head .sec-tools { flex-wrap: wrap; justify-content: flex-end; }
.sec-title .count { align-self: flex-end; margin-bottom: 5px; white-space: nowrap; }
@media (max-width: 520px) { .sec-title .count { display: none; } .sec-tools .icon-btn[data-prev], .sec-tools .icon-btn[data-next] { display: none; } }
.sec-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sec-ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; flex: none; }
.sec-title .eyebrow { display: flex; margin-bottom: 1px; }
.sec-title h2 { font-size: clamp(21px, 2.8vw, 30px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.sec-title .count { font-size: 13px; color: var(--muted); font-weight: 600; }
.sec-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ico-cert { background: var(--solar); color: var(--solar-ink); }
.ico-gal { background: var(--peach); color: var(--peach-ink); }
.ico-proj { background: var(--lav); color: var(--lav-ink); }
.ico-doc { background: var(--mint); color: var(--mint-ink); }
.ico-blog { background: var(--powder); color: var(--powder-ink); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 12px; margin-top: -4px; }
.filters::-webkit-scrollbar { display: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.empty .uil { font-size: 32px; display: block; margin-bottom: 6px; }

/* ---------- Carousel (generic) ---------- */
.rail { position: relative; }
.track { display: grid; grid-auto-flow: column; grid-auto-columns: var(--col, 78%); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; overscroll-behavior-x: contain; scrollbar-width: none; padding: 4px 2px 6px; margin: -4px -2px 0; -webkit-overflow-scrolling: touch; }
.track::-webkit-scrollbar { display: none; }
.track > * { scroll-snap-align: start; min-width: 0; }
@media (min-width: 560px) { .track { --col: calc((100% - 12px) / 2.15); } }
@media (min-width: 860px) { .track { --col: calc((100% - 36px) / 4); gap: 12px; } }
@media (min-width: 1180px) { .track.five { --col: calc((100% - 48px) / 5); } }
.track.grid-mode { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(min(170px, 46%), 1fr)); overflow: visible; scroll-snap-type: none; }
@media (min-width: 860px) { .track.grid-mode { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); } }
.dots { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; min-height: 20px; }
.dot { width: 9px; height: 9px; padding: 0; border-radius: 99px; border: 0; background: var(--line); cursor: pointer; transition: width .2s, background .2s; position: relative; }
.dot::after { content: ""; position: absolute; inset: -8px -3px; }
.dot:hover { background: var(--muted); }
.dot.on { width: 26px; background: var(--ink); }
.dots .page-label { font-size: 12px; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ---------- Certificate card ---------- */
.cert { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .2s var(--ease), border-color .2s; }
.cert:hover { border-color: color-mix(in srgb, var(--ink) 28%, transparent); transform: translateY(-2px); }
.cert .media { aspect-ratio: 1.414; background-color: var(--surface); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 14px 14px; background-position: -1px -1px; display: grid; place-items: center; padding: 8px; border-bottom: 1px solid var(--line-2); overflow: hidden; }
.cert .media img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.12)); transition: transform .3s; }
.cert:hover .media img { transform: scale(1.03); }
.cert .media .ph { font-size: 44px; color: var(--muted); display: grid; place-items: center; gap: 2px; text-align: center; }
.cert .media .ph small { font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.cert .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cert h3 { font-size: 15px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cert .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-flags { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; z-index: 2; }

/* ---------- Gallery ---------- */
.albums { --col: 62%; }
@media (min-width: 560px) { .albums { --col: calc((100% - 24px) / 3); } }
@media (min-width: 860px) { .albums { --col: calc((100% - 48px) / 5); } }
.album-tab { position: relative; display: flex; gap: 10px; align-items: center; padding: 6px; padding-right: 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, background .15s; }
.album-tab:hover { border-color: var(--muted); }
.album-tab[aria-selected="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: var(--surface); }
.album-tab img, .album-tab .noimg { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.album-tab .t { min-width: 0; }
.album-tab b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.3; font-weight: 600; }
.album-tab small { color: var(--muted); font-size: 12px; }
.viewer { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; position: relative; }
/* */
.viewer > * { min-width: 0; }
@media (min-width: 960px) { .viewer { grid-template-columns: minmax(0, 1fr) 300px; padding: 14px; } }
.stage { position: relative; background: var(--stage); border-radius: var(--r); overflow: hidden; aspect-ratio: 4/3; touch-action: pan-y; user-select: none; }
@media (min-width: 960px) { .stage { aspect-ratio: 16/10; } }
.stage-strip { display: flex; height: 100%; transition: transform .35s cubic-bezier(.2,.7,.2,1); will-change: transform; }
.stage-strip figure { margin: 0; flex: 0 0 100%; height: 100%; display: grid; place-items: center; cursor: zoom-in; position: relative; }
.stage-strip img { max-width: 100%; max-height: 100%; object-fit: contain; }
.stage .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 999px; border: 0; background: rgba(255,255,255,.88); color: #111; display: grid; place-items: center; cursor: pointer; font-size: 24px; box-shadow: 0 2px 10px rgba(0,0,0,.25); z-index: 3; transition: opacity .2s; }
.stage .nav.prev { left: 10px; } .stage .nav.next { right: 10px; }
.stage .nav:disabled { opacity: 0; pointer-events: none; }
.stage .counter { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; padding: 3px 10px; border-radius: 999px; z-index: 3; font-variant-numeric: tabular-nums; }
.stage .zoom { position: absolute; right: 10px; bottom: 10px; z-index: 3; background: rgba(0,0,0,.6); color: #fff; border: 0; width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; font-size: 18px; cursor: pointer; }
.stage .cap { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; max-width: calc(100% - 140px); background: rgba(0,0,0,.6); color: #fff; font-size: 13px; padding: 3px 10px; border-radius: 999px; z-index: 3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding: 2px 2px 6px; scroll-behavior: smooth; }
.thumbs button { position: relative; flex: 0 0 64px; height: 64px; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--surface-2); opacity: .7; transition: opacity .15s, border-color .15s; }
.thumbs button:hover { opacity: 1; }
.thumbs button.on { border-color: var(--ink); opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 960px) {
  .viewer-side { display: flex; flex-direction: column; min-height: 0; }
  .viewer-side .thumbs { flex-wrap: wrap; overflow-y: auto; overflow-x: hidden; max-height: 330px; align-content: flex-start; }
  .viewer-side .thumbs button { flex: 0 0 calc((100% - 18px) / 4); height: auto; aspect-ratio: 1; }
}
.album-info h3 { font-size: 18px; }
.album-info .meta { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.album-info .desc { font-size: 14px; color: var(--ink-2); max-height: 4.8em; overflow: hidden; }
.album-info .desc p { margin: 0 0 4px; }

/* ---------- Project cards ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 860px) { .grid-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.pcard { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .2s var(--ease), border-color .2s; }
.pcard:hover { border-color: color-mix(in srgb, var(--ink) 28%, transparent); transform: translateY(-2px); }
.pcard .media { aspect-ratio: 16/10; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 34px; }
.pcard .media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.pcard:hover .media img { transform: scale(1.04); }
.pcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard h3 { font-size: 15px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard p { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .foot { margin-top: auto; padding-top: 4px; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
@media (max-width: 480px) { .pcard p { display: none; } .pcard h3 { font-size: 14px; } }
.more-row { display: flex; justify-content: center; margin-top: 14px; }

/* ---------- Docs list ---------- */
.doc-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 860px) { .doc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.doc { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.doc .ft { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--green-soft); color: var(--green); }
.doc .ft.pdf { background: var(--red-soft); color: var(--red); }
.doc .t { min-width: 0; flex: 1; cursor: pointer; }
.doc .t b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .t small { color: var(--muted); font-size: 13px; }
.doc .acts { display: flex; gap: 6px; }

/* ---------- Tabs + posts ---------- */
.tabs { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; gap: 2px; }
.tabs button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.post-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 760px) { .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .post-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.post { position: relative; display: flex; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; text-align: left; transition: box-shadow .2s, border-color .2s; width: 100%; }
.post:hover { border-color: color-mix(in srgb, var(--ink) 28%, transparent); }
.post .th { width: 96px; height: 96px; border-radius: 10px; flex: none; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 30px; color: var(--muted); }
.post .t { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.post h3 { font-size: 15px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post p { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; }
.quiz-ico { background: var(--lav); color: var(--lav-ink) !important; }

/* ---------- Modal / sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; background: rgba(12, 14, 20, .55); opacity: 0; transition: opacity .2s; }
.modal.open { opacity: 1; }
.modal .sheet { position: relative; width: 100%; max-height: 94vh; max-height: 94dvh; background: var(--surface); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; transform: translateY(24px); transition: transform .25s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow-3); }
.modal.open .sheet { transform: none; }
@media (min-width: 760px) { .modal { align-items: center; padding: 24px; } .modal .sheet { max-width: 820px; border-radius: 20px; max-height: 90vh; } .modal .sheet.narrow { max-width: 560px; } .modal .sheet.wide { max-width: 1040px; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { overflow-y: auto; padding: 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (min-width: 760px) { .sheet-body { padding: 24px 28px; } }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.grabber { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
@media (min-width: 760px) { .grabber { display: none; } }
body.locked { overflow: hidden; }

/* Article content */
.prose { font-size: 17px; line-height: 1.75; color: var(--ink-2); overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin: 1.2em 0 .5em; } .prose h2 { font-size: 22px; } .prose h3 { font-size: 19px; }
.prose p { margin: 0 0 1em; }
.prose img { height: auto; border-radius: 12px; margin: 8px auto; cursor: zoom-in; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose iframe { width: 100%; aspect-ratio: 16/9; height: auto; border: 0; border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line); padding: 6px 10px; }
.prose blockquote { margin: 1em 0; padding: 6px 16px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.article-head h1 { font-size: clamp(22px, 3.4vw, 32px); margin: 6px 0 8px; }
.article-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }
.article-cover { width: 100%; border-radius: 14px; margin: 14px 0 6px; max-height: 420px; object-fit: cover; }
.detail-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 14px 0; }
.detail-gallery img { aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; width: 100%; }

/* Quiz */
.q { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.q legend { font-weight: 600; padding: 0; float: left; width: 100%; margin-bottom: 8px; }
.q legend span { color: var(--muted); margin-right: 6px; }
.q label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; cursor: pointer; transition: border-color .15s, background .15s; clear: both; }
.q label:hover { border-color: var(--muted); }
.q label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.q input { margin-top: 5px; accent-color: var(--accent); }
.q label.right, .q label.right:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.q label.wrong, .q label.wrong:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.score { text-align: center; padding: 18px; border-radius: var(--r); background: var(--mint); margin-bottom: 14px; }
.score b { font-family: var(--font-head); font-weight: 500; font-size: 40px; display: block; color: var(--ink); }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 90; background: rgba(8, 9, 12, .96); display: flex; flex-direction: column; opacity: 0; transition: opacity .2s; color: #fff; }
.lb.open { opacity: 1; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex: none; }
.lb-top .count { font-size: 14px; opacity: .8; font-variant-numeric: tabular-nums; }
.lb-top .sp { flex: 1; }
.lb .icon-btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.lb .icon-btn:hover { background: rgba(255,255,255,.2); }
.lb-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: pan-y; }
.lb-strip { display: flex; height: 100%; transition: transform .3s cubic-bezier(.2,.7,.2,1); }
.lb-slide { flex: 0 0 100%; height: 100%; display: grid; place-items: center; padding: 0 8px; }
.lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb-slide iframe { width: min(100%, 1000px); height: 100%; border: 0; background: #fff; border-radius: 6px; }
.lb-slide .nopdf { text-align: center; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 48px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 28px; display: none; place-items: center; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.26); }
.lb-nav.prev { left: 14px; } .lb-nav.next { right: 14px; }
@media (min-width: 760px) { .lb-nav { display: grid; } }
.lb-cap { flex: none; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); text-align: center; }
.lb-cap b { display: block; font-family: var(--font-head); font-size: 16px; }
.lb-cap small { opacity: .75; font-size: 13px; }
.lb-cap .row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.lb-cap .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; height: 34px; font-size: 14px; }

/* ---------- Footer & bottom nav ---------- */
.site-foot { margin-top: 40px; padding: 28px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.site-foot a { color: var(--ink-2); }
.foot-links { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.bnav { position: fixed; z-index: 45; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-2); padding: 4px; transition: transform .25s; }
.bnav a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 5px; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 14px; }
.bnav a .uil { font-size: 21px; }
.bnav a.active { color: var(--ink); background: var(--surface-2); }
body { padding-bottom: 86px; }
@media (min-width: 1024px) { .bnav { display: none; } body { padding-bottom: 0; } }
.to-top { position: fixed; right: 16px; bottom: 96px; z-index: 44; opacity: 0; pointer-events: none; transition: opacity .2s; box-shadow: var(--shadow-2); }
.to-top.show { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .to-top { bottom: 24px; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 24px); }
@media (min-width: 1024px) { .toasts { bottom: 24px; } }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-2); display: flex; align-items: center; gap: 8px; animation: tin .2s ease-out; }
.toast.err { background: var(--red); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--line-2), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }


/* =========================================================
   Hero orbit — gradient-blur sphere with depth, main photo in
   a circle, other photos orbiting like planets
   ========================================================= */
.orbit-sys { --S: 380px; position: relative; width: var(--S); height: var(--S); max-width: 100%; flex: none; isolation: isolate; }
.orbit-sys.orbit-lg { --S: min(380px, 100%); aspect-ratio: 1; height: auto; width: 100%; container-type: inline-size; }
.orbit-sm { --S: 112px; }
@media (min-width: 900px) { .orbit-sm { display: none; } }
/* sphere made of drifting blurred colour blobs + shading for depth */
.aura { position: absolute; inset: 11%; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 32% 28%, #fff4cc, #fbc3dd 42%, #b7d6f6 72%, #b9a7fb);
  box-shadow: inset -0.9em -1.2em 2.2em rgba(70, 30, 120, .28), inset 0.7em 0.8em 1.6em rgba(255, 255, 255, .75), 0 1.4em 3em -0.6em rgba(240, 107, 168, .45), 0 0 4em rgba(120, 186, 230, .35);
  font-size: calc(var(--S) / 24); animation: aura-breathe 8s ease-in-out infinite; }
/* rotating colour wheel under the blobs: turns clockwise while the whole sphere slowly cycles through the spectrum */
.aura::before { content: ""; position: absolute; inset: -25%; border-radius: 50%; background: conic-gradient(from 0deg, #facb0e, #f06ba8, #78bae6, #ffffff, #facb0e); filter: blur(1.4em); opacity: .6; animation: orbit-spin 16s linear infinite; }
.orbit-lg .aura { font-size: 4cqw; }
.aura i { position: absolute; width: 75%; height: 75%; border-radius: 50%; filter: blur(1.2em); mix-blend-mode: normal; opacity: .9; }
.aura .b1 { background: radial-gradient(circle, #facb0e 0%, rgba(250,203,14,0) 68%); left: -10%; top: -5%; animation: blob1 11s ease-in-out infinite; }
.aura .b2 { background: radial-gradient(circle, #f06ba8 0%, rgba(240,107,168,0) 68%); right: -15%; top: 10%; animation: blob2 13s ease-in-out infinite; }
.aura .b3 { background: radial-gradient(circle, #78bae6 0%, rgba(120,186,230,0) 68%); left: 5%; bottom: -20%; animation: blob3 12s ease-in-out infinite; }
.aura .b4 { background: radial-gradient(circle, #8b5cf6 0%, rgba(139,92,246,0) 70%); right: 0; bottom: -10%; width: 55%; height: 55%; animation: blob4 15s ease-in-out infinite; }
.aura .shine { inset: 6% auto auto 14%; width: 45%; height: 32%; background: radial-gradient(ellipse, rgba(255,255,255,.95), rgba(255,255,255,0) 70%); mix-blend-mode: normal; filter: blur(.8em); transform: rotate(-30deg); animation: none; }
@keyframes blob1 { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(35%,20%) scale(1.15); } 66% { transform: translate(10%,45%) scale(.9); } }
@keyframes blob2 { 0%,100% { transform: translate(0,0) scale(1); } 40% { transform: translate(-40%,30%) scale(.9); } 75% { transform: translate(-15%,-10%) scale(1.2); } }
@keyframes blob3 { 0%,100% { transform: translate(0,0) scale(1.1); } 50% { transform: translate(30%,-40%) scale(.9); } }
@keyframes blob4 { 0%,100% { transform: translate(0,0); } 30% { transform: translate(-50%,-30%); } 70% { transform: translate(-10%,-55%) scale(1.2); } }
@keyframes aura-breathe { 0%,100% { scale: 1; } 50% { scale: 1.04; } }
/* orbit tracks */
.otrack { position: absolute; border-radius: 50%; border: 1px dashed color-mix(in srgb, var(--ink) 18%, transparent); pointer-events: none; }
.otrack.t1 { inset: 10%; } .otrack.t2 { inset: 4%; border-style: solid; opacity: .6; }
/* main photo in a circle */
.core { position: absolute; inset: 27%; border-radius: 50%; overflow: hidden; background: var(--surface); box-shadow: 0 0 0 calc(var(--S) * .012) var(--surface), 0 10px 30px rgba(30, 20, 60, .25); z-index: 2; }
.orbit-lg .core { box-shadow: 0 0 0 1.2cqw var(--surface), 0 10px 30px rgba(30, 20, 60, .25); }
.core img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: 0; transform: scale(1.06); transition: opacity .9s ease, transform 1.2s var(--ease); }
.core img.on { opacity: 1; transform: none; }
.core-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 2em; }
/* planets */
.orbit { position: absolute; inset: 0; z-index: 3; pointer-events: none; animation: orbit-spin var(--d, 36s) linear infinite; }
.orbit.o1 { --r: 41%; --d: 34s; } .orbit.o2 { --r: 48.5%; --d: 52s; animation-direction: reverse; }
.sat { --sz: 15%; position: absolute; left: 50%; top: 50%; width: var(--sz); aspect-ratio: 1; margin: calc(var(--sz) / -2) 0 0 calc(var(--sz) / -2); padding: 0; border: 0; background: none; pointer-events: auto; cursor: pointer;
  transform: rotate(var(--a)) translateX(calc(var(--S) * var(--rf, .41))) rotate(calc(-1 * var(--a))); }
.orbit.o1 .sat { --rf: .40; } .orbit.o2 .sat { --rf: .46; --sz: 12%; }
.orbit-lg .sat { transform: rotate(var(--a)) translateX(calc(100cqw * var(--rf))) rotate(calc(-1 * var(--a))); }
.sat img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: top; border: 2px solid var(--surface); box-shadow: 0 4px 14px rgba(30, 20, 60, .3); animation: orbit-spin var(--d) linear infinite reverse; transition: box-shadow .3s; }
.orbit.o2 .sat img { animation-direction: normal; }
.sat.on img { box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(30, 20, 60, .3); }
.sat:hover img { box-shadow: 0 0 0 2px var(--ink), 0 6px 18px rgba(30, 20, 60, .35); }
.sat.star { --sz: 4%; pointer-events: none; border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ffe9a8 35%, rgba(240,107,168,0) 70%); box-shadow: 0 0 10px 3px rgba(250, 203, 14, .55); animation: twinkle 3s ease-in-out infinite; }
.orbit.o2 .sat.star { --sz: 3%; animation-delay: -1.4s; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes twinkle { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.orbit-sys:hover .orbit, .orbit-sys:hover .sat img { animation-play-state: paused; }
.orbit-sm .sat img { border-width: 1.5px; }
.orbit-sm .otrack.t2 { display: none; }
/* Small sphere on phones: keep it light */
.orbit-sm .aura i { filter: blur(6px); }
/* reduce motion: keep colour drift slow, stop planets */
@media (prefers-reduced-motion: reduce) {
  .aura i { animation-duration: 30s !important; }
  .aura::before { content: ""; position: absolute; inset: -25%; border-radius: 50%; background: conic-gradient(from 0deg, #facb0e, #f06ba8, #78bae6, #ffffff, #facb0e); filter: blur(1.4em); opacity: .6; animation: orbit-spin 40s linear infinite !important; }
  .orbit, .sat img { animation: none !important; }
}
:root[data-theme="dark"] .aura { background: #2a2140; }
:root[data-theme="dark"] .aura i { mix-blend-mode: screen; }
