*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-canvas: #FAFAFA;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F4F4F5;
  --text-primary: #18181B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --border-hairline: #E4E4E7;
  --border-strong: #D4D4D8;
  --accent: #2563EB;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Cormorant Garamond", "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.container {
  width: 100%;
  max-width: 1360px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* 3-Zone Top Bar Contract */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: rgba(250, 250, 250, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-hairline);
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand-wordmark {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 28px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}

.nav-link {
  padding: 4px 0;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-strong);
}

.nav-link.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #FFFFFF;
  background-color: var(--text-primary);
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.header-cta:hover {
  background-color: #27272A;
}

/* Main Layout */
.site-main {
  flex: 1;
}

/* Section Toolbar & Category Filter Tabs */
.works-section {
  padding-top: 48px;
  padding-bottom: 64px;
}

.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 36px;
}

.category-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 100%;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.category-icon {
  width: 18px;
  height: 21px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.category-tab:hover .category-icon,
.category-tab.is-active .category-icon {
  opacity: 1;
}

.category-tab:hover {
  color: var(--text-primary);
}

.category-tab.is-active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.category-count {
  min-width: 18px;
  padding: 2px 5px;
  border-radius: 9999px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  color: var(--text-muted);
}

.category-tab.is-active .category-count {
  color: var(--text-secondary);
}

.toolbar-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* Portfolio Grid */
.works-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 640px) {
  .works-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .works-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .works-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Artwork Card */
.artwork-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}

.artwork-card:hover {
  border-color: var(--border-strong);
}

.card-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background-color: var(--bg-subtle);
  overflow: hidden;
}

.card-main-link {
  display: block;
  width: 100%;
  height: 100%;
}

.card-stage img.slide-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.artwork-card:hover .card-stage img.slide-image {
  transform: scale(1.015);
}

.stage-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}

.slide-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid rgba(228, 228, 231, 0.9);
  background-color: rgba(255, 255, 255, 0.92);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.card-stage:hover .slide-arrow,
.card-stage:focus-within .slide-arrow,
.detail-stage:hover .slide-arrow,
.detail-stage:focus-within .slide-arrow {
  opacity: 1;
}

.slide-arrow:hover {
  background-color: #FFFFFF;
}

.slide-arrow.prev {
  left: 12px;
}

.slide-arrow.next {
  right: 12px;
}

.slide-counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background-color: rgba(24, 24, 27, 0.78);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

/* Card Thumbnail Strip */
.card-thumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 2px;
  overflow-x: auto;
}

.thumb-btn {
  width: 44px;
  height: 32px;
  padding: 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  background-color: var(--bg-subtle);
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.thumb-btn:hover {
  opacity: 0.9;
}

.thumb-btn.is-active {
  opacity: 1;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--text-primary);
}

.thumb-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-left: 8px;
}

/* Card Body */
.card-body {
  padding: 16px 18px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-meta .mono {
  font-family: var(--font-mono);
}

.card-meta .cat-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-primary);
  font-weight: 500;
}

.cat-link-icon {
  width: 14px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.card-meta .cat-link:hover {
  color: var(--accent);
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--text-primary);
}

.card-title a:hover {
  color: var(--accent);
}

.card-actions {
  padding-top: 12px;
  border-top: 1px solid #F4F4F5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 0;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.detail-link:hover {
  color: var(--text-primary);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #FFFFFF;
  background-color: var(--text-primary);
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.download-btn:hover {
  background-color: #27272A;
}

.download-btn .file-size {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.78;
}

/* Single Work Detail Page */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.breadcrumb a:hover {
  color: var(--text-primary);
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}

@media (min-width: 1024px) {
  .detail-layout {
    grid-template-columns: 1fr 360px;
    gap: 40px;
  }
}

.detail-gallery {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  overflow: hidden;
}

.detail-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-stage img.slide-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.detail-caption-bar {
  padding: 14px 20px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-thumbs {
  padding: 12px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.detail-thumbs .thumb-btn {
  width: 72px;
  height: 52px;
}

.detail-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.detail-title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.sidebar-divider {
  height: 1px;
  background-color: #F4F4F5;
}

.file-box {
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.file-name {
  font-family: var(--font-mono);
  color: var(--text-primary);
  word-break: break-all;
}

.download-btn-lg {
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
}

/* Comments (giscus) */
.comments-section {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--border-hairline);
}

.comments-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.giscus {
  width: 100%;
}

.plate-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plate-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.plate-list-item a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.plate-list-item a:hover {
  color: var(--text-primary);
}

/* Directory Guide / Structure Section */
.structure-section {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-hairline);
  padding-top: 56px;
  padding-bottom: 56px;
}

.structure-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 768px) {
  .structure-grid {
    grid-template-columns: 4fr 8fr;
    gap: 48px;
  }
}

.structure-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.structure-sub {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.tree-pre {
  margin: 0;
  padding: 20px 24px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-secondary);
  overflow-x: auto;
}

/* Lightbox Overlay */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgba(9, 9, 11, 0.9);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(24, 24, 27, 0.85);
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-caption {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #D4D4D8;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-hairline);
  background-color: var(--bg-canvas);
  padding: 28px 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.footer-links a:hover {
  color: var(--text-primary);
}

/* Focus accessibility */
:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

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