/* ── Bloc d'erreur de calcul ────────────────────────────────────── */
.calc-error {
  background: rgba(248, 81, 73, .12);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  padding: .7rem 1rem;
  font-size: .88rem;
  margin-bottom: 1rem;
  white-space: pre-line;
}
.calc-error::before {
  content: "⛔  Erreur de calcul\A";
  font-weight: 700;
}

/* ── Barre de préréglages ────────────────────────────────────────── */
.preset-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin-bottom: 1.2rem;
}
.preset-bar label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.preset-bar select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .45rem .7rem;
  font-size: .95rem;
  min-width: 260px;
  cursor: pointer;
  transition: border-color .2s;
}
.preset-bar select:focus {
  outline: none;
  border-color: var(--primary);
}
.preset-info {
  font-size: .78rem;
  color: var(--muted);
  font-style: italic;
  flex: 1;
}

/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --primary:   #2f81f7;
  --primary-dk:#1a5eb5;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --good:      #3fb950;
  --warn:      #d29922;
  --danger:    #f85149;
  --radius:    10px;
  --shadow:    0 4px 20px rgba(0,0,0,.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 1rem;
}

/* ── Header ─────────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}
header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #58a6ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  color: var(--muted);
  margin-top: .4rem;
  font-size: .95rem;
}

/* ── Layout ─────────────────────────────────────────────────────── */
main { max-width: 1300px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.2rem;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Fields ─────────────────────────────────────────────────────── */
.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .3rem;
  font-weight: 500;
}
.field input[type="number"],
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .45rem .7rem;
  font-size: .95rem;
  transition: border-color .2s;
}
.field input[type="number"]:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
}
.hint {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
  font-style: italic;
}

/* ── Results card ───────────────────────────────────────────────── */
.results { grid-column: 1 / -1; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .8rem;
  margin-bottom: 1.4rem;
}

.result-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.result-label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}
.result-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.result-unit {
  font-size: .75rem;
  color: var(--muted);
}

/* ── Gauge ──────────────────────────────────────────────────────── */
.wob-gauge {
  margin: 1.2rem 0;
}
.gauge-bar {
  height: 14px;
  background: linear-gradient(to right, var(--good), var(--warn), var(--danger));
  border-radius: 7px;
  position: relative;
  overflow: visible;
}
.gauge-fill {
  position: absolute;
  top: -4px;
  width: 22px;
  height: 22px;
  background: white;
  border: 3px solid var(--bg);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 8px rgba(0,0,0,.6);
  transition: left .5s ease;
  left: 0%;
}
.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: .73rem;
  color: var(--muted);
  margin-top: .4rem;
}

.wob-rating {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: .6rem;
  min-height: 1.5em;
}

/* ── Norms table ────────────────────────────────────────────────── */
.norms { margin: 1rem 0; }
.norms h3 { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .4rem .7rem; text-align: left; border: 1px solid var(--border); }
th { background: var(--bg); color: var(--muted); font-weight: 500; }

/* ── Button ─────────────────────────────────────────────────────── */
#btnCalculate {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: .75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
#btnCalculate:hover { background: #58a6ff; }
#btnCalculate:active { transform: scale(.98); }

/* ── Theory accordion ───────────────────────────────────────────── */
.theory {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.theory summary {
  padding: .9rem 1.2rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
  list-style: none;
}
.theory summary::before { content: "▶  "; font-size: .8em; }
details[open] .theory summary::before { content: "▼  "; }
.theory-content {
  padding: 1rem 1.4rem 1.4rem;
  border-top: 1px solid var(--border);
}
.theory-content h3 { margin-bottom: .5rem; }
.theory-content h4 { margin: 1rem 0 .3rem; color: var(--primary); }
.theory-content pre {
  background: var(--bg);
  padding: .6rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  overflow-x: auto;
  margin: .4rem 0;
  color: #79c0ff;
}
.note {
  margin-top: 1rem;
  font-size: .82rem;
  color: var(--warn);
  border-left: 3px solid var(--warn);
  padding-left: .7rem;
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1rem 1rem;
  font-size: .8rem;
  color: var(--muted);
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header h1 { font-size: 1.7rem; }
  .result-value { font-size: 1.3rem; }
}
