/* Templates page: Ledger & Ink presentation and editor behavior. */
.templates-page {
  --tpl-paper: #f6f3ec;
  --tpl-card: #fffefa;
  --tpl-wash: #ede8dc;
  --tpl-ink: #10213f;
  --tpl-copy: #3a4458;
  --tpl-muted: #596477;
  --tpl-line: #d9d2c3;
  --tpl-teal: #176b7a;
  --tpl-teal-light: #a9dce0;
  --tpl-on-teal: #fff;
  background: var(--tpl-paper);
  color: var(--tpl-ink);
  overflow-x: clip;
}
:root[data-theme="dark"] .templates-page {
  --tpl-paper: #0e1422;
  --tpl-card: #161e2e;
  --tpl-wash: #1a2334;
  --tpl-ink: #e8ebf2;
  --tpl-copy: #c2cad8;
  --tpl-muted: #a0adbf;
  --tpl-line: #2a3447;
  --tpl-teal: #79c8d0;
  --tpl-teal-light: #b9e6e9;
  --tpl-on-teal: #081820;
  color-scheme: dark;
}
:root[data-theme="light"] .templates-page { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .templates-page {
    --tpl-paper: #0e1422;
    --tpl-card: #161e2e;
    --tpl-wash: #1a2334;
    --tpl-ink: #e8ebf2;
    --tpl-copy: #c2cad8;
    --tpl-muted: #a0adbf;
    --tpl-line: #2a3447;
    --tpl-teal: #79c8d0;
    --tpl-teal-light: #b9e6e9;
    --tpl-on-teal: #081820;
    color-scheme: dark;
  }
}
.templates-page :focus-visible { outline: 3px solid var(--tpl-teal); outline-offset: 3px; }
.templates-page .utility-bar { border: 0; background: #0a1830; color: #e0e7f1; }
.templates-page .utility-bar a { color: #fff; text-underline-offset: 3px; }
.templates-page .site-header { background: color-mix(in srgb,var(--tpl-paper) 96%,transparent); }
.templates-page .site-header .brand-mark { display: none !important; }
.templates-page .site-header .brand-text { display: block !important; }
.templates-page .site-header .brand-text .b-name { color: var(--tpl-ink) !important; font: 600 30px/1 var(--head); letter-spacing: -.035em; }
.templates-page .site-header .brand-text .b-name::after { content: "."; color: var(--tpl-teal); }
.templates-page .site-header .brand-text .b-sub { display: none; }
.templates-page .primary-nav { background: #10213f; }
.templates-page .nav-inner { flex-wrap: nowrap; }
.templates-page .nav-inner a { color: #fff; }
.templates-page main { background: var(--tpl-paper); }
.templates-page .hero {
  padding: clamp(54px, 8vw, 88px) 0;
  background: #0a1830;
  border-bottom: 4px solid var(--tpl-teal);
}
.templates-page .hero::before {
  background: radial-gradient(ellipse at 82% 18%,rgba(23,107,122,.32),transparent 42%),repeating-linear-gradient(0deg,transparent 0 47px,rgba(255,255,255,.04) 47px 48px);
}
.templates-page .hero .eyebrow { border: 1px solid rgba(185,230,233,.36); border-radius: 2px; color: #b9e6e9; background: transparent; font-family: var(--mono); letter-spacing: .04em; }
.templates-page .hero h1 { max-width: 900px; line-height: 1.2; text-wrap: balance; }
.templates-page .hero h1 .accent { color: var(--tpl-teal-light); }
.templates-page .hero p.sub { max-width: 760px; color: #e0e6ef; line-height: 1.8; }
.templates-page .templates-section { padding: clamp(28px, 5vw, 52px) 0; }
.templates-page .templates-section .container { max-width: 1000px; }
.templates-page .filter-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 auto 10px; }
.templates-page .filter-bar button {
  min-height: 44px; padding: 9px 15px; color: var(--tpl-copy); background: var(--tpl-card);
  border: 1px solid var(--tpl-line); border-radius: 2px; font: 600 13px/1.3 var(--sans); cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s;
}
.templates-page .filter-bar button:hover { border-color: var(--tpl-teal); color: var(--tpl-ink); }
.templates-page .filter-bar button[aria-pressed="true"] { color: var(--tpl-on-teal); background: var(--tpl-teal); border-color: var(--tpl-teal); }
.templates-page .filter-status { min-height: 22px; margin: 0 0 16px; color: var(--tpl-muted); text-align: center; font: 500 12px/1.6 var(--mono); }
.templates-page .tmpl-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; max-width: 920px; margin: 0 auto; }
.templates-page .tmpl-card {
  min-width: 0; padding: 21px; display: flex; flex-direction: column; color: var(--tpl-copy); background: var(--tpl-card);
  border: 1px solid var(--tpl-line); border-top: 3px solid var(--tpl-teal); border-radius: 3px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.templates-page .tmpl-card.c2 { border-top-color: #6d9b8a; }
.templates-page .tmpl-card.c3 { border-top-color: #a75b43; }
.templates-page .tmpl-card.c4 { border-top-color: #b9873d; }
.templates-page .tmpl-card.c5 { border-top-color: #726287; }
.templates-page .tmpl-card.c6 { border-top-color: #496c5b; }
.templates-page .tmpl-card:hover { border-color: var(--tpl-teal); transform: translateY(-2px); box-shadow: 0 12px 28px -22px rgba(16,33,63,.55); }
.templates-page .tmpl-card .head { display: flex; align-items: flex-start; gap: 13px; margin: 0 0 12px; }
.templates-page .tmpl-card .icon { flex: 0 0 46px; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; background: var(--tpl-wash); border-radius: 2px; font-size: 21px; }
.templates-page .tmpl-card h3 { margin: 0 0 4px; color: var(--tpl-ink); font: 600 19px/1.35 var(--head); overflow-wrap: anywhere; }
.templates-page .tmpl-card .cat { color: var(--tpl-teal); font: 500 10px/1.5 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.templates-page .tmpl-card .desc { flex: 1; margin: 0 0 14px; color: var(--tpl-copy); font-size: 14px; line-height: 1.7; }
.templates-page .tmpl-card .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 14px; color: var(--tpl-muted); font: 500 11px/1.5 var(--mono); }
.templates-page .tmpl-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.templates-page .tmpl-card .actions .btn { width: 100%; min-height: 46px; justify-content: center; }

.templates-page .tmpl-overlay {
  position: fixed; z-index: 200; inset: 0; display: none; align-items: center; justify-content: center;
  padding: clamp(10px, 3vw, 24px); background: rgba(4,14,31,.78);
}
.templates-page .tmpl-overlay.show { display: flex; }
.templates-page .tmpl-modal {
  width: min(780px,100%); max-height: min(90vh,900px); overflow: auto; overscroll-behavior: contain;
  background: var(--tpl-card); color: var(--tpl-ink); border: 1px solid var(--tpl-line); border-radius: 4px;
  box-shadow: 0 30px 70px rgba(0,0,0,.4);
}
.templates-page .tmpl-modal-head {
  position: sticky; z-index: 5; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px clamp(16px,4vw,24px); color: #fff; background: #10213f; border-bottom: 3px solid var(--tpl-teal);
}
.templates-page .tmpl-modal-head h3 { margin: 0; color: #fff; font: 600 21px/1.3 var(--head); }
.templates-page .tmpl-modal-head button { min-height: 44px; padding: 8px 12px; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.5); border-radius: 2px; font: 600 13px/1.3 var(--sans); cursor: pointer; }
.templates-page .tmpl-modal-body { padding: clamp(14px,4vw,24px); }
.templates-page .tmpl-form { margin: 0 0 20px; }
.templates-page .tmpl-form .field { min-width: 0; margin: 0 0 12px; }
.templates-page .tmpl-form label { display: block; margin: 0 0 5px; color: var(--tpl-ink); font-size: 13px; font-weight: 700; line-height: 1.45; }
.templates-page .tmpl-form input,.templates-page .tmpl-form textarea {
  box-sizing: border-box; width: 100%; min-height: 46px; padding: 10px 12px; color: var(--tpl-ink); background: var(--tpl-card);
  border: 1px solid #7a8798; border-radius: 2px; font: 15px/1.5 var(--sans);
}
.templates-page .tmpl-form textarea { min-height: 90px; resize: vertical; }
.templates-page .tmpl-form input:focus-visible,.templates-page .tmpl-form textarea:focus-visible { border-color: var(--tpl-teal); box-shadow: 0 0 0 3px color-mix(in srgb,var(--tpl-teal) 24%,transparent); }
.templates-page .tmpl-form .row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.templates-page .tmpl-preview { margin: 0 0 14px; padding: clamp(16px,4vw,24px); color: #20242a; background: #fff; border: 1px solid var(--tpl-line); border-radius: 2px; font: 14px/1.75 Georgia,"Times New Roman",serif; overflow-wrap: anywhere; }
.templates-page .tmpl-preview h4 { margin: 0 0 10px; color: #111; font: 700 17px/1.4 Georgia,"Times New Roman",serif; text-align: center; text-transform: uppercase; letter-spacing: .06em; }
.templates-page .tmpl-preview .right { text-align: right; }
.templates-page .tmpl-preview .center { text-align: center; }
.templates-page .tmpl-preview p { margin: 0 0 10px; }
.templates-page .tmpl-preview .sig { margin-top: 34px; }
.templates-page .tmpl-preview .sig .line { width: min(200px,100%); margin-bottom: 4px; border-bottom: 1px solid #111; }
.templates-page .tmpl-preview table { max-width: 100%; }
.templates-page .tmpl-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding-top: 14px; border-top: 1px solid var(--tpl-line); }
.templates-page .tmpl-actions .btn { min-height: 46px; justify-content: center; }
.templates-page .copy-status { min-height: 22px; margin: 8px 0 0; color: var(--tpl-copy); font-size: 13px; line-height: 1.6; }
.templates-page .copy-status[data-state="error"] { color: #9b3328; font-weight: 700; }
:root[data-theme="dark"] .templates-page .copy-status[data-state="error"] { color: #ffad9f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .templates-page .copy-status[data-state="error"] { color: #ffad9f; }
}
.templates-page .cta-band { color: #fff; background: #0a1830; border-top: 4px solid var(--tpl-teal); }
.templates-page .cta-band h2 { color: #fff; }
.templates-page .cta-band h2 .accent { color: var(--tpl-teal-light); }
.templates-page .cta-band p { color: #e0e6ef; line-height: 1.8; }
.templates-page footer { color: var(--tpl-copy); background: var(--tpl-paper); border-top: 1px solid var(--tpl-line); }
.templates-page footer a { color: var(--tpl-teal); text-underline-offset: 3px; }

@media (max-width: 900px) {
  .templates-page .primary-nav { overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
  .templates-page .nav-inner { width: max-content; min-width: 100%; }
}
@media (max-width: 760px) {
  .templates-page .container { width: min(100% - 28px, 620px); }
  .templates-page .header-inner { align-items: center; flex-wrap: wrap; padding-block: 12px; }
  .templates-page .header-cta { justify-content: flex-start; }
  .templates-page .tmpl-grid { grid-template-columns: minmax(0,1fr); }
  .templates-page .hero h1 { font-size: clamp(34px,8vw,46px); }
  .templates-page .utility-inner { align-items: flex-start; gap: 8px; }
  .templates-page .tmpl-modal { max-height: 94vh; }
}
@media (max-width: 520px) {
  .templates-page .container { width: calc(100% - 24px); }
  .templates-page .header-inner { gap: 10px; }
  .templates-page .header-cta { gap: 6px; }
  .templates-page .header-cta .btn { min-height: 44px; padding-inline: 9px; font-size: 12px; }
  .templates-page .utility-right { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .templates-page .filter-bar { justify-content: flex-start; }
  .templates-page .filter-bar button { flex: 1 1 125px; }
  .templates-page .tmpl-form .row { grid-template-columns: minmax(0,1fr); gap: 0; }
  .templates-page .tmpl-actions { justify-content: stretch; }
  .templates-page .tmpl-actions .btn { flex: 1 1 100%; width: 100%; }
  .templates-page .cta-btns { align-items: stretch; }
  .templates-page .cta-btns .btn { width: 100%; }
}
@media (max-width: 360px) {
  .templates-page .container { width: calc(100% - 20px); }
  .templates-page .brand-text .b-name { font-size: 27px; }
  .templates-page .header-cta .btn { min-height: 44px; padding-inline: 7px; font-size: 11px; }
  .templates-page .filter-bar { gap: 6px; }
  .templates-page .filter-bar button { flex-basis: 115px; padding-inline: 9px; font-size: 12px; }
  .templates-page .tmpl-card { padding: 16px; }
  .templates-page .tmpl-modal-head h3 { font-size: 18px; }
  .templates-page .utility-inner { align-items: flex-start; }
  .templates-page .utility-right { flex-basis: 100%; }
}
@media print {
  body.templates-page > *:not(.tmpl-overlay) { display: none !important; }
  .templates-page .tmpl-overlay { position: static !important; display: block !important; padding: 0 !important; background: #fff !important; }
  .templates-page .tmpl-modal { width: 100% !important; max-width: none !important; max-height: none !important; overflow: visible !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
  .templates-page .tmpl-modal-head,.templates-page .tmpl-form,.templates-page .tmpl-actions,.templates-page .copy-status { display: none !important; }
  .templates-page .tmpl-modal-body { padding: 0 !important; }
  .templates-page .tmpl-preview { padding: 24px !important; border: 0 !important; }
}
