:root {
  --bg: #ececef;
  --panel: rgba(248, 248, 250, 0.92);
  --surface: rgba(255, 255, 255, 0.88);
  --text: #111111;
  --muted: #6f727c;
  --accent: #ff2b2b;
  --dark: #000000;
  --border: #d9dce3;
  --border-strong: #bcc1cc;
  --success-bar: #19c93b;
  --error-bar: #ff453a;
  --info-bar: #2f80ff;

  --shadow-xs: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, 0.08);

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  --transition-fast: 0.18s ease;
  --transition-med: 0.28s ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 24%),
    linear-gradient(180deg, #f2f3f5 0%, #ececef 100%);
}

.hidden {
  display: none !important;
}

/* barra de progresso */
.top-progress {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  height: 4px;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}

.top-progress.is-idle {
  opacity: 0;
}

.top-progress__bar {
  position: absolute;
  left: 0;
  top: 0;
  width: 0%;
  height: 100%;
  background: #2f80ff;
  transition: width 0.25s ease, background 0.25s ease, opacity 0.2s ease;
}

.top-progress.is-loading .top-progress__bar {
  background: #2f80ff;
}

.top-progress.is-done .top-progress__bar {
  background: #19c93b;
}

.top-progress.is-error .top-progress__bar {
  background: #ff453a;
}

.top-progress span {
  display: none !important;
}

/* header */
.page-header {
  max-width: 1380px;
  margin: 0 auto;
  padding: 14px 24px 0;
  min-height: 11vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-header h1 {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: clamp(24px, 3vw, 56px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
}

.header-actions span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid #d3d6de;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-xs);
}

/* shell */
.page-shell {
  max-width: 1380px;
  height: calc(100vh - 11vh);
  margin: 0 auto;
  padding: 8px 24px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* tabs */
.tab-switcher {
  width: min(980px, 100%);
  margin: 6px auto 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  flex-shrink: 0;
}

.tab-button {
  border: 0;
  background: transparent;
  color: #b7b9c2;
  cursor: pointer;
  padding: 0 0 14px;
  font-size: clamp(20px, 2vw, 32px);
  font-weight: 900;
  text-transform: lowercase;
  border-bottom: 4px solid transparent;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast);
}

.tab-button:hover {
  color: #80838d;
}

.tab-button.is-active {
  color: var(--text);
  border-color: var(--accent);
}

.tab-button:active {
  transform: translateY(1px);
}

/* layout principal */
.generator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(330px, 0.95fr);
  gap: 18px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

/* painÃ©is */
.panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.panel-form {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.panel-preview {
  display: grid;
  grid-template-rows: 1.2fr 0.9fr;
  gap: 18px;
  min-height: 0;
}

.preview-section,
.result-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  height: 100%;
}

/* tipografia */
label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: lowercase;
}

.panel-preview h2 {
  margin: 0 0 12px;
  font-size: clamp(20px, 2vw, 32px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

/* campos */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"] {
  width: 100%;
  min-height: 50px;
  margin-bottom: 18px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="file"]:focus {
  border-color: #111;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

input::placeholder {
  color: #9ca0aa;
}

input::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid #111;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
}

input::file-selector-button:hover {
  background: #111;
  color: #fff;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.format-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* botÃµes */
.format-btn,
.btn {
  appearance: none;
  min-width: 88px;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid #000;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.94);
  color: #000;
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  font-weight: 800;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.format-btn:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.format-btn:active,
.btn:active {
  transform: translateY(0);
}

.format-btn.is-selected,
.btn-primary {
  background: #000;
  color: #fff;
}

.btn-primary:hover {
  background: #171717;
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: #111;
  color: #fff;
}

.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.btn-full {
  width: 100%;
}

/* preview e resultado */
.preview-box,
.result-box {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
}

/* preview */
.preview-box {
  flex: 1;
  min-height: 0;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  display: flex;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

.preview-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  padding: 12px;
  border-radius: 28px;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.preview-placeholder {
  width: min(100%, 220px);
  min-height: min(220px, 100%);
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  line-height: 1.35;
  font-weight: 800;
  color: #686c77;
  border: 1px dashed #b4b8c2;
  border-radius: 26px;
  background: linear-gradient(180deg, #fcfcfd 0%, #f3f4f7 100%);
}

/* resultado */
.result-box {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.result-box p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.result-box p:last-child {
  margin-bottom: 0;
}

.result-box::-webkit-scrollbar {
  width: 8px;
}

.result-box::-webkit-scrollbar-track {
  background: #f1f2f5;
  border-radius: 999px;
}

.result-box::-webkit-scrollbar-thumb {
  background: #c5c9d2;
  border-radius: 999px;
  border: 2px solid #f1f2f5;
}

.result-box::-webkit-scrollbar-thumb:hover {
  background: #9fa4af;
}

/* login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-wrap {
  width: min(100%, 500px);
}

.login-card {
  padding: 28px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

.alert.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #efb3b3;
  border-radius: 12px;
  background: #fff1f1;
  color: #9f1414;
  font-weight: 700;
}

.is-disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* telas menores */
@media (max-width: 1200px) {
  .page-header {
    min-height: auto;
    padding-top: 12px;
  }

  .page-shell {
    height: calc(100vh - 88px);
  }

  .generator-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.95fr);
  }

  .panel {
    padding: 20px;
  }

  .panel-preview {
    grid-template-rows: 1.1fr 0.9fr;
  }
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  .page-shell {
    height: auto;
    overflow: visible;
  }

  .generator-layout {
    grid-template-columns: 1fr;
  }

  .panel-preview {
    display: flex;
    flex-direction: column;
  }

  .preview-box {
    min-height: 260px;
  }

  .result-box {
    max-height: 220px;
  }
}

@media (max-width: 760px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .page-header h1 {
    text-align: left;
    font-size: clamp(24px, 7vw, 40px);
  }

  .header-actions {
    justify-content: space-between;
  }

  .page-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .tab-switcher {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .panel-preview h2 {
    font-size: clamp(18px, 7vw, 28px);
  }

  .format-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .format-btn,
  .btn {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .page-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-shell {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 20px;
  }

  .format-buttons {
    grid-template-columns: 1fr;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="file"] {
    min-height: 46px;
    font-size: 14px;
  }

  .preview-placeholder {
    width: min(100%, 180px);
    min-height: 180px;
  }
}