/* ==========================================================================
   메이플 레코드 - 스토리 아카이브 (/Util/3/archive.css)
   심플하고 직관적인 정사 챕터 리딩 UI
   ========================================================================== */

:root {
  --st-bg: #131722;
  --st-surface: #181d2a;
  --st-surface-hover: #1d2434;
  --st-border: #252f42;
  --st-border-strong: #374662;
  --st-text: #f1f5f9;
  --st-sub: #94a3b8;
  --st-dim: #64748b;
  --st-accent: #ff7b54;
  --st-sky: #38bdf8;
  --st-emerald: #34d399;
  --st-purple: #c084fc;
  --st-amber: #fbbf24;
  --st-pink: #f472b6;
}

.story-shell {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 72px;
  box-sizing: border-box;
}

.story-icon {
  width: 16px;
  height: 16px;
  color: var(--st-dim);
  flex-shrink: 0;
}

/* 1. 상단 헤더 & 툴바 */
.story-header {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: 16px;
  padding: 22px 24px 16px;
  margin-bottom: 14px;
}

.story-header-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.story-eyebrow {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.9px;
  color: var(--st-sky);
  margin-bottom: 6px;
}

.story-title {
  margin: 0 0 6px;
  font-size: 1.48rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.4px;
}

.story-desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--st-sub);
  word-break: keep-all;
}
.story-desc strong { color: #e2e8f0; font-weight: 700; }

.story-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  background: var(--st-bg);
  border: 1px solid var(--st-border);
  border-radius: 10px;
  padding: 7px 12px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.story-search-wrap:focus-within {
  border-color: var(--st-accent);
}

.story-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.86rem;
  outline: none;
}
.story-search-input::placeholder { color: var(--st-dim); }

.story-clear-btn {
  background: #263147;
  border: none;
  color: #cbd5e1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.story-clear-btn:hover { background: #3a4a69; color: #ffffff; }

.story-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid #20293a;
}

.story-mode-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--st-sub);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-tab:hover { color: #ffffff; background: rgba(255, 255, 255, 0.04); }
.mode-tab.active {
  background: rgba(255, 123, 84, 0.15);
  color: #ff9a76;
  border-color: rgba(255, 123, 84, 0.36);
}

.tab-badge {
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  padding: 1px 7px;
  border-radius: 999px;
}
.mode-tab.active .tab-badge {
  background: rgba(255, 123, 84, 0.25);
  color: #ffd0bf;
}

.story-sync-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--st-emerald);
  flex-shrink: 0;
}
.sync-dot.is-syncing { background: var(--st-amber); }

.sync-label {
  font-size: 0.76rem;
  color: var(--st-sub);
}

.btn-sync {
  background: var(--st-bg);
  border: 1px solid var(--st-border);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-sync:hover:not(:disabled) { border-color: var(--st-sky); color: #ffffff; }
.btn-sync:disabled { opacity: 0.5; cursor: not-allowed; }

/* 2. 컨텍스트 1줄 서브 필터 바 */
.story-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.sub-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.sub-pill {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  color: var(--st-sub);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sub-pill:hover { color: #ffffff; border-color: var(--st-border-strong); }
.sub-pill.active {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.sub-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-order-toggle {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  color: #cbd5e1;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-order-toggle:hover { border-color: var(--st-border-strong); color: #ffffff; }

/* 3. 상태 박스 */
.story-state-box {
  background: var(--st-surface);
  border: 1px dashed var(--st-border);
  border-radius: 14px;
  padding: 54px 20px;
  text-align: center;
  color: var(--st-sub);
  font-size: 0.88rem;
}

.story-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.18);
  border-top-color: var(--st-accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: stSpin 0.8s linear infinite;
}
@keyframes stSpin { to { transform: rotate(360deg); } }

/* 4. 파트별 정사 챕터 리스트 */
.story-content-area {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.part-block {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: 16px;
  padding: 20px 22px;
}

.part-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid #20293a;
}

.part-head-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.part-code {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ff9a76;
  background: rgba(255, 123, 84, 0.14);
  border: 1px solid rgba(255, 123, 84, 0.3);
  padding: 2px 9px;
  border-radius: 6px;
}

.part-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
  color: #ffffff;
}

.part-sub {
  font-size: 0.78rem;
  color: var(--st-dim);
}

/* 심플 세로 서사 레일 */
.chapter-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--st-bg);
  border: 1px solid #202838;
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.chapter-item:hover {
  border-color: var(--st-border-strong);
  background: var(--st-surface-hover);
  transform: translateX(2px);
}

.chapter-num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.24);
  color: #7dd3fc;
  font-size: 0.82rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chapter-item.is-event .chapter-num {
  background: rgba(244, 114, 182, 0.12);
  border-color: rgba(244, 114, 182, 0.3);
  color: #f472b6;
}

.chapter-item.is-job .chapter-num {
  background: rgba(192, 132, 252, 0.12);
  border-color: rgba(192, 132, 252, 0.3);
  color: #d8b4fe;
}

.chapter-main {
  min-width: 0;
}

.chapter-top-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.ch-tag {
  font-size: 0.69rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}

.ch-tag.tone-library { background: rgba(45, 212, 191, 0.14); color: #5eead4; }
.ch-tag.tone-chronicle { background: rgba(192, 132, 252, 0.14); color: #d8b4fe; }
.ch-tag.tone-world { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.ch-tag.tone-job { background: rgba(236, 72, 153, 0.14); color: #f9a8d4; }
.ch-tag.tone-event { background: rgba(251, 146, 60, 0.16); color: #fdba74; }
.ch-tag.tone-api { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }

.ch-meta-inline {
  font-size: 0.73rem;
  color: var(--st-dim);
  font-weight: 600;
}

.chapter-title {
  margin: 0 0 3px;
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.chapter-summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--st-sub);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
}

.chapter-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  text-align: right;
}

.ch-region {
  font-size: 0.74rem;
  font-weight: 700;
  color: #cbd5e1;
}

.ch-level {
  font-size: 0.71rem;
  color: var(--st-dim);
}

.ch-arrow {
  font-size: 0.85rem;
  color: var(--st-dim);
  margin-top: 2px;
}
.chapter-item:hover .ch-arrow { color: var(--st-accent); }

/* 5. 스토리 상세 읽기 모달 */
.story-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.78);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.story-modal {
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  background: #151a25;
  border: 1px solid #2e3b54;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.story-modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid #232e42;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.modal-title {
  margin: 0 0 4px;
  font-size: 1.14rem;
  font-weight: 900;
  color: #ffffff;
}

.modal-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--st-sub);
}

.modal-close {
  background: #1f2738;
  border: 1px solid #32405a;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover { background: #2c3850; color: #ffffff; }

.story-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-info-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.modal-info-cell {
  background: var(--st-bg);
  border: 1px solid #222d40;
  border-radius: 10px;
  padding: 9px 12px;
}
.modal-info-cell span { display: block; font-size: 0.7rem; color: var(--st-dim); margin-bottom: 2px; }
.modal-info-cell strong { font-size: 0.84rem; color: #ffffff; font-weight: 800; }

.modal-card {
  background: var(--st-bg);
  border: 1px solid #222d40;
  border-radius: 11px;
  padding: 14px 16px;
}
.modal-card h4 { margin: 0 0 8px; font-size: 0.84rem; color: var(--st-sky); font-weight: 800; }
.modal-card p { margin: 0; font-size: 0.86rem; color: #e2e8f0; line-height: 1.68; word-break: keep-all; }
.modal-card ul { margin: 0; padding-left: 18px; font-size: 0.84rem; color: #cbd5e1; line-height: 1.7; }

.modal-char-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.modal-char-chip {
  font-size: 0.74rem;
  font-weight: 700;
  color: #cbd5e1;
  background: #192132;
  border: 1px solid #2a3750;
  padding: 3px 9px;
  border-radius: 6px;
}

.story-modal-foot {
  padding: 12px 20px;
  border-top: 1px solid #232e42;
  background: #10141d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-pager { display: flex; gap: 8px; }

.btn-pager {
  background: #1c2436;
  border: 1px solid #303e59;
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-pager:hover:not(:disabled) { border-color: var(--st-sky); color: #ffffff; }
.btn-pager:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ext {
  background: var(--st-accent);
  color: #ffffff;
  text-decoration: none;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}
.btn-ext:hover { filter: brightness(1.08); }

/* 반응형 */
@media (max-width: 720px) {
  .story-shell { padding: 14px 12px 48px; }
  .story-header { padding: 16px; }
  .story-search-wrap { max-width: none; }
  .part-block { padding: 14px; }
  .chapter-item { grid-template-columns: 36px 1fr; gap: 10px; padding: 12px; }
  .chapter-right { display: none; }
  .modal-info-row { grid-template-columns: 1fr; }
}