:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16191d;
  --muted: #5f6670;
  --line: #e1e4e8;
  --accent: #2563eb;
  --accent-soft: #e8effd;
  --bad: #c2410c;
  --great: #b45309;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --card: #1b1e22;
    --text: #e8eaed;
    --muted: #9aa0a8;
    --line: #2c3036;
    --accent: #60a5fa;
    --accent-soft: #16243d;
    --bad: #fb923c;
    --great: #fbbf24;
    color-scheme: dark;
  }
}

html { overflow-x: clip; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  overflow-x: clip;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

.top { padding: 28px 0 12px; }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-top: 16px; padding: 12px 14px;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px;
  font-size: 0.925rem;
}
.notice-actions { display: flex; align-items: center; gap: 14px; }
.notice .to-classic { font-weight: 600; }
.keep { border: 0; background: none; padding: 0; color: var(--muted); font-size: 0.875rem; text-decoration: underline; }
.top h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.01em; }
.top p { margin: 4px 0 0; color: var(--muted); }

/* Anuncios: un bloque que Google no llena (data-ad-status="unfilled") se oculta, como recomienda AdSense,
   para que no deje un hueco ni un iframe vacío encima de la calculadora. */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad { margin: 12px auto; }
/* Banner de arriba: reserva su alto y nunca se sale de su espacio. */
.ad-top { min-height: 90px; overflow: hidden; }
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }

/* minmax(0, ...) y min-width: 0: la cuadrícula nunca se ensancha por un anuncio automático que Google inserte adentro. */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 8px; margin-bottom: 8px; }
.layout > *, body > * { min-width: 0; }
@media (min-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .result { position: sticky; top: 16px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.head { display: flex; justify-content: space-between; align-items: baseline; }
.head h2 { margin: 0 0 10px; font-size: 1.1rem; }

.cols, .row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}
.cols { font-size: 0.8rem; color: var(--muted); padding: 0 2px 4px; }
.cols span:nth-child(2), .cols span:nth-child(3) { text-align: center; font-weight: 600; color: var(--text); font-size: 0.875rem; }
.cols em { font-style: normal; font-size: 0.75rem; }
.row { margin-bottom: 8px; }

input {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}
input[name=nota], input[name=creditos] { text-align: center; font-variant-numeric: tabular-nums; font-size: 1.25rem; font-weight: 600; padding: 8px 6px; }
input[name=materia] { font-size: 0.875rem; }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input.bad { border-color: var(--bad); color: var(--bad); }

button { font: inherit; cursor: pointer; }
.remove {
  width: 36px; height: 36px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 1.3rem; line-height: 1;
}
.remove:hover { background: var(--accent-soft); color: var(--bad); }
.add {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.link { border: 0; background: none; color: var(--muted); font-size: 0.875rem; text-decoration: underline; padding: 0; }
.hint { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

.result { text-align: center; }
.result .label { display: block; color: var(--muted); font-size: 0.9rem; }
#avg { display: block; font-size: 4rem; font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
/* Los fuegos artificiales de siempre, detrás del número, cuando el promedio es excelente. */
.hero { border-radius: 10px; margin: 4px 0; padding: 16px 0; transition: background-color .3s; }
.result.great .hero { background: #000 url("../img/gif1.gif") center / cover no-repeat; }
.result.great #avg { color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.exact, .credits { display: block; font-size: 0.875rem; color: var(--muted); }
.msg { font-weight: 600; margin: 10px 0 0; min-height: 1.5em; }
.result.great .msg { color: var(--great); }
.warn { color: var(--bad); font-size: 0.875rem; margin: 6px 0 0; }
details { margin-top: 12px; text-align: left; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.steps { margin: 10px 0 0; padding-left: 20px; font: 0.85rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.steps .sum { list-style: none; margin-left: -20px; }
.steps .sum.first { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.steps .total { list-style: none; margin-left: -20px; margin-top: 6px; font-weight: 700; }
.formula { font-size: 0.8rem; color: var(--muted); margin: 10px 0 0; }
.ad-calc { margin: 12px 0 0; min-height: 100px; }

.foot { margin-top: auto; text-align: center; color: var(--muted); font-size: 0.875rem; padding-top: 12px; padding-bottom: 32px; }
.foot p { margin: 4px 0; }

@media (max-width: 420px) {
  .cols, .row { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr) 32px; gap: 6px; }
  #avg { font-size: 3.4rem; }
}
