:root {
  --fonte: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --raio: 16px;
  --inset: 6px;
  --img-nitida: none;
  --img-vidro: none;
}

.tema-claro {
  --base: #e8ecf1;
  --tinta: rgba(255, 255, 255, 0.30);
  --brilho: rgba(255, 255, 255, 0.42);
  --borda: rgba(255, 255, 255, 0.62);
  --texto: #121821;
  --texto-suave: rgba(18, 24, 33, 0.62);
  --aviso: #a85d00;
  --fim: #c4262e;
  --trilho: rgba(18, 24, 33, 0.12);
  --botao: rgba(255, 255, 255, 0.55);
  --botao-hover: rgba(255, 255, 255, 0.85);
  --sombra-texto: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.tema-escuro {
  --base: #1a1f27;
  --tinta: rgba(14, 18, 25, 0.40);
  --brilho: rgba(255, 255, 255, 0.10);
  --borda: rgba(255, 255, 255, 0.22);
  --texto: #ffffff;
  --texto-suave: rgba(255, 255, 255, 0.70);
  --aviso: #ffb43d;
  --fim: #ff6b6b;
  --trilho: rgba(255, 255, 255, 0.16);
  --botao: rgba(255, 255, 255, 0.14);
  --botao-hover: rgba(255, 255, 255, 0.28);
  --sombra-texto: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.cantos-reto { --raio: 3px; --inset: 0px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--fonte);
  background: var(--base);
  color: var(--texto);
  -webkit-user-select: none;
  user-select: none;
}

#fundo {
  position: fixed;
  inset: 0;
  background: var(--img-nitida) center / 100% 100% no-repeat;
}

body:not(.com-fundo) #fundo {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(120, 160, 255, 0.35), transparent 60%),
    radial-gradient(120% 140% at 100% 100%, rgba(255, 170, 120, 0.30), transparent 60%),
    var(--base);
}

#vidro {
  position: fixed;
  inset: var(--inset);
  border-radius: var(--raio);
  border: 1px solid var(--borda);
  overflow: hidden;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, var(--brilho), transparent 46%),
    linear-gradient(var(--tinta), var(--tinta)),
    var(--img-vidro) center / 100vw 100vh no-repeat fixed;
  transition: background-color 0.6s ease;
}

body:not(.com-fundo) #vidro {
  background:
    linear-gradient(180deg, var(--brilho), transparent 46%),
    linear-gradient(var(--tinta), var(--tinta));
}

.fase-fim #vidro { box-shadow: inset 0 0 0 200vmax rgba(220, 40, 50, 0.10); }

#titulo {
  font-size: clamp(11px, 11cqh, 30px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--texto-suave);
  line-height: 1.2;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: var(--sombra-texto);
}
#titulo:empty { display: none; }

#mostrador {
  all: unset;
  cursor: pointer;
  display: block;
  line-height: 1;
  padding: 0 4cqw;
  border-radius: 8px;
}
#mostrador:focus-visible { outline: 2px solid var(--texto-suave); outline-offset: 2px; }

#digitos {
  display: block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--texto);
  text-shadow: var(--sombra-texto);
  transition: color 0.5s ease;
}

.fase-aviso #digitos { color: var(--aviso); }
.fase-fim #digitos { color: var(--fim); }
.fase-fim.rodando #digitos { animation: pulso 2s ease-in-out infinite; }

@keyframes pulso {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

#dica {
  font-size: clamp(10px, 8cqh, 18px);
  color: var(--texto-suave);
  margin-top: 1.5cqh;
  text-shadow: var(--sombra-texto);
  transition: opacity 0.3s ease;
}
.rodando #dica { opacity: 0; }

#barra {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: max(7px, 6cqh);
  height: max(3px, 1.6cqh);
  border-radius: 99px;
  background: var(--trilho);
  overflow: hidden;
}
#barra-cheia {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--texto);
  opacity: 0.8;
  transform-origin: left center;
  transition: background-color 0.5s ease;
}
.fase-aviso #barra-cheia { background: var(--aviso); }
.fase-fim #barra-cheia { background: var(--fim); }
.sem-barra #barra { display: none; }

#controles {
  position: absolute;
  top: max(6px, 4cqh);
  right: max(6px, 3cqw);
  display: flex;
  gap: max(4px, 1.2cqw);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.mostrar-controles #controles,
body:not(.rodando) #vidro:hover #controles,
#controles:focus-within {
  opacity: 1;
  transform: none;
}

#controles button {
  all: unset;
  cursor: pointer;
  width: clamp(22px, 13cqh, 36px);
  height: clamp(22px, 13cqh, 36px);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--botao);
  border: 1px solid var(--borda);
  color: var(--texto);
  transition: background-color 0.15s ease;
}
.cantos-reto #controles button { border-radius: 3px; }
#controles button:hover { background: var(--botao-hover); }
#controles button:focus-visible { outline: 2px solid var(--texto-suave); outline-offset: 1px; }
#controles svg { width: 58%; height: 58%; fill: currentColor; }
#controles .txt { font-size: clamp(10px, 6cqh, 15px); font-weight: 700; }
.ico-pause { display: none; }
.rodando .ico-pause { display: block; }
.rodando .ico-play { display: none; }

.modo-apresentacao .so-edicao,
.modo-navegador .so-edicao { display: none !important; }

#aviso {
  position: absolute;
  left: 50%;
  bottom: max(16px, 14cqh);
  transform: translateX(-50%);
  font-size: clamp(10px, 7cqh, 14px);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--botao-hover);
  color: var(--texto);
  white-space: nowrap;
}


#painel {
  --p-fundo: #f3f5f8;
  --p-cartao: #ffffff;
  --p-linha: #e2e6ec;
  --p-texto: #18202b;
  --p-suave: #5d6878;
  --p-acento: #2f6fde;
  --p-acento-fundo: #e8f0fd;
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--p-fundo);
  color: var(--p-texto);
  font-size: 13px;
  line-height: 1.35;
  -webkit-user-select: text;
  user-select: text;
}
#painel[hidden] { display: none; }

#painel header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--p-cartao);
  border-bottom: 1px solid var(--p-linha);
}
#painel header img { border-radius: 5px; }
#painel .marca { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#painel .marca strong { font-size: 14px; letter-spacing: 0.01em; }
#painel .marca span { font-size: 11.5px; color: var(--p-suave); }

#painel #fechar {
  all: unset;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--p-suave);
}
#painel #fechar:hover { background: var(--p-fundo); color: var(--p-texto); }
#painel #fechar svg { width: 16px; height: 16px; fill: currentColor; }

#painel .corpo {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 10px;
  align-content: start;
}

.bloco {
  background: var(--p-cartao);
  border: 1px solid var(--p-linha);
  border-radius: 4px;
  padding: 12px;
  min-width: 0;
}
.bloco.destaque { grid-column: 1 / -1; }
.bloco h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--p-suave);
}
.rotulo { display: block; margin: 12px 0 6px; font-weight: 600; }
.rotulo i { font-style: normal; font-weight: 400; color: var(--p-suave); }
.nota { margin: -2px 0 10px; color: var(--p-suave); font-size: 12px; }

#painel button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg + .seg { margin-top: 8px; }
.seg button {
  padding: 6px 10px;
  border: 1px solid var(--p-linha);
  border-radius: 4px;
  background: var(--p-cartao);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.seg button:hover { border-color: #b9c2ce; }
.seg button[aria-pressed="true"] {
  background: var(--p-acento-fundo);
  border-color: var(--p-acento);
  color: #1c4eaa;
  font-weight: 600;
}

.seg.cheio { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.seg.cheio button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 0;
}
.seg.cheio button:first-child { border-radius: 4px 0 0 4px; }
.seg.cheio button:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.seg.cheio button[aria-pressed="true"] { position: relative; z-index: 1; }
.seg.cheio svg { width: 16px; height: 16px; fill: currentColor; }

.tempo { display: flex; align-items: flex-start; gap: 6px; }
.tempo label { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tempo label span { font-size: 11px; color: var(--p-suave); }
.tempo b { font-size: 34px; font-weight: 300; line-height: 52px; color: var(--p-suave); }
#painel .tempo input {
  width: 84px;
  height: 52px;
  font: 600 34px/1 var(--fonte);
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--p-linha);
  border-radius: 4px;
  background: var(--p-fundo);
  color: var(--p-texto);
  -moz-appearance: textfield;
}
#painel .tempo input::-webkit-inner-spin-button,
#painel .tempo input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.atalhos { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; }
.atalhos button {
  min-width: 34px;
  padding: 4px 8px;
  border: 1px solid var(--p-linha);
  border-radius: 4px;
  background: var(--p-cartao);
  font-variant-numeric: tabular-nums;
}
.atalhos button:hover { border-color: #b9c2ce; }
.atalhos button[aria-pressed="true"] { background: var(--p-acento); border-color: var(--p-acento); color: #fff; }
.atalhos em { font-style: normal; color: var(--p-suave); margin-left: 2px; }

.texto { display: block; }
#painel input[type="text"] {
  width: 100%;
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--p-linha);
  border-radius: 4px;
  background: var(--p-cartao);
  color: inherit;
}
#painel input:focus-visible,
#painel button:focus-visible { outline: 2px solid var(--p-acento); outline-offset: 1px; }
#painel input[type="text"]:focus,
#painel .tempo input:focus { outline: none; border-color: var(--p-acento); box-shadow: 0 0 0 1px var(--p-acento); }

.chave {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  cursor: pointer;
}
.chave + .chave { border-top: 1px solid #eef1f4; }
.chave input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 99px;
  background: #c9d0da;
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.chave input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.chave input:checked { background: var(--p-acento); }
.chave input:checked::after { transform: translateX(14px); }

.volume { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.volume svg { width: 18px; height: 18px; fill: var(--p-suave); flex: none; }
.volume input { flex: 1; min-width: 0; accent-color: var(--p-acento); }

.temas button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 10px; flex: 1; }
.amostra {
  width: 100%;
  min-width: 56px;
  height: 30px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-style: normal;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.amostra b { font: 600 15px/1 var(--fonte); font-variant-numeric: tabular-nums; }
.amostra.claro { background: linear-gradient(135deg, #f4f6fa, #dfe6f1); color: #121821; }
.amostra.escuro { background: linear-gradient(135deg, #2b3446, #141922); color: #fff; }
.amostra.auto { background: linear-gradient(135deg, #f4f6fa 50%, #1d2431 50%); color: #fff; }
.amostra.auto b { mix-blend-mode: difference; }

button.secundario,
button.primario {
  padding: 7px 14px;
  border-radius: 4px;
  border: 1px solid var(--p-linha);
  background: var(--p-cartao);
}
button.secundario:hover { border-color: #b9c2ce; }
button.primario { background: var(--p-acento); border-color: var(--p-acento); color: #fff !important; font-weight: 600; }
button.primario:hover { background: #2559b6; }

#painel footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: var(--p-cartao);
  border-top: 1px solid var(--p-linha);
}

@media (max-height: 300px) {
  #painel header { padding: 6px 12px; }
  #painel footer { padding: 6px 12px; }
  #painel .corpo { padding: 8px 12px; }
}
