:root {
	--bg: #f4efe6;
	--paper: #fffaf1;
	--ink: #2f2922;
	--muted: #776b5d;
	--line: #e1d3bf;
	--wood: #c98d55;
	--wood-dark: #8a5734;
	--accent: #7f5a38;
	--green: #8aa07a;
	--blue: #7c95a8;
	--rose: #b9847c;
	--gold: #c9a15c;
	--shadow: 0 18px 45px rgba(61, 43, 26, .14);
}

/* ===== HEADER CHAND’HÔME / FICHES ATELIER ===== */

.sheet-header {
  position: relative;
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 20px;
  align-items: start;
  max-width: 1220px;
  margin: 0 auto;
  padding: 34px 22px 20px;
}

.brand {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--sage, #7f8f74);
  margin-bottom: 6px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 760px;
  line-height: 1.5;
}

.title-box {
  position: relative;
  text-align: right;
  padding-top: 8px;
}

.geo {
  position: absolute;
  right: -12px;
  top: -22px;
  width: 170px;
  height: 170px;
  opacity: 0.28;
  pointer-events: none;
}

.title-main {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  letter-spacing: 0.18em;
  font-weight: 500;
}

.subtitle-header {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a857f;
}

@media (max-width: 760px) {
  .sheet-header {
    grid-template-columns: 1fr;
  }

  .title-box {
    text-align: left;
  }

  .geo {
    right: 0;
    top: -18px;
    width: 210px;
    height: 210px;
  }
}

* {
	box-sizing: border-box
}

body {
	margin: 0;
	background: radial-gradient(circle at top left, #fff9ed 0, #f3ebdc 42%, #e8dcc8 100%);
	color: var(--ink);
	font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
	padding: 34px 22px 12px;
	max-width: 1220px;
	margin: auto;
}

.eyebrow {
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--accent);
	font-size: 12px;
	font-weight: 700
}

h1 {
	margin: 8px 0 10px;
	font-family: Georgia, serif;
	font-size: clamp(30px, 5vw, 58px);
	line-height: .98
}

.subtitle {
	max-width: 840px;
	color: var(--muted);
	font-size: 17px;
	line-height: 1.55
}

main {
	max-width: 1220px;
	margin: 0 auto 60px;
	padding: 10px 22px 40px
}

.panel {
	background: rgba(255, 250, 241, .84);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(127, 90, 56, .18);
	border-radius: 28px;
	box-shadow: var(--shadow);
}

.controls {
	display: grid;
	grid-template-columns: repeat(6, minmax(120px, 1fr));
	gap: 14px;
	padding: 18px;
	margin: 16px 0 24px;
}

label {
	font-size: 12px;
	color: var(--muted);
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	display: block;
	margin: 0 0 7px
}

select,
input {
	width: 100%;
	border: 1px solid var(--line);
	background: #fffdf8;
	border-radius: 14px;
	padding: 11px 12px;
	font-size: 15px;
	color: var(--ink);
	outline: none;
}

button {
	border: 0;
	background: #2c2c2c;
	/* couleur fixe fiable */
	color: white;
	border-radius: 8px;
	padding: 10px 14px;
	font-weight: 600;
	cursor: pointer;
	align-self: end;
}

button:hover {
	background: #444;
}

.note {
	padding: 0 18px 18px;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.45;
}

.tabs {
	display: flex;
	gap: 10px;
	margin: 20px 0 16px;
	flex-wrap: wrap
}

.tab {
	padding: 11px 15px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: #fffaf1;
	cursor: pointer;
	font-weight: 700;
	color: var(--muted);
}

.tab.active {
	background: var(--ink);
	color: #fffaf1;
	border-color: var(--ink)
}

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
	gap: 18px;
}

.segment-card {
	position: relative;
	padding: 18px;
	overflow: hidden;
}

.segment-card:before {
	content: "";
	position: absolute;
	inset: auto -40px -64px auto;
	width: 180px;
	height: 180px;
	border-radius: 50%;
	background: rgba(201, 141, 85, .10);
}

.card-top {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 14px;
	margin-bottom: 14px
}

.seg-id {
	width: 52px;
	height: 52px;
	border-radius: 18px;
	display: grid;
	place-items: center;
	font-family: Georgia, serif;
	font-size: 28px;
	font-weight: 700;
	background: var(--color, #8aa07a);
	color: white;
	box-shadow: 0 10px 22px rgba(0, 0, 0, .12);
}

.meta h3 {
	margin: 0;
	font-size: 18px
}

.meta p {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 13px
}

.focus {
	display: grid;
	grid-template-columns: minmax(320px, 1.1fr) minmax(280px, .9fr);
	gap: 18px;
	margin-bottom: 22px;
}

.focus .segment-card {
	min-height: 330px
}

.detail-table {
	padding: 20px;
}

.detail-table h2 {
	font-family: Georgia, serif;
	margin: 0 0 12px;
	font-size: 28px
}

table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0 8px
}

td {
	padding: 10px 12px;
	background: #fffdf8;
	border-top: 1px solid rgba(127, 90, 56, .13);
	border-bottom: 1px solid rgba(127, 90, 56, .13)
}

td:first-child {
	border-left: 1px solid rgba(127, 90, 56, .13);
	border-radius: 12px 0 0 12px;
	color: var(--muted);
	font-weight: 700
}

td:last-child {
	border-right: 1px solid rgba(127, 90, 56, .13);
	border-radius: 0 12px 12px 0;
	text-align: right;
	font-weight: 900
}

.hidden {
	display: none
}

@media (max-width:850px) {
	.controls {
		grid-template-columns: 1fr 1fr
	}

	.focus {
		grid-template-columns: 1fr
	}
}

@media print {
	body {
		background: white
	}

	header,
	.controls,
	.tabs,
	.note {
		display: none
	}

	main {
		max-width: none;
		margin: 0;
		padding: 0
	}

	.panel {
		box-shadow: none
	}

	.segment-card {
		break-inside: avoid
	}
}


/* --- Version image atelier réelle + valeurs dynamiques --- */
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(760px, 1fr));
	gap: 26px;
}

.segment-card.atelier-card {
	background: #fff;
	box-shadow: none;
	border: 0;
	border-radius: 0;
	padding: 18px 20px 30px;
	min-height: 285px;
	overflow: visible;
}

.segment-card.atelier-card:before {
	display: none
}

.atelier-row {
	position: relative;
	display: grid;
	grid-template-columns: 86px minmax(660px, 1fr);
	align-items: center;
	gap: 10px;
}

.side-label {
	font-weight: 900;
	color: var(--fam, #d00000);
	font-size: 22px;
	line-height: 1.55;
	align-self: center;
	padding-top: 12px;
}

.piece-zone {
	position: relative;
	width: 849px;
	height: 243px;
	max-width: 100%;
	transform-origin: left center;
}

.segment-bg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
	user-select: none;
}

.prehole {
	position: absolute;
	top: 2px;
	right: 98px;
	color: #0070c0;
	font-weight: 800;
	font-size: 13px;
	white-space: nowrap;
	z-index: 4;
}

.neighbor {
	position: absolute;
	z-index: 5;
	color: var(--fam, #d00000);
	font-weight: 900;
	font-size: 24px;
}

.cut-label {
	position: absolute;
	z-index: 5;
	left: 50%;
	top: 121px;
	transform: translate(-50%, -50%);
	color: #d00000;
	font-weight: 900;
	font-size: 16px;
	white-space: nowrap;
}

.angle-label {
	position: absolute;
	z-index: 5;
	color: #000;
	font-weight: 900;
	font-size: 17px;
	white-space: nowrap;
}

.total-note {
	position: absolute;
	left: 50%;
	bottom: -5px;
	transform: translateX(-50%);
	text-align: center;
	font-size: 12px;
	line-height: 1.45;
	color: #000;
	white-space: nowrap;
	z-index: 5;
}

.focus .segment-card.atelier-card {
	min-height: 330px;
	padding-top: 22px
}

.focus .piece-zone {
	transform: scale(1.08);
	transform-origin: left center;
	margin: 0 auto 14px
}

.focus .atelier-row {
	grid-template-columns: 86px minmax(660px, 1fr)
}

@media(max-width:980px) {
	.grid {
		grid-template-columns: 1fr
	}

	.atelier-row {
		grid-template-columns: 58px 1fr
	}

	.piece-zone {
		transform: scale(.82);
		width: 849px;
		max-width: none;
		margin-left: 0
	}

	.segment-card.atelier-card {
		overflow: hidden;
		min-height: 235px
	}

	.side-label {
		font-size: 18px
	}
}

@media(max-width:760px) {
	.piece-zone {
		transform: scale(.62)
	}

	.segment-card.atelier-card {
		min-height: 195px;
		padding: 12px
	}
}


/* --- Ajustement final : image intacte + valeurs dynamiques placées comme la fiche atelier --- */
.segment-card.atelier-card {
	padding: 14px 16px 26px;
}

.atelier-row {
	grid-template-columns: 86px minmax(720px, 1fr);
	gap: 8px;
}

.piece-zone {
	width: 849px;
	height: 243px;
	max-width: 100%;
	position: relative;
}

.segment-bg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	z-index: 1;
}

.side-label {
	color: var(--fam, #d00000);
	font-size: 22px;
	font-weight: 900;
	line-height: 1.55;
	align-self: center;
	transform: none;
}

.prehole {
	top: 6px;
	right: 86px;
	color: #006fc9;
	font-size: 13px;
	font-weight: 900;
	z-index: 10;
}

.neighbor {
	position: absolute;
	z-index: 10;
	color: var(--fam, #d00000);
	font-size: 24px;
	font-weight: 900;
	transform: none !important;
	line-height: 1;
}

.neighbor.left {
	left: 118px;
	top: 118px;
}

.neighbor.right {
	right: 125px;
	top: 118px;
}

.angle-label {
	position: absolute;
	z-index: 10;
	color: #000;
	font-size: 17px;
	font-weight: 900;
	white-space: nowrap;
	transform: none !important;
	line-height: 1;
}

.angle-label.tl {
	left: 205px;
	top: 55px;
}

.angle-label.tr {
	right: 205px;
	top: 55px;
}

.angle-label.bl {
	left: 180px;
	top: 165px;
}

.angle-label.br {
	right: 180px;
	top: 165px;
}

.cut-label {
	left: 50%;
	top: 121px;
	transform: translate(-50%, -50%) !important;
	color: #d00000;
	font-size: 16px;
	font-weight: 900;
	z-index: 10;
	white-space: nowrap;
}

.total-note {
	left: 50%;
	bottom: 2px;
	transform: translateX(-50%) !important;
	text-align: center;
	font-size: 12px;
	line-height: 1.45;
	color: #000;
	z-index: 10;
	white-space: nowrap;
}

.focus .piece-zone {
	transform: scale(1.08);
	transform-origin: left center;
	margin: 0 auto 18px;
}

@media(max-width:980px) {
	.atelier-row {
		grid-template-columns: 58px 1fr;
	}

	.piece-zone {
		transform: scale(.82);
		transform-origin: left center;
		width: 849px;
		max-width: none;
	}

	.segment-card.atelier-card {
		overflow: hidden;
		min-height: 235px;
	}

	.focus .piece-zone {
		transform: scale(.82);
	}
}

@media(max-width:760px) {

	.piece-zone,
	.focus .piece-zone {
		transform: scale(.62);
	}

	.segment-card.atelier-card {
		min-height: 195px;
		padding: 12px;
	}
}



/* --- Correction voisins : centrés dans les parallélogrammes clairs --- */
.neighbor {
	position: absolute;
	z-index: 10;
	color: var(--fam, #d00000);
	font-size: 24px;
	font-weight: 900;
	line-height: 1;
	transform: translate(-50%, -50%) !important;
}

.neighbor.left {
	left: 158px;
	top: 121px;
}

.neighbor.right {
	left: 692px;
	right: auto;
	top: 121px;
}

.focus .neighbor.left {
	left: 158px;
	top: 121px;
}

.focus .neighbor.right {
	left: 692px;
	right: auto;
	top: 121px;
}

@media(max-width:980px) {
	.neighbor.left {
		left: 158px;
		top: 121px;
	}

	.neighbor.right {
		left: 692px;
		right: auto;
		top: 121px;
	}
}



/* --- SYSTÈME D'ANCRES EN POURCENTAGE : placements stables sur l'image intacte --- */
.piece-zone {
	--neighbor-left-x: 12.0%;
	--neighbor-left-y: 46.0%;
	--neighbor-right-x: 88.8%;
	--neighbor-right-y: 46.0%;
	--angle-tl-x: 23.5%;
	--angle-tl-y: 27.0%;
	--angle-tr-x: 76.5%;
	--angle-tr-y: 27.0%;
	--angle-bl-x: 21.5%;
	--angle-bl-y: 68.0%;
	--angle-br-x: 78.5%;
	--angle-br-y: 68.0%;
	--cut-x: 50%;
	--cut-y: 50%;
	--pre-x: 72%;
	--pre-y: 11%;
}

.anchor-label,
.neighbor,
.angle-label {
	position: absolute !important;
	z-index: 12 !important;
	line-height: 1 !important;
	transform: translate(-50%, -50%) !important;
	right: auto !important;
	bottom: auto !important;
}

.neighbor {
	color: var(--fam, #d00000) !important;
	font-size: 24px !important;
	font-weight: 900 !important;
}

.neighbor.left {
	left: var(--neighbor-left-x) !important;
	top: var(--neighbor-left-y) !important;
}

.neighbor.right {
	left: var(--neighbor-right-x) !important;
	top: var(--neighbor-right-y) !important;
}

.angle-label {
	color: #000 !important;
	font-size: 17px !important;
	font-weight: 900 !important;
	white-space: nowrap !important;
}

.angle-label.tl {
	left: var(--angle-tl-x) !important;
	top: var(--angle-tl-y) !important;
}

.angle-label.tr {
	left: var(--angle-tr-x) !important;
	top: var(--angle-tr-y) !important;
}

.angle-label.bl {
	left: var(--angle-bl-x) !important;
	top: var(--angle-bl-y) !important;
}

.angle-label.br {
	left: var(--angle-br-x) !important;
	top: var(--angle-br-y) !important;
}

.cut-label {
	left: var(--cut-x) !important;
	top: var(--cut-y) !important;
	transform: translate(-50%, -50%) !important;
}

.prehole {
	left: var(--pre-x) !important;
	top: var(--pre-y) !important;
	right: auto !important;
	transform: translate(-50%, -50%) !important;
}

/* Calques de repère activables depuis le bouton “Afficher les ancres” */
.anchor-dot {
	position: absolute;
	width: 8px;
	height: 8px;
	border-radius: 999px;
	background: #e00000;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
	z-index: 30;
	transform: translate(-50%, -50%);
	display: none;
	pointer-events: none;
}

body.show-anchors .anchor-dot {
	display: block;
}

.anchor-dot.left {
	left: var(--neighbor-left-x);
	top: var(--neighbor-left-y);
}

.anchor-dot.right {
	left: var(--neighbor-right-x);
	top: var(--neighbor-right-y);
}

.anchor-dot.tl {
	left: var(--angle-tl-x);
	top: var(--angle-tl-y);
}

.anchor-dot.tr {
	left: var(--angle-tr-x);
	top: var(--angle-tr-y);
}

.anchor-dot.bl {
	left: var(--angle-bl-x);
	top: var(--angle-bl-y);
}

.anchor-dot.br {
	left: var(--angle-br-x);
	top: var(--angle-br-y);
}

.anchor-dot.ph {
	left: var(--pre-x);
	top: var(--pre-y);
}

.anchor-dot.total {
	left: var(--total-x);
	top: var(--total-y);
}


/* --- Ajustements propres : panneau paramètres + mode focus --- */
.controls {
	display: grid !important;
	grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
	gap: 14px !important;
	align-items: end !important;
}

.controls>div:nth-child(1) {
	grid-column: span 4;
}

.controls>div:nth-child(2),
.controls>div:nth-child(3),
.controls>div:nth-child(4),
.controls>div:nth-child(5) {
	grid-column: span 2;
}

#resetBtn,
#anchorBtn,
#anchorEditBtn {
	grid-column: span 2;
	min-height: 44px;
	white-space: nowrap;
}

.controls .note {
	grid-column: 1/-1 !important;
}

#freq {
	min-width: 100%;
}

.tab {
	user-select: none;
}

.segment-card.atelier-card {
	cursor: default;
}

#globalView .segment-card.atelier-card {
	cursor: pointer;
}

#globalView .segment-card.atelier-card:hover {
	outline: 2px solid rgba(127, 90, 56, .22);
	outline-offset: 4px;
}

#focusView:not(.hidden) {
	display: grid !important;
}

#globalView.hidden,
#focusView.hidden {
	display: none !important;
}

@media(max-width:1000px) {
	.controls {
		grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
	}

	.controls>div:nth-child(1) {
		grid-column: span 6;
	}

	.controls>div:nth-child(2),
	.controls>div:nth-child(3),
	.controls>div:nth-child(4),
	.controls>div:nth-child(5),
	#resetBtn,
	#anchorBtn,
	#anchorEditBtn {
		grid-column: span 3;
	}
}

@media(max-width:640px) {
	.controls {
		grid-template-columns: 1fr !important;
	}

	.controls>div:nth-child(1),
	.controls>div:nth-child(2),
	.controls>div:nth-child(3),
	.controls>div:nth-child(4),
	.controls>div:nth-child(5),
	#resetBtn,
	#anchorBtn,
	#anchorEditBtn {
		grid-column: 1/-1;
	}
}



/* Correctif robuste : le bouton Afficher les ancres rend visibles des repères sur chaque image */
body.show-anchors .piece-zone {
	outline: 1px dashed rgba(224, 0, 0, .35);
}

.anchor-dot {
	position: absolute !important;
	width: 14px !important;
	height: 14px !important;
	border-radius: 999px !important;
	background: #ff1f1f !important;
	border: 2px solid #fff !important;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, .22) !important;
	z-index: 999 !important;
	transform: translate(-50%, -50%) !important;
	display: none !important;
	pointer-events: none !important;
}

body.show-anchors .anchor-dot {
	display: block !important;
}

.anchor-dot.left {
	left: var(--neighbor-left-x) !important;
	top: var(--neighbor-left-y) !important;
}

.anchor-dot.right {
	left: var(--neighbor-right-x) !important;
	top: var(--neighbor-right-y) !important;
}

.anchor-dot.tl {
	left: var(--angle-tl-x) !important;
	top: var(--angle-tl-y) !important;
}

.anchor-dot.tr {
	left: var(--angle-tr-x) !important;
	top: var(--angle-tr-y) !important;
}

.anchor-dot.bl {
	left: var(--angle-bl-x) !important;
	top: var(--angle-bl-y) !important;
}

.anchor-dot.br {
	left: var(--angle-br-x) !important;
	top: var(--angle-br-y) !important;
}

.anchor-dot.ph {
	left: var(--pre-x) !important;
	top: var(--pre-y) !important;
}

body.show-anchors #anchorBtn {
	background: #d00000 !important;
	color: white !important;
	border-color: #d00000 !important;
}



/* Mode réglage des ancres : les points passent au-dessus, deviennent déplaçables et ne se comportent plus comme du texte. */
.segment-bg,
.piece-zone img {
	pointer-events: none !important;
	user-select: none !important;
	-webkit-user-select: none !important;
}

.anchor-dot {
	pointer-events: auto !important;
	cursor: grab !important;
	user-select: none !important;
	-webkit-user-select: none !important;
	touch-action: none !important;
	z-index: 5000 !important;
}

.anchor-dot:active {
	cursor: grabbing !important;
}

body.anchor-edit .anchor-dot {
	display: block !important;
}

body.anchor-edit .piece-zone {
	outline: 1px dashed rgba(224, 0, 0, .35);
}

body.anchor-edit #anchorEditBtn {
	background: #2f211b !important;
	color: #fff !important;
	border-color: #2f211b !important;
}

.anchor-tools {
	position: fixed;
	right: 18px;
	bottom: 18px;
	width: min(430px, calc(100vw - 36px));
	background: rgba(255, 255, 255, .96);
	border: 1px solid rgba(92, 70, 52, .25);
	border-radius: 18px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .16);
	padding: 14px;
	z-index: 9000;
	display: none;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.anchor-edit .anchor-tools {
	display: block;
}

.anchor-tools h3 {
	margin: 0 0 8px;
	font-size: 14px;
	color: #2f211b;
}

.anchor-tools p {
	margin: 0 0 10px;
	font-size: 12px;
	color: #6d5b4d;
	line-height: 1.35;
}

.anchor-tools textarea {
	width: 100%;
	min-height: 130px;
	resize: vertical;
	border: 1px solid rgba(92, 70, 52, .25);
	border-radius: 12px;
	padding: 10px;
	font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	box-sizing: border-box;
}

.anchor-tools .tool-row {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.anchor-tools button {
	border: 1px solid rgba(92, 70, 52, .25);
	background: #f7f0e6;
	border-radius: 999px;
	padding: 8px 12px;
	font-weight: 700;
	cursor: pointer;
}

.anchor-coord-badge {
	position: fixed;
	left: 12px;
	bottom: 12px;
	background: #2f211b;
	color: #fff;
	padding: 7px 10px;
	border-radius: 999px;
	font: 12px/1 system-ui, sans-serif;
	z-index: 9100;
	display: none;
}

body.anchor-edit .anchor-coord-badge {
	display: block;
}

/* Corrections finales — panneau réglage des ancres */
body.anchor-edit .anchor-dot {
	display: block !important;
	pointer-events: auto !important;
	cursor: grab !important;
	user-select: none !important;
	-webkit-user-select: none !important;
	touch-action: none !important;
	z-index: 5000 !important;
}

body.anchor-edit .anchor-dot:active {
	cursor: grabbing !important;
}

body.anchor-edit .piece-zone {
	outline: 1px dashed rgba(224, 0, 0, .35) !important;
}

#anchorEditBtn,
#anchorBtn {
	min-width: max-content;
}

.anchor-tools {
	color: #2f2922 !important;
}

.anchor-tools .tool-row {
	display: flex !important;
	gap: 10px !important;
	margin-top: 12px !important;
	flex-wrap: wrap !important;
}

.anchor-tools button {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 7px !important;
	border: 0 !important;
	border-radius: 10px !important;
	padding: 10px 14px !important;
	font-weight: 800 !important;
	font-size: 13px !important;
	cursor: pointer !important;
	opacity: 1 !important;
	box-shadow: none !important;
	white-space: nowrap !important;
}

#copyAnchorsBtn {
	background: #2f2922 !important;
	color: #fffaf1 !important;
}

#copyAnchorsBtn:hover {
	background: #493b31 !important;
}

#copyAnchorsBtn.copied {
	background: #1f7a4f !important;
	color: #ffffff !important;
}

#resetAnchorsBtn {
	background: #dfd0bb !important;
	color: #2f2922 !important;
}

#resetAnchorsBtn:hover {
	background: #d0bea4 !important;
}

.anchor-tools textarea {
	color: #2f2922 !important;
	background: #fffdf8 !important;
}

#focusView:not(.hidden) {
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) minmax(340px, 390px) !important;
	gap: 18px !important;
	align-items: start !important;
	overflow: visible !important;
}

#focusCard {
	min-width: 0 !important;
	overflow: hidden !important;
}

#focusCard .segment-card.atelier-card {
	width: 100% !important;
	min-width: 0 !important;
	overflow: hidden !important;
	padding: 18px 14px 26px !important;
	box-sizing: border-box !important;
}

#focusCard .atelier-row {
	display: grid !important;
	grid-template-columns: 70px minmax(0, 1fr) !important;
	gap: 10px !important;
	align-items: center !important;
	min-width: 0 !important;
}

#focusCard .piece-zone {
	width: 100% !important;
	max-width: 849px !important;
	aspect-ratio: 849/243 !important;
	height: auto !important;
	min-width: 0 !important;
	transform: none !important;
	margin: 0 !important;
	position: relative !important;
	overflow: hidden !important;
}

#focusCard .segment-bg {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain !important;
}

#focusCard .side-label {
	font-size: 20px !important;
	line-height: 1.45 !important;
	padding-top: 0 !important;
}

#focusView .detail-table {
	min-width: 0 !important;
	width: 100% !important;
	box-sizing: border-box !important;
}

@media(max-width:1150px) {
	#focusView:not(.hidden) {
		grid-template-columns: 1fr !important;
	}

	#focusCard {
		overflow: visible !important;
	}

	#focusCard .segment-card.atelier-card {
		overflow: visible !important;
	}

	#focusCard .atelier-row {
		grid-template-columns: 78px minmax(0, 1fr) !important;
	}

	#focusView .detail-table {
		max-width: 720px !important;
	}
}

@media(max-width:760px) {
	#focusCard .atelier-row {
		grid-template-columns: 1fr !important;
	}

	#focusCard .side-label {
		display: flex !important;
		gap: 8px !important;
		align-items: center !important;
	}
}

/* ===== HABILLAGE TYPE DEVIS CHAND’HÔME — FICHES ATELIER ===== */
/* Bloc volontairement placé en fin de fichier : il harmonise l’outil avec les devis/factures
   sans devoir démêler immédiatement les anciennes couches CSS du prototype. */

:root {
	--paper: #ffffff;
	--ink: #1f1d1a;
	--muted: #66615a;
	--line: #d9cdb8;
	--gold: #a1845b;
	--sage: #a8b694;
	--soft: #f3eee6;
	--soft-sage: #eef2e8;
	--shadow: none;
}

html,
body {
	background: #ffffff !important;
}

body {
	padding: 10px 0 24px !important;
	color: var(--ink) !important;
	font-family: "Helvetica Neue", Arial, sans-serif !important;
	line-height: 1.2;
}

.atelier-sheet {
	width: min(210mm, calc(100% - 28px));
	min-height: 273mm;
	margin: 0 auto 18px;
	background: var(--paper);
	border: 1px solid #e8e1d4;
	position: relative;
	padding: 12mm 14mm 14mm;
	overflow: hidden;
}

.atelier-sheet::before {
	content: "";
	position: absolute;
	left: 14mm;
	right: 14mm;
	top: 9mm;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--sage), transparent);
	z-index: 1;
}

.atelier-sheet .sheet-header {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: 1.18fr 0.82fr;
	gap: 2mm;
	align-items: start;
	max-width: none;
	margin: 0 0 8mm;
	padding: 0;
}

.atelier-sheet .eyebrow {
	font-size: 9px;
	letter-spacing: 0.26em;
	text-transform: uppercase;
	color: var(--sage) !important;
	margin-bottom: 5px;
	font-weight: 700;
}

.atelier-sheet .brand {
	margin: 0 0 4px;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 26px;
	font-weight: 600;
	line-height: 1.05;
	letter-spacing: 0.03em;
	color: var(--ink);
}

.atelier-sheet .tagline {
	margin: 0;
	color: var(--muted);
	font-size: 13.5px;
	max-width: 92mm;
	line-height: 1.5;
}

.atelier-sheet .title-box {
	position: relative;
	text-align: right;
	padding-top: 3mm;
}

.atelier-sheet .geo {
	position: absolute;
	right: -7mm;
	top: -6mm;
	width: 52mm;
	height: 52mm;
	opacity: 0.18;
	pointer-events: none;
}

.atelier-sheet .title-main {
	margin: 0;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 21px;
	letter-spacing: 0.12em;
	font-weight: 500;
	color: var(--ink);
}

.atelier-sheet .subtitle-header {
	margin-top: 6px;
	font-size: 10px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #8a857f;
	line-height: 1.2;
}

.atelier-sheet main {
	position: relative;
	z-index: 2;
	max-width: none;
	margin: 0;
	padding: 0;
}

.atelier-sheet .panel {
	background: #ffffff;
	border: 1px solid rgba(217, 205, 184, 0.9);
	border-radius: 14px;
	box-shadow: none;
	backdrop-filter: none;
}

.atelier-sheet .controls {
	padding: 7px 10px !important;
	margin: 0 0 8mm !important;
	gap: 8px 10px !important;
	align-items: end !important;
}

.atelier-sheet label {
	font-size: 9px;
	letter-spacing: 0.16em;
	color: var(--muted);
	margin-bottom: 4px;
}

.atelier-sheet select,
.atelier-sheet input {
	border: 1px solid var(--line);
	background: #fff;
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 12px;
	color: var(--ink);
}

.atelier-sheet button {
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 12px;
	font-weight: 700;
	background: #1f1d1a;
	color: #fff;
}

.atelier-sheet .note {
	padding: 2px 4px 3px;
	font-size: 10.5px;
	line-height: 1.35;
	color: var(--muted);
}

.atelier-sheet .tabs {
	margin: 0 0 4mm;
	gap: 8px;
}

.atelier-sheet .tab {
	padding: 8px 12px;
	border-radius: 999px;
	border: 1px solid var(--line) !important;
	background: #fff !important;
	color: var(--muted) !important;
	font-size: 11px;
	box-shadow: none !important;
}

.atelier-sheet .tab.active {
	background: var(--ink) !important;
	color: #fff !important;
	border-color: var(--ink) !important;
}

.atelier-sheet .grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 6mm;
}

.atelier-sheet .segment-card.atelier-card {
	border: 1px solid #eee5d7;
	background: #ffffff;
	margin: 0;
	padding: 6mm 7mm;
	min-height: auto;
	overflow: hidden;
}

.atelier-sheet .atelier-row {
	display: grid;
	grid-template-columns: 34px minmax(0, 1fr);
	gap: 6mm;
	align-items: center;
}

.atelier-sheet .side-label {
	font-size: 18px;
	line-height: 1.35;
	padding-top: 0;
}

.atelier-sheet .piece-zone {
	width: 100% !important;
	max-width: 849px !important;
	aspect-ratio: 849 / 243;
	height: auto !important;
	min-width: 0 !important;
	transform: none !important;
	position: relative;
}

.atelier-sheet .segment-bg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.atelier-sheet .detail-table {
	padding: 7mm;
}

.atelier-sheet .detail-table h2 {
	font-size: 18px;
	font-weight: 500;
	margin-bottom: 4mm;
}

@media (max-width: 900px) {
	.atelier-sheet {
		width: calc(100% - 18px);
		padding: 9mm 8mm 10mm;
	}

	.atelier-sheet .sheet-header {
		grid-template-columns: 1fr;
		gap: 6mm;
	}

	.atelier-sheet .title-box {
		text-align: left;
	}

	.atelier-sheet .geo {
		right: 0;
		top: -8mm;
		width: 44mm;
		height: 44mm;
	}

	.atelier-sheet .controls {
		grid-template-columns: 1fr !important;
	}

	.atelier-sheet .controls > div,
	.atelier-sheet #resetBtn,
	.atelier-sheet #anchorBtn,
	.atelier-sheet #anchorEditBtn {
		grid-column: 1 / -1 !important;
	}

	.atelier-sheet .atelier-row {
		grid-template-columns: 1fr;
		gap: 2mm;
	}

	.atelier-sheet .side-label {
		display: flex;
		gap: 8px;
	}
}

@media print {
	body {
		padding: 0 !important;
		background: #fff !important;
	}

	.atelier-sheet {
		width: auto;
		min-height: 0;
		margin: 0;
		border: none;
		padding: 10mm 12mm;
		overflow: visible;
	}

	.atelier-sheet::before {
		left: 12mm;
		right: 12mm;
		top: 7mm;
	}

	.atelier-sheet .sheet-header,
	.atelier-sheet .controls,
	.atelier-sheet .tabs {
		display: grid;
	}

	.atelier-sheet .segment-card.atelier-card {
		break-inside: avoid;
		page-break-inside: avoid;
	}
}

/* ===== CORRECTION VUE FOCUS DANS FEUILLE A4 ===== */

#focusView:not(.hidden) {
  display: block !important;
}

#focusCard {
  width: 100% !important;
  overflow: visible !important;
  margin-bottom: 8mm !important;
}

#focusCard .segment-card.atelier-card {
  width: 100% !important;
  overflow: visible !important;
  padding: 14px 16px 26px !important;
}

#focusCard .atelier-row {
  display: grid !important;
  grid-template-columns: 76px minmax(0, 1fr) !important;
  gap: 10px !important;
  align-items: center !important;
}

#focusCard .piece-zone {
  width: 100% !important;
  max-width: 849px !important;
  aspect-ratio: 849 / 243 !important;
  height: auto !important;
  transform: none !important;
  margin: 0 auto !important;
  overflow: hidden !important;
}

#focusView .detail-table {
  width: 100% !important;
  max-width: none !important;
  margin-top: 6mm !important;
}

.controls {
  grid-template-columns: repeat(10, minmax(0, 1fr)) !important;
}

#resetBtn,
#anchorBtn,
#anchorEditBtn {
  grid-column: span 2 !important;
  min-width: 0 !important;
  font-size: 11px !important;
  padding-inline: 10px !important;
}

/* ===== BOUTONS STYLE CHAND’HÔME (léger, document) ===== */

button {
  border: 1px solid rgba(127, 90, 56, 0.25) !important;
  background: #f7f3ec !important;
  color: var(--ink) !important;
  border-radius: 999px !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  box-shadow: none !important;
  transition: all 0.15s ease;
}

button:hover {
  background: #efe7db !important;
  border-color: rgba(127, 90, 56, 0.4) !important;
}

/* Bouton actif / important (Focus segment par exemple) */
.tab.active,
button.primary {
  background: var(--ink) !important;
  color: #fffaf1 !important;
  border-color: var(--ink) !important;
}

/* Boutons du panneau (les 3 que tu veux alléger) */
#resetBtn,
#anchorBtn,
#anchorEditBtn {
  padding: 5px 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 999px !important;
  background: #f4efe6 !important;
}

/* Variante hover douce */
#resetBtn:hover,
#anchorBtn:hover,
#anchorEditBtn:hover {
  background: #e9dfd0 !important;
}

/* ===== TABS STYLE CHAND’HÔME ===== */

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 18px;
}

/* état normal */
.tab {
  border: 1px solid rgba(127, 90, 56, 0.25);
  background: #f4efe6;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* hover doux */
.tab:hover {
  background: #ebe2d3;
  color: var(--ink);
}

/* état actif (plus subtil que noir plein) */
.tab.active {
  background: #2f2922;        /* garde ta teinte encre */
  color: #fffaf1;
  border-color: #2f2922;
}

/* ===== OVERRIDE FINAL — TABS DISCRETS DANS LA FEUILLE ===== */

.atelier-sheet .tabs .tab {
  border: 1px solid rgba(127, 90, 56, 0.25) !important;
  background: #f4efe6 !important;
  color: var(--muted) !important;
  border-radius: 999px !important;
  padding: 5px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

.atelier-sheet .tabs .tab:hover {
  background: #ebe2d3 !important;
  color: var(--ink) !important;
}

.atelier-sheet .tabs .tab.active {
  background: #f7f3ec !important;
  color: var(--ink) !important;
  border-color: rgba(127, 90, 56, 0.55) !important;
  font-weight: 700 !important;
}


/* ===== FIX — LONGUEUR TOTALE PILOTÉE PAR ANCRE ===== */

.atelier-sheet .piece-zone .total-note {
  position: absolute !important;
  left: var(--total-x) !important;
  top: var(--total-y) !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  z-index: 12 !important;
}

.atelier-sheet .piece-zone .anchor-dot.total {
  left: var(--total-x) !important;
  top: var(--total-y) !important;
}
/* ===== FIX FINAL STABLE — ANCRES, PERÇAGE, FOCUS ===== */

/* Supprime définitivement le vieux décor beige hérité des cartes génériques. */
.segment-card.atelier-card::before,
.atelier-sheet .segment-card.atelier-card::before,
#focusCard .segment-card.atelier-card::before {
  content: none !important;
  display: none !important;
  background: transparent !important;
}

/* Garde le repère quantité sur une seule ligne. */
.side-label,
.atelier-sheet .side-label,
#focusCard .side-label {
  white-space: nowrap !important;
}

/* Donne assez de place à gauche en mode focus. */
#focusCard .atelier-row {
  grid-template-columns: 90px minmax(0, 1fr) !important;
}

/* Important : les textes ancrés doivent pouvoir sortir légèrement de l'image. */
.segment-card.atelier-card,
.atelier-sheet .segment-card.atelier-card,
#focusCard .segment-card.atelier-card {
  overflow: visible !important;
}

.piece-zone,
.atelier-sheet .piece-zone,
#focusCard .piece-zone {
  overflow: visible !important;
}

/* Un peu d'air sous la pièce pour que la longueur totale ne soit plus grignotée. */
#focusCard .segment-card.atelier-card {
  padding-bottom: 48px !important;
}

/* Le libellé de perçage est lié à son ancre, mais placé au-dessus du point rouge. */
.piece-zone .prehole,
.atelier-sheet .piece-zone .prehole,
#focusCard .piece-zone .prehole {
  position: absolute !important;
  left: var(--pre-x) !important;
  top: var(--pre-y) !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -125%) !important;
  color: #006fc9 !important;
  font-weight: 900 !important;
  font-size: 13px !important;
  line-height: 1.1 !important;
  white-space: nowrap !important;
  z-index: 80 !important;
  pointer-events: none !important;
}

/* La longueur à découper reste strictement centrée sur l'ancre de coupe. */
.piece-zone .cut-label,
.atelier-sheet .piece-zone .cut-label,
#focusCard .piece-zone .cut-label {
  position: absolute !important;
  left: var(--cut-x) !important;
  top: var(--cut-y) !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  z-index: 40 !important;
  white-space: nowrap !important;
}

/* La longueur totale reste pilotée par son ancre et visible en entier. */
.piece-zone .total-note,
.atelier-sheet .piece-zone .total-note,
#focusCard .piece-zone .total-note {
  position: absolute !important;
  left: var(--total-x) !important;
  top: var(--total-y) !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  z-index: 40 !important;
  white-space: nowrap !important;
}

/* Les points d'ancrage restent au-dessus de tous les libellés pendant le réglage. */
.anchor-dot,
body.show-anchors .anchor-dot,
body.anchor-edit .anchor-dot {
  z-index: 120 !important;
}

.segment-warning {
  position: absolute;
  left: 6%;
  top: -6%;
  color: #a40000;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  z-index: 90;
  white-space: nowrap;
  text-align: left;
  opacity: 0.9;
	max-width: 200px;
}

.segment-warning-arrow {
  position: absolute;
  left: 38%;
  top: -8%;
  color: #a40000;
  font-size: 34px;
  line-height: 1;
  transform: rotate(25deg);
  z-index: 90;
  pointer-events: none;
  opacity: 0.85;
}
