:root {
  --bg: #253237;
  --card: #2f4048;
  --muted: #c2dfe3;
  --accent: #9db4c0;
  --glass: rgba(224, 251, 252, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box
}

html {
  min-height: 100%;
}

.hidden {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: 'Arimo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #e6eef8;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(180deg, #253237 0%, #2f4048 100%);
  background-size: 120px 120px, 120px 120px, auto;
  background-position: 0 0, 0 0, 0 0;
}

.header {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 26px 18px;
  border-bottom: 1px solid rgba(194, 223, 227, 0.12);
  background-image: url('../assets/images/logo.webp'), linear-gradient(90deg, rgba(194, 223, 227, 0.18), rgba(37, 50, 55, 0.96));
  background-repeat: no-repeat, no-repeat;
  background-position: 20px 50%, center;
  background-size: auto 100%, cover;
  user-select: none;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1200px, 100%);
}

.header-copy {
  flex: 1;
  min-width: 0;
  max-width: 480px;
  padding-left: 220px;
}

.header-copy-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.hero-panel {
  display: none;
}

.hero-panel-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  color: var(--accent)
}

.header .subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px
}

.locale-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px
}

.locale-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: linear-gradient(180deg, #3d4855 0%, #55616f 100%);
  cursor: pointer;
  font-size: 16px;
  color: #fff;
  transition: transform .15s, filter .15s, border-color .15s, box-shadow .15s;
}

.locale-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  border-color: rgba(255, 255, 255, 0.45);
}

.locale-btn.active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.locale-btn[data-lang="en"],
.locale-btn[data-lang="pt"] {
  background: linear-gradient(180deg, #3d4855 0%, #55616f 100%);
}

.app {
  display: flex;
  gap: 20px;
  padding: 18px;
  width: min(1200px, 100%);
  margin: 18px auto 0;
  flex: 1;
}

.left {
  flex: 1;
  min-width: 0;
  position: relative;
}

.right {
  width: 360px;
  min-width: 0;
}

.uploader {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px 12px;
}

.select-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 0 16px 16px;
}

.select-panel-copy {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

.preview-wrap {
  position: relative;
}

body:not(.file-loaded) .preview-wrap {
  min-height: 280px;
}

.preview-uploader {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 2;
  pointer-events: none;
}

.preview-uploader .preview-button {
  pointer-events: auto;
  padding: 20px 32px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  color: #f1f7f8;
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.18);
  font-size: 1.05rem;
  min-width: 280px;
  line-height: 1.2;
}

body:not(.file-loaded) .preview-uploader {
  display: flex;
}

body:not(.file-loaded) .uploader {
  display: none;
}

body.file-loaded .preview-uploader {
  display: none;
}

body:not(.file-loaded) .canvas-wrap {
  display: none;
}

body.file-loaded .canvas-wrap {
  display: block;
}

.button {
  background: var(--glass);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: filter .15s, border-color .15s, background .15s, box-shadow .15s;
}

.button-icon {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  object-fit: contain;
}

.button:hover {
  filter: brightness(1.1);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.button input {
  display: none
}

.info {
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.info-text.error {
  color: #f4c0c0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(159, 214, 255, 0.9);
  outline-offset: 2px;
}

.info-tooltip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  padding: 0;
}

.info-tooltip:hover,
.info-tooltip:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
}

.preview-wrap {
  background: linear-gradient(180deg, #82c8e236, transparent);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: inset 0px 0px 2px rgb(80 133 157);
  margin: 0 16px;
}

.canvas-wrap {
  position: relative;
  overflow: auto;
  max-height: 70vh;
  border-radius: 8px;
  padding: 8px;
}

.zoom-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 16, 26, 0.9);
  color: #f8fbff;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.zoom-badge.hidden {
  display: none;
}

.viewport {
  display: inline-block;
  position: relative;
  transform-origin: 0 0
}

.canvas-base {
  display: block;
  max-width: none;
  height: auto
}

#imgCanvas {
  background: #09101a;
  position: relative;
  z-index: 1
}

.overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  background: transparent;
  z-index: 2
}

.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 18px;
  background: linear-gradient(90deg, rgba(194, 223, 227, 0.08), transparent);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s
}

.canvas-wrap.drag-over .drop-overlay {
  opacity: 1;
  pointer-events: auto
}

.canvas-wrap.drag-over {
  outline: 2px dashed rgba(194, 223, 227, 0.38);
  border-radius: 10px
}

.controls {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  color: #dce9ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.controls h2 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: #fff
}

.controls label {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.controls label span,
.controls label legend {
  font-weight: 500;
  white-space: nowrap;
}

.controls .field-row {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.controls .field-row>label:not(.toggle-switch) {
  justify-self: end;
}

.controls .field-row>.input-with-actions,
.controls .field-row>.toggle-switch {
  justify-self: start;
}

.controls input[type=number] {
  width: 120px;
  min-width: 100px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #e6eef8;
}

.controls .input-with-actions input[type=color] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid rgb(255, 255, 255);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.controls .input-with-actions input[type=color]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.controls .input-with-actions input[type=color]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.controls input[type=number]:focus-visible {
  outline: 2px solid rgba(159, 214, 255, 0.9);
  outline-offset: 2px;
}

.controls .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-row {
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;
}

.grid-toggle {
  flex: 1;
  min-width: 190px;
}

.grid-color {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.grid-color input {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

input[type=color]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
  padding: 0;
}

input[type=color]::-webkit-color-swatch-wrapper {
  border: none;
  border-radius: 50%;
  padding: 0;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: auto;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch-control input[type=checkbox] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.switch {
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  position: relative;
  transition: background .18s ease, border-color .18s ease;
  flex: none;
}

.toggle-switch .switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cfd8e6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform .18s ease, background .18s ease;
}

.toggle-switch input[type=checkbox]:checked~.switch {
  background: linear-gradient(135deg, #7f98af 0%, #d6e4f0 55%, #f4fbff 100%);
  border-color: rgba(255, 255, 255, 0.34);
}

.toggle-switch input[type=checkbox]:checked~.switch::before {
  transform: translateX(18px);
  background: #9aa8bb;
}

.toggle-switch:hover .switch {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.controls .input-with-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.controls .input-with-actions .icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(224, 251, 252, 0.18);
  background: rgba(224, 251, 252, 0.08);
  color: #e6eef8;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: background .15s, border-color .15s
}

.controls .input-with-actions .icon-btn:hover {
  background: rgba(220, 224, 229, 0.16);
  border-color: rgba(220, 224, 229, 0.45)
}

.controls .input-with-actions input {
  flex: 1
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.advanced-settings {
  margin-top: 12px;
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(224, 251, 252, 0.12);
}

.section-divider {
  margin: 18px 0 8px;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.advanced-settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.advanced-settings input[type=text],
.advanced-settings select {
  width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #e6eef8;
}

.advanced-settings select {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  background: rgba(255, 255, 255, 0.04);
  color: #f8fbff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 10px;
  outline: none;
}

.advanced-settings select,
::picker(select) {
  appearance: base-select;
}

.advanced-settings select {
  flex: 1;
}

.advanced-settings select {
  background: #313d45;
  padding: 10px;
  transition: 0.4s;
  font-size: 12px;
}

.advanced-settings select:open::picker-icon {
  rotate: 180deg;
}

.advanced-settings select option {
  background: #313d45;
  color: #f8fbff;
}

.advanced-settings ::picker(select) {
  border-radius: 8px;
}

.action-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.primary {
  background: linear-gradient(135deg, #7f98af 0%, #d6e4f0 55%, #f4fbff 100%);
  color: #08101f;
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 34px rgba(29, 66, 103, 0.16);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, border-color .18s ease;
}

.primary:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 18px 40px rgba(29, 66, 103, 0.24);
  filter: brightness(1.06);
  border-color: rgba(255, 255, 255, 0.45);
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: none;
  border-color: rgba(255, 255, 255, 0.14);
}

.primary:focus-visible {
  outline: 2px solid rgba(179, 198, 211, 0.8);
  outline-offset: 2px;
}

.secondary {
  background: rgba(220, 224, 229, 0.12);
  color: #f8faff;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(194, 223, 227, 0.28);
  cursor: pointer;
  transition: filter .15s, border-color .15s, background .15s, box-shadow .15s;
}

.secondary:hover {
  filter: brightness(1.06);
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(220, 224, 229, 0.20);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(224, 251, 252, 0.14);
  cursor: pointer
}

.footer {
  width: 100%;
  max-width: 100vw;
  margin-top: 42px;
  min-height: 56px;
  padding: 14px 28px;
  border-top: 1px solid rgba(194, 223, 227, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.footer-copy {
  position: static;
  transform: none;
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  margin-right: 40px;
}

@media (max-width: 720px) {
  .footer {
    justify-content: flex-start;
  }

  .footer-copy {
    width: 100%;
    margin-left: 0;
    text-align: left;
  }
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s
}

.footer-links a:hover {
  color: var(--accent)
}

.doc-section {
  max-width: 1200px;
  margin: 0 auto 24px;
  padding: 20px 30px;
  background: rgba(224, 251, 252, 0.04);
  border: 1px solid rgba(194, 223, 227, 0.12);
  border-radius: 14px;
  color: #dce9ff
}

.doc-section a {
  color: var(--accent);
  text-decoration: underline;
}

.doc-section a:hover {
  color: #f4fbff;
}

.doc-section h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: #fff
}

.doc-section p {
  margin: 0 0 16px;
  line-height: 1.75;
  color: var(--muted);
  font-size: 15px
}

.hint {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px
}

.tile-preview {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  padding: 8px;
  border-radius: 10px
}

.tile-preview-group {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.tile-preview-canvas {
  background: #49525b;
  border: 0px solid transparent;
}

.tile-preview-info {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

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

.doc-page-main {
  flex-direction: column;
  gap: 20px;
  padding: 18px;
  max-width: 900px;
  margin: 18px auto;
}

.doc-back-link {
  width: max-content;
  margin-bottom: 18px;
}

.disabled-locale-switcher {
  pointer-events: none;
  opacity: .6;
}

.tile-preview canvas {
  display: block
}

@media (max-width:980px) {
  body {
    overflow-x: hidden;
  }

  .header {
    padding: 22px 16px;
    background-position: 16px 50%, center;
    background-size: auto 100%, cover;
  }

  .header-row {
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
  }

  .header-copy {
    max-width: 100%;
    padding-left: 16px;
  }

  .header-copy-title {
    display: none;
  }

  .header .header-copy-text {
    display: none;
  }

  .hero-panel {
    display: block;
    width: min(1200px, calc(100% - 32px));
    margin: 6px auto 0;
  }

  .hero-panel-text {
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.08);
  }

  .header-copy-text,
  .hero-panel-text,
  .controls label {
    font-size: 16px;
  }

  .info-tooltip,
  .hint,
  .tile-preview-hint {
    font-size: 14px;
  }

  .locale-switcher {
    margin-top: 12px;
    margin-left: auto;
    width: auto;
  }

  .app {
    flex-direction: column;
    margin: 18px auto 0;
    padding: 0 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .left {
    align-self: stretch;
    flex: none;
  }

  .right {
    width: 100%;
  }

  .footer {
    padding: 14px 18px;
  }
}