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

:root {
  --bg: #fafafa;
  --ink: #262626;
  --mute: #4a4a4a;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff;
  --t-hover: 125ms;
  --t-motion: 250ms;
  --ease-quint: cubic-bezier(0.23, 1, 0.32, 1);
}

body.dark {
  --bg: #141414;
  --ink: #ededed;
  --mute: #c8c8c8;
  --line: rgba(255, 255, 255, 0.12);
  --card: #1c1c1c;
}

html { touch-action: manipulation; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding:
    calc(28px + env(safe-area-inset-top, 0px))
    20px
    calc(2.5rem + env(safe-area-inset-bottom, 0px));
}

.shell { max-width: 1200px; margin: 0 auto; }

.header { text-align: center; margin-bottom: 28px; }
.header h1 {
  margin: 0 0 8px;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.header p {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--mute);
}

.views,
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.views { margin-bottom: 10px; }
.views[hidden],
.filters[hidden] { display: none; }

.case {
  margin: 0 auto 18px;
  max-width: 720px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity var(--t-motion) var(--ease-quint),
    transform var(--t-motion) var(--ease-quint);
}
.case.is-in {
  opacity: 1;
  transform: scale(1);
}
.case img {
  display: block;
  width: 100%;
  height: auto;
}
.case[hidden] { display: none; }

.combine {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0 0 20px;
}
@media (min-width: 720px) {
  .combine { grid-template-columns: 1fr 1fr; }
}
.combine[hidden] { display: none; }
.combine-card {
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.combine-card i {
  grid-row: 1 / span 2;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.combine-card strong {
  font-size: 15px;
}
.combine-card span {
  font-size: 12px;
  color: var(--mute);
}

.filter {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: transform var(--t-hover) ease, background var(--t-hover) ease;
}
.filter:hover { transform: translateY(-1px); }
.filter.is-on {
  background: var(--ink);
  color: var(--bg);
}

.grid {
  column-count: 2;
  column-gap: 12px;
}
@media (min-width: 720px) { .grid { column-count: 3; } }
@media (min-width: 1100px) { .grid { column-count: 4; } }

.tile {
  break-inside: avoid;
  margin: 0 0 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.95);
  transition:
    opacity var(--t-motion) var(--ease-quint),
    transform var(--t-motion) var(--ease-quint);
}
.tile.is-in {
  opacity: 1;
  transform: scale(1);
}
.tile img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}
.tile-can .swatch { display: none; }
.tile-color {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  font: inherit;
  color: inherit;
  text-align: left;
}
.color-top {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  column-gap: 10px;
  align-items: start;
  padding: 12px 12px 8px;
}
.color-measure {
  text-align: right;
}
.color-squares {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: var(--ink);
}
.color-lines {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--ink);
}
.color-top i {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 4px;
  border: 1px solid #6f6b62;
}
.color-top .tile-cap { padding: 0; min-width: 0; }
.tile-cap {
  padding: 10px 12px 12px;
}
.tile-cap strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}
.tile-cap span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--mute);
}

.empty {
  text-align: center;
  color: var(--mute);
  font-size: 15px;
}

.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-motion) var(--ease-quint);
}
.lightbox.is-in .lightbox-backdrop { opacity: 1; }
.lightbox-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  opacity: 0;
  transform: scale(0.95);
  transition:
    opacity var(--t-motion) var(--ease-quint),
    transform var(--t-motion) var(--ease-quint);
}
.lightbox.is-in .lightbox-card {
  opacity: 1;
  transform: scale(1);
}
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.gauges {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
}
.gauges[hidden] { display: none; }
.gauge {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.gauge-track {
  height: 10px;
  border-radius: 999px;
  background: #d4d0c6;
  border: 1px solid #6f6b62;
  overflow: hidden;
}
body.dark .gauge-track {
  background: #6a6a6a;
  border-color: #c8c8c8;
}
.gauge-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  transition: width var(--t-motion) var(--ease-quint);
}
.gauge-fill.is-dark {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}
.gauge span {
  font-size: 11px;
  color: var(--mute);
  min-width: 2.6em;
  text-align: right;
}
.lightbox-wash {
  height: 140px;
  background: #888;
}
.lightbox-wash[hidden],
.lightbox-photo-wrap[hidden] { display: none; }
.lightbox-meta .gauges { padding: 8px 0 4px; }
.lightbox-photo-wrap {
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}
.lightbox-photo-wrap img {
  display: block;
  width: 100%;
  height: auto;
}
.lightbox-meta { padding: 16px 18px 20px; }
.lightbox-meta h2 {
  margin: 0 0 6px;
  font-size: 22px;
}
.lightbox-meta p {
  margin: 0 0 8px;
  color: var(--mute);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .tile, .lightbox-card, .lightbox-backdrop, .filter, .case {
    transition: none;
  }
  .tile, .lightbox-card { opacity: 1; transform: none; }
  .gauge-fill { transition: none; }
}
