@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #e6e4f0;
  --paper: #ffffff;
  --ink: #363341;
  --muted: #7973b5;
  --accent: #a092fc;
  --accent-deep: #8876ff;
  --accent-soft: #efecff;
  --line: #cfc9e6;
  --line-soft: #e3dff1;
  --green: #7ef7c2;
  --green-ink: #174d38;
  --orange: #ffd09c;
  --orange-ink: #6b3d05;
  --red: #bc6078;
  --red-soft: #fbe7ec;
  --shadow: 0 10px 26px rgba(70, 60, 120, 0.07);
  --radius: 14px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: clamp(18px, 2vw, 32px) clamp(14px, 2.2vw, 36px) 40px;
}

/* ---------- topo ---------- */

.top { margin-bottom: 18px; }
.top .alert { margin-top: 12px; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.logo {
  display: block;
  width: min(300px, 62vw);
  height: auto;
}

a.btn { text-decoration: none; }

.intro {
  margin: 6px 0 0;
  max-width: 980px;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- colunas ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.9fr);
  gap: clamp(18px, 1.6vw, 28px);
  align-items: start;
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------- cards ---------- */

.card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.card h3 {
  margin: 4px 0 8px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
}

/* ---------- canvas ---------- */

.canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background:
    conic-gradient(#e9e7f2 0 25%, #f8f7fc 0 50%, #e9e7f2 0 75%, #f8f7fc 0) 0 0 / 16px 16px;
}

.preview-wrap { aspect-ratio: 1 / 1; }
.mock-wrap { aspect-ratio: 4 / 3; background: #a092fc; cursor: grab; }
.mock-wrap.is-dragging { cursor: grabbing; }
.mock-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}
.mock-wrap.checkerboard {
  background: conic-gradient(#e9e7f2 0 25%, #f8f7fc 0 50%, #e9e7f2 0 75%, #f8f7fc 0) 0 0 / 16px 16px;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.caption {
  margin: 8px 0 2px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  min-height: 14px;
}

/* ---------- barra de ícones ---------- */

.iconbar {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  margin-top: 12px;
}

.tip-balloon {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  margin: 0;
  padding: 10px 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.tip-balloon::after {
  content: "";
  position: absolute;
  left: 16%;
  bottom: -6px;
  border: 6px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}

.iconbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px 6px;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: #f2f0fa;
  color: var(--muted);
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}

#bar-preview .iconbtn {
  min-height: 78px;
  gap: 7px;
  padding: 10px 4px 9px;
}

.iconbtn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  opacity: 0.86;
}

#bar-preview .iconbtn img { width: 28px; height: 28px; }

.iconbtn span {
  font-size: 8px;
  line-height: 1.15;
  text-align: center;
  letter-spacing: -0.01em;
}

#bar-preview .iconbtn span { font-size: 9px; }

.iconbtn:hover { background: var(--accent-soft); }

.iconbtn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.iconbtn.active img { opacity: 1; }

.iconbtn.danger { color: var(--red); }
.iconbtn.danger img { filter: hue-rotate(300deg) saturate(0.8); }

/* ---------- campos ---------- */

.field {
  display: block;
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
}

.field select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 6px 26px 6px 9px;
  border: 1.5px solid var(--accent);
  border-radius: 7px;
  background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237973b5' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 8px center;
  font-size: 11px;
  font-weight: 400;
  appearance: none;
}

.field select:focus-visible,
.btn:focus-visible,
.iconbtn:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

.note, .hint {
  margin: 8px 0;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--muted);
}

.hint.center { text-align: center; }
.verso-alignment { padding: 7px 9px; border-radius: 7px; background: var(--accent-soft); }
.align-front { color: #2878d0; font-weight: 700; }
.align-back { color: #df3f7c; font-weight: 700; }

.warn-text {
  margin: 10px 0;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--red);
  font-weight: 700;
}

/* ---------- botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 18px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-deep);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: filter 0.12s, transform 0.12s;
}

.btn:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.btn.ghost {
  border-color: var(--line);
  color: var(--muted);
  font-weight: 400;
}

.btn.ghost.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.btn.wide { width: 100%; margin-top: 4px; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.row .btn { flex: 1; }

/* ---------- check ---------- */

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 12px;
  font-size: 9.5px;
  line-height: 1.55;
  cursor: pointer;
}

.check-line input {
  flex: none;
  width: 26px;
  height: 26px;
  margin: 1px 0 0;
  appearance: none;
  background: url("../assets/check-vazia.svg") center / contain no-repeat;
  cursor: pointer;
}

.check-line input:checked {
  background-image: url("../assets/check-ok.svg");
}

.check-line.small { font-size: 10.5px; margin-bottom: 8px; }
.check-line.small input { width: 22px; height: 22px; }

/* ---------- sliders ---------- */

.slider-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 8px 0 10px;
  font-size: 9.5px;
  color: var(--muted);
}

.slider-row input[type="range"] {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--line-soft) var(--fill, 50%));
}

.slider-row input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: var(--line-soft);
}

.slider-row input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 2px solid var(--accent);
  border-radius: 2px;
  background: #fff;
  transform: rotate(45deg);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent);
  border-radius: 2px;
  background: #fff;
  transform: rotate(45deg);
}

/* ---------- base ---------- */

.base-adjust {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 0 10px;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--accent-soft);
}

.base-adjust img { width: 30px; height: 30px; object-fit: contain; }
.base-adjust strong { display: block; font-size: 10.5px; }
.base-adjust .hint { margin: 2px 0 0; }

/* ---------- alerta e verificação ---------- */

.alert, .verify {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 10.5px;
  line-height: 1.5;
}

.alert {
  background: var(--orange);
  color: var(--orange-ink);
  border: 1.5px solid #f0b467;
}

.alert strong, .verify strong { display: block; font-size: 11.5px; margin-bottom: 2px; }

.alert p, .verify p { margin: 0; }

.verify {
  background: var(--green);
  color: var(--green-ink);
  border: 1.5px solid #57d9a4;
}

.verify.bad {
  background: var(--red-soft);
  color: #6d2438;
  border-color: var(--red);
}

/* ---------- status ---------- */

.status {
  margin: 18px 2px 0;
  font-size: 9.5px;
  color: var(--muted);
  text-align: center;
  min-height: 14px;
}

.site-foot {
  margin: 28px 2px 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.site-foot p { margin: 6px 0; }

.site-foot a {
  color: var(--accent-deep);
  font-weight: 700;
}

/* ---------- responsivo ---------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .col-right { order: 2; }
  .logo { width: min(250px, 68vw); }
  .iconbtn span { font-size: 7.5px; }
  #bar-preview .iconbtn { min-height: 74px; }
}

@media (min-width: 1900px) {
  .app { max-width: 1920px; }
  .layout { grid-template-columns: minmax(0, 1.55fr) minmax(400px, 0.9fr); }
  .card { padding: 20px 22px 22px; }
}

@media (max-width: 560px) {
  .app { padding: 14px 12px 32px; }
  .top-bar .btn { min-height: 44px; padding: 10px 18px; }
  .site-foot { font-size: 12px; margin-top: 22px; }
  .site-foot a { display: inline-block; padding: 12px 6px; }
  .card { padding: 13px 13px 15px; }
  .intro { font-size: 11.5px; }
  .iconbar { gap: 4px; }
  .iconbtn { padding: 6px 1px 5px; }
  .iconbtn img { width: 20px; height: 20px; }
  .iconbtn span { font-size: 6.6px; }
  #bar-preview .iconbtn { min-height: 68px; padding: 8px 1px 7px; gap: 5px; }
  #bar-preview .iconbtn img { width: 22px; height: 22px; }
  #bar-preview .iconbtn span { font-size: 7px; }
  .check-line { font-size: 9px; }
}
