:root {
  color-scheme: light;
  --bg: #f6f8f6;
  --bg-warm: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f1f5f2;
  --surface-strong: #e8f0ec;
  --ink: #16201c;
  --ink-soft: #32403a;
  --muted: #66736e;
  --line: #dbe4df;
  --line-strong: #b9c7c0;
  --teal: #087f7b;
  --teal-dark: #075f5d;
  --blue: #315f8c;
  --amber: #b67819;
  --coral: #c85f49;
  --shadow: 0 24px 70px rgba(22, 32, 28, 0.11);
  --soft-shadow: 0 12px 34px rgba(22, 32, 28, 0.08);
  --radius: 8px;
  --max-width: 1180px;
  --header-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: linear-gradient(180deg, var(--bg-warm) 0, var(--bg) 42rem);
  color: var(--ink);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(22, 32, 28, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 32, 28, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 72%);
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

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

a:hover {
  color: var(--teal-dark);
}

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(8, 127, 123, 0.32);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  transform: translateY(-140%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(219, 228, 223, 0.82);
  background: rgba(251, 250, 246, 0.9);
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(var(--max-width), calc(100% - 32px));
  min-height: var(--header-height);
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(8, 127, 123, 0.95), rgba(49, 95, 140, 0.95));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 850;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.2);
}

.brand-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-text strong,
.brand-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 720;
}

.nav-links a:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.detail-page,
.site-footer {
  width: min(var(--max-width), calc(100% - 32px));
  margin-inline: auto;
}

.page-status {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(182, 120, 25, 0.28);
  border-radius: var(--radius);
  background: #fff9ed;
  color: #7a4c0c;
  font-weight: 700;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
  gap: 36px;
  align-items: stretch;
  padding: 56px 0 34px;
}

.section-kicker {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 820px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.35rem, 5vw, 4.85rem);
  line-height: 0.98;
  font-weight: 850;
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 680px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.hero-meta span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 680;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 780;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--soft-shadow);
}

.button-primary:hover {
  background: #26342e;
  color: #fff;
}

.button-secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--soft-shadow);
}

.status-panel,
.archive-panel,
.date-section,
.file-list-container,
.preview-container {
  border: 1px solid rgba(185, 199, 192, 0.76);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--soft-shadow);
}

.status-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-grid div {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.stat-grid span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 780;
}

.stat-grid strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
}

#latestPreview {
  width: 100%;
  min-height: 280px;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.archive-panel {
  margin-bottom: 18px;
  padding: 18px;
}

.panel-heading,
.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading h2,
.file-list-header h2 {
  margin: 0;
  font-size: 1.32rem;
  line-height: 1.25;
}

.archive-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.archive-link {
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.archive-link:hover,
.archive-link.is-active {
  border-color: rgba(8, 127, 123, 0.42);
  background: #e4f4ef;
  color: var(--teal-dark);
}

.date-stack {
  display: grid;
  gap: 18px;
}

.date-section {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.time-index {
  display: grid;
  align-content: start;
  gap: 12px;
}

.time-index h2 {
  display: grid;
  margin: 0;
  color: var(--teal-dark);
  font-size: 1.22rem;
  line-height: 1.12;
}

.time-index h2 span {
  color: var(--ink);
  font-size: 1.45rem;
}

.time-label {
  display: grid;
  min-height: 126px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-weight: 820;
}

.data-content {
  min-width: 0;
}

.category-headers,
.run-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.category-headers {
  margin-bottom: 10px;
}

.category-headers span {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 820;
}

.run-row {
  margin-bottom: 12px;
}

.image-tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 126px;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: zoom-in;
}

.image-tile img {
  width: 100%;
  height: 126px;
  object-fit: contain;
}

.image-tile span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(22, 32, 28, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 820;
}

.image-tile.is-empty {
  cursor: default;
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 760;
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.44fr) minmax(0, 1fr);
  gap: 18px;
  margin: 28px 0 64px;
}

.file-list-container,
.preview-container {
  min-width: 0;
  padding: 18px;
}

.compare-mode-toggle {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 780;
}

.compare-mode-toggle:hover,
.compare-mode-toggle.is-active {
  border-color: rgba(8, 127, 123, 0.42);
  background: #e4f4ef;
  color: var(--teal-dark);
}

.file-list {
  display: grid;
  max-height: 680px;
  overflow: auto;
  padding-right: 6px;
}

.folder {
  display: grid;
  gap: 5px;
  margin-left: 12px;
}

.folder:first-child {
  margin-left: 0;
}

.folder-header,
.file {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}

.folder-header:hover,
.file:hover {
  background: var(--surface-soft);
  color: var(--teal-dark);
}

.folder-toggle::before {
  content: ">";
  display: inline-block;
  width: 14px;
  color: var(--muted);
  transition: transform 180ms ease;
}

.folder.is-open > .folder-header .folder-toggle::before {
  transform: rotate(90deg);
}

.folder-content {
  display: none;
}

.folder.is-open > .folder-content {
  display: grid;
}

.file {
  padding: 7px 8px 7px 22px;
  font-size: 0.84rem;
  word-break: break-all;
}

.preview-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-toolbar span {
  color: var(--muted);
  font-size: 0.86rem;
  word-break: break-all;
}

#previewImage,
.compare-image {
  width: 100%;
  max-height: 560px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.compare-container {
  display: none;
  margin-top: 14px;
}

.compare-container.is-active {
  display: block;
}

.empty-message {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-weight: 720;
}

.image-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(12, 20, 17, 0.86);
}

.image-overlay.is-active {
  display: grid;
}

#overlayImg {
  max-width: min(1200px, 94vw);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

#closeOverlay,
.scroll-to-top {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

#closeOverlay {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  font-size: 1.3rem;
}

.scroll-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 18;
  width: 44px;
  height: 44px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.scroll-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 34px 0 46px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-links {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--teal-dark);
  font-weight: 760;
}

@media (max-width: 980px) {
  .detail-hero,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .date-section {
    grid-template-columns: 1fr;
  }

  .time-index {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    align-items: stretch;
  }

  .time-index h2 {
    grid-column: 1 / -1;
  }

  .time-label {
    min-height: 44px;
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .detail-hero {
    gap: 24px;
    padding-top: 42px;
  }

  .panel-heading,
  .file-list-header,
  .site-footer,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .compare-mode-toggle {
    width: 100%;
  }

  .stat-grid,
  .category-headers,
  .run-row {
    grid-template-columns: 1fr;
  }

  .category-headers {
    display: none;
  }

  .image-tile,
  .image-tile img {
    min-height: 180px;
    height: 180px;
  }
}

@media (max-width: 460px) {
  .detail-page,
  .site-footer,
  .topbar {
    width: min(100% - 24px, var(--max-width));
  }

  .brand-text {
    max-width: 220px;
  }

  .nav-links a {
    padding-inline: 8px;
    font-size: 0.86rem;
  }

  .archive-panel,
  .status-panel,
  .date-section,
  .file-list-container,
  .preview-container {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
