﻿:root {
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #0f172a;
  --muted: #52607a;
  --line: #dce3ef;
  --line-strong: #c9d4e8;
  --primary: #0a66ff;
  --danger: #b42336;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.12);
  --radius: 16px;
}

@font-face {
  font-family: "ApproachMonoTrialLt";
  src: url("./Fontes/ApproachMonoTRIAL-Lt.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "Fraunces72Black";
  src: url("./Fontes/Fraunces_72pt-Black.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "NanamiExtralight";
  src: url("./Fontes/nanami-extralight.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "SFProTextHeavy";
  src: url("./Fontes/SF-Pro-Text-Heavy.ttf") format("truetype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}

.app-shell {
  padding: 0;
  min-height: 100vh;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  position: fixed;
  top: 0;
  left: 0;
  width: 420px;
  height: 100vh;
  z-index: 40;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  border-radius: 0;
  box-shadow: none;
  border-top: none;
  border-bottom: none;
  border-left: none;
}

.panel-head h1 {
  margin: 2px 0 0;
  font-family: "Sora", sans-serif;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: #5b6f91;
  font-weight: 700;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a7a97;
}

.background-panel,
.element-panel,
.layers {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-soft);
}

.tool-strip {
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f2f6fe;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 52px;
  flex-shrink: 0;
}

.tool-inline {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.bg-slots {
  display: grid;
  gap: 8px;
}

.bg-slot-hidden {
  display: none !important;
}

.tool-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #1f3358;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.tool-btn.active {
  border-color: #0a66ff;
  background: #eaf2ff;
  color: #0a66ff;
  box-shadow: inset 0 0 0 1px #5f9cff;
}

.background-panel {
  padding: 8px;
}

.element-panel {
  display: block;
}

.element-panel.compact {
  padding: 8px;
}

.corner-add-btn {
  border: none;
  background: transparent;
  color: #193254;
  border-radius: 6px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}

.corner-add-btn i {
  font-size: 14px;
  line-height: 1;
}

.corner-add-btn:hover {
  color: #0a66ff;
  background: transparent;
}

.hidden-file-input {
  display: none;
}

.panel-toggle {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: #eaf1fb;
  color: #193254;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  cursor: pointer;
}

.panel-toggle-static {
  cursor: default;
}

.panel-toggle i {
  transition: transform 0.2s ease;
}

.panel-toggle[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.background-content {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.menu-content {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.stack {
  display: grid;
  gap: 10px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field.check {
  align-content: end;
}

input,
select,
textarea,
button {
  font: inherit;
}

input[type="text"],
textarea,
select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input[type="range"] {
  width: 100%;
}

input[type="file"] {
  font-size: 12px;
  color: #41516f;
}

.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #1b2b4b;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  border: none;
  color: #fff;
  background: linear-gradient(180deg, #2a7bff 0%, var(--primary) 100%);
}

.btn.ghost {
  background: #eef3fb;
}

.btn.danger {
  border-color: #f1c7cd;
  color: var(--danger);
  background: #fff5f6;
}

.btn:disabled,
.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.align-end {
  align-self: end;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.layers-front-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.layers-front-btn.icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
}

#layerList {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.layer-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #2d3d5c;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layer-item.active {
  border-color: #7ea8ff;
  background: #edf4ff;
}

.layer-item.dragging {
  opacity: 0.35;
}

.layer-item.drag-over {
  border-color: #0a66ff;
}

.layer-item.drag-over-before {
  box-shadow: inset 0 3px 0 #0a66ff;
}

.layer-item.drag-over-after {
  box-shadow: inset 0 -3px 0 #0a66ff;
}

.layer-delete {
  border: 1px solid #f1c7cd;
  background: #fff5f6;
  color: #b42336;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.canvas-wrap {
  display: grid;
  grid-template-columns: auto min(44vh, 460px) 320px;
  grid-template-rows: auto auto auto;
  column-gap: 8px;
  row-gap: 12px;
  align-content: center;
  justify-content: center;
  overflow: visible;
  margin-left: 420px;
  padding: 16px 20px;
  min-height: calc(100vh - 40px);
}

.text-toolbar {
  width: 320px;
  grid-column: 3;
  grid-row: 2;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffffcc;
  backdrop-filter: blur(5px);
  padding: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.text-toolbar .text-field {
  flex: 1 1 120px;
}

.text-toolbar .text-field.grow {
  flex: 1 1 100%;
}

.text-toolbar .text-field.compact {
  flex: 0 0 90px;
}

.text-align-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.text-align-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #1b2b4b;
  border-radius: 8px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.text-align-btn.active {
  border-color: #5f9cff;
  background: #eaf2ff;
  color: #0a66ff;
}

.text-bg-control {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 6px;
  align-items: center;
}

.text-bg-none-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  position: relative;
}

.text-bg-none-btn::before,
.text-bg-none-btn::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 17px;
  height: 2px;
  background: #d11b2d;
}

.text-bg-none-btn::before {
  transform: rotate(45deg);
}

.text-bg-none-btn::after {
  transform: rotate(-45deg);
}

.text-bg-none-btn.active {
  border-color: #d11b2d;
  box-shadow: 0 0 0 1px rgba(209, 27, 45, 0.2) inset;
}

.text-bg-control input[type="color"] {
  height: 36px;
  padding: 4px;
}

.text-toolbar textarea {
  min-height: 62px;
}

.text-shadow-toggle-btn {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: #1b2b4b;
  border-radius: 8px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}

.text-shadow-toggle-btn[aria-expanded="true"] {
  border-color: #5f9cff;
  background: #eaf2ff;
  color: #0a66ff;
}

.text-shadow-panel {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(201, 212, 232, 0.85);
  border-radius: 10px;
  background: rgba(250, 252, 255, 0.88);
}

.text-shadow-panel .text-field {
  flex: 1 1 120px;
}

.text-shadow-check {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1b2b4b;
  font-size: 13px;
  font-weight: 600;
}

.text-shadow-check input {
  margin: 0;
}

.canvas-stage {
  grid-column: 2;
  grid-row: 2;
  justify-self: center;
  align-self: center;
  position: relative;
  overflow: visible;
  width: min(44vh, 460px);
  aspect-ratio: 9 / 16;
}

.canvas-frame {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background: #0a0f1c;
  border: 1px solid #d2ddf0;
  box-shadow: 0 30px 70px rgba(13, 23, 44, 0.25);
}

.canvas-stage.drag-over .canvas-frame {
  border-color: #3ba8ff;
  box-shadow:
    0 0 0 2px rgba(59, 168, 255, 0.35),
    0 30px 70px rgba(13, 23, 44, 0.25);
}

.workspace-tools {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  align-self: start;
}

.workspace-tools .tool-inline {
  width: 220px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 24px rgba(9, 18, 35, 0.18);
}

#storyCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.content-zoom-hud {
  position: absolute;
  left: calc(100% + 10px);
  right: auto;
  bottom: 10px;
  z-index: 16;
  width: auto;
  display: grid;
  gap: 6px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(117, 138, 170, 0.72);
  background: #4f5866;
  color: #ebf4ff;
  pointer-events: auto;
}

.content-zoom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.content-zoom-pct {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.content-zoom-reset {
  border: 1px solid rgba(183, 219, 255, 0.55);
  background: rgba(7, 13, 24, 0.52);
  color: #f5f9ff;
  border-radius: 6px;
  padding: 2px 6px;
  height: 21px;
  font-size: 10px;
  cursor: pointer;
}

.content-zoom-reset:hover {
  border-color: rgba(78, 241, 255, 0.85);
  color: #d7feff;
}

.group-context-menu {
  position: absolute;
  z-index: 40;
  min-width: 132px;
  display: grid;
  gap: 6px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(104, 120, 148, 0.72);
  background: rgba(36, 44, 58, 0.98);
  box-shadow: 0 12px 28px rgba(10, 16, 28, 0.28);
}

.group-context-menu button {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(179, 197, 223, 0.42);
  background: rgba(14, 20, 32, 0.9);
  color: #f1f6ff;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.group-context-menu button:hover {
  border-color: #76b9ff;
  color: #d7edff;
}

.emoji-grid {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  max-height: 320px;
  overflow: auto;
  align-content: start;
}

.emoji-grid .hint {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-style: dashed;
  background: transparent;
  grid-column: 1 / -1;
}

.emoji-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #213252;
  padding: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-tile:hover {
  border-color: #7ea8ff;
  background: #f4f8ff;
}

.emoji-tile img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.inline-wrap {
  position: absolute;
  display: block;
  z-index: 20;
}

.inline-editor {
  position: relative;
  border: 2px solid #8ab0ff;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  padding: 8px;
  box-shadow: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  resize: none;
}

.actions {
  width: 100%;
  grid-column: 2;
  grid-row: 3;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.actions .btn {
  padding: 7px 10px;
}

@media (max-width: 1080px) {
  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .controls {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    order: 2;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
  }

  .canvas-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    margin-left: 0;
    padding: 0;
    min-height: auto;
    order: 1;
    justify-items: center;
  }

  .workspace-tools {
    position: static;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin-left: 0;
    gap: 8px;
  }

  .workspace-tools .tool-inline {
    width: min(62vw, 250px);
  }

  .text-toolbar {
    width: min(88vw, 430px);
    grid-column: 1;
    grid-row: 2;
  }

  .canvas-frame {
    width: 100%;
    height: 100%;
  }

  .canvas-stage {
    width: min(88vw, 430px);
    grid-column: 1;
    grid-row: 3;
  }

  .actions {
    width: min(88vw, 430px);
    grid-column: 1;
    grid-row: 4;
  }

  .emoji-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}
