/* Print studio chrome, in the same style as the schedule page.
   The sheet itself (the models) is styled in paper.css. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --panel: #f5f5f3;
  --stage: #ececea;
  --text: #17181a;
  --muted: #6c7078;
  --faint: #a4a8ae;
  --line: #e7e7e4;
  --accent: #cc0000;
  --accent-text: #ffffff;
  --accent-soft: #fdeeee;
  --shadow: 0 12px 40px rgba(0, 0, 0, .18);
  --bar-h: 56px;
  /* Model miniatures: width, and the matching scale of a 297mm sheet. */
  --mini-w: 138px;
  --mini-s: 0.1229;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --panel: #191b1e;
    --stage: #0a0b0c;
    --text: #ececed;
    --muted: #9a9ea6;
    --faint: #62666d;
    --line: #26292d;
    --accent: #ff5a4f;
    --accent-text: #1a0605;
    --accent-soft: #2a1716;
    --shadow: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
h1, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; stroke-width: 1.8; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-weight: 550; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel); }
.btn.icon { width: 36px; padding: 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wide { width: 100%; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.link { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

/* ---------- top bar ---------- */
.bar {
  grid-area: bar; z-index: 6;
  display: flex; align-items: center; gap: 10px;
  height: var(--bar-h); padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.person { display: flex; align-items: center; gap: 4px; margin: 0 auto; min-width: 0; }
.who { min-width: 0; max-width: 340px; gap: 8px; }
.who #who-name { overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.who small { color: var(--muted); font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.who small:empty { display: none; }
.who .ic { width: 15px; height: 15px; color: var(--muted); }

/* ---------- stage ---------- */
.stage { grid-area: stage; position: relative; display: flex; padding: 36px; overflow: auto; background: var(--stage); }
.stage.drop { box-shadow: inset 0 0 0 3px var(--accent); }
.scaler { flex: none; margin: auto; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 10px 30px rgba(0, 0, 0, .14); }
.sheet .hot { outline-color: var(--accent) !important; }
.sheet.hot { outline-color: var(--accent); }
.sheet-empty {
  position: absolute; inset: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #6c7078; font: 400 20px system-ui, sans-serif;
}
.sheet-empty .ic { width: 64px; height: 64px; color: #cc0000; stroke-width: 1.4; }
.sheet-empty strong { color: #17181a; font-size: 34px; letter-spacing: -.01em; }

.app:has(.phototool:not([hidden])) .zoom { display: none; }
.zoom {
  position: fixed; z-index: 4; right: calc(348px + 14px); bottom: 14px;
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.zoom button { display: grid; place-items: center; height: 30px; min-width: 32px; padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 550; }
.zoom button:hover { color: var(--text); }
.zoom #zoom-fit { min-width: 68px; border-inline: 1px solid var(--line); }
.zoom .ic { width: 14px; height: 14px; }

/* ---------- side panel ---------- */
.side { grid-area: side; display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-left: 1px solid var(--line); }
.tabs { flex: none; display: flex; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { display: flex; align-items: center; gap: 7px; padding: 13px 0 11px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs button:hover { color: var(--text); }
.tabs b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); font-size: 11px; font-weight: 650; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button[aria-selected="true"] b { background: var(--text); color: var(--bg); box-shadow: none; }
.pane { flex: 1; min-height: 0; overflow: hidden auto; padding: 16px; scrollbar-width: thin; }

/* Models: real miniatures of the sheet */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--mini-w) + 14px), 1fr)); gap: 10px; }
.model { display: grid; gap: 1px; justify-items: start; align-content: start; padding: 6px; border: 1px solid var(--line); border-radius: 10px; text-align: left; }
.model:hover { background: var(--panel); }
.model.on { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.model strong { margin-top: 7px; font-weight: 650; }
.model small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.mini {
  justify-self: center;
  width: var(--mini-w); height: calc(var(--mini-w) * 210 / 297);
  overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #fff; pointer-events: none;
}
.mini .sheet { --scale: var(--mini-s); }

/* Looks: one row each */
.pane h3 { display: flex; align-items: baseline; gap: 8px; margin: 20px 0 6px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pane h3:first-child { margin-top: 0; }
.pane h3 small { font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--faint); }
.looks { border-top: 1px solid var(--line); }
.look { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.look > button:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; height: 42px; text-align: left; }
.look > button:first-child span:last-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.look > button:first-child:hover { color: var(--accent); }
.look.on { font-weight: 650; }
.look .ic { margin-left: auto; color: var(--accent); }
.look .del { display: grid; place-items: center; width: 36px; height: 36px; color: var(--faint); }
.look .del:hover { color: var(--accent); }
.look .del .ic { margin: 0; color: inherit; width: 16px; height: 16px; }
.chip { flex: none; display: flex; align-items: center; justify-content: center; gap: 3px; width: 46px; height: 26px; border: 1px solid; border-radius: 5px; }
.chip i { width: 6px; height: 12px; border-radius: 2px; }
.save { display: flex; gap: 6px; margin-top: 20px; }
.io { display: flex; gap: 16px; margin-top: 12px; }

/* ---------- settings controls ---------- */
.tip { margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.inspector { margin: 0 -16px; border-bottom: 1px solid var(--line); }
.group { border-top: 1px solid var(--line); }
.group summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-weight: 600; list-style: none; cursor: pointer; user-select: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary:hover { background: var(--panel); }
.group summary .ic { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.group[open] summary .ic { transform: rotate(180deg); }
.group.flash summary { animation: flash 1s; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } }
.group-body { display: grid; gap: 14px; padding: 2px 16px 16px; }
.inspector > .btn { width: calc(100% - 32px); margin: 14px 16px; }

input[type="text"], input[type="search"], select {
  width: 100%; min-width: 0; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.f { display: grid; gap: 6px; min-width: 0; }
.f-l { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.f-note { margin: -4px 0; color: var(--muted); font-size: 12px; }

/* Sliders: a thin track filled up to the handle (--p), with a number box for exact values. */
.f-range .f-l { align-items: center; }
.num { display: inline-flex; align-items: baseline; gap: 1px; padding: 1px 6px; border-radius: 6px; color: var(--text); box-shadow: inset 0 0 0 1px transparent; }
.num:hover, .num:focus-within { box-shadow: inset 0 0 0 1px var(--line); background: var(--bg); }
.num input { width: 3.2ch; height: 20px; padding: 0; border: 0; background: none; text-align: right; font-weight: 550; -moz-appearance: textfield; appearance: textfield; outline: 0; }
.num input::-webkit-inner-spin-button, .num input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num i { font-style: normal; color: var(--muted); font-size: 12px; }

.slider { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 22px; margin: 0; background: none; cursor: pointer; --p: 50%; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--p), var(--line) var(--p)); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--p), var(--line) var(--p)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text); transition: transform .12s; }
.slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text); transition: transform .12s; }
.slider:hover::-webkit-slider-thumb, .slider:focus-visible::-webkit-slider-thumb { border-color: var(--accent); transform: scale(1.15); }
.slider:hover::-moz-range-thumb, .slider:focus-visible::-moz-range-thumb { border-color: var(--accent); transform: scale(1.15); }
.slider:active::-webkit-slider-thumb { background: var(--accent); border-color: var(--accent); }
.slider:active::-moz-range-thumb { background: var(--accent); border-color: var(--accent); }
.slider:focus-visible { outline: 0; }

.f-toggle { grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.f-toggle .f-l { color: var(--text); font-size: 14px; }
.f-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.f-toggle i { position: relative; width: 36px; height: 20px; border-radius: 99px; background: var(--faint); transition: background .15s; }
.f-toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.f-toggle input:checked + i { background: var(--accent); }
.f-toggle input:checked + i::after { transform: translateX(16px); }
.f-toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; padding: 2px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.seg button { flex: 1; height: 30px; padding: 0 6px; border-radius: 6px; font-size: 13px; font-weight: 550; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line); }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.swatches label { display: grid; gap: 3px; min-width: 0; cursor: pointer; }
.swatches span { overflow: hidden; color: var(--muted); font-size: 10.5px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
input[type="color"] { width: 100%; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: none; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.f-color { grid-template-columns: 1fr 56px; align-items: center; }
.f-color .f-l { color: var(--text); font-size: 14px; }

.f-image { grid-template-columns: 84px 1fr; align-items: center; gap: 12px; }
.f-image img { width: 84px; height: 62px; border: 1px solid var(--line); border-radius: 7px; object-fit: cover; }
.f-image div { display: grid; gap: 6px; justify-items: start; }
.f-image span { display: flex; gap: 14px; }
.f-drop { justify-items: center; gap: 4px; width: 100%; padding: 18px 12px; border: 1.5px dashed var(--faint); border-radius: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.f-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.f-drop .ic { width: 24px; height: 24px; color: var(--text); }
.f-drop strong { color: var(--text); font-size: 14px; font-weight: 600; }

/* ---------- photo mode: the bar under the preview ---------- */
.sheet.photo-mode .photo-target { outline: 3px solid var(--accent); outline-offset: -3px; }
.sheet.photo-mode .photo-target, .sheet.photo-mode .photo-target * { cursor: grab; touch-action: none; }
.sheet.photo-mode.grabbing .photo-target, .sheet.photo-mode.grabbing .photo-target * { cursor: grabbing; }
.phototool {
  position: fixed; z-index: 7; bottom: 14px; left: calc((100vw - 348px) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 348px - 28px);
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow);
}
.pt-hint { display: flex; align-items: center; gap: 6px; padding: 0 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.pt-zoom { display: flex; align-items: center; gap: 6px; padding: 0 4px; color: var(--muted); }
.pt-zoom .slider { width: 130px; }
.pt-zoom .ic { width: 14px; height: 14px; }
.phototool .seg button { padding: 0 10px; }

/* ---------- click-to-edit popup ---------- */
.pop {
  position: fixed; z-index: 20; width: 300px; max-height: min(540px, calc(100dvh - 16px));
  display: flex; flex-direction: column; gap: 12px; padding: 12px 14px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); box-shadow: var(--shadow);
}
.pop-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px -4px 0; font-size: 15px; }
.pop-head .btn { border-color: transparent; }
.pop-body { display: grid; gap: 14px; overflow: hidden auto; padding: 2px 10px 2px 2px; scrollbar-width: thin; }
.pop-body:empty::before { content: "Nada para ajustar aqui."; color: var(--muted); }
.pop .link { justify-self: start; align-self: flex-start; }

/* ---------- person picker ---------- */
.dlg {
  width: min(400px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 24px)); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 12px 18px; font-size: 17px; letter-spacing: -.01em; }
.search { position: relative; flex: none; display: block; margin: 0 18px 4px; }
.search .ic { position: absolute; top: 11px; left: 12px; color: var(--muted); }
.search input { height: 40px; padding-left: 38px; }
.people { overflow-y: auto; padding: 0 18px 14px; }
.people h3 { margin: 16px 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.people button { display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; border-bottom: 1px solid var(--line); text-align: left; }
.people button:hover { color: var(--accent); }
.people button.on { font-weight: 650; }
.people .key { width: 14px; height: 14px; color: var(--faint); }
.people .tick { margin-left: auto; color: var(--accent); }
.people .none { margin: 28px 0; color: var(--muted); text-align: center; }

/* ---------- desktop: fixed app window ---------- */
@media (min-width: 900px) {
  body { overflow: hidden; }
  .app {
    display: grid; height: 100dvh;
    grid-template: "bar bar" var(--bar-h) "stage side" minmax(0, 1fr) / minmax(0, 1fr) 348px;
  }
}

/* ---------- phone: preview pinned on top, panel scrolls below ---------- */
@media (max-width: 899px) {
  :root { --stage-h: calc((100vw - 24px) * 210 / 297 + 24px); }
  .app { display: flex; flex-direction: column; min-height: 100dvh; }
  .bar { position: sticky; top: 0; padding: 0 10px; gap: 6px; }
  .bar h1, .who small, #prev, #next, .zoom, .tip { display: none; }
  .person { margin: 0; flex: 1; }
  .who { flex: 1; justify-content: space-between; max-width: none; }
  .stage { position: sticky; top: var(--bar-h); z-index: 5; flex: none; height: var(--stage-h); padding: 12px; overflow: hidden; }
  .side { flex: 1; border: 0; }
  .tabs { position: sticky; top: calc(var(--bar-h) + var(--stage-h)); z-index: 5; background: var(--bg); }
  .pane { overflow: visible; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .group:first-child { border-top: 0; }
  .pop { left: 0; right: 0; bottom: 0; width: auto; max-height: 52dvh; border-width: 1px 0 0; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .dlg { width: 100vw; max-width: none; max-height: 86dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 16px 16px 0 0; }
  .seg button { height: 34px; }
  input[type="color"] { height: 36px; }
  .phototool { left: 0; right: 0; bottom: 0; transform: none; max-width: none; flex-wrap: wrap; justify-content: flex-end; border-width: 1px 0 0; border-radius: 16px 16px 0 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .pt-hint { flex-basis: 100%; }
  .pt-zoom { flex: 1 1 100%; }
  .pt-zoom .slider { width: auto; flex: 1; }
  .phototool .seg { margin-right: auto; }
}

/* Outside photo mode a picture is just another clickable part of the sheet. */
.sheet:not(.photo-mode) .can-drag { cursor: pointer; touch-action: auto; }
