/* ---------- 공용 머리말 (메인·영화 같은 모양) ---------- */
.masthead { line-height: 1.65; }   /* 페이지마다 본문 줄 간격이 달라도 머리말 높이는 같게 */
.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.masthead {
  position: relative; z-index: 1; display: grid; grid-template-columns: auto 1fr auto; gap: 28px; align-items: end;
  padding: 12px 32px 16px; border-bottom: 3px double var(--ink);
}
.masthead__issue { font: 500 11px/1 var(--mono); letter-spacing: .22em; color: var(--curtain); }
.masthead__title { margin: 6px 0 0; font: 700 36px/1 var(--serif); letter-spacing: -.02em; }
.masthead__title em { font-style: normal; color: var(--curtain); }
.masthead__dek { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }
.masthead__name { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.masthead__name .masthead__title { margin: 0; }
.about-toggle { display: none; }
@keyframes masthead-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) {
  .masthead { grid-template-columns: 1fr auto; padding: 10px 16px 12px; gap: 10px; align-items: center; }
  .masthead__title { font-size: 30px; }
  .about-toggle {
    display: inline-block; font: 500 12px var(--sans); color: var(--ink-2); background: none;
    border: 1px solid var(--rule); border-radius: 999px; padding: 4px 10px; cursor: pointer;
  }
  .about-toggle[aria-expanded="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
  .masthead__dek { grid-column: 1 / -1; grid-row: 2; font-size: 12.5px; display: none; }
  .masthead.is-about .masthead__dek { display: block; animation: masthead-rise .25s ease both; }
}

/* ---------- 모바일 머리말 아래 휘장: 오페라 무대 위 커튼처럼 늘어진 천, 아래 끝은 금색 띠 ---------- */
@media (max-width: 900px) {
  .masthead { border-bottom: 0; }
  .masthead::after, .masthead::before { content: ""; position: absolute; left: 0; right: 0; top: 100%; pointer-events: none; }
  .masthead::after {
    height: 26px; opacity: var(--drape-alpha); filter: drop-shadow(0 3px 3px rgba(28, 16, 10, .25));
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='26'%3E%3Cpath d='M0 0H130V3C116 4 108 26 65 26C22 26 14 4 0 3Z'/%3E%3C/svg%3E") 0 0 / 130px 26px repeat-x; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='26'%3E%3Cpath d='M0 0H130V3C116 4 108 26 65 26C22 26 14 4 0 3Z'/%3E%3C/svg%3E") 0 0 / 130px 26px repeat-x;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='26'%3E%3Cdefs%3E%3ClinearGradient id='b0' gradientUnits='userSpaceOnUse' x1='0' y1='0' x2='0' y2='10'%3E%3Cstop offset='0' stop-color='%23fff' stop-opacity='.09'/%3E%3Cstop offset='.18' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='.5' stop-color='%23000' stop-opacity='.24'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.6'/%3E%3C/linearGradient%3E%3ClinearGradient id='b1' gradientUnits='userSpaceOnUse' x1='0' y1='10' x2='0' y2='17'%3E%3Cstop offset='0' stop-color='%23fff' stop-opacity='.09'/%3E%3Cstop offset='.18' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='.5' stop-color='%23000' stop-opacity='.24'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.6'/%3E%3C/linearGradient%3E%3ClinearGradient id='b2' gradientUnits='userSpaceOnUse' x1='0' y1='17' x2='0' y2='26'%3E%3Cstop offset='0' stop-color='%23fff' stop-opacity='.09'/%3E%3Cstop offset='.18' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='.5' stop-color='%23000' stop-opacity='.24'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.6'/%3E%3C/linearGradient%3E%3ClinearGradient id='j' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0' stop-color='%23000' stop-opacity='.42'/%3E%3Cstop offset='.22' stop-color='%23000' stop-opacity='0'/%3E%3Cstop offset='.78' stop-color='%23000' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.42'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 0H130V3C116 3.35 108 10 65 10C22 10 14 3.35 0 3Z' fill='url(%23b0)'/%3E%3Cpath d='M0 3C14 3.35 22 10 65 10C108 10 116 3.35 130 3L130 3C116 3.70 108 17 65 17C22 17 14 3.70 0 3Z' fill='url(%23b1)'/%3E%3Cpath d='M0 3C14 3.70 22 17 65 17C108 17 116 3.70 130 3L130 3C116 4.15 108 26 65 26C22 26 14 4.15 0 3Z' fill='url(%23b2)'/%3E%3Crect width='130' height='26' fill='url(%23j)'/%3E%3C/svg%3E") 0 0 / 130px 26px repeat-x,
      linear-gradient(180deg, var(--drape-dark), var(--drape) 30%, var(--drape-light) 70%, var(--drape) 100%);
  }
  .masthead::before {
    z-index: 1; height: 28px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='28' fill='none'%3E%3Cpath d='M0 3.4C14 4.4 22 25 65 25C108 25 116 4.4 130 3.4' stroke='%23c9a046' stroke-width='3'/%3E%3Cpath d='M0 2.6C14 3.6 22 24 65 24C108 24 116 3.6 130 2.6' stroke='%23f2dc96' stroke-width='.7'/%3E%3C/svg%3E") 0 0 / 130px 28px repeat-x;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3));
  }
}

/* 왼쪽 길잡이 패널 (메인·영화 페이지 공용). 메뉴만 둔다: 영화 정보는 대화 옆에 섞지 않는다 */
.rail {
  display: flex; flex-direction: column; gap: 2px; width: 184px; min-height: 0; padding: 18px 12px 14px;
  border-right: 1px solid var(--rule); background: var(--paper); overflow: hidden; transition: width .2s ease;
}
.rail svg { flex: none; width: 18px; height: 18px; }
.rail__brand { display: none; text-decoration: none; color: var(--ink); margin: 2px 10px 18px; white-space: nowrap; }
.rail__brand small { display: block; font: 500 10px/1 var(--mono); letter-spacing: .22em; color: var(--curtain); }
.rail__brand b { display: block; font: 700 24px/1.2 var(--serif); margin-top: 6px; }
.rail--brand .rail__brand { display: block; }   /* 머리말이 없는 페이지(영화)는 패널에 이름을 둔다 */
.rail__new {
  display: flex; align-items: center; gap: 8px; align-self: flex-start; font: 500 13px var(--sans); color: var(--paper);
  background: var(--ink); border: 1px solid var(--ink); border-radius: 999px; padding: 8px 16px 8px 12px; margin-bottom: 20px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s, border-color .2s;
}
.rail__new:hover { background: var(--curtain); border-color: var(--curtain); }
.rail__label { margin: 4px 10px 8px; font: 500 10.5px/1 var(--mono); letter-spacing: .22em; color: var(--ink-3); white-space: nowrap; }
.rail__item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font: 600 15px var(--serif); white-space: nowrap;
}
.rail__item:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.rail__item.is-on { color: var(--ink); }
.rail__item.is-on::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 4px; background: var(--curtain); }
.rail__fold {
  margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; background: none;
  font: 12px var(--mono); color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.rail__fold:hover { color: var(--ink); }
.rail__fold svg { transition: transform .2s; }

/* 최근 대화 (이 기기에 7일 저장, 메인 페이지만) */
.history { display: flex; flex-direction: column; min-height: 0; margin-top: 18px; }
.history[hidden] { display: none; }
.history__list { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; }
.history__item {
  position: relative; display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 7px 10px; border-radius: 8px; font: 13px/1.35 var(--sans); color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history__item:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.history__item.is-on { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.history__clear {
  align-self: flex-start; margin: 8px 10px 0; padding: 0; border: 0; background: none; cursor: pointer;
  font: 12px var(--sans); color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px;
}
.history__clear:hover { color: var(--curtain); }
body.rail-folded .history { display: none; }

body.rail-folded .rail { width: 64px; }
body.rail-folded .rail :is(.rail__label, .rail__brand, span) { display: none; }
body.rail-folded .rail__new { width: 40px; height: 40px; padding: 0; justify-content: center; }
body.rail-folded .rail__fold svg { transform: rotate(180deg); }

.rail-toggle, .rail-scrim { display: none; }

@media (max-width: 900px) {
  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 15; width: min(260px, 80vw); padding-top: 22px;
    background: var(--card);
    transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  }
  .rail__brand { display: block; }
  .rail__fold { display: none; }
  body.rail-open .rail { transform: none; box-shadow: 20px 0 40px -20px rgba(0, 0, 0, .5); }
  .rail-scrim {
    display: block; position: fixed; inset: 0; z-index: 14; background: rgba(20, 16, 12, .35);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.rail-open .rail-scrim { opacity: 1; pointer-events: auto; }
  .stage { z-index: auto; }   /* 메인에서 서랍(.stage 안)이 어둡게 덮는 막(바깥) 위로 올라오게 */
  .rail-toggle {
    display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--ink); border-radius: 50%;
    background: transparent; color: var(--ink); cursor: pointer;
  }
}

/* ---------- 왼쪽 패널 커튼 자락 (PC만. 모바일 서랍에는 넣지 않는다) ----------
   색은 화면 모드와 상관없이 짙은 와인빛 극장 커튼. 투명도를 조금 줘서 종이 배경에 녹아들게 한다 */
:root { --drape-dark: #3b0e0c; --drape: #661a15; --drape-light: #7f2b23; --drape-alpha: .92; }
@media (prefers-color-scheme: dark) { :root { --drape-dark: #250807; --drape: #4f1511; --drape-light: #6c2a22; --drape-alpha: .85; } }

/* 왼쪽 패널 가장자리: 위는 넓고 타이백(62%)에서 모였다가 아래로 조금 풀리는 커튼 자락 */
.rail { --drape-w: 30px; border-right: 0; padding-right: calc(var(--drape-w) + 6px); }
@media (min-width: 901px) { .rail { position: relative; } }   /* 모바일은 위의 position: fixed(서랍) 유지 */
@media (max-width: 900px) { .rail { padding-right: 12px; } .rail::before, .rail::after { display: none; } }
.rail::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: var(--drape-w); pointer-events: none; opacity: var(--drape-alpha);
  transform-origin: top right; transition: transform .28s ease-in, opacity .28s ease-in;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0H30V100H10C13 86 23.5 76 23.5 62C23.5 44 1 26 0 0Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0H30V100H10C13 86 23.5 76 23.5 62C23.5 44 1 26 0 0Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
  background:
    radial-gradient(ellipse 120% 16% at 85% 62%, rgba(0, 0, 0, .4), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 100' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='p' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0' stop-color='%23000' stop-opacity='.5'/%3E%3Cstop offset='.3' stop-color='%23000' stop-opacity='.12'/%3E%3Cstop offset='.55' stop-color='%23fff' stop-opacity='.1'/%3E%3Cstop offset='.75' stop-color='%23000' stop-opacity='.08'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.42'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0.00 0C1.00 26 23.50 44 23.50 62C23.50 76 13.00 86 10.00 100L12.50 100C15.12 86 24.31 76 24.31 62C24.31 44 4.62 26 3.75 0Z' fill='url(%23p)'/%3E%3Cpath d='M3.75 0C4.62 26 24.31 44 24.31 62C24.31 76 15.12 86 12.50 100L17.08 100C19.02 86 25.80 76 25.80 62C25.80 44 11.27 26 10.62 0Z' fill='url(%23p)'/%3E%3Cpath d='M10.62 0C11.27 26 25.80 44 25.80 62C25.80 76 19.02 86 17.08 100L23.00 100C24.05 86 27.73 76 27.73 62C27.73 44 19.85 26 19.50 0Z' fill='url(%23p)'/%3E%3Cpath d='M19.50 0C19.85 26 27.73 44 27.73 62C27.73 76 24.05 86 23.00 100L30.00 100C30.00 86 30.00 76 30.00 62C30.00 44 30.00 26 30.00 0Z' fill='url(%23p)'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat,   /* 주름: 위에서 퍼졌다가 타이백으로 휘어 모이고 아래로 다시 퍼진다. 바깥(왼쪽)일수록 촘촘 */
    linear-gradient(90deg, var(--drape-dark), var(--drape) 25%, var(--drape-light) 60%, var(--drape)),
    linear-gradient(180deg, rgba(0, 0, 0, .25), transparent 18%);
}
.rail::before {   /* 타이백: 모인 자락을 감은 금색 꼰 끈과 작은 술 */
  content: ""; position: absolute; z-index: 1; right: 0; top: 62%; width: calc((var(--drape-w) + 4px) * 1.6);
  aspect-ratio: 34 / 60; transform: translateY(-48%); pointer-events: none; transition: opacity .15s;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 60'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23f4dd94'/%3E%3Cstop offset='.5' stop-color='%23c9a046'/%3E%3Cstop offset='1' stop-color='%2386621f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='none' stroke='url(%23g)' stroke-linecap='round'%3E%3Cpath d='M25.5 27.5C28 25.6 33 25.4 34 27.2' stroke-width='2.2'/%3E%3Cpath d='M25.5 30.2C28 28.4 33 28.2 34 30' stroke-width='2.2'/%3E%3Cpath d='M26 29C25 32 24.6 34.5 24.8 37' stroke-width='1.4'/%3E%3C/g%3E%3Ccircle cx='25.6' cy='28.8' r='2' fill='url(%23g)'/%3E%3Cpath d='M23.2 38.6Q24.8 36.6 26.4 38.6L27.4 47H22.2Z' fill='url(%23g)'/%3E%3Cpath d='M23 41V46.6M24.2 41V46.8M25.4 41V46.8M26.6 41V46.6' stroke='%237a581c' stroke-width='.45'/%3E%3C/svg%3E") right center / contain no-repeat;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .4));
}
/* 접힌 상태에서는 커튼 없이 아이콘만 */
/* 접힌 상태에서는 커튼 없이 아이콘만: 접을 때 커튼이 오른쪽으로 걷히며 사라진다 */
body.rail-folded .rail { padding-right: 12px; border-right: 1px solid var(--rule); }
body.rail-folded .rail::after { transform: scaleX(0); opacity: 0; }
body.rail-folded .rail::before { opacity: 0; }

/* 펼칠 때: 커튼이 위쪽을 축으로 펼쳐지며 두어 번 흔들리다 멈추고, 이어서 금색 끈이 감긴다 (rail.js가 잠깐 붙이는 클래스) */
body.rail-unfurl .rail::after { animation: drape-in .95s cubic-bezier(.3, .7, .25, 1) both; }
body.rail-unfurl .rail::before { animation: tie-in .45s .55s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes drape-in {
  0%   { transform: scaleX(0) skewY(0); opacity: 0; }
  35%  { transform: scaleX(1.12) skewY(-2.5deg); opacity: var(--drape-alpha); }
  58%  { transform: scaleX(.94) skewY(1.6deg); }
  78%  { transform: scaleX(1.03) skewY(-.6deg); }
  100% { transform: scaleX(1) skewY(0); opacity: var(--drape-alpha); }
}
@keyframes tie-in {
  0%   { transform: translateY(-48%) translateX(6px) rotate(-12deg) scale(.6); opacity: 0; }
  100% { transform: translateY(-48%); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .rail, .rail::before, .rail::after { transition: none !important; animation: none !important; }
}
