/* Bows & Headbands Lab — cream, berry and gold, with a soft festive feel. */
@font-face { font-family: 'Cinzel'; src: url('../fonts/cinzel-bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Rubik'; src: url('../fonts/rubik-bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Pacifico'; src: url('../fonts/pacifico.woff') format('woff'); font-weight: 400; font-display: swap; }

:root {
  --ink: #2a1a1f; --ink2: #5a3a42;
  --berry: #9b1d3a; --berry2: #c43b5a;
  --gold: #c9a227; --gold2: #e8c56b;
  --forest: #1e4a34;
  --cream: #f7efe4; --cream2: #ead9c8; --paper: #fff8f1;
  --line: #e0cfc4; --blush: #f3d6d0;
  --warn: #9a4b12; --red: #b32626;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh;
}
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--berry); }
button:disabled { opacity: .45; cursor: default; }
button.on, .seg button.on { background: linear-gradient(#9b1d3a, #7a1630); border-color: #6a1228; color: #fff8f1; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
select, input[type=text], input[type=number], textarea {
  background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
input[type=range] { accent-color: var(--berry); width: 100%; }
input[type=checkbox] { accent-color: var(--berry); }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: linear-gradient(#fff8f1, #f3e4d6); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; }
.logo .bow { fill: var(--berry); }
.logo .tail { stroke: var(--gold); fill: none; stroke-width: 2; stroke-linecap: round; }
h1, h2, summary, .tpl b, .dlg h2 { font-family: 'Cinzel', Georgia, serif; letter-spacing: .03em; }
h1 { margin: 0; font-size: 22px; color: var(--berry); }
.tag { color: var(--ink2); font-size: 13px; }
.modes { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; }

.layout { display: grid; grid-template-columns: 330px 1fr 230px; grid-template-areas: 'options stage saved'; min-height: 0; }
.options { grid-area: options; overflow-y: auto; padding: 10px 12px 80px; background: rgba(255, 248, 241, .92); border-right: 1px solid var(--line); max-height: calc(100vh - 120px); }
.stage { grid-area: stage; position: relative; display: flex; flex-direction: column; min-height: 0; }
.saved { grid-area: saved; padding: 12px; background: rgba(255, 248, 241, .92); border-left: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 120px); }
.view { flex: 1; min-height: 360px; position: relative; background: #3a2428; }
.view canvas { display: block; width: 100% !important; height: 100% !important; position: absolute; inset: 0; }
.render-badge {
  position: absolute; left: 10px; bottom: 138px; z-index: 3; pointer-events: none;
  background: rgba(42, 26, 31, .78); color: #fff8f1; font: 700 11px/1 Rubik, sans-serif;
  letter-spacing: .04em; text-transform: uppercase; padding: 5px 8px; border-radius: 6px;
}
.view-tools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; z-index: 2; }
.view-tools > * { pointer-events: auto; }
.view-tools .chk, .view-tools button { background: rgba(255, 248, 241, .9); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.seg { display: flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.info { flex: none; height: 128px; overflow-y: auto; box-sizing: border-box; padding: 8px 14px; background: rgba(255, 248, 241, .95); border-top: 1px solid var(--line); }
.stats { font: 700 15px Rubik, sans-serif; color: var(--berry); }
.warnings { margin: 4px 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.warnings .err { color: var(--red); }
.tips summary { font-size: 14px; cursor: pointer; color: var(--ink2); }
.tips ul { margin: 4px 0; padding-left: 18px; font-size: 13px; color: var(--ink2); }
.busy { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(42, 26, 31, .92); color: var(--cream); border: 1px solid var(--gold); padding: 12px 18px; border-radius: 10px; min-width: 220px; text-align: center; z-index: 4; }
.busy .bar { height: 6px; background: #000; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.busy .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .15s; }

.sec { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: #fff; }
.sec > summary { padding: 9px 12px; cursor: pointer; color: var(--berry); font-size: 15px; list-style: none; }
.sec > summary::before { content: '✦ '; color: var(--gold); }
.sec[open] > summary { border-bottom: 1px solid var(--line); }
.sec > :not(summary) { margin: 8px 12px; }
.field { display: block; }
.field .lbl { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 3px; }
.hint, .muted { display: block; color: #7a5c58; font-size: 12px; margin: 3px 0 0; }
.slider { display: flex; gap: 8px; align-items: center; }
.slider output { min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.templates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#templateGrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.tpl { text-align: left; display: flex; flex-direction: column; padding: 7px 9px; }
.tpl b { font-size: 13px; color: var(--berry); }
.tpl small, .tpl .blurb { font-size: 11px; color: var(--ink2); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; font-size: 12px; gap: 2px; }
.swatch input { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 0; }
.palettes { display: flex; flex-wrap: wrap; gap: 6px; }
.pal { font-size: 12px; padding: 5px 8px; }
.pal i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }

.saved h2 { margin: 0 0 8px; font-size: 17px; color: var(--berry); }
.save-row { display: flex; gap: 6px; }
.save-row input { flex: 1; min-width: 0; }
.saved-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.saved-list li { display: flex; gap: 4px; }
.saved-list .load { flex: 1; display: flex; gap: 8px; align-items: center; text-align: left; padding: 4px; min-width: 0; overflow: hidden; }
.saved-list img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.saved-list .empty { color: #7a5c58; font-size: 13px; }
.icon { padding: 4px 8px; }

.downloads { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: linear-gradient(#fff8f1, #f3e4d6); border-top: 1px solid var(--gold); z-index: 5; }
.dl-label { color: var(--ink2); font-size: 14px; }
.downloads .primary { background: linear-gradient(#9b1d3a, #7a1630); border-color: #6a1228; color: #fff8f1; font-weight: 600; }
.dl-status { font-size: 13px; color: var(--ink2); }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--cream); border: 1px solid var(--gold); padding: 10px 16px; border-radius: 10px; z-index: 9; }

.dlg { border: 0; border-radius: 16px; padding: 0; width: min(820px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(42,26,31,.28); background: var(--paper); color: var(--ink); }
.dlg::backdrop { background: rgba(42, 26, 31, .55); }
.dlg form { padding: 20px; }
.dlg h2 { margin: 0 0 6px; font-size: 1.6rem; color: var(--berry); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 300px 1fr; grid-template-areas: 'options stage' 'saved saved'; }
  .saved { max-height: none; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  body { font-size: 14px; display: block; height: auto; }
  .top { padding: 8px 10px; gap: 8px; }
  h1 { font-size: 18px; }
  .tag { display: none; }
  .modes { margin-left: 0; width: 100%; order: 3; }
  .modes button { flex: 1 1 30%; padding: 6px 4px; font-size: 12px; }
  .actions { margin-left: auto; }
  .actions button { padding: 5px 8px; }
  .layout { grid-template-columns: 1fr; grid-template-areas: 'stage' 'options' 'saved'; grid-template-rows: auto auto auto; }
  .view { min-height: 300px; height: 48vh; flex: none; }
  .render-badge { bottom: auto; top: auto; left: 10px; bottom: 10px; }
  .info { height: auto; overflow: visible; }
  .options { max-height: none; border-right: 0; padding-bottom: 12px; }
  .downloads { padding: 8px; gap: 6px; }
  .downloads button { flex: 1 1 45%; font-size: 12.5px; padding: 7px 4px; }
  .dl-label { display: none; }
  .dl-status { flex-basis: 100%; }
  #templatesDlg { margin: auto 0 0; width: 100vw; max-width: 100vw; max-height: 58dvh; border-radius: 16px 16px 0 0; }
  #templatesDlg::backdrop { background: rgba(42, 26, 31, .35); }
  #templatesDlg form { padding: 14px 14px 10px; }
  #templatesDlg h2 { font-size: 1.3rem; }
  #templateGrid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #templatesDlg .dlg-actions { position: sticky; bottom: -10px; background: var(--paper); padding: 8px 0; margin-top: 8px; }
}
