/* =====================================================================
 *  Portfolio styles — editorial / module-handbook design.
 *  Light theme, serif body, sans for UI. Inspired by the candidate's
 *  module handbook layout (KPI strip, "§" section markers, course-code
 *  badges, prose-first reading column).
 * ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #ffffff;
  --bg-soft:   #f4f5f7;
  --bg-rule:   #fbfbfc;
  --text:      #14171f;
  --text-2:    #2a2f3a;
  --muted:     #6b7180;
  --muted-2:   #9aa0ad;
  --rule:      #e5e7eb;
  --rule-2:    #eef0f3;
  --accent:    #1f2937;
  --accent-2:  #4338ca;
  --link:      #3b3a99;
  --link-hover:#1f1d6b;

  /* Discipline accents — used sparingly */
  --robotics:  #0f766e;
  --controls:  #1e40af;
  --mech:      #92400e;
  --ml:        #9d174d;
  --cad:       #c2410c;
  --other:     #4b5563;

  --serif:    "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans:     "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:     "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; background: var(--bg); }

body {
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

/* =====================================================================
 *  Layout
 * ===================================================================== */
.container { max-width: 820px; margin: 0 auto; padding: 0 32px; }
.container--wide { max-width: 1120px; }

.page {
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.page > main { flex: 1; }

/* =====================================================================
 *  Page header strip (running header — like top of every PDF page)
 * ===================================================================== */
.runhead {
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
}
.runhead .container {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 14px; padding-bottom: 14px;
  gap: 20px;
}
.runhead .left strong { color: var(--text); font-weight: 600; }
.runhead .left span { color: var(--muted); margin-left: 8px; }
.runhead .right { letter-spacing: .14em; text-transform: uppercase; font-weight: 500; }

/* Date line (right-aligned, below header on cover page) */
.date-line {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  padding: 28px 0 0;
}

/* =====================================================================
 *  Name plate (the gray box on cover page)
 * ===================================================================== */
.nameplate {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 28px 32px;
  margin: 32px 0 56px;
}
.nameplate__head {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
}
.nameplate__head h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: -0.01em;
  margin: 0;
}
.nameplate__tag {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .25em;
  font-weight: 600;
  color: var(--text);
  background: rgba(0,0,0,.04);
  padding: 5px 12px;
  border-radius: 3px;
  text-transform: uppercase;
}
.nameplate__sub {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  margin: 6px 0 18px;
}
.nameplate__rule {
  border: 0; border-top: 1px solid var(--rule);
  margin: 14px 0 16px;
}
.nameplate__contact {
  display: flex; flex-wrap: wrap; gap: 24px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-2);
}
.nameplate__contact span { color: var(--muted); margin-right: 8px; }
.nameplate__contact a { color: var(--text-2); }

/* Two-column nameplate with portrait photo on the right */
.nameplate--with-photo {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 28px;
  align-items: center;
}
.nameplate__main { min-width: 0; }
.nameplate__photo {
  width: 180px; height: 180px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--rule);
}
.nameplate__photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
@media (max-width: 700px) {
  .nameplate--with-photo {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .nameplate__photo {
    width: 140px; height: 140px;
    margin: 0 auto;
  }
}

/* =====================================================================
 *  Section heading block (§ 01 + title + intro)
 * ===================================================================== */
.section-mark {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .35em;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
}
h1.section-title, h2.section-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 38px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0 0 18px;
  color: var(--text);
}
h2.section-title { font-size: 32px; }
.section-rule {
  border: 0;
  border-top: 1px solid var(--text);
  margin: 0 0 22px;
  width: 100%;
}
.section-intro {
  color: var(--muted);
  font-style: italic;
  font-size: 15.5px;
  margin: 0 0 30px;
  max-width: 680px;
}

.title-block {
  margin: 64px 0 32px;
}

/* =====================================================================
 *  KPI strip (cover)
 * ===================================================================== */
.kpi {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 22px 0;
  margin: 28px 0 0;
}
@media (max-width: 1000px) {
  .kpi { grid-template-columns: repeat(3, 1fr); }
}
.kpi .label {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 8px;
}
.kpi .value {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.005em;
}
@media (max-width: 700px) {
  .kpi { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* =====================================================================
 *  Course summary table
 * ===================================================================== */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 14px;
  margin: 4px 0 24px;
}
.summary-table th, .summary-table td {
  text-align: left;
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.summary-table th {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: .02em;
  background: var(--bg-rule);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.summary-table td.code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  letter-spacing: .04em;
  white-space: nowrap;
}
.summary-table td.semester {
  font-style: italic;
  color: var(--muted);
}
.summary-table td.cat {
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--muted);
}
.summary-table tbody tr { transition: background .12s ease; }
.summary-table tbody tr:hover { background: var(--bg-rule); }
.summary-table a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.summary-table a:hover { border-bottom-color: var(--text); color: var(--text); }
.summary-table tr.totals td {
  font-weight: 600;
  border-top: 2px solid var(--text);
  border-bottom: none;
}

/* =====================================================================
 *  Module card (one per project on the index, "course module" style)
 * ===================================================================== */
.module {
  border-top: 1px solid var(--rule);
  padding: 28px 0 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.module:last-of-type { border-bottom: 1px solid var(--rule); }
.module__head {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.code-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 3px;
  white-space: nowrap;
}
.code-badge--robotics  { color: var(--robotics); }
.code-badge--controls  { color: var(--controls); }
.code-badge--mech      { color: var(--mech); }
.code-badge--ml        { color: var(--ml); }
.code-badge--cad       { color: var(--cad); }
.code-badge--other     { color: var(--other); }

.module__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.005em;
  line-height: 1.25;
  margin: 0;
}
.module__title a { color: var(--text); }
.module__title a:hover { color: var(--text); border-bottom: 1px solid var(--text); text-decoration: none; }

.module__meta {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 12px;
  display: flex; gap: 6px 16px; flex-wrap: wrap;
}
.module__meta li { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.module__meta li::before {
  content: ""; width: 3px; height: 3px; border-radius: 50%;
  background: var(--muted-2);
}
.module__meta li:first-child::before { display: none; }

.module ul, .module p { margin: 0; }
.module__label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.module__body p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 12px;
}
.module__body p:last-child { margin-bottom: 0; }

/* The vertical bar block ("Personal project work") */
.module__quote {
  border-left: 3px solid var(--text);
  padding: 4px 0 4px 16px;
  margin: 14px 0 0;
}
.module__quote .module__label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11.5px;
  margin-bottom: 4px;
}
.module__quote p { font-style: italic; color: var(--text-2); margin: 0; font-size: 15px; }

.module__cta {
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 13px;
}
.module__cta a {
  color: var(--text);
  border-bottom: 1px solid var(--text);
  padding-bottom: 1px;
}
.module__cta a:hover { color: var(--link); border-bottom-color: var(--link); text-decoration: none; }

/* =====================================================================
 *  Discipline picker (Step 1) + project cards (Step 2)
 * ===================================================================== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin: 8px 0 32px;
}
.cat-card {
  display: block; text-align: left;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.cat-card:hover {
  transform: translateY(-3px);
  border-color: var(--text);
  box-shadow: 0 14px 30px rgba(20,23,31,.08);
}
.cat-card__previews {
  display: grid;
  grid-template-columns: repeat(3, 1fr);  /* default */
  gap: 2px;
  background: var(--rule);
  height: 140px;
}
.cat-card__previews[data-count="1"] { grid-template-columns: 1fr; }
.cat-card__previews[data-count="2"] { grid-template-columns: 1fr 1fr; }
.cat-card__previews img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-soft);
}
.cat-card__body {
  padding: 18px 20px 20px;
}
.cat-card__body h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.005em;
  margin: 10px 0 6px;
  color: var(--text);
}
.cat-card__body p {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 8px;
}
.cat-card__count {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 10px;
}

.cat-back {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
}
.cat-back:hover { color: var(--text); }

/* Step 2 — project cards */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  margin: 8px 0 56px;
}
.proj-card {
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.proj-card:hover {
  transform: translateY(-3px);
  border-color: var(--text);
  box-shadow: 0 14px 30px rgba(20,23,31,.08);
  text-decoration: none;
}
.proj-card__cover {
  height: 200px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.proj-card__cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}
.proj-card:hover .proj-card__cover img { transform: scale(1.04); }
.proj-card__body {
  padding: 18px 20px 18px;
  display: flex; flex-direction: column;
  flex: 1;
}
.proj-card__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.proj-card__date {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
}
.proj-card h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 4px 0 8px;
  color: var(--text);
}
.proj-card p {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 12px;
  flex: 1;
}
.proj-card .tags {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.proj-card .tags li {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  padding: 3px 8px;
  border-radius: 3px;
}

/* =====================================================================
 *  Detail page (single module)
 * ===================================================================== */
.detail-meta {
  list-style: none; padding: 0;
  display: flex; gap: 6px 16px; flex-wrap: wrap;
  font-family: var(--sans); font-size: 13px;
  color: var(--muted);
  margin: 8px 0 24px;
}
.detail-meta li { display: inline-flex; align-items: center; gap: 6px; }
.detail-meta li::before {
  content: ""; width: 3px; height: 3px; border-radius: 50%;
  background: var(--muted-2);
}
.detail-meta li:first-child::before { display: none; }

.detail-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 18px 0 12px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--text);
  transition: all .15s ease;
  cursor: pointer;
}
.btn:hover { border-color: var(--text); color: var(--text); text-decoration: none; }
.btn--primary {
  background: var(--text); color: var(--bg);
  border-color: var(--text);
}
.btn--primary:hover { background: #000; color: var(--bg); border-color: #000; }

/* Prose body */
.prose {
  margin-top: 32px;
  max-width: 720px;
}
.prose h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.005em;
  margin: 36px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.prose h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.prose p {
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--text);
  margin: 0 0 14px;
}
.prose ul, .prose ol {
  font-size: 16px;
  line-height: 1.75;
  padding-left: 22px;
  margin: 0 0 18px;
  color: var(--text);
}
.prose li { margin-bottom: 4px; }
.prose strong { color: #000; font-weight: 600; }
.prose em { color: var(--text-2); font-style: italic; }
.prose code {
  font-family: var(--mono);
  font-size: 13.5px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--text);
}

.sidebar {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-2);
}
.sidebar h3 {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 6px;
  font-weight: 600;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar p { margin: 0 0 4px; color: var(--text); }
.sidebar .tags {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.sidebar .tags li {
  font-size: 11.5px;
  font-family: var(--sans);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  padding: 3px 9px;
  border-radius: 3px;
  color: var(--text-2);
}

/* Sidebar mini-gallery (the curated picks) — full image, no cropping */
.mini-gallery {
  display: grid;
  grid-template-columns: 1fr;     /* One per row, full sidebar width */
  gap: 10px;
  margin-top: 4px;
}
.mini-tile {
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg);
  transition: border-color .15s ease, transform .15s ease;
  display: block;
  width: 100%;
}
.mini-tile:hover { border-color: var(--text); transform: translateY(-1px); }
.mini-tile img {
  width: 100%;
  height: auto;                   /* Image's own aspect ratio — full picture */
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 56px;
  align-items: start;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; gap: 32px; } }

/* =====================================================================
 *  Gallery
 * ===================================================================== */
.gallery-section {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.gallery-section h2 {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 16px;
  font-weight: 600;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.gallery button {
  padding: 0;
  height: 280px;             /* Fixed tile height so every page is uniform */
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg);
  transition: border-color .15s ease, transform .15s ease;
  display: block;
}
.gallery button:hover { border-color: var(--text); transform: translateY(-2px); }
.gallery img {
  width: 100%; height: 100%;
  object-fit: contain;       /* Show the full page; letter-box if needed */
  display: block;
  background: var(--bg);
}

/* Lightbox (kept dark for image focus) */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(20,23,31,.95);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100; padding: 32px;
}
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }
.lightbox button {
  position: absolute;
  top: 18px; right: 22px;
  background: var(--bg); border: 1px solid var(--rule);
  color: var(--text); width: 42px; height: 42px;
  border-radius: 50%; cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.lightbox .nav { top: 50%; transform: translateY(-50%); }
.lightbox .nav.prev { left: 22px; right: auto; }
.lightbox .nav.next { right: 22px; }

/* =====================================================================
 *  Next / prev module
 * ===================================================================== */
.next-prev {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-top: 56px;
  padding-top: 22px; border-top: 1px solid var(--rule);
}
@media (max-width: 600px) { .next-prev { grid-template-columns: 1fr; } }
.next-prev a {
  display: block; padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--serif);
  text-decoration: none;
  transition: border-color .15s ease;
}
.next-prev a:hover { border-color: var(--text); text-decoration: none; }
.next-prev .label {
  font-family: var(--sans);
  font-size: 11px; letter-spacing: .15em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 4px; font-weight: 600;
}
.next-prev .ttl { font-size: 15px; line-height: 1.4; margin: 0; font-weight: 500; }
.next-prev .next { text-align: right; }

/* =====================================================================
 *  Footer (running footer like the PDF)
 * ===================================================================== */
.runfoot {
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  margin-top: 80px;
}
.runfoot .container {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 18px; padding-bottom: 28px;
  gap: 20px;
}
.runfoot .center { color: var(--muted); }
.runfoot a { color: var(--muted); }
.runfoot a:hover { color: var(--text); }

/* =====================================================================
 *  Filter chips (used on index)
 * ===================================================================== */
.filter {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 24px;
}
.chip {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--rule);
  padding: 6px 13px;
  border-radius: 3px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { color: var(--text); border-color: var(--text); }
.chip.is-active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* =====================================================================
 *  Picker (re-themed light)
 * ===================================================================== */
.picker-toolbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}
.picker-toolbar .container {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.picker-stats { color: var(--muted); font-family: var(--sans); font-size: 13px; margin-left: auto; }
.picker-section { padding: 28px 0; border-top: 1px solid var(--rule); }
.picker-section h2 {
  font-family: var(--serif); font-weight: 600;
  font-size: 22px; margin: 0 0 6px;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.picker-section .slug { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.picker-section .count { font-family: var(--sans); font-size: 12px; color: var(--accent-2); }
.picker-controls { display: flex; gap: 8px; margin: 8px 0 14px; flex-wrap: wrap; }
.picker-controls button {
  font-family: var(--sans); font-size: 12px;
  padding: 6px 12px; border-radius: 3px;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--rule); cursor: pointer;
}
.picker-controls button:hover { color: var(--text); border-color: var(--text); }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.picker-tile {
  position: relative;
  border: 2px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s ease, transform .15s ease;
}
.picker-tile:hover { transform: translateY(-2px); border-color: var(--text); }
.picker-tile.is-selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(67,56,202,.12);
}
.picker-tile img {
  width: 100%; height: 160px; object-fit: contain;
  background: var(--bg-soft); display: block;
}
.picker-tile .meta {
  padding: 6px 8px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  display: flex; justify-content: space-between; gap: 6px;
  border-top: 1px solid var(--rule);
}
.picker-tile .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-tile .meta .kind { color: var(--accent-2); font-weight: 600; }
.picker-tile .meta .kind.custom { color: var(--mech); }
.picker-tile.is-custom { border-color: rgba(146,64,14,.45); }
.picker-tile.is-custom.is-selected { box-shadow: 0 0 0 3px rgba(146,64,14,.15); }
.picker-tile .badge-check {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-weight: 700; font-size: 13px;
}
.picker-tile.is-selected .badge-check {
  background: var(--accent-2); border-color: var(--accent-2); color: var(--bg);
}
.picker-tile.is-selected .badge-check::after { content: "✓"; }

/* Cover star button on each tile */
.picker-tile .cover-btn {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--rule);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  z-index: 2;
  opacity: 0;
  transition: all .15s ease;
}
.picker-tile:hover .cover-btn { opacity: 1; }
.picker-tile .cover-btn:hover { color: #d97706; border-color: #d97706; }
.picker-tile .cover-btn.is-on { opacity: 1; background: #fbbf24; color: #ffffff; border-color: #f59e0b; }
.picker-tile.is-cover {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245,158,11,.18) !important;
}

/* Trash button — only on custom tiles, only on hover */
.picker-tile .trash-btn {
  position: absolute; top: 8px; left: 40px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  z-index: 2;
  opacity: 0;
  transition: all .15s ease;
}
.picker-tile:hover .trash-btn { opacity: 1; }
.picker-tile .trash-btn:hover { color: #ffffff; background: #b91c1c; border-color: #b91c1c; }
.picker-tile.is-uploading { pointer-events: none; opacity: .7; }
.picker-tile .upload-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.78);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-2); font-family: var(--sans);
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
.picker-tile.upload-failed { border-color: #b91c1c !important; }
.picker-jump {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 16px 0 0; font-family: var(--sans); font-size: 12px;
}
.picker-jump a {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--muted);
}
.picker-jump a:hover { color: var(--text); border-color: var(--text); text-decoration: none; }

.dropzone {
  border: 2px dashed var(--rule);
  border-radius: 4px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  margin: 14px 0 0;
  cursor: pointer;
  transition: all .15s ease;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent-2); color: var(--text);
  background: rgba(67,56,202,.04);
}
.dropzone strong { color: var(--text); }
.dropzone input[type=file] { display: none; }
.dropzone-hint { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }

.settings-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--text);
  cursor: pointer; font-size: 16px;
}
.settings-btn.is-set { border-color: var(--robotics); color: var(--robotics); }
.settings-btn.is-unset { border-color: #b91c1c; color: #b91c1c; }
.settings-drawer {
  position: fixed; top: 0; right: 0;
  width: min(420px, 100vw); height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--rule);
  padding: 28px 24px;
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 50; overflow-y: auto;
  box-shadow: -20px 0 40px rgba(20,23,31,.08);
}
.settings-drawer.is-open { transform: translateX(0); }
.settings-drawer h2 { font-family: var(--serif); margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.settings-drawer p { font-family: var(--sans); color: var(--muted); font-size: 13px; line-height: 1.6; }
.settings-drawer label {
  display: block; font-family: var(--sans);
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em;
  margin: 18px 0 6px; font-weight: 600;
}
.settings-drawer input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 3px; font-size: 14px;
  font-family: var(--sans);
}
.settings-drawer input:focus { outline: none; border-color: var(--accent-2); }
.settings-drawer .actions {
  display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap;
}
.settings-drawer .close {
  position: absolute; top: 16px; right: 18px;
  background: transparent; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer;
}
.settings-drawer code { font-size: 12px; color: var(--accent-2); font-family: var(--mono); }
.scrim {
  position: fixed; inset: 0;
  background: rgba(20,23,31,.45);
  z-index: 40; display: none;
}
.scrim.is-open { display: block; }
.toast-stack {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 200; max-width: 360px;
}
.toast {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-2);
  border-radius: 4px;
  font-family: var(--sans); font-size: 13.5px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(20,23,31,.10);
  animation: toast-in .25s ease;
}
.toast.err  { border-left-color: #b91c1c; }
.toast.ok   { border-left-color: var(--robotics); }
.toast .small { color: var(--muted); font-size: 12px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

@media (max-width: 700px) {
  .container { padding: 0 22px; }
  .nameplate { padding: 22px 22px; }
  .nameplate__head h1 { font-size: 28px; }
  h1.section-title { font-size: 30px; }
  .module__title { font-size: 19px; }
}
