/* ===== BestQR — QR Frames & Templates page foundation =====
   Structure only: gallery grid, filter chips, preview placeholders and the three editor regions.
   Final template visuals and editor styling are added later (see docs/qr-templates-codex-handoff.md). */
body.qtemplates { --accent: #4f46e5; --accent-600: #4338ca; --accent-soft: #eef0ff; --accent-ring: #4f46e52e; }

.qt-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 22px; }

.qt-section { margin-top: 8px; }
.qt-section + .qt-section { margin-top: 44px; }
.qt-head h2 { margin: 0 0 6px; font-size: 24px; }
.qt-head p { margin: 0 0 18px; color: var(--muted); max-width: 62ch; }

/* Category filters */
.qt-filters { margin-bottom: 20px; }
.qt-filters .u-chip { cursor: pointer; }

/* Gallery */
.qt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; align-items: start; }
.qt-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.qt-card[hidden] { display: none; }
.qt-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.qt-card-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.qt-card h3 { margin: 0; font-size: 17px; }
.qt-card p { margin: 0 0 8px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.qt-cat { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); }
.qt-card .u-btn { margin-top: auto; }

/* Preview placeholder: the editor/gallery replaces the contents of [data-template-preview] and keeps this box.
   The aspect ratio follows data-orientation until the final canvas sizes are set. */
.qt-preview { display: grid; place-items: center; align-content: center; gap: 6px; margin: 16px 16px 0; border-radius: 12px; color: var(--muted-2); font-size: 12px;
  background: repeating-conic-gradient(#f1f2f7 0 25%, #f8f9fc 0 50%) 50% / 20px 20px; border: 1px dashed var(--border-strong); }
.qt-preview .icon { width: 28px; height: 28px; }
.qt-preview[data-orientation="portrait"] { aspect-ratio: 3 / 4; }
.qt-preview[data-orientation="landscape"] { aspect-ratio: 4 / 3; }
.qt-preview[data-orientation="square"] { aspect-ratio: 1 / 1; }

/* Editor regions */
.qt-selected { margin: 0 0 16px; font-weight: 600; }
.qt-editor-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.qt-editor-side { display: grid; gap: 22px; }
.qt-mount { min-height: 160px; }
#qt-editor-preview { min-height: 320px; }
.qt-empty { margin: 0; color: var(--muted); font-size: 14px; }
@media (max-width: 900px) { .qt-editor-grid { grid-template-columns: 1fr; } }

/* Finished editor */
.qt-grid { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 18px; }
.qt-card { box-shadow: 0 7px 24px rgba(24, 31, 56, .04); transition: border-color .2s, box-shadow .2s; }
.qt-card:not(.qt-coming):hover { border-color: var(--accent); box-shadow: 0 12px 28px rgba(35, 44, 80, .1); }
.qt-preview { padding: 18px; overflow: hidden; background: #f4f5f9; border: 0; }
.qt-preview svg { display: block; max-width: 100%; max-height: 280px; width: auto; height: auto; box-shadow: 0 8px 22px rgba(20, 28, 49, .11); }
.qt-preview[data-orientation="landscape"] svg { width: 100%; }
.qt-card.qt-coming { opacity: .7; }
.qt-card.qt-coming .u-btn { cursor: default; }
.qt-card.qt-coming .qt-preview { background: repeating-conic-gradient(#f1f2f7 0 25%, #f8f9fc 0 50%) 50% / 20px 20px; }
.qt-card.qt-coming .qt-preview .icon { width: 28px; height: 28px; }
.qt-editor-grid { grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr); }
.qt-mount { min-height: 0; }
#qt-editor-preview { min-height: 0; display: flex; flex-direction: column; align-items: center; }
#qt-editor-preview svg { display: block; width: min(100%, 520px); height: auto; box-shadow: 0 12px 35px rgba(25, 31, 55, .13); }
.qt-field { display: grid; gap: 7px; margin-bottom: 17px; }
.qt-field label { font-size: 13px; font-weight: 700; color: #30374b; }
.qt-field small, .qt-preview-note, #qt-export-actions p { color: var(--muted); font-size: 12px; line-height: 1.45; }
.qt-field .u-input { width: 100%; box-sizing: border-box; }
.qt-field input[type="color"] { height: 44px; padding: 4px; cursor: pointer; }
.qt-field input[type="file"] { max-width: 100%; font-size: 13px; }
.qt-error { color: #ae2835; font-size: 12px; min-height: 1em; }
.qt-reset { margin-top: 4px; }
.qt-preview-note { margin: 15px 0 0; text-align: center; }
.qt-downloads { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.qt-downloads .u-btn:disabled { opacity: .45; cursor: not-allowed; }
.qt-export-status { min-height: 1em; }
@media (max-width: 900px) {
  .qt-editor-grid { grid-template-columns: 1fr; }
  .qt-editor-side { order: -1; }
  #qt-editor-preview svg { max-height: 60vh; width: auto; max-width: 100%; }
}
@media (max-width: 600px) {
  .qt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .qt-card-body { padding: 11px; }
  .qt-card h3 { font-size: 15px; }
  .qt-card p { font-size: 12px; }
  .qt-preview { margin: 8px 8px 0; padding: 8px; }
  .qt-preview svg { max-height: 160px; }
  .qt-downloads .u-btn { flex: 1; }
}

/* QR Styles mode */
.qt-modebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 6px; margin: 4px 0 34px; background: #eef0f7; border-radius: 16px; }
.qt-mode-tab { border: 0; border-radius: 11px; padding: 15px 18px; background: transparent; color: #384158; font: inherit; font-weight: 750; text-align: left; cursor: pointer; }
.qt-mode-tab span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.qt-mode-tab.is-active { background: #fff; color: #222d58; box-shadow: 0 3px 13px #25345b18; }
.qt-style-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.qt-style-card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 13px; text-align: left; font: inherit; color: inherit; cursor: pointer; background: #fff; border: 1px solid var(--border); border-radius: 17px; }
.qt-style-card.is-selected { border-color: #6554b8; box-shadow: 0 0 0 3px #6554b827; }
.qt-style-card strong { font-size: 17px; }
.qt-style-card small { color: var(--muted); }
.qt-style-art { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; margin-bottom: 8px; border-radius: 11px; background: #f4f5f9; }
.qt-style-art svg { width: 100%; height: 100%; }
.qt-style-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.qt-style-two select { min-height: 42px; }
#qt-style-preview { display: grid; place-items: center; min-height: 300px; }
#qt-style-preview svg { display: block; width: min(100%, 520px); height: auto; box-shadow: 0 12px 35px rgba(25,31,55,.13); }
#qt-style-export p { color: var(--muted); font-size: 12px; line-height: 1.45; }
#qt-templates-mode[hidden], #qt-styles-mode[hidden] { display: none; }
@media (max-width: 650px) { .qt-style-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .qt-style-card { padding: 9px; } .qt-style-card strong { font-size: 14px; } .qt-style-card small { font-size: 11px; } .qt-mode-tab { padding: 10px; font-size: 13px; } .qt-mode-tab span { font-size: 11px; } }
