/* ============================================================
   Octavo — estilos
   Base editorial: papel hueso, tinta casi negra, grises.
   Acento: azul tinta.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --paper:    #f4f1ea;
  --card:     #ffffff;
  --ink:      #1b1b19;
  --ink-soft: #565651;
  --muted:    #8d8d86;
  --line:     #e4dfd4;
  --line-2:   #efebe1;
  --accent:   #2f4b6e;
  --accent-d: #243a55;
  --accent-soft: #e9eff6;
  --danger:   #9a3b3b;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'EB Garamond', 'Times New Roman', Georgia, serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27,27,25,.05), 0 8px 24px rgba(27,27,25,.06);
  --maxw: 760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
  padding-bottom: 96px; /* room for action bar */
}

/* ---------- Header ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(244,241,234,.86);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.brand__mark {
  font-family: var(--serif); font-weight: 500; font-size: 26px; letter-spacing: .01em;
  line-height: 1; color: var(--ink);
}
.brand__tag {
  font-size: 11px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.langtoggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; background: var(--card); flex: none;
}
.langtoggle button {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: .06em;
  padding: 6px 11px; color: var(--muted);
}
.langtoggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 18px; }
.intro {
  margin: 4px 0 18px; color: var(--ink-soft); font-size: 14px;
}
.intro b { color: var(--ink); font-weight: 500; }

.section-label {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin: 26px 4px 10px;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Cover editor ---------- */
.cover-edit { padding: 16px; display: grid; gap: 16px; }
@media (min-width: 620px) {
  .cover-edit { grid-template-columns: 1fr 200px; align-items: start; }
}
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.field input, .field textarea {
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff; width: 100%; resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 11px; color: var(--muted); letter-spacing: 0; text-transform: none; }
.field--row { display: flex; align-items: center; gap: 8px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.checkline input { width: auto; }

.preview-pane { display: grid; gap: 8px; justify-items: center; }
.preview-pane .mini-cap { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.panel-canvas {
  width: 100%; max-width: 200px; aspect-ratio: 11 / 17; /* panel 2.75x4.25 */
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(27,27,25,.10); display: block;
}

/* ---------- Page cards ---------- */
.pages { display: grid; gap: 14px; }
.page-card { padding: 14px; display: grid; grid-template-columns: 96px 1fr; gap: 14px; }
@media (min-width: 520px) { .page-card { grid-template-columns: 120px 1fr; } }
.page-card__pv { position: relative; }
.page-card__pv .panel-canvas { max-width: none; }
.page-card__num {
  position: absolute; top: -8px; left: -8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 500;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.page-card__body { min-width: 0; display: grid; gap: 10px; align-content: start; }

.typetoggle { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.typetoggle button {
  border: 0; background: transparent; cursor: pointer; font-family: var(--sans);
  font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 999px; color: var(--ink-soft);
}
.typetoggle button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px;
  text-align: center; color: var(--muted); font-size: 13px; cursor: pointer;
  background: #fff; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-d); }
.dropzone strong { color: var(--ink); font-weight: 500; }

.inputs-grid { display: grid; gap: 8px; }
.inputs-grid.two { grid-template-columns: 1fr 110px; }
.inp {
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; width: 100%;
}
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { resize: vertical; min-height: 64px; line-height: 1.4; }

.card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.iconbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--ink-soft); padding: 6px 10px; display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans);
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }
.iconbtn--danger:hover { border-color: var(--danger); color: var(--danger); }
.spacer { flex: 1; }

/* ---------- Action bar ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(244,241,234,.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.actionbar__inner { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 10px; }
.btn {
  font-family: var(--sans); font-size: 15px; font-weight: 500; cursor: pointer;
  border-radius: 12px; padding: 13px 16px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--ghost { flex: none; }
.btn--primary { flex: 1; background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn--primary:disabled { opacity: .5; cursor: progress; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: none; }
.modal.open { display: block; }
.modal__scrim { position: absolute; inset: 0; background: rgba(27,27,25,.45); backdrop-filter: blur(2px); }
.modal__panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--card); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 20px;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal__title { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.modal__close { border: 0; background: var(--paper); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--ink-soft); }

.sheet-preview { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; box-shadow: var(--shadow); background:#fff; }
.toggle-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.note { font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* ---------- Fold guide ---------- */
.guide-steps { display: grid; gap: 14px; margin-top: 8px; }
.guide-step { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.guide-step .n {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-d);
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.guide-step p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.guide-diagram { width: 100%; max-width: 420px; margin: 4px auto 16px; display: block; }

.privacy {
  margin: 28px auto 8px; max-width: var(--maxw); text-align: center;
  font-size: 12px; color: var(--muted); padding: 0 18px; line-height: 1.6;
}
.privacy svg { vertical-align: -2px; margin-right: 4px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
