/* Central de Templates Império — estilos públicos e base compartilhada */
:root {
  --bg: #050e0a;
  --bg-2: #08170f;
  --surface: #0c1f16;
  --surface-2: #10291d;
  --line: rgba(201, 164, 92, .16);
  --line-strong: rgba(201, 164, 92, .38);
  --green: #1b7a52;
  --green-2: #23966a;
  --green-soft: rgba(35, 150, 106, .14);
  --gold: #c9a45c;
  --gold-2: #e6c987;
  --gold-soft: rgba(201, 164, 92, .12);
  --text: #eef3ef;
  --muted: #9db4a8;
  --danger: #e0705f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Cinzel', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -200px, #0f3826 0%, transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { color: #fff; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.bg-ornament {
  position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .5;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(201,164,92,.07) 1px, transparent 0);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

/* ---------- Ícones ---------- */
.ico { width: 22px; height: 22px; flex: none; }
.ico.sm { width: 16px; height: 16px; }

/* ---------- Topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(5, 14, 10, .82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); margin-right: auto; }
.brand .crest { width: 34px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.brand-text strong { font-family: var(--font-display); font-size: 19px; letter-spacing: .16em; color: var(--gold-2); }
.btn-back {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px 8px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--surface);
  font-size: 14px; font-weight: 600; transition: background .2s, border-color .2s;
  order: 2;
}
.btn-back:hover { background: var(--surface-2); color: #fff; border-color: var(--gold); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 14px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--gold-2); }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }
.crumbs .sep { opacity: .45; }

.main { padding-top: 20px; padding-bottom: 48px; }
.footer { padding: 24px 16px 40px; color: var(--muted); font-size: 12px; text-align: center; letter-spacing: .04em; border-top: 1px solid var(--line); }

/* ---------- Títulos ---------- */
.hero { text-align: center; padding: 28px 0 24px; }
.hero-crest .crest { width: 76px; height: 86px; margin: 0 auto 14px; filter: drop-shadow(0 8px 24px rgba(201,164,92,.25)); }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.hero h1, .page-head h1 { font-size: clamp(24px, 6vw, 36px); font-weight: 700; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 10px auto 0; max-width: 560px; }
.page-head { margin: 4px 0 22px; }
.page-head .lead { margin-left: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--gold-2); background: var(--gold-soft); border: 1px solid var(--line);
}

/* ---------- Escolha de perfil / categorias ---------- */
.choice-grid, .cat-grid { display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.cat-grid { max-width: none; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.choice, .cat-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.choice { min-height: 96px; }
.choice:hover, .cat-card:hover { transform: translateY(-2px); border-color: var(--line-strong); color: var(--text); box-shadow: 0 14px 36px rgba(0,0,0,.45), 0 0 0 1px rgba(201,164,92,.1); }
.choice:active, .cat-card:active { transform: scale(.99); }
.choice-icon, .cat-icon, .card-icon {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 14px;
  background: radial-gradient(circle at 30% 20%, var(--green-2), #0d4a31);
  color: var(--gold-2); border: 1px solid var(--line-strong);
}
.choice-icon .ico, .cat-icon .ico { width: 26px; height: 26px; }
.choice-text, .cat-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.choice-text strong { font-size: 18px; text-transform: uppercase; letter-spacing: .03em; }
.cat-text strong { font-size: 17px; }
.choice-text small, .cat-text small { color: var(--muted); font-size: 14px; }
.choice-arrow { color: var(--gold); opacity: .8; }
.switch-profile { text-align: center; color: var(--muted); font-size: 14px; margin-top: 28px; }

/* ---------- Abas de categoria ---------- */
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; margin-bottom: 4px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs a {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--line); background: var(--surface);
}
.cat-tabs a.active { color: var(--bg); background: var(--gold); border-color: var(--gold); font-weight: 600; }

.device-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.device-jump a { font-size: 13px; padding: 5px 10px; border-radius: 8px; background: var(--green-soft); color: var(--text); border: 1px solid rgba(35,150,106,.25); }
.device-jump a:hover { border-color: var(--green-2); }

/* ---------- Cards ---------- */
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border-radius: var(--radius);
  background: linear-gradient(170deg, var(--surface-2), var(--surface) 40%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  position: relative;
}
.card::before {
  content: ''; position: absolute; inset: 0 18px auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .5;
}
.card-head { display: flex; align-items: center; gap: 12px; }
.card-icon { width: 40px; height: 40px; border-radius: 11px; }
.card-icon .ico { width: 20px; height: 20px; }
.card-head h2 { font-size: 18px; font-weight: 700; }
.card-desc { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.device-img {
  margin: 0; border-radius: var(--radius-sm); overflow: hidden;
  background: #031008; border: 1px solid var(--line);
  display: grid; place-items: center;
}
/* A imagem mantém a proporção original (tutoriais costumam ser verticais), com altura limitada. */
.device-img img { width: auto; max-width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.device-img.placeholder { aspect-ratio: 16 / 10; color: var(--muted); gap: 6px; font-size: 13px; align-content: center; justify-items: center; }
.device-img.placeholder .ico { width: 32px; height: 32px; opacity: .6; }

.msg { display: flex; flex-direction: column; gap: 12px; }
.msg-body {
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
  padding: 14px; border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .28); border: 1px solid rgba(255,255,255,.05);
  font-size: 15px; line-height: 1.6; max-height: 340px; overflow-y: auto;
  user-select: text;
}
.var { color: var(--gold-2); background: var(--gold-soft); border-radius: 4px; padding: 0 3px; font-weight: 600; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  font-weight: 700; font-size: 15px; letter-spacing: .02em; text-transform: uppercase;
  border: 1px solid transparent; transition: background .2s, transform .15s var(--ease), border-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn-copy, .btn-primary { background: linear-gradient(180deg, var(--green-2), var(--green)); color: #fff; border-color: rgba(255,255,255,.08); }
.btn-copy:hover, .btn-primary:hover { background: linear-gradient(180deg, #29a777, var(--green-2)); color: #fff; }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1406; }
.btn-gold:hover { color: #000; filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--gold-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--gold-soft); color: #fff; border-color: var(--gold); }
.btn-copy .when-done { display: none; }
.btn-copy .when-idle, .btn-copy .when-done { display: inline-flex; align-items: center; gap: 8px; }
.btn-copy .when-done { display: none; }
.btn-copy.copied { background: var(--gold); color: #1a1406; }
.btn-copy.copied .when-idle { display: none; }
.btn-copy.copied .when-done { display: inline-flex; animation: pop .35s var(--ease); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty .ico { width: 36px; height: 36px; opacity: .6; margin-bottom: 6px; }
.err-detail { white-space: pre-wrap; text-align: left; font-size: 12px; background: #000; padding: 12px; border-radius: 8px; color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  background: #0f2f20; color: #fff; border: 1px solid var(--gold);
  font-weight: 600; font-size: 15px; box-shadow: 0 12px 30px rgba(0,0,0,.5);
  transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }

/* ---------- Animações ---------- */
.reveal { animation: rise .5s var(--ease) both; }
.card-grid > .reveal:nth-child(2), .cat-grid > .reveal:nth-child(2), .choice-grid > .reveal:nth-child(2) { animation-delay: .05s; }
.card-grid > .reveal:nth-child(3), .cat-grid > .reveal:nth-child(3) { animation-delay: .1s; }
.card-grid > .reveal:nth-child(n+4) { animation-delay: .14s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Celular ---------- */
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
  .btn-back span { display: none; }
  .btn-back { padding: 8px; }
  .brand-text small { font-size: 10px; }
  .choice { padding: 18px 16px; }
  .choice-text strong { font-size: 16px; }
  .btn-copy, .device-card .btn-ghost { width: 100%; }
  .hero { padding-top: 16px; }
}
