:root {
	color-scheme: dark;
	--page: #0c0c0e;
	--surface: #141417;
	--surface-haut: #1c1c20;
	--survol: #1f1f24;
	--survol-fort: #27272d;
	--trait: #24242a;
	--trait-fort: #34343c;
	--texte: #ececef;
	--doux: #a1a1aa;
	--faible: #6b6b75;
	--accent: #4ade80;
	--danger: #f87171;
	--danger-fond: #2a1416;
	--danger-trait: #5b2328;
	--heure: 48px;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--trait-fort) transparent; scrollbar-width: thin; }
body {
	margin: 0;
	min-height: 100vh;
	background: var(--page);
	color: var(--texte);
	font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- connexion */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; }
.carte-connexion { width: 100%; max-width: 400px; }
.carte-connexion h1 { margin: 0 0 24px; text-align: center; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.champ { margin-bottom: 14px; }
.champ label { display: block; font-size: 12.5px; font-weight: 500; color: var(--doux); margin-bottom: 8px; }
.champ input {
	width: 100%; height: 44px; padding: 0 14px;
	background: var(--surface); color: var(--texte);
	border: 1px solid var(--trait); border-radius: 10px;
	font: inherit; outline: none; transition: border-color .12s;
}
.champ input:focus { border-color: var(--faible); }
.primaire {
	width: 100%; margin-top: 6px; height: 42px;
	background: var(--texte); color: var(--page);
	border: 1px solid var(--texte); border-radius: 8px;
	font-weight: 600; cursor: pointer; transition: background .12s;
}
.primaire:hover { background: #fff; }
.erreur {
	margin-bottom: 16px; padding: 10px 12px;
	background: var(--danger-fond); border: 1px solid var(--danger-trait); border-radius: 8px;
	color: var(--danger); font-size: 13px;
}

/* ---------------------------------------------------------------- barre */
.barre {
	position: sticky; top: 0; z-index: 5;
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	height: 56px; padding: 0 16px;
	padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
	background: var(--page); border-bottom: 1px solid var(--trait);
}
.nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.logo { width: 28px; height: 28px; margin-right: 8px; border-radius: 7px; object-fit: contain; flex: none; }
.nav h1 { margin: 0 0 0 10px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre form { margin: 0; }
.icone {
	display: inline-flex; align-items: center; justify-content: center; flex: none;
	width: 34px; height: 34px; padding: 0;
	background: transparent; color: var(--doux);
	border: 1px solid transparent; border-radius: 8px; cursor: pointer;
	transition: background .12s, color .12s;
}
.icone:hover { background: var(--survol); color: var(--texte); }
.bouton {
	height: 34px; padding: 0 12px;
	background: var(--surface); color: var(--texte);
	border: 1px solid var(--trait); border-radius: 8px;
	font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
	transition: background .12s, border-color .12s;
}
.bouton:hover { background: var(--survol); border-color: var(--trait-fort); }
.danger-doux { color: var(--danger); }
.danger-doux:hover { background: var(--danger-fond); border-color: var(--danger-trait); }
.lien { padding: 0; background: none; border: 0; color: var(--doux); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.lien:hover { color: var(--texte); }

/* ---------------------------------------------------------------- mise en page */
.page {
	display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 16px; align-items: start;
	padding: 16px; max-width: 1680px; margin: 0 auto;
}
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; }
.cote {
	position: sticky; top: 72px;
	display: flex; flex-direction: column; gap: 16px;
	height: calc(100dvh - 88px);
}

/* ---------------------------------------------------------------- semaine */
.semaine { overflow: hidden; }
.bande { display: none; }
.grille { --cols: 5; }
.tete, .journee, .corps { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
.tete { border-bottom: 1px solid var(--trait); }
.tete > div { padding: 10px 8px 9px; text-align: center; font-size: 12px; color: var(--doux); text-transform: capitalize; }
.tete .num { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; margin-left: 4px; padding: 0 6px; border-radius: 13px; color: var(--texte); font-size: 14px; font-weight: 600; }
.tete .auj .num { background: var(--texte); color: var(--page); }
.journee { border-bottom: 1px solid var(--trait); }
.journee > div { display: flex; flex-direction: column; gap: 3px; padding: 4px; min-width: 0; }
.journee .etiquette { justify-content: center; align-items: flex-end; padding-right: 8px; color: var(--faible); font-size: 11px; }
.corps { position: relative; }
.heures > div { height: var(--heure); padding-right: 8px; text-align: right; color: var(--faible); font-size: 11px; transform: translateY(-7px); }
.heures > div:first-child { visibility: hidden; }
.colonne { position: relative; border-left: 1px solid var(--trait); }
.colonne .ligne { height: var(--heure); border-top: 1px solid var(--trait); }
.colonne .ligne:first-child { border-top-color: transparent; }
.colonne.auj { background: #111114; }

.ev {
	position: absolute; left: 3px; right: 3px; overflow: hidden;
	padding: 4px 7px; border-radius: 6px; border-left: 3px solid var(--c-trait);
	background: var(--c-fond); color: var(--c-texte);
	font-size: 12px; line-height: 1.3; text-align: left; cursor: pointer;
	border-top: 0; border-right: 0; border-bottom: 0;
}
.ev:hover { filter: brightness(1.15); }
.ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { display: block; opacity: .8; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.court { padding-top: 1px; padding-bottom: 1px; }
.ev.court b { display: inline; }
.ev.court span { display: inline; margin-left: 6px; }
.puce {
	display: block; width: 100%; padding: 2px 7px; border-radius: 5px; border: 0; border-left: 3px solid var(--c-trait);
	background: var(--c-fond); color: var(--c-texte); font-size: 11.5px; font-weight: 600; text-align: left;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.maintenant { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 2; pointer-events: none; }
.maintenant::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.vide-jour { grid-column: 2 / -1; padding: 28px 0; text-align: center; color: var(--faible); font-size: 13px; }

.c-gris   { --c-fond: #1f1f24; --c-trait: #71717a; --c-texte: #e4e4e7; }
.c-bleu   { --c-fond: #14213a; --c-trait: #60a5fa; --c-texte: #cfe1ff; }
.c-cyan   { --c-fond: #0f272c; --c-trait: #22d3ee; --c-texte: #c4f3fb; }
.c-vert   { --c-fond: #12271b; --c-trait: #4ade80; --c-texte: #c8f5d6; }
.c-jaune  { --c-fond: #29240f; --c-trait: #facc15; --c-texte: #fbefb0; }
.c-orange { --c-fond: #2c1d10; --c-trait: #fb923c; --c-texte: #fddcbf; }
.c-rouge  { --c-fond: #2d1517; --c-trait: #f87171; --c-texte: #fdd0d0; }
.c-rose   { --c-fond: #2c1524; --c-trait: #f472b6; --c-texte: #fbd3ea; }
.c-violet { --c-fond: #201a36; --c-trait: #a78bfa; --c-texte: #e0d9ff; }

/* ---------------------------------------------------------------- notes */
.notes { flex: none; max-height: 36%; overflow: auto; padding: 14px 16px 10px; }
.notes h2, .dialogue h2 { margin: 0; font-size: 13px; font-weight: 600; }
.notes h2 { margin-bottom: 8px; color: var(--doux); }
.notes ul { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-top: 1px solid var(--trait); }
.notes li:first-child { border-top: 0; }
.notes .n-date { flex: none; width: 74px; color: var(--doux); font-size: 12px; padding-top: 1px; }
.notes .n-date.proche { color: var(--texte); font-weight: 600; }
.notes .n-date.passee { color: var(--faible); text-decoration: line-through; }
.notes .n-texte { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
.notes .icone { width: 24px; height: 24px; margin-top: -2px; }
.notes .icone svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- discussion */
.discussion { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fil { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; font-size: 13.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.moi { align-self: flex-end; padding: 8px 12px; background: var(--surface-haut); border: 1px solid var(--trait); border-radius: 12px 12px 4px 12px; }
.msg.claude { align-self: flex-start; padding: 2px 2px; }
.msg.action { align-self: center; color: var(--faible); font-size: 12px; text-align: center; }
.msg.erreur { color: var(--danger); }
.msg.attente { color: var(--faible); }
.msg .pj { display: block; margin-top: 4px; color: var(--doux); font-size: 12px; }
.msg .ignores { display: block; margin-top: 4px; color: var(--faible); font-size: 12px; }
.msg .meta { display: flex; gap: 12px; margin-top: 4px; }
.msg .meta .fait { color: var(--faible); font-size: 12px; }
.msg.annule > .corps-msg { color: var(--faible); text-decoration: line-through; }

.compose { flex: none; padding: 10px; border-top: 1px solid var(--trait); }
.saisie { display: flex; align-items: flex-end; gap: 6px; padding: 5px; background: var(--page); border: 1px solid var(--trait); border-radius: 12px; transition: border-color .12s; }
.saisie:focus-within { border-color: var(--trait-fort); }
.saisie textarea {
	flex: 1; min-width: 0; max-height: 180px; padding: 7px 4px; resize: none;
	background: transparent; color: var(--texte); border: 0; outline: none;
	font: inherit; font-size: 14px; line-height: 1.45;
}
.saisie textarea::placeholder { color: var(--faible); }
.joindre input { display: none; }
.envoyer {
	display: inline-flex; align-items: center; justify-content: center; flex: none;
	width: 34px; height: 34px; padding: 0; border-radius: 9px; cursor: pointer;
	background: var(--texte); color: var(--page); border: 0; transition: background .12s;
}
.envoyer:hover:not(:disabled) { background: #fff; }
.envoyer:disabled { background: var(--survol-fort); color: var(--faible); cursor: default; }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.piece { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 28px; padding: 0 4px 0 10px; background: var(--surface-haut); border: 1px solid var(--trait); border-radius: 8px; font-size: 12px; color: var(--doux); }
.piece span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.piece button { width: 22px; height: 22px; }
.piece button svg { width: 13px; height: 13px; }
body.depot .saisie { border-color: var(--accent); }

.bulle { display: none; }

/* ---------------------------------------------------------------- détail */
.dialogue {
	width: min(440px, calc(100vw - 32px)); padding: 20px;
	background: var(--surface); color: var(--texte);
	border: 1px solid var(--trait-fort); border-radius: 12px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
}
.dialogue::backdrop { background: rgba(0, 0, 0, .6); }
.dialogue-tete { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dialogue h2 { font-size: 16px; }
.pastille { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c-trait); }
.d-ligne { margin: 0 0 6px; font-size: 13.5px; }
.d-ligne:empty, .d-details:empty { display: none; }
.doux { color: var(--doux); }
.d-details { margin: 10px 0 0; padding: 10px 12px; background: var(--page); border: 1px solid var(--trait); border-radius: 8px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialogue-bas { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------------------------------------------------------------- téléphone */
@media (max-width: 999px) {
	.page { display: block; padding: 10px; padding-bottom: 150px; }
	.cote { position: static; height: auto; margin-top: 10px; gap: 10px; }
	.notes { max-height: none; }
	.discussion { border: 0; background: none; }
	.fil { max-height: none; overflow: visible; padding: 6px 4px; }
	.compose {
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
		padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
		background: var(--page); border-top: 1px solid var(--trait);
	}
	.saisie textarea { font-size: 16px; }
	.bulle:not([hidden]) {
		display: block; position: fixed; left: 10px; right: 10px; z-index: 6;
		bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 45vh; overflow: auto;
		padding: 12px 14px 10px; background: var(--surface-haut); border: 1px solid var(--trait-fort); border-radius: 12px;
		box-shadow: 0 16px 40px rgba(0, 0, 0, .55); font-size: 14px; overflow-wrap: anywhere;
	}
	#bulle-texte { white-space: pre-wrap; }
	.bulle.erreur { color: var(--danger); }
	.bulle-bas { display: flex; justify-content: flex-end; gap: 16px; margin-top: 8px; }
	.barre { height: 52px; padding: 0 8px; }
	.nav { gap: 2px; }
	.logo { width: 24px; height: 24px; margin-right: 4px; }
	.nav h1 { margin-left: 6px; font-size: 14px; }
	.bouton#auj { height: 32px; padding: 0 10px; }
	.bande { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 6px; border-bottom: 1px solid var(--trait); }
	.bande button {
		display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0;
		background: none; border: 0; border-radius: 8px; cursor: pointer; color: var(--doux); font-size: 11px; text-transform: capitalize;
	}
	.bande button b { font-size: 15px; font-weight: 600; color: var(--texte); }
	.bande button.choisi { background: var(--surface-haut); }
	.bande button.auj b { color: var(--accent); }
	.bande button i { width: 4px; height: 4px; border-radius: 2px; background: var(--faible); }
	.bande button i.rien { background: transparent; }
	.tete { display: none; }
	.tete, .journee, .corps { grid-template-columns: 44px minmax(0, 1fr); }
	.colonne.auj { background: none; }
}
