* {
  box-sizing: border-box;
}

:root {
  --bg: #ebe4da;
  --sidebar: #faf7f2;
  --text: #2f2a25;
  --muted: #7a6b60;
  --border: #d7cabd;
  --accent: #8f725d;
  --accent-dark: #6f5847;
  --white: #ffffff;
  --dark: #29231f;
  --shadow: rgba(68, 52, 39, 0.22);
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Manrope, Arial, Helvetica, sans-serif;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 390px 1fr;
}

.sidebar {
  background: rgba(250, 247, 242, 0.96);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  padding: 26px 24px 30px;
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: min(240px, 86%);
  height: auto;
  object-fit: contain;
}

.psychology-symbol {
  color: var(--accent);
  font-family: "Times New Roman", Georgia, serif;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  margin-top: 2px;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 24px 0 13px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #5d5047;
  margin-bottom: 8px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.label-row span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--white);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 114, 93, 0.14);
}

textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.5;
}

input[type="file"] {
  padding: 10px;
}

input[type="color"] {
  height: 46px;
  padding: 5px;
}

input[type="range"] {
  border: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--accent);
}

.secondary-btn,
.download-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  transition: 0.2s ease;
}

.secondary-btn {
  background: #eadfd3;
  color: var(--text);
  padding: 12px 16px;
  margin-bottom: 4px;
}

.secondary-btn:hover {
  background: #ded0c1;
}

.download-btn {
  background: var(--dark);
  color: var(--white);
  padding: 15px 18px;
  margin-top: 8px;
}

.download-btn:hover {
  background: #171310;
}

.font-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
}

.font-option {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #4f433b;
  border-radius: 15px;
  padding: 10px 12px;
  cursor: pointer;
  transition: 0.2s ease;
  text-align: left;
}

.font-option:hover {
  background: #f2e9df;
  transform: translateY(-1px);
}

.font-option.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(143, 114, 93, 0.22);
}

.font-preview {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.font-name {
  display: block;
  margin-top: 4px;
  font-family: Inter, Arial, sans-serif;
  font-size: 12px;
  opacity: 0.82;
}

.align-toolbar,
.signature-align-toolbar,
.signature-position-toolbar {
  display: grid;
  gap: 8px;
}

.align-toolbar,
.signature-align-toolbar {
  grid-template-columns: repeat(3, 1fr);
}

.signature-position-toolbar {
  grid-template-columns: repeat(2, 1fr);
}

.align-btn,
.position-btn,
.signature-align-btn,
.signature-position-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #5e5148;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 800;
}

.align-btn,
.signature-align-btn,
.signature-position-btn {
  border-radius: 13px;
  padding: 10px 8px;
  font-size: 13px;
}

.align-btn:hover,
.position-btn:hover,
.signature-align-btn:hover,
.signature-position-btn:hover {
  background: #f2e9df;
}

.align-btn.active,
.position-btn.active,
.signature-align-btn.active,
.signature-position-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(143, 114, 93, 0.22);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  margin-bottom: 0;
}

.checkbox-line input {
  width: auto;
  accent-color: var(--accent);
}

.checkbox-line span {
  font-size: 14px;
  color: var(--text);
  font-weight: 800;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-auto-rows: 44px;
  gap: 9px;
  justify-content: center;
  margin-top: 4px;
}

.position-btn {
  border-radius: 13px;
  font-size: 0;
  line-height: 1;
  display: grid;
  place-items: center;
  color: #5e5148;
}

.position-btn.active {
  color: #ffffff;
}

.position-symbol {
  width: 18px;
  height: 18px;
  position: relative;
  display: block;
}

.position-symbol::before {
  content: "";
  position: absolute;
  width: 13px;
  height: 2px;
  background: currentColor;
  top: 8px;
  left: 2px;
  border-radius: 999px;
}

.position-symbol::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  top: 5px;
  right: 2px;
  transform: rotate(45deg);
  border-radius: 1px;
}

.pos-right {
  transform: rotate(0deg);
}

.pos-left {
  transform: rotate(180deg);
}

.pos-top {
  transform: rotate(-90deg);
}

.pos-bottom {
  transform: rotate(90deg);
}

.pos-top-right {
  transform: rotate(-45deg);
}

.pos-top-left {
  transform: rotate(-135deg);
}

.pos-bottom-right {
  transform: rotate(45deg);
}

.pos-bottom-left {
  transform: rotate(135deg);
}

.position-dot {
  width: 8px;
  height: 8px;
  display: block;
  border-radius: 50%;
  background: currentColor;
}

.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px 24px 34px;
  background: var(--bg);
}

.format-toolbar {
  width: min(980px, 96%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.format-btn {
  min-width: 112px;
  border: 1px solid var(--border);
  background: #faf7f2;
  color: #5e5148;
  border-radius: 17px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: 0.2s ease;
}

.format-btn:hover {
  background: #f2e9df;
  transform: translateY(-1px);
}

.format-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
  box-shadow: 0 16px 30px rgba(143, 114, 93, 0.3);
}

.format-icon {
  display: block;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.icon-square {
  width: 25px;
  height: 25px;
}

.icon-vertical {
  width: 21px;
  height: 27px;
}

.icon-story {
  width: 18px;
  height: 32px;
}

.icon-horizontal {
  width: 35px;
  height: 18px;
}

.format-name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.format-size {
  font-size: 12px;
  opacity: 0.86;
  line-height: 1;
}

.format-info {
  width: min(980px, 96%);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.canvas-shell {
  width: min(780px, 96%);
  background: linear-gradient(180deg, #fffdfa 0%, #f4ede5 100%);
  padding: 16px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 30px 90px var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
  background: #ddd3c8;
  cursor: default;
}

/* Desktop: a página não rola inteira.
   A barra lateral e o preview rolam separadamente. */
@media (min-width: 1101px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .preview-area {
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .canvas-shell {
    margin-bottom: 40px;
  }
}

@media (max-width: 1100px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  }

  .preview-area {
    height: auto;
    overflow: visible;
    padding-top: 22px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 20px 16px 24px;
  }

  .format-btn {
    min-width: 96px;
    padding: 10px 12px;
  }

  .position-grid {
    grid-template-columns: repeat(3, 48px);
  }

  .canvas-shell {
    padding: 10px;
    border-radius: 22px;
  }
}