:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7c;
  --line: #dde2e8;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --ok: #1d7a46;
  --warn: #a15c00;
  --bad: #b3261e;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); }
header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: center;
}
header.top .brand { font-weight: 700; margin-right: auto; text-decoration: none; color: var(--text); }
header.top nav { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
header.top nav a { text-decoration: none; padding: 0.2rem 0; }
header.top nav a.current { font-weight: 700; border-bottom: 2px solid var(--accent); }
header.top form { margin: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
main.narrow { max-width: 420px; }
h1 { font-size: 1.5rem; margin: 0.4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.6rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.banner { padding: 0.6rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.banner.info { background: #e7f0fd; border: 1px solid #b9d2f6; }
.banner.warn { background: #fff4e0; border: 1px solid #f0cf94; }
/* Brief 60 bis, S4: a value to check in the item to validate, on the yellow of the warnings. */
.review-details p { margin: 0.25rem 0; }
.review-text { field-sizing: content; min-height: 4rem; }
.review-details .doubt { background: #fff4e0; border-left: 4px solid #f0cf94; padding: 0.15rem 0.5rem; }
.banner.bad { background: #fde9e7; border: 1px solid #f2b8b3; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* A shadow on the side where more of a wide table can be scrolled to. */
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) 0 0,
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)) 0 0,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 2.5rem 100%, 2.5rem 100%, 0.9rem 100%, 0.9rem 100%;
  background-attachment: local, local, scroll, scroll;
  background-color: var(--surface);
}
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
label { display: block; font-weight: 600; margin: 0.7rem 0 0.25rem; }
label.inline { display: inline-flex; gap: 0.4rem; align-items: center; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
td select, td input { min-width: 7rem; }
textarea { min-height: 6rem; font-family: inherit; }
textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0 0; }
button, .button {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.8rem;
}
button.secondary, .button.secondary { background: var(--surface); color: var(--accent); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.small, .button.small { padding: 0.25rem 0.6rem; margin-top: 0; font-size: 0.9rem; }
button.link { background: none; border: none; color: var(--accent); padding: 0; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.row > * { flex: 1 1 240px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.actions form { margin: 0; }
.tag { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.82rem; background: #eceff3; white-space: nowrap; }
.tag.ok { background: #e0f3e8; color: var(--ok); }
.tag.warn { background: #fff0d6; color: var(--warn); }
.tag.bad { background: #fde3e1; color: var(--bad); }
.muted { color: var(--muted); }
.breakable { overflow-wrap: anywhere; }
pre { white-space: pre-wrap; word-break: break-word; background: #f1f3f6; padding: 0.7rem; border-radius: 6px; margin: 0; font-size: 0.88rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.35rem 0; }
input[type=date], input[type=time], input[type=datetime-local] { width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
fieldset.group { border: 1px solid var(--line); border-radius: var(--radius); margin: 1rem 0 0; padding: 0.2rem 0.9rem 0.9rem; }
fieldset.group legend { font-weight: 600; padding: 0 0.3rem; }
.field-label { font-weight: 600; margin: 0.7rem 0 0.25rem; }
.field-error { color: var(--bad); font-size: 0.9rem; margin: 0.2rem 0 0; }
[aria-invalid=true] { border-color: var(--bad) !important; }
.field-table .table-wrap { margin-bottom: 0.4rem; }
.field-table td input[type=checkbox] { min-width: 0; }
progress { width: 100%; height: 0.9rem; accent-color: var(--accent); }
.run-progress .run-state { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; margin: 0 0 0.6rem; }
.run-progress .run-step { font-weight: 600; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.15rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
@media (max-width: 640px) {
  main { padding: 0.7rem; }
  /* A wide table keeps readable columns and scrolls sideways. */
  .table-wrap table.wide { min-width: 44rem; }
  h1 { font-size: 1.3rem; }
  th, td { padding: 0.45rem 0.5rem; }
}

/* Brief 66b, points 11 and 13: under 700 px, a table marked "cards" shows one card per row,
   without sideways scrolling. A cell with data-label shows its label above its value; the
   "card-line" cells follow each other on one line, joined by a dot; "card-only" shows on a card only. */
.card-only { display: none; }
@media (max-width: 700px) {
  .table-wrap.cards-wrap { overflow: visible; border: 0; border-radius: 0; background: none; }
  .table-wrap table.cards, .table-wrap table.cards.wide { min-width: 0; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.cards tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 0.75rem; }
  table.cards td { border: 0; padding: 0.15rem 0; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
  table.cards td.card-line { display: inline; white-space: nowrap; }
  table.cards td.card-line:not(:empty):has(~ td.card-line:not(:empty))::after { content: "\00a0·"; }
  table.cards .card-only { display: inline; }
  table.cards a.study-link { font-weight: 700; color: var(--base, var(--text)); text-decoration: none; }
  /* Brief 67, point 1: the cards of forms.js (cardTables): the first cell as a bold title (its
     link too), then one "label : value" line per other cell; the state tag stays as it is. */
  table.auto-cards tr.cards-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.auto-cards tfoot, table.auto-cards tr > th { display: block; border: 0; padding: 0.15rem 0; }
  table.auto-cards tr > td, table.auto-cards tr > th { text-align: left; }
  table.auto-cards tr > :first-child:not([colspan]), table.auto-cards tr > :first-child:not([colspan]) a { font-weight: 700; }
  table.auto-cards td[data-label]::before, table.auto-cards th[data-label]::before { content: attr(data-label) "\00a0: "; display: inline; font-size: inherit; }
  table.auto-cards tr > td, table.auto-cards tr > td:first-child, table.auto-cards tr > th { width: auto; min-width: 0; }
  table.auto-cards tr > :first-child input, table.auto-cards tr > :first-child select { width: 100%; }
}

/* Brief 66b, point 16: the big start buttons of a page, the same size, side by side on a
   computer and one under the other on a phone. */
.start-choices { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1rem; margin: 0 0 1.5rem; }
.start-choices:not(:has(a)) { display: none; }
a.start-choice { display: flex; flex-direction: column; justify-content: center; gap: 0.2rem; min-height: 72px; padding: 0.9rem 1.2rem; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); text-decoration: none; }
a.start-choice strong { font-size: 1.15rem; }
a.start-choice:hover, a.start-choice:focus-visible { filter: brightness(1.1); }
@media (max-width: 700px) { .start-choices { grid-auto-flow: row; } }

/* A list item shown as a card: its lines one under the other (brief 66b, point 16). */
.item-card { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
ul.plain li.item-card { padding: 1rem; }
.item-card .button { margin-top: 0.4rem; }
.item-card > a:first-child { font-weight: 700; color: var(--base, var(--text)); text-decoration: none; }

/* Brief 63, point 7: a folded block shows it unfolds (arrow, wide target, open or closed state). */
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.5rem 0; font-weight: 600; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "\25B8"; display: inline-block; flex: none; transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary::after { content: "Voir plus"; margin-left: auto; font-weight: 400; font-size: 0.9em; text-decoration: underline; }
details[open] > summary::after { content: "Masquer"; }

/* Brief 63, point 3: the numbered steps of the house and settings screen. */
.setup-steps { list-style: none; padding: 0; margin: 0; }
.setup-step { margin: 0 0 1.5rem; }
.setup-step > h2 { display: flex; align-items: center; gap: 0.6rem; font-size: 1.15rem; }
.setup-number { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: #1f4e8c; color: #fff; font-size: 1rem; }
.setup-hint { font-weight: 600; }
.study-actions .page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.home-zone { display: flex; flex-direction: column; gap: 0.25rem; text-decoration: none; margin: 1rem 0; }
