/* enextpage — 종이 한 장과 잉크. 기획서 3장 BI. */

/* ---------------------------------------------------------- 토큰 */
:root,
[data-theme="paper"] {
  --paper: #F5F3EE;
  --ink: #1C1C1C;
  --graphite: #6E6A63;
  --rule: #DAD6CD;
  --blue: #2F4A6D;
  --fold: #E6E2D9;
}
[data-theme="sepia"] {
  --paper: #F1E7D0;
  --ink: #3B2F22;
  --graphite: #7C6A55;
  --rule: #DDCFB2;
  --blue: #2F4A6D;
  --fold: #E4D7BB;
}
[data-theme="night"] {
  --paper: #141414;
  --ink: #CFCAC0;
  --graphite: #8A857C;
  --rule: #2C2C2C;
  --blue: #8FA6C4;
  --fold: #222222;
}
:root {
  --serif: "RIDIBatang", "KoPubWorld Batang", "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", "AppleMyungjo", serif;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --latin-serif: "Source Serif 4", Georgia, serif;
  --measure: 40rem;
  color-scheme: light;
}
[data-theme="night"] { color-scheme: dark; }

/* ---------------------------------------------------------- 기본 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--blue); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.35; margin: 0 0 .5em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.quiet { color: var(--graphite); }
.small { font-size: 13px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------- 로고 */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo svg { width: 22px; height: 28px; flex: none; }
.logo .wordmark { font-family: var(--latin-serif); font-size: 21px; letter-spacing: -.01em; line-height: 1; }
.logo .wordmark span { color: var(--graphite); }

/* ---------------------------------------------------------- 사이트 틀 */
.site-header,
.site-main,
.site-footer {
  width: 100%;
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: 22px;
}
.site-nav { display: flex; gap: 18px; font-size: 14px; flex-wrap: wrap; justify-content: flex-end; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; }
.site-main { padding-bottom: 72px; min-height: 60vh; }
.site-footer {
  border-top: 1px solid var(--rule);
  padding-top: 20px; padding-bottom: max(28px, env(safe-area-inset-bottom));
  font-size: 13px; color: var(--graphite);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-footer a { color: var(--graphite); }

.flash { list-style: none; margin: 0 0 24px; padding: 0; }
.flash li { border-left: 2px solid var(--ink); padding: 6px 12px; margin-bottom: 6px; }

/* ---------------------------------------------------------- 버튼, 폼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 20px;
  border: 1.5px solid var(--ink); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-quiet { border-color: var(--rule); font-weight: 500; }
.btn-quiet:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn-small { min-height: 32px; padding: 0 14px; font-size: 13px; }
.btn-danger { border-color: #9C3A2E; color: #9C3A2E; }
.btn-danger:hover { background: #9C3A2E; color: var(--paper); }
.linkish {
  background: none; border: 0; padding: 0; color: var(--blue); font: inherit;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 20px; }

.field { margin-bottom: 22px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { display: block; color: var(--graphite); font-size: 13px; margin-top: 6px; }
input[type="text"], input[type="email"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: transparent; color: var(--ink);
  font: 15px/1.5 var(--sans);
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; }
textarea { resize: vertical; }
textarea.manuscript {
  min-height: 60vh;
  font: 17px/1.9 var(--serif);
  padding: 20px;
}
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices label {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.choices input { accent-color: var(--ink); }
.choices label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 5px; accent-color: var(--ink); }

/* ---------------------------------------------------------- 종이 한 장 (접힌 모서리) */
.sheet {
  position: relative;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 44px 36px 36px;
  clip-path: polygon(0 0, calc(100% - 44px) 0, 100% 44px, 100% 100%, 0 100%);
}
.sheet::after {
  content: "";
  position: absolute; top: -1.5px; right: -1.5px;
  width: 44px; height: 44px;
  background: linear-gradient(to bottom left,
    transparent calc(50% - 1px), var(--ink) calc(50% - 1px),
    var(--ink) calc(50% + .75px), var(--fold) calc(50% + .75px));
  border-left: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}

/* ---------------------------------------------------------- 홈 */
.hero { margin: 24px 0 56px; }
.hero h1 {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  line-height: 1.18;
  letter-spacing: -.02em;
  margin-bottom: 24px;
}
.hero p { font-size: 17px; max-width: 30em; }
.hero .turn { display: inline-block; color: var(--graphite); font-family: var(--serif); font-weight: 400; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 56px; display: grid; gap: 0; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 2.2em 1fr; gap: 4px;
  padding: 14px 0; border-top: 1px solid var(--rule);
}
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps li::before { content: counter(step); font-family: var(--latin-serif); color: var(--graphite); }
.section-title { font-size: 1.1rem; margin: 0 0 12px; }

.shelf { list-style: none; padding: 0; margin: 0 0 48px; }
.shelf li { border-top: 1px solid var(--rule); }
.shelf li:last-child { border-bottom: 1px solid var(--rule); }
.shelf a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; align-items: baseline;
  padding: 14px 0; color: var(--ink); text-decoration: none;
}
.shelf a:hover .shelf-title { text-decoration: underline; }
.shelf-title { font-family: var(--serif); font-weight: 700; }
.shelf-sub { grid-column: 1; color: var(--graphite); font-size: 13px; }
.shelf-meta { grid-row: 1 / span 2; grid-column: 2; color: var(--graphite); font-size: 13px; text-align: right; }
.meter { display: block; height: 2px; background: var(--rule); margin-top: 6px; width: 64px; margin-left: auto; }
.meter i { display: block; height: 100%; background: var(--ink); }

/* ---------------------------------------------------------- 작품 표지 */
.cover-head { display: grid; grid-template-columns: 148px 1fr; gap: 28px; align-items: start; margin: 8px 0 32px; }
.cover-art {
  aspect-ratio: 3 / 4; width: 100%;
  border: 1px solid var(--rule); background: var(--paper); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.cover-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-art.blank {
  border-color: var(--ink);
  padding: 16px; text-align: center;
  font: 700 16px/1.4 var(--serif);
}
.cover-meta h1 { margin-bottom: 8px; }
.cover-meta .byline { color: var(--graphite); margin-bottom: 14px; }
.cover-meta .byline a { color: var(--ink); }
.description { white-space: pre-line; font-family: var(--serif); font-size: 16px; line-height: 1.85; }
.notice { font-size: 13px; color: var(--graphite); border-left: 2px solid var(--rule); padding-left: 10px; margin-top: 16px; }

.toc { list-style: none; margin: 0; padding: 0; }
.toc li { border-top: 1px solid var(--rule); }
.toc li:last-child { border-bottom: 1px solid var(--rule); }
.toc a {
  display: flex; gap: 14px; align-items: baseline;
  padding: 13px 0; color: var(--ink); text-decoration: none;
}
.toc a:hover .toc-title { text-decoration: underline; }
.toc .num { width: 2.6em; flex: none; color: var(--graphite); font-family: var(--latin-serif); }
.toc .toc-title { flex: 1; font-family: var(--serif); }
.tag {
  display: inline-block; font-size: 12px; line-height: 1;
  border: 1px solid var(--rule); border-radius: 999px; padding: 4px 8px; color: var(--graphite);
  white-space: nowrap;
}
.tag-strong { border-color: var(--ink); color: var(--ink); }

@media (max-width: 560px) {
  .cover-head { grid-template-columns: 104px 1fr; gap: 18px; }
  .cover-meta h1 { font-size: 1.45rem; }
  .sheet { padding: 40px 22px 26px; }
}

/* ---------------------------------------------------------- 로그인 게이트, 로그인 */
.gate { max-width: 26rem; margin: 6vh auto 0; text-align: center; }
.gate .context { color: var(--graphite); font-size: 13px; margin-bottom: 28px; }
.gate h1 { font-size: 1.5rem; }
.login-options { display: grid; gap: 10px; margin-top: 24px; text-align: left; }
.login-options .btn { width: 100%; }
.login-options form { display: grid; gap: 10px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--graphite); font-size: 13px; margin: 8px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.devlink { word-break: break-all; font-size: 13px; border: 1px dashed var(--rule); padding: 12px; margin-top: 20px; }

/* ---------------------------------------------------------- 스튜디오 */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 8px 0 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.crumbs { font-size: 13px; color: var(--graphite); margin-bottom: 6px; }
.crumbs a { color: var(--graphite); }
.rows { list-style: none; padding: 0; margin: 0 0 32px; }
.rows > li {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px 0; border-top: 1px solid var(--rule);
}
.rows > li:last-child { border-bottom: 1px solid var(--rule); }
.rows .grow { flex: 1; min-width: 12rem; }
.rows .row-title { font-family: var(--serif); font-weight: 700; color: var(--ink); text-decoration: none; }
.rows .row-title:hover { text-decoration: underline; }
.rows form { display: inline; margin: 0; }
.mini { display: inline-flex; gap: 4px; }
.mini button {
  width: 30px; height: 30px; border: 1px solid var(--rule); border-radius: 6px;
  background: transparent; color: var(--ink); cursor: pointer; font-size: 13px;
}
.mini button:hover { border-color: var(--ink); }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.panel-box { border-top: 1px solid var(--ink); padding-top: 20px; margin-top: 40px; }
.cuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; list-style: none; padding: 0; margin: 16px 0; }
.cuts li { border: 1px solid var(--rule); padding: 8px; font-size: 12px; color: var(--graphite); }
.cuts img { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; object-position: top; background: var(--fold); margin-bottom: 6px; }
.cuts .mini { margin-top: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sticky-actions {
  position: sticky; bottom: 0; background: var(--paper);
  border-top: 1px solid var(--rule); padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 10px; flex-wrap: wrap; z-index: 2;
}
.copyline { display: flex; gap: 8px; align-items: center; }
.copyline input { flex: 1; font-size: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); }
table.data th { font-weight: 600; color: var(--graphite); }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; }
.qr { width: 132px; height: 132px; image-rendering: pixelated; border: 1px solid var(--rule); }
[data-theme="night"] .qr { filter: invert(.88); }

/* ---------------------------------------------------------- 토스트 */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 6px; font: 14px/1.4 var(--sans);
  opacity: 0; pointer-events: none; transition: opacity 120ms;
  z-index: 40; max-width: calc(100vw - 48px); text-align: center;
}
.toast.show { opacity: 1; }

/* ======================================================================
   리더 — 본문만. 가운데를 누르면 메뉴. (기획서 6장)
   ====================================================================== */
body.reading { overflow: hidden; overscroll-behavior: none; height: 100%; }
html:has(body.reading) { height: 100%; overflow: hidden; }

#viewport {
  position: fixed; inset: 0;
  background: var(--paper);
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
}
@media (hover: hover) and (pointer: fine) {
  /* 데스크톱에서는 문장 복사를 막지 않는다 */
  #viewport { -webkit-user-select: text; user-select: text; }
}
#frame { position: absolute; left: 50%; transform: translateX(-50%); overflow: hidden; }
#content {
  --fs: 18px; --lh: 1.8; --page-h: 600px;
  font-family: var(--serif);
  font-size: var(--fs);
  line-height: var(--lh);
  color: var(--ink);
  text-align: justify;
  text-justify: inter-character;
  word-break: normal; /* 전자책처럼 음절 단위로 줄을 나눠 양쪽 정렬 빈칸을 줄인다 */
  line-break: strict;
  overflow-wrap: break-word;
  hyphens: auto;
  orphans: 2; widows: 2;
  column-fill: auto;
  will-change: transform;
}
#content[data-font="sans"] { font-family: var(--sans); }
#content > * { margin: 0 0 .85em; }
#content h1, #content h2, #content h3 { text-align: left; break-after: avoid; margin: 1.2em 0 .7em; }
#content h1:first-child, #content h2:first-child { margin-top: 0; }
#content blockquote { margin-left: 0; padding-left: 1em; border-left: 1px solid var(--rule); color: var(--graphite); }
#content hr { margin: 1.5em auto; width: 3em; }
#content a { color: var(--blue); }

/* 시: 행갈이와 들여쓰기를 원문 그대로, 한 편이 한 화면에서 시작 */
.poem { text-align: left; }
.poem + .poem { break-before: column; }
.poem h2 { font-size: 1.15em; margin: 0 0 1.4em !important; }
.poem-body { white-space: pre-wrap; text-align: left; }

/* 웹툰 */
.cut { margin: 0 !important; }
.mode-columns .cut {
  height: var(--page-h);
  display: flex; align-items: center; justify-content: center;
  break-inside: avoid;
}
.mode-columns .cut + .cut { break-before: column; }
.mode-columns .cut img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }

/* 마지막 쪽: 다음 회차 카드 한 장 */
.end-card {
  break-before: column;
  height: var(--page-h);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
  text-align: center; font-family: var(--sans); font-size: 15px; line-height: 1.6;
  margin: 0 !important;
}
.end-card .end-mark { font-family: var(--serif); font-size: 1.3em; }
.end-card .next-title { font-family: var(--serif); font-weight: 700; font-size: 1.15em; }
.end-card .btn { margin-top: 6px; }

#page-no {
  position: absolute; left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  text-align: center; font: 12px/1 var(--sans); color: var(--graphite);
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* 웹툰 세로 스크롤 */
#viewport.mode-scroll {
  overflow-y: auto; overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.mode-scroll #frame { position: static; transform: none; width: 100%; overflow: visible; }
.mode-scroll #content { text-align: center; will-change: auto; }
.mode-scroll .cut img { display: block; width: 100%; max-width: 720px; height: auto; margin: 0 auto; }
.mode-scroll .end-card { height: auto; min-height: 60vh; padding: 48px 24px calc(48px + env(safe-area-inset-bottom)); }

/* 메뉴 오버레이 */
.menu {
  position: fixed; left: 0; right: 0; z-index: 10;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans);
}
.menu[hidden], .panel[hidden] { display: none; }
.menu-top {
  top: 0;
  border-bottom: 1px solid var(--rule);
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px;
}
.menu-title { text-align: center; line-height: 1.3; min-width: 0; }
.menu-title b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-title span { font-size: 12px; color: var(--graphite); }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer; text-decoration: none;
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.menu-bottom {
  bottom: 0;
  border-top: 1px solid var(--rule);
  padding: 14px 20px max(12px, env(safe-area-inset-bottom));
}
.progress-row { display: flex; align-items: center; gap: 12px; max-width: 36rem; margin: 0 auto; }
.progress-label { font-size: 12px; color: var(--graphite); min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.menu-actions { display: flex; justify-content: space-around; max-width: 28rem; margin: 10px auto 0; }
.menu-actions button {
  background: none; border: 0; color: var(--ink); font: 14px/1 var(--sans);
  min-width: 64px; min-height: 40px; cursor: pointer; border-radius: 8px;
}
.menu-actions button[aria-expanded="true"] { text-decoration: underline; text-underline-offset: 4px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 24px; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); margin-top: -7px; border: 0;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 0; }

.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 72vh; overflow-y: auto;
  background: var(--paper); color: var(--ink);
  border-top: 1.5px solid var(--ink);
  padding: 18px 20px max(20px, env(safe-area-inset-bottom));
  font-family: var(--sans);
}
.panel-inner { max-width: 30rem; margin: 0 auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h2 { font-family: var(--sans); font-size: 15px; margin: 0; }
.setting { display: grid; grid-template-columns: 5.5em 1fr; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.setting .label { font-size: 14px; color: var(--graphite); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: 999px;
  background: transparent; color: var(--ink); font: 14px/1 var(--sans); cursor: pointer;
}
.seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.seg .size-label { align-self: center; padding: 0 8px; font-size: 13px; color: var(--graphite); font-variant-numeric: tabular-nums; }
.panel .toc a { padding: 11px 0; }
.panel .toc a[aria-current="page"] .toc-title { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* 로그인 코드 입력 */
.code-input {
  text-align: center;
  font: 600 26px/1.2 var(--latin-serif) !important;
  letter-spacing: .35em;
  padding: 12px !important;
}
