:root {
  --bg: #f3efe7;
  --paper: rgba(255, 251, 245, 0.94);
  --ink: #1d2428;
  --muted: #66727b;
  --line: rgba(53, 65, 74, 0.12);
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warning: #9a5d00;
  --danger: #8f2135;
  --shadow: 0 16px 40px rgba(53, 42, 24, 0.10);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    linear-gradient(180deg, #faf7f2 0%, #efe7da 100%);
  font-family: "IBM Plex Sans KR", "Pretendard", "Segoe UI", sans-serif;
}

body {
  position: relative;
  padding: 18px;
}

.ambient {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.45;
  pointer-events: none;
}

.ambient-a {
  top: -40px;
  right: 8%;
  width: 280px;
  height: 280px;
  background: rgba(15, 118, 110, 0.18);
}

.ambient-b {
  bottom: 8%;
  left: 4%;
  width: 240px;
  height: 240px;
  background: rgba(201, 97, 33, 0.15);
}

.hero,
.panel,
.sidebar-panel,
.entity-list {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  border-radius: 28px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
}

.eyebrow.small {
  margin-bottom: 4px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.02;
}

.lead {
  margin-top: 10px;
  max-width: 860px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions,
.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.ghost {
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid rgba(15, 118, 110, 0.22);
}

.stats {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(53, 65, 74, 0.08);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.workspace {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 250px);
}

.sidebar {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.sidebar-panel,
.panel,
.entity-list {
  border-radius: var(--radius);
}

.sidebar-panel,
.panel {
  padding: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field.compact {
  max-width: 200px;
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 11px 13px;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(15, 118, 110, 0.06);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.segment {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}

.segment.is-active {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.save-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.entity-list {
  overflow: auto;
  padding: 10px;
  min-height: 0;
  /* 군집 398개 목록이 페이지 전체를 늘려 사진 영역이 화면 밖으로
     밀리지 않도록 목록 자체 스크롤로 제한한다 */
  max-height: calc(100vh - 340px);
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
}

.entity-button {
  width: 100%;
  text-align: left;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid transparent;
}

.entity-button[aria-current="true"] {
  background: rgba(15, 118, 110, 0.10);
  border-color: rgba(15, 118, 110, 0.28);
}

.entity-title {
  display: block;
  font-weight: 800;
}

.entity-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.detail-panel {
  display: grid;
  gap: 16px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.detail-meta,
.section-copy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.pill.accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pill.warning {
  background: rgba(154, 93, 0, 0.10);
  color: var(--warning);
}

.pill.danger {
  background: rgba(143, 33, 53, 0.10);
  color: var(--danger);
}

.cluster-controls {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  align-items: end;
}

.action-field {
  margin: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.sheet-thumb,
.photo-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 14px;
  background: #d7ddd9;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.photo-card {
  border: 1px solid rgba(53, 65, 74, 0.10);
  border-radius: 18px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 10px;
}

.photo-open {
  background: transparent;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
}

.photo-open:hover {
  transform: none;
}

.photo-meta-block {
  display: grid;
  gap: 6px;
}

.photo-title {
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.photo-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inline-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.photo-select {
  margin-top: 4px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.lightbox {
  width: min(920px, calc(100vw - 40px));
  border: 0;
  border-radius: 24px;
  padding: 18px;
  background: rgba(253, 250, 245, 0.98);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.lightbox::backdrop {
  background: rgba(20, 21, 24, 0.7);
}

.lightbox img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 16px;
  background: #ece8e0;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.lightbox-meta {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .entity-list {
    max-height: 280px;
  }
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  .hero,
  .detail-head,
  .section-head {
    flex-direction: column;
  }

  .hero-actions,
  .status-stack {
    width: 100%;
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cluster-controls {
    grid-template-columns: 1fr;
  }
}
