/* ReadyBinder app — screen + print. No external fonts, no external anything. */

:root {
  --paper: #faf7f0;
  --card: #ffffff;
  --ink: #2b2721;
  --muted: #7a7266;
  --line: #e6dfd2;
  --brand: #2f5d50;
  --brand-dark: #234a3f;
  --accent: #c0662b;
  --gold: #a3742a;
  --gold-bg: #f7ecd4;
  --ok: #2f7d4f;
  --err: #b23a3a;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 15px; }

#app {
  display: grid;
  grid-template: "top top" auto "nav main" 1fr / 300px 1fr;
  height: 100vh;
}

/* ---- top bar ---- */
#topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; }
.brand-mark { margin-right: 2px; }
.saved { color: var(--muted); font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pro-badge { color: var(--ok); font-weight: 600; font-size: 13.5px; border: 1px solid #cfe6d8; background: #eef7f1; border-radius: 999px; padding: 5px 12px; }

/* ---- buttons ---- */
.btn {
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  text-decoration: none; display: inline-block;
}
.btn:hover { border-color: #d0c6b4; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-gold { background: var(--gold-bg); border-color: #e2cf9e; color: var(--gold); }
.btn-lg { font-size: 16px; padding: 12px 18px; width: 100%; text-align: center; margin-top: 10px; }
.btn-add { color: var(--brand); border-style: dashed; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- nav ---- */
#nav {
  grid-area: nav;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 12px 10px 40px;
  background: #f4efe4;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.nav-item:hover { background: #ece5d5; }
.nav-item.active { background: var(--card); box-shadow: 0 1px 4px rgba(43, 39, 33, .07); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-title { font-weight: 600; font-size: 14px; }
.nav-tag { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-pct { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.nav-pct.complete { color: var(--ok); font-weight: 700; font-size: 14px; }

/* ---- main / form ---- */
#main { grid-area: main; overflow-y: auto; padding: 30px clamp(18px, 5vw, 64px) 80px; }
.section-head { display: flex; gap: 16px; align-items: flex-start; max-width: 760px; margin-bottom: 8px; }
.section-icon { font-size: 34px; margin-top: 4px; }
.section-head h1 { font-family: var(--serif); margin: 0 0 6px; font-size: 28px; }
.section-intro { color: var(--muted); margin: 0; max-width: 640px; line-height: 1.5; }

.block { max-width: 760px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin-top: 18px; }
.block h3 { font-family: var(--serif); margin: 0 0 4px; font-size: 18px; }

.field { margin-top: 14px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; font-family: var(--sans); font-size: 14.5px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf9;
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus { outline: 2px solid #bcd3cb; border-color: var(--brand); }
.field ::placeholder { color: #b3a996; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.item-card { position: relative; border: 1px solid var(--line); border-radius: 11px; padding: 4px 16px 16px; margin-top: 14px; background: #fefcf7; }
.item-remove {
  position: absolute; top: 10px; right: 10px;
  font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; text-decoration: underline;
}
.item-remove:hover { color: var(--err); }
.btn-add { margin-top: 14px; }

.section-footer { max-width: 760px; display: flex; justify-content: space-between; margin-top: 26px; }

/* ---- dialogs ---- */
dialog { border: none; border-radius: 16px; padding: 0; max-width: 460px; width: calc(100vw - 40px); box-shadow: 0 24px 70px rgba(30, 25, 15, .3); }
dialog::backdrop { background: rgba(35, 30, 22, .45); }
.dlg { padding: 26px 26px 22px; position: relative; }
.dlg h2 { font-family: var(--serif); margin: 0 0 10px; font-size: 22px; }
.dlg p { line-height: 1.5; margin: 8px 0; }
.dlg-list { padding-left: 4px; list-style: none; margin: 12px 0; }
.dlg-list li { margin: 8px 0; line-height: 1.45; }
.dlg-note { color: var(--muted); font-size: 12.5px; }
.dlg-note a { color: var(--brand); }
.dlg-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.dlg-divider::before, .dlg-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dlg-label { display: block; font-weight: 600; font-size: 13px; margin: 8px 0 5px; }
.dlg input[type="password"], .dlg input[type="text"], .dlg input:not([type]) {
  width: 100%; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
}
.dlg input[type="file"] { font-size: 13px; }
.keyrow { display: flex; gap: 8px; }
.keyrow input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.dlg-error { color: var(--err); font-size: 13px; }
.dlg-ok { color: var(--ok); font-size: 13px; }
.dlg-close { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.pro-tag { background: var(--gold-bg); color: var(--gold); font-size: 10.5px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0; text-transform: none; font-weight: 600; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; transition: all .3s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- narrow screens ---- */
@media (max-width: 860px) {
  #app { grid-template: "top" auto "nav" auto "main" 1fr / 1fr; height: auto; }
  #nav { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 8px; }
  .nav-item { flex: 0 0 auto; }
  .nav-tag, .nav-pct { display: none; }
  .saved { display: none; }
}

/* ==========================================================================
   PRINT — the binder itself
   ========================================================================== */

#printRoot { display: none; }

@media print {
  #app, dialog, .toast { display: none !important; }
  body { background: #fff; }
  #printRoot { display: block; font-family: var(--sans); color: #1c1914; font-size: 12.5px; }

  @page { size: letter portrait; margin: 0.7in 0.75in; }

  .p-watermark {
    position: fixed; inset: 0; z-index: 10; pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    transform: rotate(-28deg);
    font-size: 26px; font-weight: 800; letter-spacing: .06em;
    color: rgba(160, 60, 40, .16); text-align: center;
  }

  /* cover */
  .p-cover { page-break-after: always; text-align: center; padding-top: 2.4in; }
  .p-cover h1 { font-family: var(--serif); font-size: 40px; margin: 26px 0 8px; }
  .p-cover-family { font-family: var(--serif); font-size: 22px; color: #4a443a; }
  .p-cover-sub { margin-top: 40px; font-size: 15px; line-height: 1.7; color: #4a443a; }
  .p-cover-updated { margin-top: 60px; font-size: 12px; color: #7a7266; text-transform: uppercase; letter-spacing: .12em; }
  .p-cover-rule { width: 1.6in; height: 3px; background: #2f5d50; margin: 0 auto; }
  .p-cover-rule:last-child { margin-top: 26px; }

  /* section divider pages */
  .p-divider { page-break-before: always; page-break-after: always; text-align: center; padding-top: 3in; }
  .p-divider-icon { font-size: 54px; }
  .p-divider h2 { font-family: var(--serif); font-size: 34px; margin: 18px 0 6px; }
  .p-divider p { color: #6b6457; font-size: 14px; }

  /* content */
  .p-section { page-break-before: always; }
  .p-cover + .p-section { page-break-before: always; }
  .p-section-head {
    font-family: var(--serif); font-size: 21px; font-weight: 700;
    border-bottom: 2.5px solid #2f5d50; padding-bottom: 7px; margin-bottom: 4px;
  }
  .p-intro { color: #55503f; font-size: 12px; line-height: 1.5; margin: 6px 0 14px; }

  .p-field { margin: 12px 0; page-break-inside: avoid; }
  .p-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #6b6457; margin-bottom: 3px; }
  .p-value { font-size: 13px; line-height: 1.55; white-space: normal; }
  .p-ruled { padding-top: 2px; }
  .p-rule { height: 22px; border-bottom: 1px solid #c9c1af; }

  .p-listtitle { font-family: var(--serif); font-size: 16px; font-weight: 700; margin: 18px 0 4px; }
  .p-item { border: 1px solid #c9c1af; border-radius: 8px; padding: 4px 14px 12px; margin: 10px 0; page-break-inside: avoid; }
  .p-item .p-field { margin: 9px 0; }

  .p-steps li { margin: 10px 0; line-height: 1.55; font-size: 13px; }

  .p-toc-row { display: flex; align-items: baseline; gap: 8px; font-size: 14px; padding: 7px 0; border-bottom: 1px solid #e3dccb; }
  .p-toc-num { font-family: var(--serif); font-weight: 700; width: 22px; color: #2f5d50; }
  .p-toc-tag { margin-left: auto; color: #7a7266; font-size: 11px; text-align: right; }

  .p-upsell { border: 2px dashed #c9c1af; border-radius: 10px; padding: 16px 20px; }

  .p-wallet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; }
  .p-wallet { border: 1.5px dashed #8b8371; border-radius: 8px; padding: 12px 14px; width: 3.4in; }
  .p-wallet-title { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: #b23a3a; margin-bottom: 6px; }
  .p-wallet-row { font-size: 10.5px; margin: 4px 0; line-height: 1.4; }
}
