/* ---------- Tokens ---------- */
:root {
  --bg: #f1f2f4;
  --surface: #fafafb;
  --surface-2: #ffffff;
  --text: #121316;
  --muted: #6b6f78;
  --line: #e6e7ea;
  --hatch: #e3e4e8;
  --ink: #121316;          /* black pill */
  --ink-text: #ffffff;
  --blue: #3593f7;
  --orange: #ff8a3d;
  --green: #18c964;
  --red: #ef4444;
  --shadow: 0 1px 2px rgba(18, 19, 22, .04), 0 6px 20px rgba(18, 19, 22, .05);
  --shadow-lg: 0 10px 30px rgba(18, 19, 22, .12);
  --r-card: 22px;
  --r-inner: 18px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e10; --surface: #16171a; --surface-2: #1d1f23; --text: #f2f3f5; --muted: #8d919a;
    --line: #26282d; --hatch: #24262b; --ink: #f2f3f5; --ink-text: #0d0e10;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e10; --surface: #16171a; --surface-2: #1d1f23; --text: #f2f3f5; --muted: #8d919a;
  --line: #26282d; --hatch: #24262b; --ink: #f2f3f5; --ink-text: #0d0e10;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
main, .site-header, .site-footer { max-width: 1200px; margin: 0 auto; padding-inline: 28px; }
.hatch-bg {
  background-image: repeating-linear-gradient(-45deg, var(--hatch) 0 6px, transparent 6px 12px);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px; padding-block: 18px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 700; font-size: 21px; letter-spacing: -.02em; white-space: nowrap; }
.logo {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #4aa3ff, #1f7ae8); box-shadow: var(--shadow);
}
.pills { display: flex; gap: 8px; margin-left: 32px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 46px; padding: 0 20px; border-radius: 999px;
  text-decoration: none; font-size: 14px; font-weight: 500; color: var(--muted);
  background: var(--surface-2); box-shadow: var(--shadow); transition: color .15s, background .15s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--ink); color: var(--ink-text); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 0; background: var(--surface-2); color: var(--text); box-shadow: var(--shadow);
}
.icon-btn:hover { color: var(--blue); }
.icon-btn:focus-visible, .pill:focus-visible, .button:focus-visible, .chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff; background: linear-gradient(145deg, var(--orange), #f05a28);
  box-shadow: 0 0 0 3px var(--surface-2), var(--shadow);
}

/* ---------- Hero ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 56px 0 32px; flex-wrap: wrap; }
h1 { font-size: clamp(36px, 5vw, 52px); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; margin: 0 0 12px; }
.lede { font-size: 17px; color: var(--muted); margin: 0; max-width: 560px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: 999px;
  text-decoration: none; font-weight: 500; font-size: 14px; color: var(--text);
  background: var(--surface-2); box-shadow: var(--shadow); border: 0; transition: transform .15s;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--ink); color: var(--ink-text); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.button svg { flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.sub .up { color: var(--green); font-weight: 600; }

/* ---------- Stats strip ---------- */
.stats { padding: 22px 24px 26px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { padding: 0 20px; border-left: 1px solid var(--line); position: relative; }
.stat:first-child { border-left: 0; padding-left: 4px; }
.stat-label { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.stat-label .arrow { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); box-shadow: var(--shadow); color: var(--muted); }
.stat-value { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.stat-value b { font-size: 30px; font-weight: 600; letter-spacing: -.03em; }
.stat-value small { font-size: 12px; color: var(--muted); }
.stat-value small .up { color: var(--green); font-weight: 600; }
.segbar { display: flex; align-items: center; margin-top: 24px; padding-inline: 4px; }
.seg { height: 10px; flex: 1; border-radius: 999px; }
.seg.blue { background: var(--blue); }
.seg.orange { background: var(--orange); margin-left: -4px; }
.seg.green { background: var(--green); margin-left: -4px; }
.seg.hatch { background-image: repeating-linear-gradient(-45deg, var(--hatch) 0 3px, transparent 3px 6px); background-color: color-mix(in srgb, var(--hatch) 40%, transparent); margin-left: 4px; }
.knob { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); border: 4px solid; margin-left: -9px; margin-right: -5px; position: relative; z-index: 1; flex: none; }
.knob.blue { border-color: var(--blue); }
.knob.orange { border-color: var(--orange); }
.knob.green { border-color: var(--green); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 13px var(--font); height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 0; background: var(--surface-2); color: var(--muted); box-shadow: var(--shadow);
}
.chip:hover { color: var(--text); }
.chip[aria-selected="true"] { background: var(--ink); color: var(--ink-text); }

/* ---------- Project grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.project {
  background: var(--surface-2); border-radius: var(--r-inner); box-shadow: var(--shadow);
  display: flex; flex-direction: column; cursor: pointer; text-align: left; border: 0; padding: 10px;
  font: inherit; color: inherit; transition: transform .2s ease, box-shadow .2s ease;
}
.project:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.project:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.project.featured { grid-column: span 2; }

.cover {
  position: relative; aspect-ratio: 16 / 10; border-radius: 13px; overflow: hidden;
  background-color: var(--surface); flex: 1 0 auto;
}
.project.featured .cover { aspect-ratio: 16 / 6; }
.detail-cover { flex: none; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
/* Generated cover: rounded pill bars in striped tracks, like the reference chart */
.bars { position: absolute; inset: 16px; display: flex; gap: 7px; }
.bars i {
  flex: 1; position: relative; border-radius: 999px; display: block; overflow: hidden;
  background-image: repeating-linear-gradient(-45deg, var(--hatch) 0 4px, transparent 4px 8px);
}
.bars b { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 999px; display: block; }
.bars b.stack { box-shadow: 0 -14px 0 0 var(--orange); }
.cover .initials {
  position: absolute; top: 14px; left: 14px; height: 30px; padding: 0 12px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: var(--surface-2); color: var(--text); box-shadow: var(--shadow);
}
.badge {
  position: absolute; top: 14px; right: 14px; height: 26px; padding: 0 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text); box-shadow: var(--shadow);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }

.project-body { padding: 14px 8px 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.project-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.project h3 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.project .go {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); color: var(--muted); transition: background .15s, color .15s;
}
.project:hover .go { background: var(--ink); color: var(--ink-text); }
.project p { margin: 0; color: var(--muted); font-size: 14px; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: auto; padding-top: 10px; font-size: 12px; color: var(--muted); }
.dot { display: inline-flex; align-items: center; gap: 6px; }
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--blue)); }
.empty { color: var(--muted); }

/* ---------- About / contact ---------- */
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.split .card { margin-bottom: 20px; }
.about-body { font-size: 16px; max-width: 640px; }
.about-body p { margin: 0 0 12px; }
.about-body p:last-child { margin-bottom: 0; }
.contact { background-color: var(--surface); }
.contact-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.site-footer { padding-block: 24px 40px; color: var(--muted); font-size: 13px; }

/* ---------- Dialog ---------- */
dialog {
  width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 12px; border: 0;
  border-radius: 26px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(10, 11, 13, .45); backdrop-filter: blur(4px); }
dialog .close { position: absolute; top: 24px; right: 24px; z-index: 2; width: 38px; height: 38px; }
.detail-cover { aspect-ratio: 16 / 7; border-radius: 18px; }
.detail-content { padding: 22px 16px 14px; }
.detail-content h3 { font-size: 28px; font-weight: 600; letter-spacing: -.03em; margin: 0 0 8px; }
.detail-content .meta { padding-top: 0; margin-bottom: 18px; font-size: 13px; }
.detail-content .long p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.detail-content .links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 18px; }
.gallery img { border-radius: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .pills { margin-left: 0; }
  .stat-row { grid-template-columns: repeat(2, 1fr); row-gap: 20px; }
  .stat:nth-child(3) { border-left: 0; padding-left: 4px; }
  .split { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 760px) {
  main, .site-header, .site-footer { padding-inline: 16px; }
  .site-header { flex-wrap: wrap; gap: 12px; padding-block: 12px; }
  .pills { order: 3; width: 100%; }
  .pill { height: 40px; padding: 0 14px; flex: 1; justify-content: center; font-size: 13px; }
  .icon-btn, .avatar { width: 40px; height: 40px; }
  .logo { width: 38px; height: 38px; border-radius: 11px; }
  .brand { font-size: 18px; }
  .hero { padding: 32px 0 24px; }
  .hero-actions { gap: 8px; }
  .hero-actions .button { height: 42px; padding: 0 16px; }
  .hero-actions .button.primary { order: -1; }
  .stat { padding: 0 12px; }
  .stat-label { white-space: nowrap; font-size: 13px; }
  .stat-label .arrow { display: none; }
  .stat-value b { font-size: 26px; }
  .card { padding: 18px; border-radius: 20px; }
  .project.featured { grid-column: auto; }
  .project.featured .cover { aspect-ratio: 16 / 10; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
