/* ── 디자인 토큰 ─────────────────────────────────────────── */
:root {
  /* Color: 종이와 먹. 강조색은 주홍 하나, 무료 표시에만 녹색을 쓴다. */
  --paper: #f5f2ea;
  --surface: #fffdf8;
  --ink: #1c1b18;
  --ink-2: #57534b;
  --ink-3: #777268;
  --line: #dcd6c8;
  --accent: #b8321a;
  --accent-soft: #f4dfd8;
  --free: #1f5b4a;
  --free-soft: #dde9e3;

  /* Type: 제목은 명조, 정보는 고딕 */
  --font-display: 'Noto Serif KR', 'Nanum Myeongjo', serif;
  --font-body: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 30px;
  --lh-tight: 1.35;
  --lh-body: 1.55;

  /* Spacing: 4px 단위 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 40px;

  /* Radius: 인쇄물처럼 각지게. 둥근 것은 칩뿐 */
  --r-sm: 2px;
  --r-pill: 999px;

  /* Shadow: 그림자 대신 선. 포커스 링만 예외 */
  --rule: 1px solid var(--line);
  --focus-ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);

  /* Icon */
  --icon: 16px;
  --icon-stroke: 1.5;

  /* Motion */
  --dur: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ── 기본 ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.icon {
  width: var(--icon);
  height: var(--icon);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

/* ── 머리말 ─────────────────────────────────────────────── */
.masthead {
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--ink);
}

.masthead h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

.masthead h1 a { color: inherit; text-decoration: none; }
/* 검색엔진이 읽는 h1 에 무엇을 하는 사이트인지 함께 둔다. 보이는 크기는 작게. */
.masthead h1 .h1-sub { display: block; margin-top: 2px; font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 400; color: var(--ink-2); letter-spacing: 0; }

.masthead p {
  margin: var(--sp-1) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* ── 필터 ───────────────────────────────────────────────── */
.controls {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  border-bottom: var(--rule);
  padding: var(--sp-3) 0;
}

.chips {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--sp-4));
  padding: 2px var(--sp-4);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px var(--sp-3);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; margin-left: 2px; }

.selects {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.selects label { flex: 1; max-width: 200px; }
.selects span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

select {
  width: 100%;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}

.notice {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-sm);
  color: var(--accent);
}
.notice:empty { display: none; }

/* ── 목록 ───────────────────────────────────────────────── */
.grid {
  list-style: none;
  margin: 0;
  padding: var(--sp-5) 0 var(--sp-6);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-4);
}

.card a { display: block; color: inherit; text-decoration: none; }

.poster {
  position: relative;
  /* 포스터는 대부분 세로형(A판 비율)이다. */
  aspect-ratio: 5 / 7;
  background: var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 400ms var(--ease);
}
.card a:hover .poster img { transform: scale(1.02); }

.poster.noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--ink-3);
  text-align: center;
}

.badge {
  position: absolute;
  left: var(--sp-2);
  top: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
.badge.soon { background: var(--accent); color: #fff; }

.card h3 {
  margin: var(--sp-3) 0 var(--sp-1);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: var(--lh-tight);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.card a:hover h3 { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.venue {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.facts {
  margin: var(--sp-3) 0 0;
  padding-top: var(--sp-3);
  border-top: var(--rule);
  font-size: var(--fs-sm);
}
.facts dt { color: var(--ink-3); font-size: var(--fs-xs); }
.facts dd { margin: 0 0 var(--sp-2); font-variant-numeric: tabular-nums; }
.facts .left { color: var(--ink-2); }
.facts .left.soon { color: var(--accent); font-weight: 600; }

.price {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.free {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--free);
  background: var(--free-soft);
  border-radius: var(--r-sm);
  padding: 1px 6px;
}
.unknown { color: var(--ink-3); }

.empty {
  grid-column: 1 / -1;
  padding: var(--sp-6) 0;
  text-align: center;
  color: var(--ink-2);
}

/* ── 상세 ───────────────────────────────────────────────── */
.topbar {
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--ink);
}

.back {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}
.back:hover { text-decoration: underline; text-underline-offset: 3px; }

.detail { padding: var(--sp-5) 0 var(--sp-6); }

.d-poster {
  background: var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
/* 이미지가 늦게 와도 아래 글이 밀리지 않게 포스터 자리를 먼저 잡는다(목록 카드와 같은 5:7). */
.d-poster img { display: block; width: 100%; aspect-ratio: 5 / 7; max-height: 80vh; object-fit: contain; }

.d-body { margin-top: var(--sp-5); }

.status {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px var(--sp-2);
}
.status.soon { color: #fff; background: var(--accent); border-color: var(--accent); }

.detail h1 {
  margin: var(--sp-3) 0 var(--sp-2);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: var(--lh-tight);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.answer { margin: var(--sp-3) 0 0; font-size: var(--fs-md); color: var(--ink); }
.description { margin: var(--sp-4) 0 0; color: var(--ink-2); white-space: pre-line; }

.d-facts {
  margin: var(--sp-5) 0;
  border-top: var(--rule);
  display: grid;
  grid-template-columns: 4.5em 1fr;
}
.d-facts dt, .d-facts dd { margin: 0; padding: var(--sp-3) 0; border-bottom: var(--rule); }
.d-facts dt { color: var(--ink-3); font-size: var(--fs-sm); padding-top: 14px; }
.d-facts dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.d-facts a { color: inherit; text-underline-offset: 3px; }

.left { color: var(--ink-2); font-size: var(--fs-sm); white-space: nowrap; }
.left.soon { color: var(--accent); font-weight: 600; }
.d-facts .left { margin-left: var(--sp-2); }

.lines { list-style: none; margin: 0; padding: 0; }
.free + .lines { margin-top: var(--sp-1); }

.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

.btn {
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); }

.others { margin-top: var(--sp-6); }
.others h2 { margin: 0 0 var(--sp-2); font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; }
.others ul { list-style: none; margin: 0; padding: 0; border-top: var(--rule); }
.others a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: var(--rule);
  color: inherit;
  text-decoration: none;
}
.others a:hover .o-title { text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 720px) {
  .detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--sp-6); align-items: start; }
  .d-poster { position: sticky; top: var(--sp-4); }
  .d-body { margin-top: 0; }
  .detail h1 { font-size: var(--fs-xl); }
}

/* ── 꼬리말 ─────────────────────────────────────────────── */
footer {
  border-top: var(--rule);
  padding: var(--sp-5) 0 var(--sp-6);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
footer p { margin: 0 0 var(--sp-1); }

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-6) var(--sp-5);
  }
  .card h3 { font-size: var(--fs-lg); }
  .facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-1) var(--sp-3);
  }
  .facts dt { font-size: var(--fs-sm); }
  .facts dd { margin: 0; }
}

/* ── 머리말 링크 ────────────────────────────────────────── */
.mast-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.to-mine {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* 모아 보기 링크: 칩과 같은 생김새의 링크 */
.quick { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.quick a {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px var(--sp-3);
}
.quick a:hover { border-color: var(--ink-3); color: var(--ink); }
.quick a[aria-current='page'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.quick .n, .gu-nav .n, .sec-h .n { font-variant-numeric: tabular-nums; opacity: 0.7; font-weight: 400; }

/* ── 카드 저장 버튼 ─────────────────────────────────────── */
.card { position: relative; }
.save {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  /* 보이는 크기는 '오늘 종료' 배지 높이에 맞춰 작게, 누르는 영역은 ::before 로 40px 확보 */
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.save::before { content: ''; position: absolute; inset: -7px; }
.save .icon { width: 14px; height: 14px; }
.save:not([data-state='wish']):not([data-state='visited']) { background: rgba(255, 253, 248, 0.85); border-color: transparent; }
.save .i-done { display: none; }
.save[data-state='wish'] { color: #fff; background: var(--accent); border-color: var(--accent); }
.save[data-state='wish'] .i-wish { fill: currentColor; }
.save[data-state='visited'] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.save[data-state='visited'] .i-wish { display: none; }
.save[data-state='visited'] .i-done { display: block; }

/* ── 모아 보기·전시장 페이지 ───────────────────────────── */
.page-head { padding: var(--sp-5) 0 var(--sp-2); }
.page-head h1 {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: var(--lh-tight);
  word-break: keep-all;
}
.page-head .venue { margin-bottom: var(--sp-2); }
.lead { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); }
.page-head .actions { margin-top: var(--sp-4); }
.sec-h { margin: var(--sp-5) 0 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }

.gu-nav { margin: 0 0 var(--sp-6); padding-top: var(--sp-4); border-top: var(--rule); }
.gu-nav h2 { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); color: var(--ink-3); font-weight: 600; }
.gu-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.gu-nav a { font-size: var(--fs-sm); color: var(--ink); text-underline-offset: 3px; }
.gu-nav a[aria-current='page'] { font-weight: 700; }

.past { list-style: none; margin: var(--sp-2) 0 0; padding: 0; border-top: var(--rule); }
.past a {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: var(--rule); color: inherit; text-decoration: none;
}
.past a:hover .o-title { text-decoration: underline; text-underline-offset: 3px; }
.past small { display: block; font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px; }
.p-date { flex: none; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ── 상세: 장소 링크, 종료, 내 기록 ───────────────────── */
.detail .venue a, .d-facts dd a { color: inherit; text-underline-offset: 3px; }
.status.ended { color: var(--ink-3); background: var(--line); border-color: var(--line); }
.ended-note { margin: var(--sp-3) 0 0; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); background: var(--surface); border-left: 2px solid var(--ink-3); }

button.btn { font: inherit; font-size: var(--fs-sm); font-weight: 600; background: transparent; cursor: pointer; }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.on:hover { background: var(--accent); color: #fff; opacity: 0.9; }

.mine { margin: 0 0 var(--sp-5); padding: var(--sp-4); background: var(--surface); border: var(--rule); border-radius: var(--r-sm); scroll-margin-top: var(--sp-4); }
.mine h2 { margin: 0 0 var(--sp-2); font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; }
.mine .actions { margin-top: var(--sp-3); }
.mine-done { margin: 0; }
.mine-memo { margin: var(--sp-2) 0 0; color: var(--ink-2); white-space: pre-line; }
.mine-note { margin: var(--sp-3) 0 0; font-size: var(--fs-xs); color: var(--ink-3); }
.mine-note a { color: inherit; text-underline-offset: 3px; }
.mine-note:empty { display: none; }

.field { display: block; margin-top: var(--sp-3); font-size: var(--fs-sm); }
.field span { display: block; margin-bottom: var(--sp-1); color: var(--ink-2); }
.field em { font-style: normal; color: var(--ink-3); }
.field input, .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3);
}
.field textarea { resize: vertical; }
/* iOS 사파리는 날짜 칸에 고유 너비·가운데 정렬을 줘서 박스 밖으로 넘친다. 기본 모양을 끄고 다른 칸과 맞춘다. */
.field input[type='date'] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  min-height: 42px;
  line-height: 24px;
  text-align: left;
}
.field input[type='date']::-webkit-date-and-time-value { text-align: left; margin: 0; }

/* ── 내 전시 ───────────────────────────────────────────── */
.page-head .chips { margin-top: var(--sp-4); }
.m-year-h { margin: var(--sp-5) 0 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }
.m-year-h span { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 400; color: var(--ink-3); }
.m-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; border-top: var(--rule); }
.m-row { padding: var(--sp-4) 0; border-bottom: var(--rule); }
.m-row a { display: flex; gap: var(--sp-4); color: inherit; text-decoration: none; }
/* 버튼은 썸네일(72px) + 간격만큼 들여 텍스트 열에 맞춘다. */
.m-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0 0 calc(72px + var(--sp-4)); }
.btn.sm { flex: 0 0 auto; min-height: 36px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.m-form { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-4); background: var(--surface); border: var(--rule); border-radius: var(--r-sm); }
.m-form .field:first-child { margin-top: 0; }
.m-row a:hover h2 { text-decoration: underline; text-underline-offset: 3px; }
.m-thumb {
  flex: none; width: 72px; aspect-ratio: 5 / 7; background: var(--line); border-radius: var(--r-sm); overflow: hidden;
  display: grid; place-items: center; font-size: var(--fs-xs); color: var(--ink-3); text-align: center;
}
.m-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.m-text { min-width: 0; }
.m-text h2 { margin: 0 0 2px; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; line-height: var(--lh-tight); word-break: keep-all; overflow-wrap: anywhere; }
.m-period { margin: var(--sp-1) 0 0; font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.m-when { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.m-when.soon { color: var(--accent); }
.m-when.ended { color: var(--ink-3); font-weight: 400; }
.m-memo { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); color: var(--ink-2); white-space: pre-line; }
#list > .empty { display: block; }

.backup { margin: var(--sp-6) 0; padding-top: var(--sp-4); border-top: var(--rule); font-size: var(--fs-sm); color: var(--ink-2); }
.backup h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--ink); }
.backup p { margin: 0; }
.btn.file { position: relative; cursor: pointer; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (min-width: 720px) {
  .page-head h1 { font-size: var(--fs-xl); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ── 소개 ───────────────────────────────────────────────── */
.about { max-width: 640px; padding-bottom: var(--sp-6); }
.about h2 { margin: var(--sp-5) 0 var(--sp-2); font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }
.about p, .about li { color: var(--ink-2); }
.about ul { padding-left: 1.2em; margin: 0; }
.about a { color: var(--ink); text-underline-offset: 3px; }
footer a { color: inherit; text-underline-offset: 3px; }
