:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #2f5fff;
  --primary-dark: #1f45d1;
  --green: #1a8a4a;
  --green-bg: #e6f6ec;
  --red: #c0303f;
  --red-bg: #fbe8ea;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 16px 40px;
}

h1, h2, h3 { line-height: 1.25; }

a { color: var(--primary); text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 12px;
}

.topbar h1 {
  font-size: 1.3rem;
  margin: 0;
}

.topbar nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.95rem;
  padding: 0;
}

main {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.field-row {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-wide {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  width: 100%;
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input { flex: 1; min-width: 0; }

.radio-group {
  display: flex;
  gap: 18px;
  font-weight: 400;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 400;
}

.discount-box {
  background: var(--green-bg);
  color: var(--green);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  margin-bottom: 16px;
  display: inline-block;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
}

button.primary-btn:hover { background: var(--primary-dark); }

button.primary-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

button.secondary-btn {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}

button.secondary-btn:hover { background: #f0f1f3; }

#ler-pressel-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  white-space: nowrap;
}

.warning-box {
  background: #fff4e5;
  border: 1px solid #f0c36d;
  color: #92610f;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.status-text {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.error-text {
  color: var(--red);
  font-size: 0.9rem;
}

/* --- Resultado / seções --- */

.section-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.section-header .section-actions {
  display: flex;
  gap: 8px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.copy-card {
  position: relative;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.92rem;
  word-break: break-word;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.copy-card:hover { background: #eef1f6; }

.copy-card:active { background: #e2e7f0; }

.copy-card .char-count {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.char-count.ok {
  background: var(--green-bg);
  color: var(--green);
}

.char-count.bad {
  background: var(--red-bg);
  color: var(--red);
}

.copy-card.copied::after {
  content: "Copiado!";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(47, 95, 255, 0.92);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
}

.sitelink-card .sl-line { margin-bottom: 2px; }
.sitelink-card .sl-url { color: var(--muted); font-size: 0.8rem; word-break: break-all; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 50;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

/* display:flex acima tem a mesma especificidade do [hidden] do navegador,
   e regra de autor sempre vence regra do user-agent — por isso precisa
   deste seletor mais específico para o atributo `hidden` conseguir
   esconder o overlay de fato. */
.overlay[hidden] {
  display: none;
}

.login-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 {
  font-size: 1.2rem;
  margin: 0;
}

.login-box button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex-wrap: wrap;
}

.history-item:hover { background: #f9fafb; }

.history-item .meta { color: var(--muted); font-size: 0.85rem; }

.tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef1f6;
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 520px) {
  body { padding: 0 10px 32px; }
  .card-panel, .section-block { padding: 14px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
