* { box-sizing: border-box; }
body { margin: 0; background: #f4f6fc; color: #16224a; font-family: Inter, sans-serif; }
.masthead { background: #fff; border-bottom: 1px solid #e1e7f5; }
.masthead__inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.masthead__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #16224a; }
.masthead__sigil { font-size: 22px; color: #4a6fff; }
.masthead__title { font-weight: 800; }
.masthead__tagline { font-size: 12px; color: #6a3cff; }
.back-link { color: #4a6fff; text-decoration: none; font: 600 14px Inter, sans-serif; }

.bf { max-width: 1000px; margin: 0 auto; padding: 24px 20px 90px; }
.bf__hero { text-align: center; padding: 12px 0 18px; }
.bf__h1 { font: 800 28px/1.15 Inter, sans-serif; margin: 0 0 10px; }
.bf__sub { font: 400 15px/1.55 Inter, sans-serif; color: #5b6786; max-width: 720px; margin: 0 auto; }

.step { background: #fff; border: 1px solid #e1e7f5; border-radius: 16px; margin: 16px 0; overflow: hidden; }
.step__h { display: flex; align-items: center; gap: 12px; padding: 14px 18px; font: 700 16px Inter, sans-serif; border-bottom: 1px solid #eef2fb; }
.step__n { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: linear-gradient(135deg,#4a6fff,#6a3cff); color: #fff; font: 700 13px Inter; }
.step__b { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px){ .row2 { grid-template-columns: 1fr; } }
.f { display: flex; flex-direction: column; gap: 5px; font: 600 12px Inter, sans-serif; color: #5b6786; }
.f input, .f select, .f textarea, .mono { padding: 10px 12px; font: 500 14px Inter, sans-serif; color: #16224a; border: 1.5px solid #d3dcf0; border-radius: 9px; outline: none; width: 100%; }
.f textarea { min-height: 90px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .mono:focus { border-color: #4a6fff; }
.mono { font-family: JetBrains Mono, monospace; font-size: 13px; line-height: 1.5; min-height: 160px; resize: vertical; }

.btn { align-self: flex-start; padding: 11px 20px; font: 700 14px Inter, sans-serif; color: #fff; background: linear-gradient(135deg,#4a6fff,#6a3cff); border: 0; border-radius: 10px; cursor: pointer; }
.btn.secondary { background: #eef2fb; color: #4a6fff; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.mini { padding: 6px 12px; font: 600 12px Inter, sans-serif; margin-left: auto; }
.btn.mini.secondary { margin-left: 8px; }
.mini { padding: 4px 10px; font: 600 12px Inter, sans-serif; color: #4a6fff; background: #eef2fb; border: 0; border-radius: 7px; cursor: pointer; }
.empty { color: #a6abc8; font-size: 13px; }

.codex { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px){ .codex { grid-template-columns: 1fr; } }
.codex__h { display: flex; align-items: center; gap: 8px; font: 700 13px Inter, sans-serif; margin-bottom: 8px; }
.card { border: 1px solid #e6ebf7; border-radius: 10px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; background: #fafbff; }
.card__name { font: 600 13px JetBrains Mono, monospace; padding: 7px 9px; border: 1.5px solid #d3dcf0; border-radius: 7px; outline: none; }
.card__role { font: 500 12px Inter; padding: 6px 9px; border: 1.5px solid #e6ebf7; border-radius: 7px; outline: none; color: #5b6786; }
.card__facts { font: 500 12px JetBrains Mono, monospace; min-height: 48px; padding: 7px 9px; border: 1.5px solid #e6ebf7; border-radius: 7px; outline: none; resize: vertical; }

.ol { border-left: 3px solid #4a6fff; padding: 8px 12px; margin-bottom: 8px; background: #fafbff; border-radius: 0 8px 8px 0; }
.ol__t { font: 600 14px Inter, sans-serif; }
.ol__beat { font: 400 13px Inter, sans-serif; color: #5b6786; margin: 4px 0; }
.tag { display: inline-block; font: 600 11px JetBrains Mono, monospace; background: #eef2fb; color: #4a6fff; padding: 2px 8px; border-radius: 12px; margin: 2px 4px 2px 0; }

.ch { border: 1px solid #e6ebf7; border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.ch__head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: #fafbff; border-bottom: 1px solid #eef2fb; font: 600 14px Inter, sans-serif; }
.ch__inj { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; }
.pill { font: 600 11px Inter, sans-serif; padding: 3px 9px; border-radius: 12px; background: #eef2fb; color: #4a6fff; }
.pill--canon { background: #e4f7ef; color: #1f8f63; }
.pill--muted { background: #f0f2f8; color: #8a96b4; }
.pill--warn { background: #fdeae5; color: #c0432f; }
.ch__text { padding: 4px 16px 16px; font: 400 14.5px/1.7 Georgia, serif; color: #1e2438; white-space: pre-wrap; }

.status { position: sticky; bottom: 0; margin-top: 16px; padding: 12px 16px; background: #16224a; color: #fff; border-radius: 12px; font: 500 14px JetBrains Mono, monospace; min-height: 20px; }
.status a { color: #8fb3ff; }

/* иллюстрации + публикация */
.f--row { flex-direction: row; align-items: center; gap: 8px; font: 500 13px Inter, sans-serif; color: #16224a; }
.hint { font: 400 12px Inter, sans-serif; color: #8a96b4; margin-top: 8px; }
.art-style { font: 500 13px Inter, sans-serif; color: #2a3a66; background: #f6f3fe; border-radius: 10px; padding: 12px 14px; }
.art-style.empty { color: #a6abc8; background: #fafbff; }
.art-style .vis { margin-top: 6px; font: 500 12px JetBrains Mono, monospace; color: #5b6786; }
.ch__media { padding: 0 14px; }
.ch__media .hero { width: 100%; border-radius: 10px; margin: 4px 0 8px; display: block; }
.pages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 0 10px; }
@media (max-width: 600px){ .pages { grid-template-columns: 1fr; } }
.pg { margin: 0; border: 1px solid #e6ebf7; border-radius: 10px; overflow: hidden; background: #fafbff; }
.pg img { width: 100%; display: block; }
.pg figcaption { padding: 8px 10px; font: 500 13px Georgia, serif; color: #1e2438; }
.pub.empty { color: #a6abc8; font: 400 13px Inter, sans-serif; }
.pub .dl { display: inline-block; margin: 4px 10px 4px 0; padding: 10px 18px; background: linear-gradient(135deg,#4a6fff,#6a3cff); color: #fff; border-radius: 10px; text-decoration: none; font: 700 14px Inter, sans-serif; }
.pub .err { color: #c0432f; font: 500 12px JetBrains Mono, monospace; margin-top: 6px; }

/* ── Библиотека книг ── */
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.library .empty { color: #a6abc8; font: 400 13px Inter, sans-serif; grid-column: 1/-1; }
.libcard { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid #e3e6f5; border-radius: 12px; background: #fff; transition: border-color .12s, transform .12s; }
.libcard:hover { border-color: #6a3cff; transform: translateY(-1px); }
.libcard__open { display: flex; gap: 10px; align-items: center; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.libcard__act { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.libbtn { font: 600 12px Inter, sans-serif; padding: 5px 10px; border-radius: 8px; border: 1px solid #d7dbf0; background: #f6f7fc; color: #3a3f5c; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.libbtn:hover { background: #eef0fb; border-color: #6a3cff; color: #4a2cd0; }
.libbtn--del:hover { background: #fdecec; border-color: #e25555; color: #c0392b; }
.libcard__cov { width: 48px; height: 66px; flex: 0 0 48px; border-radius: 6px; overflow: hidden; background: #f0f1fa; display: flex; align-items: center; justify-content: center; }
.libcard__cov img { width: 100%; height: 100%; object-fit: cover; }
.libcard__cov span { font: 600 9px Inter, sans-serif; color: #b4b8d0; text-align: center; line-height: 1.2; }
.libcard__t { font: 700 14px Inter, sans-serif; color: #1b1d2c; }
.libcard__s { font: 500 12px Inter, sans-serif; color: #8a90ab; margin-top: 2px; }

/* ── Обложка ── */
.cover-box { margin-bottom: 12px; }
.cover-box:empty { display: none; }
.cover-img { display: block; width: 240px; max-width: 100%; border-radius: 12px; box-shadow: 0 8px 28px rgba(40,30,90,.18); }
.cover-cap { font: 600 12px Inter, sans-serif; color: #8a90ab; margin-top: 6px; }
.tabs { display: flex; gap: 8px; margin: 0 0 18px; }
.tab { padding: 9px 18px; border: 1.5px solid #d3dcf0; background: #fff; color: #5b6786; border-radius: 10px; font: 700 14px Inter, sans-serif; cursor: pointer; }
.tab.is-on { background: #5a4fc0; border-color: #5a4fc0; color: #fff; }
.cover-fonts { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 12px; max-width: 420px; }
.cover-fonts .f { flex: 1 1 200px; }
.cover-fonts .hint { flex: 1 1 100%; margin-top: 2px; }
