:root {
  /* ============================================================
     PORTFOLIO DS — "build log / terminal" identity.
     Warm-ink canvas + signal-lime accent, cyan for data,
     amber/coral for state. Dark-first.
     ============================================================ */

  /* --- Ink scale --- */
  --ink-1000: #06080A;
  --ink-950:  #0A0D10;
  --ink-900:  #0E1216;
  --ink-850:  #12171C;
  --ink-800:  #181E24;
  --ink-700:  #232B33;
  --ink-600:  #313B45;
  --ink-500:  #46535F;

  /* --- Text on ink --- */
  --text-hi:    #EAF0EE;
  --text-body:  #B7C2BE;
  --text-muted: #7E8B86;
  --text-faint: #525C58;

  /* --- Hairlines --- */
  --line:        #1C242B;
  --line-strong: #2A343D;

  /* --- Signal lime (primary accent) --- */
  --lime-100: #EBFBC9;
  --lime-300: #D4F88A;
  --lime-400: #C5F559;
  --lime-500: #B0EE2E;
  --lime-600: #93C826;
  --lime-700: #6E9518;
  --lime-glow:  rgba(176,238,46,0.22);
  --lime-wash:  rgba(176,238,46,0.10);
  --lime-line:  rgba(176,238,46,0.32);
  --on-lime:    #0A0D10;

  /* --- Cyan (data / secondary signal) --- */
  --cyan-400: #6FE7E0;
  --cyan-500: #34D6CC;
  --cyan-wash: rgba(52,214,204,0.12);
  --cyan-line: rgba(52,214,204,0.34);

  /* --- State --- */
  --amber-400: #F6C758;
  --amber-500: #ECAE2B;
  --amber-wash: rgba(236,174,43,0.12);
  --coral-400: #FF8A7A;
  --coral-500: #FF6B5E;
  --coral-wash: rgba(255,107,94,0.12);

  /* --- Semantic surfaces / text / borders / accent --- */
  --surface-page:   var(--ink-950);
  --surface-base:   var(--ink-900);
  --surface-card:   var(--ink-850);
  --surface-raised: var(--ink-800);
  --surface-well:   var(--ink-1000);
  --surface-inset:  var(--ink-700);

  --border-subtle:  var(--line);
  --border-default: var(--line-strong);
  --border-strong:  var(--ink-600);
  --border-focus:   var(--lime-500);

  --text-primary:   var(--text-hi);
  --text-disabled:  var(--text-faint);
  --text-on-accent: var(--on-lime);

  --accent-fill:  var(--lime-500);
  --accent-glow:  var(--lime-glow);
  --accent-wash:  var(--lime-wash);
  --accent-line:  var(--lime-line);

  --data:      var(--cyan-500);
  --data-wash: var(--cyan-wash);
  --success:   var(--lime-500);
  --warning:   var(--amber-500);
  --danger:    var(--coral-500);

  /* ============================================================
     TYPOGRAPHY
     ============================================================ */
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-sans:    'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --fs-2xs:  0.6875rem;
  --fs-xs:   0.75rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md:   1.0625rem;
  --fs-lg:   1.375rem;
  --fs-xl:   1.75rem;
  --fs-2xl:  2.5rem;
  --fs-3xl:  3.5rem;
  --fs-4xl:  4.75rem;

  --lh-tight:   1.05;
  --lh-snug:    1.25;
  --lh-normal:  1.5;
  --lh-relaxed: 1.72;

  --ls-tight:  -0.02em;
  --ls-snug:   -0.01em;
  --ls-normal: 0;
  --ls-wide:   0.04em;
  --ls-wider:  0.14em;

  /* ============================================================
     SPACING, RADII, SHADOWS, MOTION, LAYOUT
     ============================================================ */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.5rem;
  --space-6:  2rem;
  --space-7:  2.5rem;
  --space-8:  3rem;
  --space-9:  4rem;
  --space-10: 5.5rem;
  --space-11: 7rem;

  --radius-xs:   3px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.40);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.45);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.50);
  --shadow-lg:  0 18px 48px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 0 1px var(--accent-line), 0 6px 28px var(--accent-glow);
  --ring-focus:  0 0 0 2px var(--surface-page), 0 0 0 4px var(--lime-500);

  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 360ms;

  --maxw-content: 1080px;
  --maxw-wide:    1320px;
  --header-h:     68px;
  --grid-line: rgba(255,255,255,0.022);
  --grid-size: 32px;

  /* ============================================================
     LEGACY ALIASES — keep older rules in this file working while
     they're migrated to the tokens above.
     ============================================================ */
  --bg:             var(--surface-page);
  --bg-secondary:   var(--surface-base);
  --bg-card:        var(--surface-card);
  --text:           var(--text-primary);
  --text-secondary: var(--text-muted);
  --border:         var(--border-subtle);
  --border-light:   var(--border-default);
  --shadow:         rgba(0, 0, 0, 0.5);
  --shadow-accent:  var(--lime-glow);
  --accent:         var(--lime-500);
  --accent-hover:   var(--lime-400);
  --accent-light:   var(--lime-300);
  --on-accent:      var(--on-lime);
  --accent-text:    var(--lime-500);
  --gradient:       linear-gradient(135deg, var(--lime-500) 0%, var(--cyan-500) 100%);
}

/* ============================================================
   LIGHT THEME — set via <html data-theme="light">.
   Re-declares the raw scales + a few washes/shadows; semantic
   aliases (--bg, --text, --accent, etc.) flip automatically.
   ============================================================ */
[data-theme="light"] {
  --ink-1000: #ECEFE7;
  --ink-950:  #F7F8F3;
  --ink-900:  #F0F2EA;
  --ink-850:  #FFFFFF;
  --ink-800:  #F1F3EB;
  --ink-700:  #E4E7DD;
  --ink-600:  #C7CDBE;
  --ink-500:  #AAB29F;

  --text-hi:    #161A14;
  --text-body:  #3B423A;
  --text-muted: #5E665B;
  --text-faint: #97A08F;

  --line:        #E4E7DC;
  --line-strong: #D3D8C8;

  --lime-500: #B0EE2E;
  --lime-400: #C5F559;
  --lime-600: #93C826;
  --lime-300: #D4F88A;
  --lime-glow:  rgba(150,200,30,0.34);
  --lime-wash:  rgba(140,190,30,0.16);
  --lime-line:  rgba(120,160,20,0.48);
  --on-lime:    #14210A;

  --cyan-500: #0E988F;
  --cyan-400: #12B0A6;
  --cyan-wash: rgba(14,152,143,0.12);
  --cyan-line: rgba(14,152,143,0.32);
  --amber-500: #C8870E;
  --coral-500: #E1483A;
  --coral-wash: rgba(225,72,58,0.12);

  --shadow-xs:  0 1px 2px rgba(20,30,16,0.06);
  --shadow-sm:  0 2px 8px rgba(20,30,16,0.08);
  --shadow-md:  0 10px 26px rgba(20,30,16,0.10);
  --shadow-lg:  0 20px 48px rgba(20,30,16,0.14);
  --grid-line: rgba(20,40,10,0.045);

  --shadow:        rgba(20,30,16,0.10);
  --shadow-accent: var(--lime-glow);
  --accent-hover:  var(--lime-400);
  --accent-light:  var(--lime-600);
  --on-accent:     var(--on-lime);
  --gradient:      linear-gradient(135deg, var(--lime-500) 0%, var(--cyan-500) 100%);

  /* accent used as TEXT color: lime reads poorly on paper, so swap to ink */
  --accent-text: #1B2016;
}

::selection { background: var(--lime-glow); color: var(--text-hi); }

* { 
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); }
code, kbd, pre, samp { font-family: var(--font-mono); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
  border-radius: var(--radius-sm);
}

/* ============================================================
   PHASE 2 — header (.khead) + terminal hero (.khero)
   ============================================================ */
.ds-eyebrow { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: var(--ls-wider); color: var(--text-secondary); }
.ds-eyebrow--lime { color: var(--accent-text); }

.ds-grid-bg {
  background-color: var(--surface-page);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}

.ds-well { background: var(--surface-well); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); font-family: var(--font-mono); }

.ds-caret { display: inline-block; width: 0.55em; height: 1.05em; transform: translateY(0.12em); background: var(--accent); margin-left: 0.12em; animation: ds-blink 1.05s steps(1) infinite; }
@keyframes ds-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ds-caret { animation: none; } }

/* ---- header ---- */
.khead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface-page) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.khead__in {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.klogo { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.klogo__mono {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--accent-fill);
  color: var(--on-lime);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}
.klogo__txt { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--text-primary); letter-spacing: var(--ls-snug); }
.klogo__last { color: var(--text-secondary); font-weight: 500; }
.khead__nav { display: flex; align-items: center; gap: var(--space-2); }
.khead__sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 var(--space-1); }
.khead__nav .kbtn--secondary { height: 32px; padding: 0 12px; font-size: var(--fs-xs); }

/* ---- buttons ---- */
.kibtn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.kibtn:hover { background: var(--accent-wash); color: var(--accent-text); box-shadow: none; transform: none; }

.kbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.kbtn:hover { transform: translateY(-1px); }
.kbtn--primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-lime); box-shadow: var(--shadow-glow); }
.kbtn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.kbtn--secondary:hover { border-color: var(--accent); color: var(--accent-text); }

/* ---- terminal hero ---- */
.khero { border-bottom: 1px solid var(--border-subtle); }
.khero__in { max-width: 1400px; margin: 0 auto; padding: var(--space-10) 2rem var(--space-9); }
.khero__in--term { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--space-7); align-items: center; }
.kterm { border-radius: var(--radius-lg); border: 1px solid var(--border-default); overflow: hidden; box-shadow: var(--shadow-md); }
.kterm__bar { display: flex; align-items: center; gap: 7px; padding: 10px var(--space-4); border-bottom: 1px solid var(--border-subtle); background: var(--surface-base); }
.kterm__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.kterm__dot:nth-child(1) { background: var(--danger); }
.kterm__dot:nth-child(2) { background: var(--warning); }
.kterm__dot:nth-child(3) { background: var(--success); }
.kterm__path { margin-left: var(--space-2); font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-wide); color: var(--text-faint); }
.kterm__body { padding: var(--space-5) var(--space-5) var(--space-6); display: flex; flex-direction: column; gap: 5px; }
.kterm__line { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-secondary); margin: 0; }
.kterm__pr { color: var(--accent-text); margin-right: 8px; }
.kterm__out { font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.65; color: var(--text-body); margin: 0 0 var(--space-3) 0; padding-left: 2px; }
.kterm__lead { color: var(--text-primary); }
.kterm__stat { white-space: nowrap; }
.kterm__sv { color: var(--accent-text); font-weight: 700; }
.kterm__sep { color: var(--text-faint); margin: 0 8px; }
.kterm__side { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
.khero__h { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-2xl); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); color: var(--text-primary); margin: var(--space-2) 0 0; }
.khero__cta { display: flex; gap: var(--space-3); margin-top: var(--space-5); flex-wrap: wrap; }

/* theme toggle icon swap */
.theme-icon-dark, .theme-icon-light { display: inline-flex; }
.theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline-flex; }

@media (max-width: 900px) {
  .khero__in--term { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .khead__sep { display: none; }
  .khead__nav [aria-label="GitHub"],
  .khead__nav [aria-label="LinkedIn"] { display: none; }
  .klogo__txt { font-size: var(--fs-sm); }
  .khero__in { gap: var(--space-3); }
  .khero__h { font-size: var(--fs-xl); }
  .khero__cta { gap: var(--space-2); }
  .khero__cta .kbtn { padding: 0 14px; height: 36px; font-size: var(--fs-xs); }
  #heroStats { display: flex; flex-wrap: wrap; row-gap: 2px; }
  .kterm__stat { font-size: var(--fs-2xs); }
  .kterm__sep { margin: 0 4px; }
}

/* ---------- work section / filter ---------- */
.kwork { flex: 1; padding-block: var(--space-8) var(--space-10); }

.kfilter { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-6); }
.kfilter__title { display: flex; align-items: center; gap: var(--space-3); }
.kfilter__count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.kfilter__layout { margin-left: auto; display: inline-flex; gap: 2px; }
.kfilter__controls { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }

.filters-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.custom-select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: relative;
}

.filter-label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}

.custom-multiselect {
  position: relative;
  min-width: 180px;
}

.multiselect-trigger {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s;
  text-align: left;
}

.multiselect-trigger:hover {
  border-color: var(--border-light);
}

.multiselect-trigger.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-accent);
}

.multiselect-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multiselect-arrow {
  font-size: 0.7rem;
  margin-left: 0.5rem;
  transition: transform 0.2s;
}

.multiselect-trigger.active .multiselect-arrow {
  transform: rotate(180deg);
}

.multiselect-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  min-width: 100%;
  width: max-content;
  max-width: 350px;
}

.multiselect-dropdown.active {
  display: block;
}

.multiselect-option {
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.multiselect-option:last-child {
  border-bottom: none;
}

.multiselect-option:hover {
  background: var(--accent-wash);
}

.multiselect-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.multiselect-option label {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.kfilter__controls select,
.kfilter__controls input {
  padding: 0.3rem 0.6rem;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.3s;
  min-width: 140px;
  line-height: 1.2;
  height: 32px;
}

.kfilter__controls select[multiple] {
  padding: 0.4rem 0.6rem;
}

.kfilter__controls select[multiple] option {
  padding: 0.4rem 0.6rem;
  margin: 0;
  color: var(--text);
  background: var(--surface-card);
}

.kfilter__controls select[multiple] option:checked {
  background: var(--accent);
  color: var(--on-accent);
}

.kfilter__controls input[type="search"] {
  max-width: 250px;
  flex: 1;
}

.kfilter__controls select:hover,
.kfilter__controls input:hover {
  border-color: var(--border-light);
}

.kfilter__controls select:focus,
.kfilter__controls input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--shadow-accent);
}

.kfilter__controls input {
  min-width: 200px;
  flex: 1;
}

@media (max-width: 430px) {
  .kfilter__controls { flex-direction: column; align-items: stretch; }
  .kfilter__controls select,
  .kfilter__controls input,
  .kfilter__controls input[type="search"] { width: 100%; min-width: 0; max-width: none; }
}

.kgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

.kpc {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.kpc__rule { position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--accent-fill); opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.kpc:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--shadow-md); }
.kpc:hover .kpc__rule { opacity: 1; }
.kpc:hover .kpc__titletxt,
.kpc:hover .kpc__cta { color: var(--accent-text); }
.kpc:hover .kpc__arrow { transform: translateX(3px); }
[data-theme="light"] .kpc:hover .kpc__titletxt {
  color: var(--text-hi);
  text-decoration: underline;
  text-decoration-color: var(--accent-fill);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.kpc__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.kpc__idx { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: 700; color: var(--text-faint); letter-spacing: -0.02em; }
.kpc__status { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 500; letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-secondary); }
.kpc__dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.kpc__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-snug); color: var(--text-primary); margin: 0 0 var(--space-3); display: flex; align-items: center; gap: 8px; }
.kpc__icon { display: inline-flex; color: var(--text-faint); flex-shrink: 0; }
.kpc:hover .kpc__icon { color: var(--accent-text); }
.kpc__titletxt { color: var(--text-primary); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
.kpc { cursor: pointer; }
.kpc__meta { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.kmeta { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: var(--ls-wide); color: var(--text-secondary); padding: 3px 9px; border-radius: var(--radius-md); background: var(--surface-well); border: 1px solid var(--border-subtle); }
.kmeta--line { background: transparent; border: 1px solid var(--border-strong); }
.kmeta__hash { color: var(--accent-text); }
.kpc__desc { font-size: var(--fs-sm); line-height: var(--lh-relaxed); color: var(--text-secondary); margin: 0 0 var(--space-4); flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kpc__tech { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--space-4); }
.ktag { font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 500; color: var(--text-body); background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 2px 8px; white-space: nowrap; }
.kpc__more { align-self: center; font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-faint); }
.kpc__foot { display: flex; align-items: center; justify-content: space-between; padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.kpc__cta { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm); color: var(--text-primary); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
.kpc__arrow { display: inline-block; transition: transform var(--dur-fast) var(--ease-out); }
.kpc__lnks { display: inline-flex; gap: 4px; }
.kpc__lnk { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); color: var(--text-secondary); text-decoration: none; font-size: 1rem; transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.kpc__lnk:hover { color: var(--accent-text); background: var(--accent-wash); }

@media (max-width: 640px) {
  .kgrid { grid-template-columns: 1fr; }
}

/* ---- layout toggle ---- */
.klayout__btn { color: var(--text-secondary); }
.klayout__btn:hover { color: var(--accent); border-color: var(--accent-line); }
.klayout__btn--active { border-color: var(--accent-line); color: var(--accent); }

/* ---- list view ---- */
.klist {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-card);
}

.krow {
  display: grid;
  grid-template-columns: 44px 16px minmax(0, 1fr) 96px 220px 56px 28px;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-fast) var(--ease-out);
}
.krow:last-child { border-bottom: none; }
.krow::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent-fill);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.krow:hover { background: var(--surface-raised); }
.krow:hover::before { opacity: 1; }
.krow:hover .krow__titletxt { color: var(--accent-text); }
.krow:hover .krow__arrow svg { transform: translateX(3px); }

.krow__idx { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 700; color: var(--text-faint); text-align: center; }
.krow__status { display: flex; justify-content: center; }
.krow__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.krow__title { font-family: var(--font-display); font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); margin: 0; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.krow__icon { display: inline-flex; color: var(--text-faint); flex-shrink: 0; margin-right: 7px; }
.krow:hover .krow__icon { color: var(--accent-text); }
.krow__titletxt { transition: color var(--dur-fast) var(--ease-out); overflow: hidden; text-overflow: ellipsis; }
.krow__desc { font-size: var(--fs-sm); color: var(--text-secondary); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.krow__meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-secondary); white-space: nowrap; }
.krow__tech { display: flex; gap: 4px; overflow: hidden; }
.krow__year { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); text-align: right; }
.krow__arrow svg { color: var(--text-faint); transition: transform var(--dur-fast) var(--ease-out); }

@media (max-width: 860px) {
  .krow { grid-template-columns: 32px 14px minmax(0, 1fr) 28px; }
  .krow__meta, .krow__tech, .krow__year { display: none; }
}

@media (max-width: 430px) {
  .krow { grid-template-columns: 36px 14px minmax(0, 1fr) 24px; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
}

.loading-state,
.error-state {
  text-align: center;
  padding: var(--space-9) var(--space-6);
  color: var(--text-muted);
}

.loading-icon,
.error-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.back-icon {
  font-size: 1.1rem;
  transition: transform var(--dur-fast) var(--ease-out);
}

.kbtn--secondary:hover .back-icon {
  transform: translateX(-3px);
}

.kwrap { max-width: var(--maxw-wide); margin: 0 auto; padding-inline: var(--space-6); width: 100%; box-sizing: border-box; }

/* ============================================================
   PROJECT DETAIL (.kdetail)
   ============================================================ */
.kdetail { padding-block: var(--space-6) var(--space-10); }
.kdetail .kwrap { max-width: var(--maxw-content); margin: 0 auto; padding-inline: var(--space-6); }

.kdetail__topnav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-7); flex-wrap: wrap; }

.kback {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: none; border: none; cursor: pointer; text-decoration: none;
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-secondary);
  padding: 0;
  transition: color var(--dur-fast) var(--ease-out);
}
.kback:hover { color: var(--accent-text); }
.kback svg { transition: transform var(--dur-fast) var(--ease-out); }
.kback:hover svg { transform: translateX(-3px); }

.kdetail__hero { padding-bottom: var(--space-6); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-7); }
.kdetail__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-6); }
.kdetail__idrow { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.kdetail__idx { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 700; color: var(--text-faint); letter-spacing: -0.02em; }
.kdetail__title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-2xl); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); color: var(--text-primary); margin: 0 0 var(--space-3); display: flex; align-items: center; gap: 10px; }
.kdetail__icon { display: inline-flex; color: var(--accent-text); flex-shrink: 0; }
.kdetail__icon svg { width: 28px; height: 28px; }
.kdetail__summary { font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--text-secondary); max-width: 60ch; margin: 0; }
.kdetail__actions { display: flex; gap: var(--space-3); flex-shrink: 0; }
.kdetail__metarow { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-5); flex-wrap: wrap; }
.kdetail__tech { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: var(--space-2); }

.kdetail__body { display: flex; flex-direction: column; gap: var(--space-8); }

/* about */
.kdetail__about { max-width: 68ch; display: flex; flex-direction: column; gap: var(--space-4); }
.kdetail__about p { font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--text-body); margin: 0; }
.kdetail__about p.klead { color: var(--text-primary); font-weight: 500; }
.kdetail__about strong { color: var(--text-primary); font-weight: 600; }
.kdetail__about em { font-style: italic; color: var(--accent-text); }
.kdetail__about ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.kdetail__about ul li { position: relative; padding-left: var(--space-5); line-height: var(--lh-relaxed); color: var(--text-body); }
.kdetail__about ul li::before { content: "▸"; position: absolute; left: 0; color: var(--accent-text); font-weight: bold; }

/* gallery */
.kgal { display: flex; flex-direction: column; gap: var(--space-4); }

.kgal__viewer { position: relative; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-well); padding: var(--space-4); }
.kgal__track { display: flex; gap: var(--space-4); transition: transform var(--dur-slow) var(--ease-out); }
.kgal__item { flex: 0 0 calc((100% - 2 * var(--space-4)) / 3); min-width: 0; padding: 0; margin: 0; border: none; border-radius: var(--radius-md); overflow: hidden; background: none; cursor: zoom-in; display: block; transition: transform var(--dur-base) var(--ease-out); }
.kgal__item:hover { transform: scale(1.02); }
.kgal__item img { width: 100%; height: 400px; object-fit: cover; display: block; }

.kgal__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  z-index: 2;
}
.kgal__nav:hover { border-color: var(--accent); color: var(--accent-text); transform: translateY(-50%) scale(1.05); }
.kgal__nav:disabled { opacity: 0.3; cursor: not-allowed; }
.kgal__nav svg { width: 22px; height: 22px; }
.kgal__prev { left: var(--space-4); }
.kgal__next { right: var(--space-4); }

.kgal__dots { display: flex; gap: var(--space-2); justify-content: center; }
.kgal__dot {
  width: 8px; height: 8px; padding: 0; border-radius: 50%;
  background: var(--border-strong); border: 1px solid var(--border-strong);
  cursor: pointer; transition: all var(--dur-base) var(--ease-out);
}
.kgal__dot:hover { background: var(--text-faint); }
.kgal__dot.is-active { width: 22px; border-radius: var(--radius-xs); background: var(--accent-fill); border-color: var(--accent-fill); }

/* lightbox */
.klightbox {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--ink-1000) 92%, transparent);
  align-items: center; justify-content: center; padding: var(--space-7);
  backdrop-filter: blur(8px);
}
.klightbox.is-open { display: flex; }
.klb__stage { margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.klb__stage img { max-width: 84vw; max-height: 80vh; object-fit: contain; border-radius: var(--radius-lg); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.klb__count { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: var(--ls-wide); color: var(--text-secondary); }
.klb__close { position: absolute; top: 24px; right: 24px; }
.klb__nav { position: absolute; top: 50%; transform: translateY(-50%); }
.klb__prev { left: 24px; }
.klb__next { right: 24px; }

/* architecture */
.karch { display: flex; flex-direction: column; gap: var(--space-4); }
.karch__well { padding: var(--space-6); display: flex; justify-content: center; overflow-x: auto; }
.karch .mermaid { width: 100%; display: flex; justify-content: center; min-height: 40px; }
.karch .mermaid svg { max-width: 100%; height: auto; }

/* discussion */
.kdiscuss { display: flex; flex-direction: column; gap: var(--space-4); }

/* project nav (prev / next) */
.kpnav { display: flex; align-items: center; gap: var(--space-2); }
.kpnav--bottom { justify-content: center; padding-top: var(--space-7); border-top: 1px solid var(--border-subtle); margin-top: var(--space-2); }
.kpnav--top { justify-content: flex-end; }

.kpnav__btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: 999px;
  padding: var(--space-2) var(--space-4); cursor: pointer; text-decoration: none; max-width: 220px;
  transition: border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.kpnav__btn:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.kpnav__btn:hover .kpnav__title { color: var(--accent-text); }
.kpnav__btn:hover svg { color: var(--accent-text); }
.kpnav__btn svg { color: var(--text-faint); flex-shrink: 0; transition: color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.kpnav__prev:hover > svg { transform: translateX(-3px); }
.kpnav__next:hover > svg { transform: translateX(3px); }
.kpnav__title { display: inline-flex; align-items: center; gap: var(--space-1); font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-xs); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--dur-fast) var(--ease-out); }
.kpnav__icon { display: inline-flex; flex-shrink: 0; }
.kpnav__icon svg { width: 16px; height: 16px; color: var(--text-faint); }

@media (max-width: 1024px) {
  .kgal__item { flex: 0 0 calc(50% - var(--space-2)); }
}

@media (max-width: 768px) {
  .kgal__item { flex: 0 0 100%; }
}

@media (max-width: 640px) {
  .kdetail__top { flex-direction: column; gap: var(--space-4); }
  .kdetail__actions { width: 100%; flex-direction: column; }
  .kdetail__actions .kbtn { width: 100%; justify-content: center; }
  .kdetail__title { font-size: var(--fs-xl); }
  .kgal__item img { height: 320px; }
  .kgal__nav { width: 36px; height: 36px; }
  .kgal__nav svg { width: 18px; height: 18px; }
  .kpnav--top .kpnav__title { display: none; }
  .kpnav--top .kpnav__btn { padding: var(--space-2); border-radius: 50%; }
  .kpnav--bottom .kpnav__btn { max-width: 45%; }
}

.giscus {
  margin-top: var(--space-4);
}

.giscus iframe {
  border-radius: var(--radius-md);
}

:where(button) {
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-out);
  font-weight: 500;
  font-family: inherit;
}

:where(button):hover {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-lime);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}


/* ---------- footer ---------- */
.kfoot { border-top: 1px solid var(--border-subtle); background: var(--surface-base); padding-block: var(--space-7); margin-top: auto; }
.kfoot__in { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.kfoot__brand { display: flex; flex-direction: column; gap: var(--space-2); }
.kfoot__prompt { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-body); }
.kfoot__copy { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.kfoot__links { display: flex; gap: var(--space-5); }
.kfoot__links a {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--text-secondary); text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.kfoot__links a:hover { color: var(--accent); }

@media (max-width: 768px) {
  .kwrap { padding-inline: var(--space-4); }
  .kwork { padding-block: var(--space-6) var(--space-8); }

  button {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
  }

  .kfoot__in { flex-direction: column; align-items: flex-start; }
}

