/* The customizer's own UI (DESIGN.md section 5). Loaded only on
   /templates/<cat>/<slug>/customize/. The shell is site.css; this is the
   panel, the stage, the field components, the proof and the bars. */

.cz-bar {
  position: sticky; top: 0; z-index: 20; background: var(--sheet); border-bottom: 1px solid var(--rule);
}
.cz-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.cz-bar .title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cz-bar .title .name { font-family: var(--serif); font-weight: 500; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cz-bar .title .back { font-size: 13px; color: var(--pencil); text-decoration: none; white-space: nowrap; }
.cz-bar .title .back:hover { color: var(--accent); }
.cz-bar .buy { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.cz-bar .buy .note { font-size: 12px; color: var(--pencil); max-width: 34em; text-align: right; }

.cz { display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.cz-panel { background: var(--sheet); padding: 24px 24px 40px; display: flex; flex-direction: column; gap: 26px; border-right: 1px solid var(--rule); }
.cz-panel fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
.cz-panel legend { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pencil); padding: 0; margin-bottom: 10px; }
.cz-panel .row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cz-panel .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cz-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--pencil); border-top: 1px solid var(--rule); padding-top: 16px; }
.cz-foot button { background: none; border: 0; padding: 0; color: var(--pencil); text-decoration: underline; cursor: pointer; font-size: 13px; }
.cz-foot button:hover { color: var(--accent); }

/* Field components. */
.field textarea { resize: vertical; min-height: 88px; }
.field .warn[hidden] { display: none; }
.field.over input, .field.over textarea { border-color: var(--accent); }
.field.over .count { color: var(--accent); }
.field .hint { font-size: 12px; color: var(--pencil); }
.field .suffix { position: relative; }
.field .suffix input { padding-right: 34px; }
.field .suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--pencil); font-family: var(--mono); font-size: 13px; pointer-events: none; }
/* A select never shows a bare native caret; the chevron sits at right 14px. */
.field select {
  font: 16px/1.4 var(--sans); color: var(--ink); padding: 10px 38px 10px 12px; border: 1px solid var(--rule); background: var(--sheet); border-radius: 0; width: 100%; min-height: 44px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 5.5l4 4 4-4' fill='none' stroke='%2317181a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 14px;
}
.field select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--ink); }
.switch { width: 38px; height: 22px; border-radius: 11px; background: var(--ink); position: relative; border: 0; padding: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 120ms ease, right 120ms ease; }
.switch[aria-checked="false"] { background: var(--rule); }
.switch[aria-checked="false"]::after { right: auto; left: 3px; }
.dropzone {
  border: 1px dashed var(--rule); background: var(--desk); padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 64px; position: relative;
}
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.has { border-style: solid; background: var(--sheet); }
.dropzone img { height: 40px; width: auto; max-width: 120px; }
.dropzone .text { font-size: 14px; color: var(--ink-2); }
.dropzone .remove { font-size: 13px; color: var(--pencil); text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; position: relative; z-index: 1; }
.dropzone .remove:hover { color: var(--accent); }
/* The list editor. */
.list { display: grid; gap: 10px; }
.list .lrow {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) 24px; grid-template-areas: "grip main rm" "grip nums rm"; gap: 6px 8px; align-items: start;
  padding: 10px 0; border-bottom: 1px solid var(--rule);
}
.list .lrow input { min-height: 40px; padding: 8px 10px; font-size: 15px; width: 100%; font-family: var(--sans); color: var(--ink); border: 1px solid var(--rule); background: var(--sheet); border-radius: 0; }
.list .lrow .grip { grid-area: grip; color: var(--pencil); cursor: grab; font-size: 14px; line-height: 40px; text-align: center; user-select: none; }
.list .lrow .lmain { grid-area: main; }
.list .lrow .lnums { grid-area: nums; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.list .lrow .ncell { display: grid; gap: 3px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pencil); }
.list .lrow.dragging { opacity: 0.5; }
.list .lrow .rm { grid-area: rm; background: none; border: 0; padding: 0; color: var(--pencil); cursor: pointer; font-size: 20px; line-height: 40px; }
.list .lrow .rm:hover { color: var(--accent); }
.list .lrow input.n { text-align: right; font-variant-numeric: tabular-nums; }
.list .add { justify-self: start; font-size: 14px; padding: 10px 14px; min-height: 40px; }
.list .add[disabled] { background: transparent; color: var(--pencil); border-color: var(--rule); cursor: not-allowed; }
/* Paper size. */
.seg { display: inline-flex; border: 1px solid var(--ink); }
.seg button { background: transparent; border: 0; padding: 10px 16px; font-size: 14px; color: var(--ink); cursor: pointer; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button + button { border-left: 1px solid var(--ink); }

/* The stage. */
.cz-stage { background: var(--desk-2); padding: 32px; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-content: start; gap: 14px; position: sticky; top: 62px; height: calc(100vh - 62px); box-sizing: border-box; min-width: 0; }
.cz-stage .sheet-frame { width: 100%; max-width: 100%; }
.cz-stage .paper { position: relative; margin: 0 auto; }
.cz-stage .paper iframe { border: 0; display: block; transform-origin: 0 0; background: #fff; }
.proof {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='180'%3E%3Ctext x='130' y='100' text-anchor='middle' font-family='ui-monospace,Menlo,monospace' font-size='44' font-weight='700' letter-spacing='12' fill='%23b3261e' fill-opacity='0.08' transform='rotate(-22 130 100)'%3EPROOF%3C/text%3E%3C/svg%3E");
}
.cz-stage .caption { font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.cz-stage .expand { display: none; }

/* Mobile bottom bar. */
.cz-bottom { display: none; }

@media (max-width: 980px) {
  .cz { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .cz-bar .buy { display: none; }
  .cz-stage { position: relative; top: 0; height: 40vh; min-height: 260px; padding: 16px; order: -1; grid-template-rows: minmax(0, 1fr) auto; }
  .cz-stage.open { height: auto; }
  .cz-stage .expand { display: block; position: absolute; right: 12px; bottom: 10px; font-family: var(--mono); font-size: 11px; color: var(--pencil); background: none; border: 0; text-decoration: underline; cursor: pointer; }
  .cz-stage .caption { display: none; }
  .cz-panel { border-right: 0; padding: 20px 16px 140px; }
  .cz-bottom {
    display: flex; flex-direction: column; gap: 6px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--sheet); border-top: 1px solid var(--rule); padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .cz-bottom .btn { width: 100%; }
  .cz-bottom .note { font-size: 12px; color: var(--pencil); text-align: center; }
}

@media print {
  .cz-stage, .cz-bar, .cz-bottom { display: none !important; }
}
