/* =========================================================================
   OhmCode — design system
   No framework, no build step. Tokens first, components after.
   ========================================================================= */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Surfaces (dark is the default identity) */
  --bg:            #0a0d13;
  --bg-header:     rgba(10, 13, 19, 0.82);
  --surface:       #121722;
  --surface-2:     #182031;
  --surface-3:     #1f2839;
  --surface-sunk:  #0d1119;

  --border:        #253048;
  --border-soft:   #1c2436;
  --border-strong: #33415e;

  /* Text */
  --text:   #eef2f9;
  --text-2: #b6c0d1;
  --text-3: #8a95a9;
  --text-4: #626e84;

  /* Brand */
  --accent:        #4d8dff;
  --accent-hover:  #3d7cf0;
  --accent-ink:    #ffffff;
  --accent-soft:   rgba(77, 141, 255, 0.14);
  --accent-line:   rgba(77, 141, 255, 0.34);
  --accent-2:      #8b5cf6;
  --cyan:          #2dd4d4;

  /* Semantic */
  --ok:        #34d399;
  --ok-soft:   rgba(52, 211, 153, 0.12);
  --warn:      #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --err:       #fb7185;
  --err-soft:  rgba(251, 113, 133, 0.12);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 4px 16px -6px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.75);

  /* Geometry */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --wrap: 1120px;
  --wrap-prose: 760px;

  /* Type */
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Anel das amostras de cor: precisa contrastar com o fundo da pagina para
     que a amostra Preta apareca no tema escuro e a Branca no tema claro. */
  --swatch-ring: rgba(255, 255, 255, 0.32);

  /* Resistor illustration */
  --res-body-1: #efe0bd;
  --res-body-2: #dcc99b;
  --res-body-3: #bb9d67;
  --res-lead-1: #dfe4ec;
  --res-lead-2: #a8afbd;
  --res-lead-3: #79808f;
}

[data-theme="light"] {
  color-scheme: light;

  --bg:            #f3f6fa;
  --bg-header:     rgba(255, 255, 255, 0.86);
  --surface:       #ffffff;
  --surface-2:     #f5f7fb;
  --surface-3:     #e9eef6;
  --surface-sunk:  #f8fafc;

  --border:        #dce3ed;
  --border-soft:   #e8ecf3;
  --border-strong: #c2ccdb;

  --text:   #0f172a;
  --text-2: #44506a;
  --text-3: #64708a;
  --text-4: #8792a8;

  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft:  rgba(37, 99, 235, 0.10);
  --accent-line:  rgba(37, 99, 235, 0.28);
  --accent-2:     #7c3aed;
  --cyan:         #0e8f9c;

  --ok:        #059669;
  --ok-soft:   rgba(5, 150, 105, 0.10);
  --warn:      #b45309;
  --warn-soft: rgba(180, 83, 9, 0.10);
  --err:       #dc2626;
  --err-soft:  rgba(220, 38, 38, 0.08);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 4px 16px -6px rgba(15, 23, 42, 0.14);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, 0.30);

  --swatch-ring: rgba(0, 0, 0, 0.30);

}

/* ---------- 2. Reset ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

img, svg, video, canvas { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4 { line-height: 1.22; font-weight: 700; letter-spacing: -0.018em; }
::selection { background: var(--accent-soft); color: var(--text); }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 3. Utilities ------------------------------------------------- */
/* Atencao: quem combinar outra classe com .wrap no MESMO elemento deve usar
   padding-block (nunca o shorthand `padding`), senao zera este recuo lateral. */
.wrap  { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
.prose { max-width: var(--wrap-prose); }
.mono  { font-family: var(--font-mono); font-variant-ligatures: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
@media (min-width: 640px) { .wrap { padding-inline: 24px; } }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600; font-size: 0.875rem;
  transform: translateY(-180%); transition: transform 0.18s ease;
}
.skip-link:focus { transform: translateY(0); }

/* ---------- 4. Header ---------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; font-size: 1.0625rem; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px -4px var(--accent-line);
}
.brand-accent { color: var(--accent); }

/* Nome da ferramenta + assinatura do projeto, empilhados.
   O nome domina; a assinatura fica subordinada. */
.brand-text { display: grid; gap: 3px; line-height: 1; }
.brand-name { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.032em; }
/* Assinatura completa ("by divTools") como background-image: so a variante do
   tema atual e baixada — dois <img> com display:none seriam ambos buscados. */
.byline {
  display: block; width: 58px; height: 11px; opacity: 0.9;
  background: no-repeat left center / contain url("../../Images/by-divtools-dark.webp");
}
[data-theme="light"] .byline { background-image: url("../../Images/by-divtools-light.webp"); }

/* Rodape: marca do projeto, sem descricao */
.footer-logo {
  display: block; width: 130px; height: 27px;
  background: no-repeat left center / contain url("../../Images/divtools-dark.webp");
}
[data-theme="light"] .footer-logo { background-image: url("../../Images/divtools-light.webp"); }

.nav-desktop { display: none; gap: 2px; }
.nav-desktop a {
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 0.9rem;
  color: var(--text-3); font-weight: 500; transition: color 0.15s, background-color 0.15s;
}
.nav-desktop a:hover { color: var(--text); background: var(--surface-2); }
@media (min-width: 900px) { .nav-desktop { display: flex; } }

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-3); background: transparent;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
@media (min-width: 900px) { #menu-toggle { display: none; } }

.nav-mobile { display: none; flex-direction: column; padding: 6px 0 12px; border-top: 1px solid var(--border-soft); }
.nav-mobile.is-open { display: flex; }
.nav-mobile a { padding: 11px 8px; border-radius: var(--r-sm); color: var(--text-2); font-size: 0.95rem; font-weight: 500; }
.nav-mobile a:hover { background: var(--surface-2); color: var(--text); }
@media (min-width: 900px) { .nav-mobile { display: none !important; } }

/* O icone mostra a preferencia ATUAL (auto / claro / escuro), nao a proxima
   acao — com tres estados isso e menos ambiguo. Auto e o padrao, inclusive
   quando o atributo ainda nao foi escrito. */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-auto { display: block; }
[data-theme-pref="light"] .theme-toggle .icon-auto { display: none; }
[data-theme-pref="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme-pref="dark"]  .theme-toggle .icon-auto { display: none; }
[data-theme-pref="dark"]  .theme-toggle .icon-moon { display: block; }

/* ---------- 5. Hero ------------------------------------------------------ */
.hero { padding-block: 34px 20px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.hero h1 { font-size: clamp(1.75rem, 1.15rem + 2.6vw, 2.7rem); font-weight: 800; letter-spacing: -0.03em; }
.hero-sub { margin-top: 12px; color: var(--text-2); font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem); max-width: 60ch; }
.hero-sub strong { color: var(--text); font-weight: 600; }

/* ---------- 6. Card + section shell -------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section { padding-block: 40px; }
.section-title { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem); letter-spacing: -0.025em; }
.section-lead { margin-top: 10px; color: var(--text-2); }
.section h3 { font-size: 1.2rem; margin-top: 32px; }
.section h4 { font-size: 1rem; }
.section p  { color: var(--text-2); }
.section .prose > p, .section .prose > ol, .section .prose > ul { margin-top: 14px; }
.section .prose li { margin-top: 6px; color: var(--text-2); }
.section .prose ol, .section .prose ul { padding-left: 1.25em; }
.section a.inline-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.section a.inline-link:hover { color: var(--accent-hover); }

/* ---------- 7. Calculator: tabs ------------------------------------------ */
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tab {
  /* Sao 4 abas: comeca compacto e cresce conforme sobra largura. */
  flex: 1; padding: 13px 4px; font-size: 0.78rem; font-weight: 600;
  color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  white-space: nowrap; min-width: 0;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface); border-bottom-color: var(--accent); }
.tab .tab-long  { display: none; }
.tab .tab-short { display: inline; }
@media (min-width: 380px) { .tab { font-size: 0.83rem; padding: 14px 6px; } }
@media (min-width: 700px) {
  .tab { font-size: 0.9rem; padding: 14px 10px; }
  .tab .tab-long  { display: inline; }
  .tab .tab-short { display: none; }
}

/* ---------- 8. Calculator: layout ---------------------------------------- */
/* Mobile: o seletor de faixas/codificacao vem ANTES da silhueta, para o usuario
   definir o formato do componente e so entao ver o desenho mudar. */
.calc-body {
  display: grid; gap: 20px; padding: 18px 16px 22px;
  grid-template-areas: "bands" "visual" "controls" "result" "history";
}
@media (min-width: 640px) { .calc-body { padding: 24px; gap: 22px; } }

/* As areas base precisam vir ANTES do media query: sao rules de mesma
   especificidade, entao quem estiver por ultimo no arquivo vence. */
.calc-bands    { grid-area: bands; min-width: 0; }
.calc-controls { grid-area: controls; min-width: 0; }
.calc-visual   { grid-area: visual; min-width: 0; }
.calc-result   { grid-area: result; min-width: 0; }
.calc-history  { grid-area: history; min-width: 0; }

/* Desktop: layout inalterado — coluna da esquerda empilha seletor, controles e
   historico; a da direita, silhueta e resultado, com historico e resultado
   comecando na mesma linha. */
@media (min-width: 980px) {
  .calc-body {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1fr);
    grid-template-areas: none;
    align-items: start;
    column-gap: 28px;
  }
  .calc-bands    { grid-area: 1 / 1 / 2 / 2; }
  .calc-controls { grid-area: 2 / 1 / 3 / 2; }
  .calc-history  { grid-area: 3 / 1 / 4 / 2; }
  .calc-visual   { grid-area: 1 / 2 / 3 / 3; }
  .calc-result   { grid-area: 3 / 2 / 4 / 3; }
}

/* So aparece no desktop (ex.: exemplos rapidos de codigo SMD) */
.only-desktop { display: none; }
@media (min-width: 980px) { .only-desktop { display: block; } }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 8px; letter-spacing: 0.005em;
}
.field-hint { margin-top: 7px; font-size: 0.78rem; color: var(--text-4); }

.input, .select {
  width: 100%; padding: 11px 13px;
  background: var(--surface-sunk); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus-visible, .select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-4); }
.input.mono { font-size: 1.0625rem; letter-spacing: 0.01em; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a95a9' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.input-group .select { width: auto; flex: none; min-width: 92px; }

.field-error { margin-top: 7px; font-size: 0.8rem; color: var(--err); font-weight: 500; }
.field-error[hidden] { display: none; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--r-md);
}
.segmented button {
  padding: 7px 14px; border-radius: 7px; font-size: 0.875rem; font-weight: 600;
  color: var(--text-3); transition: color 0.15s, background-color 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.segmented.is-wide { display: flex; }
.segmented.is-wide button { flex: 1; }

/* Botoes de acao rapida (ex.: exemplos de codigo SMD). Nao sao um seletor de
   estado, entao nao devem parecer um segmented control. */
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-row button {
  flex: 1 1 auto; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-sunk);
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
  color: var(--text-2); letter-spacing: 0.02em;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.quick-row button:hover { color: var(--text); border-color: var(--accent); background: var(--surface-2); }
.quick-row button:active { transform: scale(0.97); }

/* ---------- 9. Band chips ------------------------------------------------ */
.band-chips {
  /* auto-fit: em telas estreitas as faixas quebram para uma segunda linha em vez
     de espremer o valor. A ordem da leitura continua da esquerda para a direita. */
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
}
.band-chip {
  /* grid com a linha do meio elastica: o valor fica sempre alinhado embaixo,
     mesmo quando o rotulo do papel quebra em duas linhas */
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 7px;
  padding: 11px 4px 9px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-sunk);
  transition: border-color 0.15s, background-color 0.15s, transform 0.12s;
  text-align: center; min-width: 0;
}
.band-chip > * { min-width: 0; max-width: 100%; }
.band-chip:hover { border-color: var(--accent); background: var(--surface-2); }
.band-chip:active { transform: scale(0.97); }
.band-chip[data-active="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.band-chip .swatch {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px var(--swatch-ring), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.band-chip .swatch.is-empty {
  background: var(--surface-3);
  box-shadow: inset 0 0 0 2px var(--border-strong);
}
.band-chip .chip-role {
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.045em;
  color: var(--text-4); line-height: 1.2;
  display: flex; align-items: center;
}
.band-chip .chip-val {
  font-family: var(--font-mono); font-size: 0.76rem; font-weight: 600; color: var(--text);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  letter-spacing: -0.02em;
}
@media (min-width: 420px) { .band-chip .chip-val { font-size: 0.8rem; letter-spacing: normal; } }
@media (min-width: 400px) {
  .band-chip .swatch { width: 34px; height: 34px; }
  .band-chip .chip-role { font-size: 0.69rem; }
}

/* ---------- 10. Resistor illustration ------------------------------------ */
.resistor-stage {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 12px;
  display: grid; place-items: center;
  /* altura reservada: evita salto de layout antes do SVG ser desenhado
     (SVG 640x200 com max-width 440 => 138px de altura) */
  min-height: 174px;
}
@media (min-width: 640px) { .resistor-stage { padding: 26px 20px; min-height: 190px; } }
.resistor-stage svg { width: 100%; max-width: 440px; height: auto; }
.resistor-stage .band-hit { cursor: pointer; }
.resistor-stage .band-hit:hover .band-outline { opacity: 1; }
.band-outline { opacity: 0; transition: opacity 0.15s; }

/* ---------- 11. Result --------------------------------------------------- */
.result {
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 58%),
    var(--surface-2);
  padding: 18px;
}
@media (min-width: 640px) { .result { padding: 22px; } }
.result.is-error { border-color: var(--err); background: var(--err-soft); }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.result-value {
  font-family: var(--font-mono); font-weight: 700; letter-spacing: -0.035em;
  /* 1.05 cortava as métricas altas da JetBrains Mono (o Ω e os dígitos) */
  font-size: clamp(2rem, 1.3rem + 3.2vw, 3rem); line-height: 1.2; color: var(--text);
}
.result-tol { margin-top: 4px; font-size: 0.95rem; font-weight: 600; color: var(--cyan); }
.badge {
  flex: none; padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.72rem; font-weight: 600; color: var(--text-3); white-space: nowrap;
}

.result-rows { margin-top: 14px; display: grid; gap: 7px; }
.result-row { display: flex; gap: 10px; align-items: baseline; font-size: 0.85rem; }
.result-row dt { color: var(--text-4); flex: none; min-width: 86px; }
.result-row dd { color: var(--text-2); font-family: var(--font-mono); }
.result-row dd.plain { font-family: var(--font-sans); }
.result-swatches { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.result-swatches span {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px var(--swatch-ring), 0 1px 2px rgba(0, 0, 0, 0.25);
}

.result-note {
  margin-top: 14px; padding: 9px 12px; border-radius: var(--r-sm);
  font-size: 0.8rem; line-height: 1.5;
  display: flex; gap: 8px; align-items: flex-start;
}
.result-note svg { flex: none; margin-top: 2px; }
.result-note.tone-warn { background: var(--warn-soft); color: var(--warn); }
.result-note.tone-ok   { background: var(--ok-soft);   color: var(--ok); }
.result-note.tone-err  { background: var(--err-soft);  color: var(--err); }
.result-note[hidden] { display: none; }

.result-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-md);
  font-size: 0.875rem; font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--border); color: var(--text-2); background: var(--surface); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-3); }
.btn svg { flex: none; }
.btn.is-done { background: var(--ok); border-color: var(--ok); color: #05261a; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn:disabled:hover { background: var(--accent); border-color: transparent; }
.btn-ghost:disabled:hover { background: var(--surface); border-color: var(--border); color: var(--text-2); }

/* ---------- 12. Color picker dialog -------------------------------------- */
/* O <dialog> ocupa a viewport inteira e serve so de container. O escurecimento
   e o blur ficam em .picker-scrim (um div comum), nao em ::backdrop: naquele
   pseudo-elemento o backdrop-filter e instavel e chega a "vazar" o fundo do
   painel. Como o transform da animacao fica no painel (e nao no <dialog>),
   nenhum containing block novo e criado e o scrim cobre a tela toda. */
.picker {
  position: fixed; inset: 0;
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  margin: 0; padding: 0; border: none; background: transparent; overflow: hidden;
}
.picker[open] { display: flex; align-items: flex-end; justify-content: center; }
.picker::backdrop { background: transparent; }

.picker-scrim {
  position: absolute; inset: 0;
  background: rgba(4, 8, 16, 0.55);
  backdrop-filter: blur(7px) saturate(0.9);
  -webkit-backdrop-filter: blur(7px) saturate(0.9);
}

.picker-panel {
  position: relative; z-index: 1;
  width: 100%;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto;
}

@media (min-width: 640px) {
  .picker[open] { align-items: center; }
  .picker-panel {
    width: min(430px, calc(100vw - 32px));
    border-radius: var(--r-xl); padding: 20px;
    max-height: min(86vh, 640px);
  }
}

/* --- animacoes de entrada e saida --- */
@keyframes oc-scrim-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes oc-scrim-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes oc-sheet-in  { from { transform: translateY(100%); } to { transform: none; } }
@keyframes oc-sheet-out { from { transform: none; } to { transform: translateY(100%); } }
@keyframes oc-pop-in    { from { transform: translateY(10px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes oc-pop-out   { from { transform: none; opacity: 1; } to { transform: translateY(10px) scale(0.96); opacity: 0; } }

.picker[open] .picker-scrim { animation: oc-scrim-in 0.24s ease both; }
.picker[open] .picker-panel { animation: oc-sheet-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both; }
.picker.is-closing .picker-scrim { animation: oc-scrim-out 0.2s ease both; }
.picker.is-closing .picker-panel { animation: oc-sheet-out 0.24s cubic-bezier(0.4, 0, 1, 1) both; }

@media (min-width: 640px) {
  .picker[open] .picker-panel      { animation: oc-pop-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .picker.is-closing .picker-panel { animation: oc-pop-out 0.18s ease both; }
}

.picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.picker-title { font-size: 0.98rem; font-weight: 700; }
.picker-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }
.picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 380px) { .picker-grid { gap: 10px; } }

.swatch-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border-radius: var(--r-md);
  border: 1px solid transparent; transition: background-color 0.15s, border-color 0.15s;
  min-width: 0;
}
.swatch-btn:hover { background: var(--surface-2); }
.swatch-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.swatch-btn .swatch {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px var(--swatch-ring), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.swatch-btn .swatch-name { font-size: 0.7rem; font-weight: 600; color: var(--text-2); line-height: 1.15; text-align: center; }
.swatch-btn .swatch-meaning { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-4); line-height: 1.15; }

/* ---------- 13. History -------------------------------------------------- */
.panel {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.01em; }
.link-btn { font-size: 0.78rem; color: var(--text-3); font-weight: 500; transition: color 0.15s; }
.link-btn:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.history-list { list-style: none; padding: 0; margin: 0; max-height: 236px; overflow-y: auto; }
.history-list li + li { border-top: 1px solid var(--border-soft); }
.history-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 11px 16px; transition: background-color 0.15s;
}
.history-item:hover { background: var(--surface-2); }
.history-swatches { display: flex; gap: 2px; flex: none; }
.history-swatches span {
  width: 7px; height: 20px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
}
.history-main { min-width: 0; display: grid; gap: 1px; }
.history-val { font-family: var(--font-mono); font-size: 0.86rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.history-meta {
  font-size: 0.72rem; color: var(--text-4); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty-state { padding: 18px 16px; font-size: 0.82rem; color: var(--text-4); }

/* ---------- 14. Tables --------------------------------------------------- */
.table-wrap {
  margin-top: 18px; border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow-x: auto; background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.data-table { font-size: 0.86rem; min-width: 520px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-3); color: var(--text-2);
  text-align: left; font-weight: 600; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 11px 14px; white-space: nowrap;
}
.data-table tbody tr { border-top: 1px solid var(--border-soft); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td { padding: 10px 14px; color: var(--text-2); vertical-align: middle; }
.data-table td.mono { color: var(--text); }
.data-table .color-cell { display: flex; align-items: center; gap: 9px; white-space: nowrap; color: var(--text); font-weight: 500; }
.data-table .color-cell .swatch {
  width: 15px; height: 15px; border-radius: 4px; flex: none;
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
}
.table-note { margin-top: 10px; font-size: 0.78rem; color: var(--text-4); }

/* ---------- 15. Feature grid + examples ---------------------------------- */
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 22px; }
@media (min-width: 700px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.feature { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: 18px; }
.feature h4 { margin-bottom: 7px; }
.feature p { font-size: 0.88rem; }
.feature .feature-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent); margin-bottom: 12px;
}

.examples-grid { display: grid; gap: 9px; grid-template-columns: repeat(2, 1fr); margin-top: 20px; }
@media (min-width: 520px) { .examples-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .examples-grid { grid-template-columns: repeat(5, 1fr); } }
.example-btn {
  text-align: left; padding: 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.15s, background-color 0.15s, transform 0.12s;
}
.example-btn:hover { border-color: var(--accent); background: var(--surface-2); }
.example-btn:active { transform: scale(0.985); }
.example-val { font-family: var(--font-mono); font-weight: 700; font-size: 0.95rem; color: var(--text); }
.example-bands { display: flex; gap: 3px; margin-top: 8px; }
.example-bands span {
  width: 9px; height: 16px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
}

/* ---------- 16. FAQ ------------------------------------------------------ */
.faq { margin-top: 20px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.faq details + details { border-top: 1px solid var(--border-soft); }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 16px; cursor: pointer; list-style: none;
  font-size: 0.92rem; font-weight: 600; color: var(--text);
  transition: background-color 0.15s;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { background: var(--surface-2); }
.faq summary svg { flex: none; color: var(--text-4); transition: transform 0.2s; }
.faq details[open] summary svg { transform: rotate(45deg); }
.faq .faq-answer { padding: 0 16px 16px; font-size: 0.9rem; color: var(--text-2); }

/* ---------- 17. Ads ------------------------------------------------------ */
.ad-slot {
  margin: 0 auto; display: block; text-align: center;
  min-height: var(--ad-h, 100px);
}
.ad-section { padding-block: 6px 26px; }
.ad-label {
  display: block; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-4); margin-bottom: 6px; font-weight: 600;
}
.ad-placeholder {
  display: grid; place-items: center; min-height: var(--ad-h, 100px);
  border: 1px dashed var(--border); border-radius: var(--r-md);
  color: var(--text-4); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--surface-sunk);
}
.adsbygoogle { display: block; }

/* Quando o AdSense nao tem anuncio para o espaco ele marca o <ins> como
   "unfilled". Sem isto sobraria o rotulo "Publicidade" pairando sobre um
   retangulo vazio — feio e questionavel perante a politica de rotulagem. */
.ad-slot:has(ins[data-ad-status="unfilled"]) { min-height: 0; }
.ad-slot:has(ins[data-ad-status="unfilled"]) .ad-label { display: none; }

/* ---------- 18. Footer --------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 20px; }
.footer-grid { display: grid; gap: 26px; padding: 38px 0; grid-template-columns: 1fr; }
@media (min-width: 700px) { .footer-grid { grid-template-columns: 1.6fr 1fr 1fr; gap: 32px; } }
.footer-col h3 { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); margin-bottom: 11px; }
.footer-col ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.footer-col a { font-size: 0.875rem; color: var(--text-3); transition: color 0.15s; }
.footer-col a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.footer-bottom {
  border-top: 1px solid var(--border-soft); padding: 16px 0;
  font-size: 0.78rem; color: var(--text-4); text-align: center;
}

/* ---------- 19. Toast + consent ------------------------------------------ */
/* Escondido de verdade: so o translate deixava uma tira do balao aparecendo
   na base da tela (o "artefato preto"). */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 14px);
  z-index: 90; padding: 11px 18px; border-radius: var(--r-pill);
  background: var(--text); color: var(--bg); font-size: 0.85rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; pointer-events: none; max-width: calc(100vw - 32px);
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0s linear 0.3s;
}
.toast.is-visible {
  transform: translate(-50%, 0); opacity: 1; visibility: visible;
  transition-delay: 0s, 0s, 0s;
}

.consent {
  position: fixed; z-index: 95; left: 12px; right: 12px; bottom: 12px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 16px; display: grid; gap: 12px;
  max-width: 560px; margin-inline: auto;
}
.consent[hidden] { display: none; }
.consent p { font-size: 0.82rem; color: var(--text-2); }
.consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-actions .btn { flex: 1 1 auto; }

/* ---------- 20. Legal pages ---------------------------------------------- */
.legal { padding-block: 34px 50px; }
.legal h1 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem); }
.legal .updated { margin-top: 8px; font-size: 0.82rem; color: var(--text-4); }
.legal h2 { font-size: 1.15rem; margin-top: 30px; }
.legal h3 { font-size: 1rem; margin-top: 20px; }
.legal p, .legal li { color: var(--text-2); font-size: 0.94rem; }
.legal p { margin-top: 12px; }
.legal ul, .legal ol { margin-top: 12px; padding-left: 1.3em; display: grid; gap: 6px; }
.legal a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.legal .callout {
  margin-top: 18px; padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); font-size: 0.88rem;
}
