.secondary-view { min-height: 100dvh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--bg); }
.secondary-toolbar { position: sticky; z-index: 12; top: 0; display: grid; height: 48px; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 0 4px; border-bottom: 1px solid #29292f; background: rgba(18,18,18,.96); backdrop-filter: blur(14px); }
.secondary-toolbar h1 { overflow: hidden; margin: 0; font-size: 17px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.secondary-toolbar button { display: grid; width: 40px; height: 40px; place-items: center; border: 0; background: transparent; }
.overlay-toolbar { position: absolute; right: 0; left: 0; border-bottom: 0; background: linear-gradient(rgba(0,0,0,.78), transparent); }
.favorite-button, .delete-button { border-radius: 50%; font-size: 25px; }
.favorite-button.selected { color: var(--accent); }
.delete-button { color: #c8c8cc; font-size: 19px; }

.library-search { display: grid; height: 44px; grid-template-columns: 22px 1fr 28px; align-items: center; gap: 8px; margin: 14px 16px 16px; padding: 0 10px 0 13px; border: 1px solid #303037; border-radius: 8px; background: #202025; color: #77777f; }
.library-search input { min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; }
.library-search input::-webkit-search-cancel-button { display: none; -webkit-appearance: none; }
.library-search button { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: #92929a; font-size: 20px; }
.search-results { padding-bottom: 24px; }
.library-empty { grid-column: 1 / -1; min-height: 300px; }
.empty-state button { min-height: 40px; margin-top: 14px; padding: 0 18px; border: 1px solid #44444c; border-radius: 7px; background: #232329; font-size: 12px; font-weight: 700; }
.card-favorite { position: absolute; z-index: 2; top: 8px; right: 8px; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: rgba(0,0,0,.72); color: var(--accent); font-size: 13px; }

.template-detail-view { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.template-preview-stage { display: grid; min-height: 500px; place-items: center; overflow: hidden; background: #050505; }
.template-preview-stage video { display: block; width: 100%; height: min(72dvh, 610px); max-height: 610px; background: #050505; object-fit: contain; }
.template-detail-copy { padding: 19px 18px 24px; }
.template-detail-copy > span, .result-copy > span { color: var(--accent); font-size: 10px; font-weight: 800; }
.template-detail-copy h2, .result-copy h2 { margin: 8px 0 7px; font-size: 24px; }
.template-detail-copy p, .result-copy p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.template-detail-copy dl, .result-copy dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 0; }
.template-detail-copy dl div, .result-copy dl div { min-width: 0; padding: 11px 12px; border: 1px solid #303037; border-radius: 7px; background: #1b1b1f; }
.template-detail-copy dt, .result-copy dt { color: #7f7f87; font-size: 9px; text-transform: uppercase; }
.template-detail-copy dd, .result-copy dd { overflow: hidden; margin: 5px 0 0; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.page-action-dock, .result-action-dock { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; width: min(100%, var(--app-width)); margin: 0 auto; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #2f2f35; background: rgba(18,18,18,.96); backdrop-filter: blur(14px); }
.page-primary, .page-secondary { display: grid; width: 100%; min-height: 52px; place-items: center; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 800; text-decoration: none; }

.result-view { padding-bottom: calc(146px + env(safe-area-inset-bottom)); }
.result-media-grid { display: grid; gap: 3px; min-height: 420px; padding: 0; background: #050505; }
.result-media-grid.single { grid-template-columns: 1fr; }
.result-media-grid.multiple { grid-template-columns: 1fr 1fr; padding: 3px; }
.result-media-grid img, .result-media-grid video { width: 100%; height: 100%; min-height: 220px; max-height: 610px; background: #050505; object-fit: contain; }
.result-media-grid.multiple img, .result-media-grid.multiple video { max-height: 340px; }
.result-copy { padding: 18px 18px 26px; }
.result-action-dock { display: grid; gap: 9px; }
#result-open-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.page-secondary { min-height: 42px; border: 1px solid #42424a; background: #202024; color: #fff; font-size: 12px; }
.result-unavailable { display: grid; min-height: 420px; align-content: center; justify-items: center; padding: 30px; background: #0b0b0d; text-align: center; }
.result-unavailable > span { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid #4a4a52; border-radius: 50%; color: var(--accent); font-weight: 800; }
.result-unavailable h2 { margin: 14px 0 7px; font-size: 18px; }
.result-unavailable p { max-width: 280px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.result-empty { min-height: 560px; }
.modal-actions .danger { border-color: #753342; background: #5b2834; color: #fff; }

.credit-detail-summary { display: flex; height: 92px; align-items: center; justify-content: space-between; padding: 0 19px; border-bottom: 1px solid #2d2d33; background: #1a1a1e; }
.credit-detail-summary > span { color: var(--muted); font-size: 12px; }
.credit-detail-summary > strong { display: flex; align-items: center; gap: 7px; font-family: "Roboto Numbers", sans-serif; font-size: 26px; }
.credit-transaction-list { padding: 10px 16px 28px; }
.credit-transaction { display: grid; min-height: 68px; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid #2c2c32; }
.transaction-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: #27272d; color: var(--gold); font-weight: 800; }
.credit-transaction strong, .credit-transaction small, .transaction-amount { display: block; }
.credit-transaction strong { font-size: 12px; text-transform: capitalize; }
.credit-transaction small { margin-top: 4px; color: #777780; font-size: 9px; }
.transaction-amount { min-width: 74px; font-family: "Roboto Numbers", sans-serif; font-size: 15px; text-align: right; }
.transaction-amount.positive { color: var(--green); }
.transaction-amount.negative { color: var(--accent); }
.transaction-amount small { font-family: Roboto, Arial, sans-serif; }
.credit-empty { min-height: 500px; }

.document-view { padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
.document-content { padding: 22px 16px 40px; }
.document-content h2 { margin: 24px 0 8px; font-size: 16px; }
.document-content h2:first-child { margin-top: 0; }
.document-content p { margin: 0 0 14px; color: #c0c0c5; font-size: 15px; line-height: 1.65; }
.document-content a { color: #ff91a8; overflow-wrap: anywhere; }
.document-content details { border-bottom: 1px solid #303037; }
.document-content summary { padding: 17px 26px 17px 0; font-size: 14px; font-weight: 700; cursor: pointer; }
.document-content details p { padding: 0 0 17px; }
.document-updated, .document-note { color: #777780 !important; font-size: 11px !important; }
.contact-link { display: grid; min-height: 52px; place-items: center; margin: 18px 0 26px; border-radius: 8px; background: var(--accent); color: #fff !important; font-size: 13px; font-weight: 800; text-decoration: none; }

body.route-search .bottom-nav, body.route-template .bottom-nav, body.route-result .bottom-nav,
body.route-credit-details .bottom-nav, body.route-document .bottom-nav { display: none; }

@media (max-height: 650px) {
  .template-preview-stage { min-height: 360px; }
  .template-preview-stage video { height: 64dvh; }
  .result-media-grid, .result-unavailable { min-height: 330px; }
}
