/* Daybreak FrontLine — 연재 사이트
   밤하늘 남색과 오지 않는 새벽의 주황 한 줄. 나머지는 조용하게. */

:root {
  --night: #0e1a2e;
  --night-2: #16253f;
  --night-text: #e9eef8;
  --night-sub: #9aa8c2;
  --dawn: #f28c28;
  --dawn-deep: #d9701a;
  --dawn-soft: rgba(242, 140, 40, .14);

  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #18202e;
  --sub: #48526a;
  --muted: #7b8496;
  --line: #e4e7ec;
  --hover: #eff2f6;
  --danger: #d6453d;
  --ok: #1f8f5f;

  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;

  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --serif: 'Noto Serif KR', 'Nanum Myeongjo', 'Apple Myungjo', serif;

  --reader-size: 18px;
  --reader-lh: 1.9;
  --reader-font: var(--sans);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1322;
  --surface: #111c2f;
  --text: #e6ebf3;
  --sub: #b2bccd;
  --muted: #8892a6;
  --line: #1f2c43;
  --hover: #172438;
  --dawn-soft: rgba(242, 140, 40, .16);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b1322;
    --surface: #111c2f;
    --text: #e6ebf3;
    --sub: #b2bccd;
    --muted: #8892a6;
    --line: #1f2c43;
    --hover: #172438;
    --dawn-soft: rgba(242, 140, 40, .16);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--dawn); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--night); border-color: var(--night); color: #fff; }
.btn.primary:hover { background: var(--night-2); }
:root[data-theme="dark"] .btn.primary { background: var(--dawn); border-color: var(--dawn); color: var(--night); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn.primary { background: var(--dawn); border-color: var(--dawn); color: var(--night); } }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--sub); font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer; }
.link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 상단 ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1080px; margin: 0 auto; padding: 18px 24px;
}
.brand { font-weight: 800; letter-spacing: -.02em; text-decoration: none; font-size: 17px; }
.site-nav a { text-decoration: none; color: var(--sub); font-size: 15px; font-weight: 500; }
.site-nav a:hover { color: var(--text); }
.site-header.on-night .brand { color: var(--night-text); }
.site-header.on-night .site-nav a { color: var(--night-sub); }
.site-header.on-night .site-nav a:hover { color: #fff; }

/* ---------- 밤하늘 (작품 머리) ---------- */
.night-top { background: var(--night); color: var(--night-text); }
.sky { position: relative; overflow: hidden; min-height: min(78vh, 640px); display: flex; align-items: flex-end; }
.sky-stars { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-inner { position: relative; z-index: 1; max-width: 1080px; width: 100%; margin: 0 auto; padding: 48px 24px 96px; }
.work-status { margin: 0 0 14px; color: var(--night-sub); font-size: 14px; font-weight: 600; }
.work-title {
  margin: 0; font-size: clamp(44px, 9vw, 112px); line-height: .95; font-weight: 800;
  letter-spacing: -.045em; max-width: 11ch;
}
.work-sub { margin: 18px 0 0; color: var(--night-sub); font-size: 17px; font-weight: 500; }
.work-logline { margin: 22px 0 0; max-width: 34em; font-size: 18px; line-height: 1.7; color: #d6deec; }
.sky-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.sky .btn.primary { background: var(--dawn); border-color: var(--dawn); color: var(--night); }
.sky .btn.primary:hover { background: #ff9b3a; }
.sky .btn.ghost { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.16); color: var(--night-text); }
.sky .btn.ghost:hover { background: rgba(255,255,255,.12); }

/* 오지 않는 새벽: 수평선 위 주황 한 줄 */
.horizon {
  position: absolute; left: 0; right: 0; bottom: 34px; height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(242,140,40,.15) 12%, var(--dawn) 55%, #ffb36b 72%, rgba(242,140,40,.2) 92%, transparent 100%);
  box-shadow: 0 0 18px 2px rgba(242,140,40,.35), 0 0 60px 8px rgba(242,140,40,.12);
}
.horizon::after {
  content: ''; position: absolute; left: 0; right: 0; top: 2px; height: 34px;
  background: linear-gradient(180deg, rgba(5,10,20,.0), rgba(5,10,20,.55));
}
@media (prefers-reduced-motion: no-preference) {
  .horizon { animation: horizon-in 1.6s cubic-bezier(.2,.7,.2,1) both; transform-origin: 62% 50%; }
  @keyframes horizon-in { from { transform: scaleX(.05); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
}

/* ---------- 본문 페이지 ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }
.page.narrow { max-width: 520px; }
.block + .block { margin-top: 56px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.block h2 { margin: 0 0 14px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.block-head h2 { margin: 0; }
.count { color: var(--muted); font-weight: 600; margin-left: 4px; }
.synopsis p { margin: 0 0 1em; color: var(--sub); font-size: 17px; line-height: 1.85; max-width: 36em; }

.ep-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ep-list li { border-bottom: 1px solid var(--line); }
.ep-row { display: flex; gap: 18px; align-items: center; padding: 16px 4px; text-decoration: none; border-radius: var(--radius-s); }
.ep-row:hover { background: var(--hover); }
.ep-no { width: 2.6em; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.ep-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ep-title { font-size: 17px; font-weight: 600; }
.ep-meta { display: flex; gap: 10px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ep-row.read .ep-title { color: var(--muted); font-weight: 500; }

.work-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.work-list a { display: grid; gap: 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); text-decoration: none; }
.work-list a:hover { background: var(--hover); }
.wl-title { font-weight: 700; font-size: 18px; }
.wl-meta { display: flex; gap: 10px; color: var(--muted); font-size: 13px; }
.wl-log { color: var(--sub); font-size: 15px; }

.empty { padding: 56px 0; text-align: center; }
.empty p { margin: 6px 0; }

.site-footer { max-width: 760px; margin: 0 auto; padding: 32px 24px 56px; color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }

/* ---------- 읽기 화면 ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 30; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--dawn); box-shadow: 0 0 10px rgba(242,140,40,.6); transition: width .08s linear; }

.reader-bar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: transform .25s, border-color .2s;
}
.reader-bar.scrolled { border-bottom-color: var(--line); }
.reader-bar.away { transform: translateY(-100%); }
.rb-back, .rb-settings { justify-self: start; background: none; border: 0; padding: 8px 10px; border-radius: 8px; font-size: 15px; font-weight: 600; color: var(--sub); text-decoration: none; cursor: pointer; }
.rb-settings { justify-self: end; }
.rb-back:hover, .rb-settings:hover { background: var(--hover); color: var(--text); }
.rb-title { display: flex; gap: 8px; align-items: baseline; min-width: 0; font-size: 14px; }
.rb-work { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.rb-ep { font-weight: 700; white-space: nowrap; }

.reader-panel {
  position: fixed; z-index: 25; top: 64px; right: 16px; width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: 0 18px 48px rgba(8, 15, 30, .18); padding: 8px 18px;
}
.rp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.rp-row + .rp-row { border-top: 1px solid var(--line); }
.rp-label { font-size: 14px; color: var(--sub); font-weight: 500; }
.seg, .choice { display: flex; align-items: center; gap: 4px; background: var(--hover); border-radius: 10px; padding: 3px; }
.seg button, .choice button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--sub); cursor: pointer; min-width: 36px; }
.seg button.big { font-size: 17px; }
.seg output { min-width: 34px; text-align: center; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.choice button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.reader { max-width: 680px; margin: 0 auto; padding: 40px 24px 96px; }
.chapter-head { margin: 24px 0 56px; }
.ch-no { margin: 0 0 10px; color: var(--dawn-deep); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .ch-no { color: var(--dawn); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .ch-no { color: var(--dawn); } }
.ch-title { margin: 0; font-size: clamp(28px, 5vw, 38px); line-height: 1.25; letter-spacing: -.03em; font-weight: 800; }
.ch-meta { margin: 14px 0 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.prose { font-family: var(--reader-font); font-size: var(--reader-size); line-height: var(--reader-lh); letter-spacing: -.003em; }
.prose p { margin: 0 0 1.05em; }
:root[data-font="serif"] { --reader-font: var(--serif); }
:root[data-font="serif"] .prose { letter-spacing: 0; }

/* 장면 전환: 짧은 새벽 선 */
.prose hr.scene { border: 0; height: 2px; width: 72px; margin: 3em auto; background: linear-gradient(90deg, transparent, var(--dawn), transparent); opacity: .85; }

/* 교신·기록 블록 */
.prose .comm {
  margin: 1.4em 0; padding: .9em 1.1em;
  border-left: 2px solid var(--dawn); background: var(--dawn-soft); border-radius: 0 var(--radius-s) var(--radius-s) 0;
  font-family: var(--sans); font-size: .92em; line-height: 1.75;
}
.prose .comm p { margin: 0 0 .35em; }
.prose .comm p:last-child { margin-bottom: 0; }

/* 위키 용어 링크: 읽기를 방해하지 않게 점선 밑줄만 */
.prose a.term { text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--dawn) 70%, transparent); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.prose a.term:hover { color: var(--dawn-deep); }
:root[data-terms="off"] .prose a.term { text-decoration: none; pointer-events: none; color: inherit; }

.author-note { margin-top: 64px; padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.author-note h2 { margin: 0 0 8px; font-size: 15px; color: var(--sub); }
.author-note p { margin: 0 0 .6em; color: var(--sub); line-height: 1.8; }

.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 64px; }
.cn { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); text-decoration: none; min-height: 84px; }
.cn:hover { background: var(--hover); }
.cn.next { text-align: right; }
.cn.next:not(.disabled) { background: var(--night); border-color: var(--night); color: #fff; }
.cn.next:not(.disabled):hover { background: var(--night-2); }
.cn.next:not(.disabled) .cn-label { color: var(--dawn); }
.cn-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.cn-title { font-weight: 700; font-size: 15px; }
.cn.disabled { opacity: .6; justify-content: center; }
.back-list { text-align: center; margin-top: 28px; }
.back-list a { color: var(--muted); font-size: 14px; }

/* ---------- 관리 화면 ---------- */
.admin { background: var(--bg); }
.admin-bar { display: flex; align-items: center; gap: 24px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.admin-bar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.admin-bar nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--sub); font-size: 14px; font-weight: 600; }
.admin-bar nav a:hover { background: var(--hover); }
.admin-bar nav a[aria-current="page"] { background: var(--hover); color: var(--text); }
.admin-bar form { margin: 0; }
.admin-main { max-width: 1040px; margin: 0 auto; padding: 32px 28px 80px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 12px; }
.head-sub { font-size: 15px; font-weight: 500; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flash { margin-bottom: 18px; padding: 12px 16px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); font-weight: 600; font-size: 14px; }
.error { padding: 12px 16px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); font-weight: 600; font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 22px 24px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.panel h2 { margin: 0; font-size: 19px; }
.panel-head p { margin: 4px 0 0; font-size: 13px; }
.sep { display: inline-block; width: 1px; height: 10px; background: var(--line); margin: 0 8px; vertical-align: middle; }
.pad { padding: 8px 0; margin: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td a { text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--hover); color: var(--sub); font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.on { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill.wait { background: var(--dawn-soft); color: var(--dawn-deep); }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--sub); }
.field small { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--dawn); box-shadow: 0 0 0 3px var(--dawn-soft); }
.field textarea { resize: vertical; line-height: 1.7; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-ep { display: grid; grid-template-columns: 120px 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; }
.inline-form { grid-template-columns: 1fr 1.4fr 1.4fr auto; align-items: end; margin: 18px 0 24px; }
.danger-zone { margin-top: 40px; padding: 18px 22px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: var(--radius-m); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.danger-zone p { margin: 0; }
.danger-text { color: var(--danger); }

.editor textarea#body { font-family: var(--sans); font-size: 16px; line-height: 1.9; min-height: 60vh; padding: 20px 22px; }
.editor-tabs { display: flex; align-items: center; gap: 4px; }
.editor-tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.editor-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.counter { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.hint { margin: 8px 2px 0; color: var(--muted); font-size: 13px; }
.hint code { background: var(--hover); padding: 1px 6px; border-radius: 5px; }
.reader-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 32px clamp(20px, 6vw, 64px); min-height: 60vh; }
.publish-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 16px; align-items: end; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }

.login-card { max-width: 380px; margin: 14vh auto; padding: 36px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.login-card form { margin-top: 24px; display: grid; gap: 16px; }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 720px) {
  .site-header { padding: 14px 18px; }
  .sky-inner { padding: 40px 18px 84px; }
  .sky { min-height: 72vh; }
  .work-logline { font-size: 16px; }
  .page { padding: 36px 18px 64px; }
  .reader { padding: 24px 20px 80px; }
  .chapter-head { margin-bottom: 40px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .rb-work { display: none; }
  .admin-bar { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
  .admin-main { padding: 24px 16px 64px; }
  .grid2, .grid3, .grid-ep, .publish-row, .inline-form { grid-template-columns: 1fr; }
  .panel-head, .admin-head, .danger-zone { flex-direction: column; align-items: stretch; }
  .table th:nth-child(4), .table td:nth-child(4), .table th:nth-child(6), .table td:nth-child(6) { display: none; }
}

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