:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
  background: #0b0c0f;
  color: #f3f4f6;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100%; background: #0b0c0f; }
main { width: min(760px, 100%); margin: 0 auto; padding: 10px 10px calc(18px + env(safe-area-inset-bottom)); }

.hero { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 2px 2px 8px; }
h1 { margin: 0; font-size: 1.55rem; line-height: 1.05; }
h2 { margin: 0; font-size: .94rem; }
.eyebrow { margin: 0 0 2px; color: #9ca3af; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }

.card { background: #15171c; border: 1px solid #2a2e37; border-radius: 12px; padding: 11px; margin-bottom: 8px; }
.badge { border: 1px solid #3c4250; border-radius: 999px; padding: 5px 8px; font-size: .7rem; white-space: nowrap; }

.controls { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 7px; padding: 8px; }
.sticky-top { position: sticky; top: 6px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
button, select { min-height: 40px; border-radius: 9px; border: 1px solid #3c4250; background: #222630; color: #fff; padding: 0 12px; font: inherit; }
button.primary { font-weight: 700; background: #e5e7eb; color: #111827; border-color: #e5e7eb; }
button:disabled { opacity: .42; }
button:not(:disabled) { cursor: pointer; }
.session-line { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; color: #9ca3af; font-size: .72rem; }
.session-line code { color: #d1d5db; }

.situation-card { overflow: hidden; }
.situation-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.section-label { display: block; margin: 0 0 4px; color: #8f96a3; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.situation-value { min-height: 1.25em; font-size: clamp(1.45rem, 7vw, 2.25rem); line-height: 1.05; font-weight: 800; letter-spacing: -.035em; }
.situation-subtitle { min-height: 2.5em; margin-top: 5px; color: #b6bcc7; font-size: .82rem; line-height: 1.25; }
.confidence-box { min-width: 60px; text-align: right; }
.confidence-box strong { display: block; font-size: 1.25rem; }
.confidence-box span { color: #838b98; font-size: .62rem; }
.confidence-track { height: 4px; margin: 9px 0 10px; border-radius: 999px; overflow: hidden; background: #252932; }
.confidence-track > div { width: 0; height: 100%; background: currentColor; transition: width .2s ease; }

.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.fact { min-height: 76px; padding: 8px; border-radius: 9px; background: #0f1115; border: 1px solid #252932; overflow: hidden; }
.fact > span { display: block; color: #858d9a; font-size: .68rem; }
.fact > strong { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.fact > small { display: block; margin-top: 4px; color: #a8aeba; font-size: .68rem; line-height: 1.2; min-height: 2.4em; }

.evidence-block { margin-top: 10px; }
.evidence { min-height: 4.1em; margin: 0; padding-left: 19px; color: #c9ced7; font-size: .76rem; line-height: 1.35; }
.evidence li { margin: 2px 0; }

.truth-card { position: sticky; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 15; box-shadow: 0 -8px 26px rgba(0,0,0,.26); }
.truth-title p { margin: 2px 0 8px; color: #8f96a3; font-size: .7rem; }
.truth-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.truth-controls select { min-width: 0; width: 100%; }

.compact-details { padding: 0; overflow: hidden; }
.compact-details summary { cursor: pointer; padding: 11px; font-weight: 650; font-size: .86rem; }
.compact-details[open] summary { border-bottom: 1px solid #2a2e37; }
.details-help { margin: 9px 11px 6px; color: #8f96a3; font-size: .72rem; }
.sensor-health { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 7px 11px 12px; font-size: .76rem; }
.sensor-health .name { color: #aeb4c0; }
.sensor-health .state { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.timeline { margin: 0; padding: 9px 11px 11px 30px; max-height: 220px; overflow-y: auto; font-size: .75rem; }
.timeline li { margin: 4px 0; color: #c7cbd4; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (min-width: 620px) {
  main { padding: 14px; }
  .facts-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fact { min-height: 84px; }
}

@media (max-width: 430px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .session-line { grid-column: 1 / -1; text-align: left; }
  .situation-head { gap: 7px; }
}

/* Sessions + analyse serveur */
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-row p { margin: 3px 0 0; color: #8f96a3; font-size: .72rem; }
.small-btn { min-height: 34px; padding: 0 10px; font-size: .76rem; }
.sessions-status { margin: 10px 0 7px; color: #8f96a3; font-size: .72rem; }
.sessions-list { display: grid; gap: 6px; }
.session-row { width: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; padding: 9px 10px; background: #0f1115; border: 1px solid #252932; }
.session-row-main { min-width: 0; }
.session-row-title { display: block; font-weight: 700; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row-meta { display: block; margin-top: 3px; color: #8f96a3; font-size: .68rem; line-height: 1.25; }
.session-row-side { text-align: right; }
.session-row-side strong { display: block; font-size: .78rem; }
.session-row-side small { display: block; margin-top: 2px; color: #8f96a3; font-size: .64rem; }

body.session-running .truth-card { position: sticky; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 15; box-shadow: 0 -8px 26px rgba(0,0,0,.26); }
body:not(.session-running) .truth-card { position: static; box-shadow: none; }

.analysis-dialog { width: min(760px, calc(100% - 16px)); max-height: calc(100dvh - 16px); padding: 0; border: 1px solid #343945; border-radius: 14px; background: #111318; color: #f3f4f6; }
.analysis-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(2px); }
.analysis-shell { max-height: calc(100dvh - 18px); display: flex; flex-direction: column; }
.analysis-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 13px; border-bottom: 1px solid #2a2e37; background: #111318; }
.analysis-header h2 { font-size: 1rem; }
.analysis-subtitle { margin: 4px 0 0; color: #949ba8; font-size: .68rem; overflow-wrap: anywhere; }
.icon-btn { min-width: 38px; min-height: 38px; padding: 0; font-size: 1.35rem; line-height: 1; }
.analysis-body { overflow-y: auto; padding: 10px; }
.analysis-loading, .analysis-error { padding: 24px 10px; text-align: center; color: #aeb4c0; font-size: .8rem; }
.analysis-error { color: #fca5a5; }
.analysis-summary { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; margin-bottom: 8px; }
.analysis-kpi { padding: 9px; border: 1px solid #292e37; border-radius: 9px; background: #0c0e12; }
.analysis-kpi span { display: block; color: #858d9a; font-size: .64rem; text-transform: uppercase; letter-spacing: .04em; }
.analysis-kpi strong { display: block; margin-top: 3px; font-size: .95rem; }
.analysis-section { margin-top: 8px; padding: 10px; border: 1px solid #292e37; border-radius: 10px; background: #15171c; }
.analysis-section h3 { margin: 0 0 8px; font-size: .82rem; }
.analysis-note { margin: 0; color: #aeb4c0; font-size: .72rem; line-height: 1.35; }
.analysis-observations { margin: 0; padding-left: 18px; font-size: .73rem; color: #cbd0d9; line-height: 1.4; }
.analysis-observations li { margin: 3px 0; }
.analysis-table-wrap { overflow-x: auto; }
.analysis-table { width: 100%; border-collapse: collapse; font-size: .68rem; }
.analysis-table th, .analysis-table td { padding: 6px 5px; border-bottom: 1px solid #292e37; text-align: right; white-space: nowrap; }
.analysis-table th:first-child, .analysis-table td:first-child { text-align: left; }
.analysis-table th { color: #8f96a3; font-weight: 600; }
.analysis-table tr:last-child td { border-bottom: 0; }
.phase-list { display: grid; gap: 5px; }
.phase { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 7px 8px; border-radius: 8px; background: #0c0e12; border: 1px solid #252932; }
.phase strong { font-size: .72rem; }
.phase span { color: #949ba8; font-size: .66rem; text-align: right; }
.analysis-definition { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(0,1.3fr); gap: 5px 10px; margin: 0; font-size: .7rem; }
.analysis-definition dt { color: #858d9a; }
.analysis-definition dd { margin: 0; overflow-wrap: anywhere; }
.analysis-empty { color: #858d9a; font-size: .7rem; }

@media (min-width: 620px) {
  .analysis-summary { grid-template-columns: repeat(4, minmax(0,1fr)); }
}


/* Timeline sémantique — première lecture de l'analyse */
.semantic-section { margin-top: 0; border-color: #3a414f; background: #101319; }
.semantic-section h3 { font-size: .9rem; }
.semantic-table { font-size: .72rem; }
.semantic-table th:nth-child(2), .semantic-table td:nth-child(2) { text-align: left; white-space: normal; min-width: 180px; }
.semantic-table th:last-child, .semantic-table td:last-child { text-align: right; }
.semantic-table tbody tr:hover { background: rgba(255,255,255,.035); }
.semantic-confidence { display: inline-block; min-width: 48px; font-weight: 750; font-variant-numeric: tabular-nums; }
.semantic-note { margin-top: 9px; }
