[x-cloak] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header.topbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
header.topbar nav { display: flex; gap: 14px; align-items: center; font-size: 0.9rem; }
header.topbar nav a {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
header.topbar nav a:hover { color: var(--text); }
header.topbar nav a svg { flex-shrink: 0; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 svg, h2 svg, h3 svg { vertical-align: -5px; margin-right: 6px; color: var(--primary); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 12px; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--primary);
  color: var(--surface);
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn.accent { background: var(--accent); color: var(--surface); }
.btn.danger { background: #c0392b; color: #fff; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--text) 20%, transparent);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}
textarea { min-height: 88px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }
.checkbox-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; min-height: auto; margin: 4px 0 0; }
.checkbox-row label { margin: 0; font-weight: 400; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--secondary) 20%, var(--surface));
  color: var(--text);
}

.hidden { display: none; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.m-0 { margin: 0; }
.table-scroll { overflow-x: auto; }
.visually-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 480px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.epreuve-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.epreuve-card h3 { font-size: 1rem; margin-bottom: 4px; }
.epreuve-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

.error-msg { color: #c0392b; font-size: 0.9rem; margin: -8px 0 12px; }
.success-msg { color: #1e7e34; font-size: 0.9rem; margin: -8px 0 12px; }

.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps .step {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
}
.steps .step.done { background: var(--primary); }

table.rotation-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.rotation-table th, table.rotation-table td {
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  padding: 8px;
  text-align: left;
}
table.rotation-table select { margin: 0; min-height: 36px; }

.empty-state { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.empty-state svg { margin: 0 auto 12px; color: var(--text-muted); }

.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; }
.palette-card {
  border: 2px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  background: var(--surface);
  font: inherit;
  text-align: left;
  color: var(--text);
  min-height: 44px;
}
.palette-card:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.palette-card.actif { border-color: var(--accent); border-width: 2px; }
.palette-card .nom { font-size: 0.85rem; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.palette-card .swatches { display: flex; gap: 5px; }
.palette-card .swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--text) 15%, transparent); }

.card-icon { color: var(--primary); margin-bottom: 8px; }

.rang-row { display: flex; align-items: center; gap: 8px; }
.rang-row label { flex: 2; margin: 0; font-weight: 400; }
.rang-row input { flex: 1; margin: 0; }

.sync-banner {
  background: var(--bg-warning, #fff3cd);
  color: #8a6d00;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
}

table.classement-table { width: 100%; border-collapse: collapse; font-size: 1.3rem; }
table.classement-table th, table.classement-table td {
  padding: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  text-align: left;
}
table.classement-table tbody tr:first-child td {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.6rem;
}
