:root {
  --bg: #ffffff;
  --ink: #111111;
  --line: #111111;
  --tile: #f0f0f0;
  --lb-bg: rgba(255, 255, 255, 0.58);
  --scroll-thumb: #111111;
  --gutter: clamp(1.75rem, 4vw, 4.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0e0e0e;
  --ink: #ececec;
  --line: #ececec;
  --tile: #1a1a1a;
  --lb-bg: rgba(14, 14, 14, 0.68);
  --scroll-thumb: #ececec;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button {
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  touch-action: manipulation;
}

.card, .thumb img, .lightbox-stage, .lightbox img {
  touch-action: manipulation;
}

.thumb, .thumb img, .lightbox-stage, .lightbox img {
  -webkit-touch-callout: none;
}

.is-hidden {
  display: none !important;
}

.custom-cursor {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  * {
    cursor: none !important;
  }

  .custom-cursor {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: 40px;
    height: 40px;
    margin: -1px 0 0 -1px;
    color: var(--ink);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    will-change: transform;
  }

  .custom-cursor.is-visible {
    opacity: 1;
  }

  .custom-cursor svg {
    width: 100%;
    height: 100%;
    display: block;
  }

  .cursor-loupe {
    opacity: 0;
    transition: opacity 0.12s ease;
  }

  .custom-cursor.is-zoom-in .cursor-loupe,
  .custom-cursor.is-zoom-out .cursor-loupe {
    opacity: 1;
  }

  .custom-cursor.is-zoom-out .cursor-plus-v {
    opacity: 0;
  }
}

.intro {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.28s var(--ease);
}

.intro.is-done {
  opacity: 0;
  pointer-events: none;
}

.intro-track {
  position: relative;
  width: 150px;
  height: 44px;
}

.intro-line {
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 150px;
  height: 1px;
  background: var(--ink);
  transform-origin: left center;
  transform: scaleX(0);
  animation: drawLine 0.72s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}

.intro-pen-carrier {
  position: absolute;
  left: 0;
  bottom: 4.5px;
  width: 0;
  height: 0;
  animation: glidePen 0.72s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}

.intro-pen {
  position: absolute;
  left: 0;
  top: 0;
  width: 82px;
  height: auto;
  transform-origin: 0.57px 50%;
  transform: translate(-0.57px, -50%) rotate(-32deg);
}

@keyframes drawLine {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes glidePen {
  from { transform: translateX(0); }
  to   { transform: translateX(150px); }
}

.shell {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 0.36s var(--ease), transform 0.42s var(--ease);
}

.shell.is-ready {
  opacity: 1;
  transform: scale(1);
}

.header {
  width: 100%;
  height: 134px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.6rem var(--gutter) 1.35rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  transition: border-color 0.2s ease;
}

.brand {
  display: inline-block;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.0;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-align: left;
  transition: transform 0.16s var(--ease);
}

.brand:hover {
  transform: translateY(-2px);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2.75rem;
}

.nav-link {
  position: relative;
  display: inline-block;
  font-size: 1.05rem;
  color: var(--ink);
  padding-bottom: 4px;
  transition: transform 0.16s var(--ease);
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: var(--origin, center center);
  transition: transform 0.24s var(--ease);
}

.nav-link.active::after {
  transform: scaleX(1);
}

.nav-link:hover {
  transform: translateY(-2px);
}

.theme-btn {
  display: inline-block;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0 0 3px;
  transition: transform 0.16s var(--ease);
}

.theme-btn:hover {
  transform: translateY(-2px);
}

.stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 1.5rem var(--gutter);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
}

.view.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: viewIn 0.2s var(--ease) both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quote {
  text-align: center;
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: clamp(1.5rem, 3vh, 2.75rem);
  line-height: 1.6;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 1.8vw, 1.75rem);
  width: 100%;
  max-width: min(1440px, 118vh);
  margin: 0 auto;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
  margin: 1rem auto 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.empty-state--works {
  min-height: 55%;
  margin: 0 auto;
}

.empty-kitty {
  width: 56px;
  height: auto;
  color: var(--ink);
  flex-shrink: 0;
}

.view--works.active {
  justify-content: flex-start;
  padding-top: 0.75rem;
}

.filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin-bottom: 1.75rem;
  flex-shrink: 0;
}

.filter-btn {
  position: relative;
  display: inline-block;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 0.25rem 0;
  transition: transform 0.16s var(--ease);
}

.filter-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: var(--origin, center center);
  transition: transform 0.24s var(--ease);
}

.filter-btn:hover {
  transform: translateY(-2px);
}

.filter-btn.active::after {
  transform: scaleX(1);
}

.works-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.works-scroll::-webkit-scrollbar {
  width: 4px;
}

.works-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.works-scroll::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 2px;
}

.works-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.65rem;
  max-width: 1520px;
  margin: 0 auto;
}

.card {
  display: flex;
  flex-direction: column;
  transition: transform 0.14s var(--ease);
}

.card:active {
  transform: scale(0.99);
}

.thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--tile);
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: transform 0.32s var(--ease);
}

.card:hover .thumb img {
  transform: scale(1.022);
}

.caption {
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editorial-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 740px);
  gap: 2.75rem;
  margin: 0 auto;
  font-size: 1.15rem;
  line-height: 1.8;
}

.editorial-label {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.98rem;
}

.editorial-body p + p {
  margin-top: 1.5rem;
}

.inline-link {
  display: inline;
  font-size: inherit;
  line-height: inherit;
  text-decoration: underline;
  text-underline-offset: 5px;
  transition: text-underline-offset 0.16s var(--ease);
}

.inline-link:hover {
  text-underline-offset: 9px;
}

.email-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.inline-btn {
  display: inline-block;
  font-size: 0.92rem;
  color: var(--ink);
  padding: 0;
  transition: transform 0.16s var(--ease);
}

.inline-btn:hover {
  transform: translateY(-2px);
}

.status-line {
  font-size: 0.95rem;
  color: var(--ink);
}

.footer {
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink);
  padding: 1rem var(--gutter) 1.5rem;
  flex-shrink: 0;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: var(--lb-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  z-index: 100;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), visibility 0.2s var(--ease);
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-stage {
  position: relative;
  display: inline-block;
}

.lightbox-stage.is-zoomed {
  z-index: 102;
}

.lightbox img {
  max-width: 82vw;
  max-height: 78vh;
  object-fit: contain;
  display: block;
  background: var(--tile);
  transform: scale(0.98);
  transition: transform 0.22s var(--ease);
}

.lightbox.open img {
  transform: scale(1);
}

.lightbox.open img.is-zoomed {
  transform: scale(2.2);
}

.lightbox-meta {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.lightbox-count {
  position: fixed;
  top: 2rem;
  left: 2.25rem;
  font-size: 0.9rem;
  color: var(--ink);
  z-index: 105;
}

.lightbox-btn {
  position: fixed;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 0.75rem 1.25rem;
  z-index: 105;
  transition: transform 0.16s var(--ease);
}

.lightbox-close { top: 1.25rem; right: 2rem; }
.lightbox-prev  { left: 1.5rem; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 1.5rem; top: 50%; transform: translateY(-50%); }

.lightbox-close:hover { transform: translateY(-2px); }
.lightbox-prev:hover  { transform: translateY(-50%) translateX(-3px); }
.lightbox-next:hover  { transform: translateY(-50%) translateX(3px); }

@media (max-width: 768px) {
  html, body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
  }

  .header {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .nav {
    width: 100%;
    justify-content: center;
    gap: 1.35rem;
    flex-wrap: wrap;
  }

  .nav-link { font-size: 0.95rem; }

  .stage { padding: 2rem var(--gutter); }
  .quote { font-size: 1rem; }

  /* === MOBILE FILTER FIX === */
  .filters {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    gap: 1rem;
    padding: 0.5rem 0;
    margin-bottom: 1.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 2px solid transparent;
  }

  .filter-btn.active::after {
    bottom: 0.4rem;
  }

  .filters::after {
    content: "→";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--ink);
    opacity: 0.4;
    pointer-events: none;
    padding-left: 1.5rem;
    background: linear-gradient(to right, transparent, var(--bg) 60%);
    transition: opacity 0.2s ease;
  }

  .filters.is-scrolled-end::after {
    opacity: 0;
  }
  /* === END MOBILE FILTER FIX === */

  .home-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .works-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .works-scroll { overflow-y: visible; padding-right: 0; }
  .empty-state--works { padding: 3.5rem 0; }

  .editorial-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    font-size: 1rem;
  }

  .lightbox img { max-width: 92vw; }
  .lightbox-count { top: 1.95rem; left: 1.25rem; font-size: 0.85rem; }
  .lightbox-close { right: 0.5rem; }
  .lightbox-prev  { left: 0.5rem; top: auto; bottom: 1.5rem; transform: none; }
  .lightbox-next  { right: 0.5rem; top: auto; bottom: 1.5rem; transform: none; }
  .lightbox-prev:hover { transform: translateX(-3px); }
  .lightbox-next:hover { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}