@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { background: #000; color: #fff; font-family: monospace; display: flex; flex-direction: column; }
#header { padding: 10px 16px; background: #1a1a1a; display: flex; justify-content: space-between; align-items: center; font-family: 'Outfit', sans-serif; flex-shrink: 0; }
#header-left { display: flex; align-items: center; }
#header-center { display: flex; gap: 12px; align-items: center; }
#header-right { display: flex; gap: 12px; align-items: center; }
#panelSelector { display: flex; border: 1px solid #444; border-radius: 8px; overflow: hidden; }
#panelSelector button { border: none; border-radius: 0; border-right: 1px solid #333; padding: 8px 14px; }
#panelSelector button:last-child { border-right: none; }
#coordsBox { display: flex; gap: 5px; align-items: center; }
#coordsBox input { background: #222; color: #0FC3B7; border: 1px solid #0FC3B7; padding: 6px 10px; width: 200px; font-family: monospace; font-size: 12px; border-radius: 4px; }
#coordsBox button { background: #0FC3B7; color: #000; border: none; padding: 6px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; }
#coordsBox button:hover { background: #00E3D5; }
#branding { display: flex; align-items: center; gap: 6px; font-size: 15px; }
#branding .brand-inou { color: #0FC3B7; font-weight: 600; }
#branding .brand-health { color: #888; font-weight: 300; }
#panels { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.panel { flex: 1; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid #333; }
.panel:last-child { border-right: none; }
.panel-header { padding: 5px 10px; background: #2a2a2a; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.panel-header .series-name { color: #0FC3B7; font-weight: 500; }
.panel-header .study-select { max-width: 45%; }
.panel-header .series-select { min-width: 0; }
.panel-content { flex: 1; display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative; min-height: 0; }
.panel-content.zoomed { cursor: grab; }
.panel-content.panning { cursor: grabbing; }
.panel-content img { max-width: 100%; max-height: 100%; }
.thumbnails { min-height: 56px; background: #111; display: flex; padding: 8px 16px; gap: 12px; align-items: center; font-family: 'Outfit', sans-serif; }
.slice-scrubber { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 12px; min-width: 200px; max-width: 560px; }
.scrubber-label { font-size: 11px; color: #666; margin-bottom: 4px; }
.scrubber-row { display: flex; align-items: center; gap: 12px; }
.scrubber-track-wrap { flex: 1; min-width: 0; }
.scrubber-track { height: 8px; background: #222; border-radius: 4px; position: relative; cursor: pointer; }
.scrubber-fill { height: 100%; background: linear-gradient(90deg, #00F3E4, #0FC3B7); border-radius: 4px; position: absolute; left: 0; top: 0; pointer-events: none; }
.scrubber-handle { width: 16px; height: 16px; background: #0FC3B7; border-radius: 50%; position: absolute; top: 50%; transform: translate(-50%, -50%); cursor: grab; box-shadow: 0 0 8px rgba(15,195,183,0.5); }
.scrubber-handle:active { cursor: grabbing; }
.scrubber-ticks { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: #444; }
.cine-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cine-play, .cine-speed {
	background: #252525;
	color: #ccc;
	border: 1px solid #555;
	border-radius: 8px;
	font-family: 'Outfit', sans-serif;
	font-size: 13px;
	cursor: pointer;
	padding: 6px 10px;
	line-height: 1;
	min-width: 36px;
}
.cine-play:hover, .cine-speed:hover { border-color: #0FC3B7; color: #fff; }
.cine-play.playing { background: #0FC3B7; border-color: #0FC3B7; color: #fff; }
.cine-speed { min-width: 40px; font-variant-numeric: tabular-nums; }
.cine-bpm { font-size: 11px; color: #888; font-variant-numeric: tabular-nums; min-width: 3.5em; }

/* Annotation tool strip (under image) + overlay */
.anno-tools {
	display: flex;
	border: 1px solid #444;
	border-radius: 8px;
	overflow: hidden;
	flex-shrink: 0;
}
.anno-tools button {
	background: #1a1a1a;
	color: #ccc;
	border: none;
	border-right: 1px solid #333;
	padding: 8px 10px;
	font-family: 'Outfit', sans-serif;
	font-size: 12px;
	cursor: pointer;
}
.anno-tools button:last-child { border-right: none; }
.anno-tools button:hover { color: #fff; }
.anno-tools button.active { background: #0FC3B7; color: #fff; }
.anno-layer {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 3;
	overflow: visible;
}
.anno-layer .anno-item { pointer-events: visiblePainted; }
.anno-layer .anno-hit { pointer-events: fill; }
.anno-layer .anno-del { opacity: 0; pointer-events: none; transition: opacity 0.12s; }
.anno-layer .anno-item:hover .anno-del,
.anno-layer .anno-del:hover { opacity: 1; pointer-events: auto; cursor: pointer; }
.anno-list-panel, #annoListPanel {
	position: fixed;
	width: 240px;
	max-height: 40vh;
	overflow: auto;
	background: #1a1a1a;
	border: 1px solid #444;
	border-radius: 8px;
	z-index: 2000;
	font-family: 'Outfit', sans-serif;
	font-size: 12px;
	color: #ddd;
	padding: 8px 0;
	box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.anno-list-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 4px 12px 8px;
	font-weight: 600;
	color: #0FC3B7;
}
.anno-list-head button {
	background: transparent;
	border: none;
	color: #888;
	font-size: 16px;
	cursor: pointer;
}
.anno-list-row {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 12px;
	border-top: 1px solid #2a2a2a;
}
.anno-list-actions { display: flex; gap: 4px; }
.anno-list-row button {
	background: #333;
	border: 1px solid #555;
	color: #ccc;
	border-radius: 4px;
	padding: 2px 8px;
	cursor: pointer;
	font-size: 11px;
}
.anno-list-empty { padding: 12px; color: #666; }
.thumb { height: 70px; cursor: pointer; opacity: 0.6; }
.thumb:hover { opacity: 0.8; }
.thumb.active { opacity: 1; border: 2px solid #0FC3B7; }
select {
	background: #252525;
	color: #fff;
	border: 1px solid #555;
	padding: 8px 36px 8px 12px;
	border-radius: 8px;
	font-family: 'Outfit', sans-serif;
	font-size: 13px;
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23B45309' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	transition: border-color 0.15s, background-color 0.15s;
}
select:hover { background-color: #2a2a2a; border-color: #0FC3B7; }
select:focus { outline: none; border-color: #0FC3B7; }
button { 
	background: #1a1a1a; 
	color: #fff; 
	border: 1px solid #333; 
	padding: 8px 16px; 
	border-radius: 8px;
	font-family: 'Outfit', sans-serif;
	font-size: 13px;
	cursor: pointer; 
	transition: background-color 0.15s, border-color 0.15s;
}
button:hover { background: #222; border-color: #444; }
button:disabled { background: #111; color: #555; cursor: not-allowed; border-color: #222; }
button:disabled:hover { background: #111; }

.sync-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: #888;
	cursor: pointer;
}
.sync-label input[type="checkbox"] {
	appearance: none;
	width: 14px;
	height: 14px;
	border: 1px solid #444;
	border-radius: 3px;
	background: #1a1a1a;
	cursor: pointer;
	position: relative;
}
.sync-label input[type="checkbox"]:checked {
	background: #0FC3B7;
	border-color: #0FC3B7;
}
.sync-label input[type="checkbox"]:checked::after {
	content: '';
	position: absolute;
	left: 4px;
	top: 1px;
	width: 4px;
	height: 8px;
	border: solid #000;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}
.sync-label span { white-space: nowrap; }

#coordDisplay {
	position: fixed;
	bottom: 45px;
	right: 20px;
	background: rgba(0,0,0,0.8);
	padding: 5px 12px;
	font-size: 13px;
	color: #0FC3B7;
	border: 1px solid rgba(245,158,11,0.3);
	border-radius: 4px;
	z-index: 1000;
	font-variant-numeric: tabular-nums;
}
#wlHint {
	position: fixed;
	background: rgba(0,0,0,0.9);
	padding: 6px 12px;
	font-size: 12px;
	font-family: 'Outfit', sans-serif;
	color: #fff;
	border: 1px solid rgba(255,255,255,0.3);
	border-radius: 6px;
	z-index: 2000;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s;
}
#wlHint.show { opacity: 1; }
#debugInfo {
	color: #f88;
	font-size: 11px;
	display: none;
}
.rect-overlay {
	position: absolute;
	border: 2px solid #ff0;
	background: rgba(255, 255, 0, 0.1);
	pointer-events: none;
}
.grid-overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
	display: none;
	z-index: 6;
	background-image:
		linear-gradient(to right, rgba(255, 221, 0, 0.4) 1px, transparent 1px),
		linear-gradient(to bottom, rgba(255, 221, 0, 0.4) 1px, transparent 1px);
	background-size: calc(100% / var(--gc, 12)) calc(100% / var(--gr, 12));
	border-right: 1px solid rgba(255, 221, 0, 0.4);
	border-bottom: 1px solid rgba(255, 221, 0, 0.4);
}
body.grid-on .grid-overlay { display: block; }
.grid-overlay .glbl { position: absolute; color: #00F3E4; font: 700 12px 'Outfit', sans-serif; text-shadow: 0 0 2px #000, 0 0 3px #000; }
.grid-overlay .gcol { top: 1px; transform: translateX(-50%); }
.grid-overlay .gcol.gbot { top: auto; bottom: 1px; }
.grid-overlay .grow { left: 2px; transform: translateY(-50%); }
.grid-overlay .grow.gright { left: auto; right: 2px; }
#gridBtn { background: #1a1a1a; color: #ccc; border: 1px solid #444; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-family: 'Outfit', sans-serif; font-size: 14px; }
#gridBtn.active { background: #00F3E4; color: #000; border-color: #00F3E4; }
.heat-canvas, .play-hatch-canvas {
	position: absolute;
	top: 0; left: 0;
	width: 100%; height: 100%;
	display: none;
	pointer-events: none;
}
.play-hatch-canvas { z-index: 2; }
.panel-content.heat-on img { visibility: hidden; }
/* Play: one live cine image; stripes sit on top of noisy air only */
.panel-content.cine-playing img { visibility: visible !important; }
.panel-content.cine-playing .heat-canvas { display: none !important; }
.heat-toolbar {
	display: flex; flex-direction: column; justify-content: center; gap: 6px;
	padding: 6px 12px; margin-left: auto;
	border-left: 1px solid #222;
	font-family: 'Outfit', sans-serif; font-size: 11px; color: #bbb;
}
.heat-toolbar .heat-row { display: flex; align-items: center; gap: 6px; }
.heat-title { color: #f59e0b; font-weight: 600; font-size: 10px; letter-spacing: .5px; text-transform: uppercase; }
.heat-btn { background: #1a1a1a; color: #ccc; border: 1px solid #333; border-radius: 4px; padding: 3px 9px; cursor: pointer; font-size: 11px; font-family: 'Outfit', sans-serif; }
.heat-btn.active { background: #f59e0b; color: #000; border-color: #f59e0b; }
.heat-slider { display: flex; align-items: center; gap: 4px; }
.heat-slider input { width: 68px; }
.heat-status { color: #888; font-size: 10px; min-width: 60px; }
.img-wrapper {
	position: relative;
	display: inline-block;
	transition: transform 0.15s ease-out;
	transform-origin: center center;
}
.crosshair-h, .crosshair-v {
	position: absolute;
	background: rgba(245, 158, 11, 0.7);
	pointer-events: none;
}
.crosshair-h {
	height: 1px;
	left: 0;
	right: 0;
}
.crosshair-v {
	width: 1px;
	top: 0;
	bottom: 0;
}
.panel-label {
	position: absolute;
	top: 5px;
	left: 5px;
	color: #0FC3B7;
	font-size: 14px;
	font-weight: bold;
	text-shadow: 1px 1px 2px #000;
}
#helpBtn {
	background: #222;
	border: 2px solid #0FC3B7;
	color: #0FC3B7;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-size: 16px;
	font-weight: bold;
	cursor: pointer;
	margin-left: 20px;
	line-height: 24px;
	text-align: center;
	padding: 0;
}
#helpBtn:hover { background: #0FC3B7; color: #000; }

/* Image info overlay - premium medical display */
.image-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	pointer-events: none;
	font-family: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
	z-index: 10;
}

/* Corner info blocks */
.overlay-top-left {
	position: absolute;
	top: 16px;
	left: 16px;
	display: flex;
	flex-direction: column;
	gap: 0;
}
.overlay-top-right {
	position: absolute;
	top: 16px;
	right: 16px;
	text-align: right;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0;
}
.overlay-bottom-left {
	position: absolute;
	bottom: 16px;
	left: 16px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.overlay-bottom-right {
	position: absolute;
	bottom: 16px;
	right: 16px;
	text-align: right;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
}

/* Patient and study info */
.overlay-patient {
	font-size: 15px;
	font-weight: 500;
	color: rgba(255,255,255,0.95);
	text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 20px rgba(0,0,0,0.6);
	letter-spacing: 0.3px;
	line-height: 20px;
}
.overlay-datetime {
	font-size: 13px;
	color: rgba(255,255,255,0.95);
	text-shadow: 0 1px 4px rgba(0,0,0,0.9);
	line-height: 20px;
}
.overlay-accession {
	font-size: 13px;
	color: rgba(255,255,255,0.5);
	text-shadow: 0 1px 3px rgba(0,0,0,0.8);
	line-height: 20px;
}
.overlay-institution {
	font-size: 13px;
	color: rgba(255,255,255,0.5);
	text-shadow: 0 1px 3px rgba(0,0,0,0.8);
	line-height: 20px;
}
.overlay-study {
	font-size: 11px;
	font-weight: 400;
	color: rgba(255,255,255,0.6);
	text-shadow: 0 1px 3px rgba(0,0,0,0.8);
	line-height: 20px;
}

/* Series name - prominent orange accent */
.overlay-series {
	font-size: 15px;
	font-weight: 600;
	color: #0FC3B7;
	text-shadow: 0 0 12px rgba(245,158,11,0.4), 0 1px 4px rgba(0,0,0,0.9);
	letter-spacing: 0.5px;
	line-height: 20px;
}

/* Cardiac gating summary - subordinate to the series name above it */
.overlay-cardiac {
	font-size: 13px;
	color: rgba(255,255,255,0.5);
	text-shadow: 0 1px 3px rgba(0,0,0,0.8);
	line-height: 20px;
}

/* Slice info */
.overlay-slice {
	font-size: 20px;
	font-weight: 300;
	color: rgba(255,255,255,0.95);
	text-shadow: 0 1px 4px rgba(0,0,0,0.9);
	font-variant-numeric: tabular-nums;
}
.overlay-slice-total {
	font-size: 13px;
	color: rgba(255,255,255,0.5);
}
.overlay-pos {
	font-size: 13px;
	font-weight: 400;
	color: rgba(255,255,255,0.9);
	text-shadow: 0 1px 3px rgba(0,0,0,0.8);
	font-variant-numeric: tabular-nums;
	line-height: 20px;
}
.overlay-thickness {
	font-size: 10px;
	color: rgba(255,255,255,0.4);
	line-height: 20px;
}

/* W/L display - elegant pill design */
.overlay-wl {
	display: flex;
	gap: 12px;
	align-items: center;
	align-self: flex-end;
	background: rgba(0,0,0,0.4);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	padding: 8px 14px;
	border-radius: 20px;
	border: 1px solid rgba(255,255,255,0.2);
}
.overlay-wl-item {
	display: flex;
	align-items: baseline;
	gap: 6px;
}
.overlay-wl-label {
	font-size: 10px;
	font-weight: 500;
	color: rgba(255,255,255,0.4);
	text-transform: uppercase;
	letter-spacing: 1px;
}
.overlay-wl-value {
	font-size: 14px;
	font-weight: 500;
	color: rgba(255,255,255,0.9);
	font-variant-numeric: tabular-nums;
	min-width: 55px;
	text-align: right;
}
.overlay-wl-value.wl-adjusted {
	color: #ffeb3b !important;
	text-shadow: 0 0 8px rgba(255,235,59,0.5);
}
.overlay-wl-divider {
	width: 1px;
	height: 16px;
	background: rgba(255,255,255,0.15);
}

/* Orientation markers - elegant edge labels */
.overlay-orient {
	position: absolute;
	font-size: 20px;
	font-weight: 600;
	color: rgba(245,158,11,0.7);
	text-shadow: 0 0 10px rgba(0,0,0,0.9), 0 0 20px rgba(0,0,0,0.6);
	letter-spacing: 1px;
}
.overlay-orient-top {
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
}
.overlay-orient-bottom {
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
}
.overlay-orient-left {
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}
.overlay-orient-right {
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
}

/* Zoom indicator */
.overlay-zoom {
	font-size: 12px;
	font-weight: 500;
	color: rgba(255,255,255,0.6);
	background: rgba(0,0,0,0.4);
	padding: 4px 10px;
	border-radius: 12px;
	display: none;
}
.overlay-zoom.active {
	display: inline-block;
	color: #0FC3B7;
}
/* Tour overlay */
#tourOverlay {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.5);
	z-index: 3000;
}
#tourOverlay.show { display: block; }
#tourSpotlight {
	position: absolute;
	border: 3px solid #0FC3B7;
	border-radius: 8px;
	box-shadow: 0 0 0 9999px rgba(0,0,0,0.5), 0 0 20px #0FC3B7;
	pointer-events: none;
	transition: all 0.3s ease;
	z-index: 1;
}
#tourTooltip {
	position: absolute;
	background: #111;
	border: 2px solid #0FC3B7;
	color: #fff;
	padding: 15px 20px;
	max-width: 450px;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.5;
	z-index: 3001;
	display: block;
}
#tourTooltip h3 { color: #0FC3B7; margin: 0 0 8px 0; font-size: 16px; }
#tourTooltip p { margin: 0 0 12px 0; }
#tourTooltip .tour-nav { display: flex; justify-content: space-between; align-items: center; }
#tourTooltip .tour-nav button {
	background: #0FC3B7; color: #000; border: none; padding: 6px 16px;
	border-radius: 4px; cursor: pointer; font-weight: bold;
}
#tourTooltip .tour-nav button:hover { background: #0aa; }
#tourTooltip .tour-skip { background: transparent !important; color: #888 !important; }
#tourTooltip .tour-step { color: #666; font-size: 12px; }
#tourBtn {
	background: #222; border: 1px solid #555; color: #0FC3B7;
	padding: 5px 10px; cursor: pointer; font-size: 12px;
}
#tourBtn:hover { background: #333; }
#helpModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.8);
	z-index: 2000;
	justify-content: center;
	align-items: center;
}
#helpModal.show { display: flex; }
#helpContent {
	background: #111;
	border: 1px solid #0FC3B7;
	padding: 20px 30px;
	max-width: 400px;
	font-size: 14px;
	line-height: 1.8;
}
#helpContent h2 { color: #0FC3B7; margin: 0 0 15px 0; font-size: 18px; }
#helpContent table { width: 100%; }
#helpContent td { padding: 4px 0; }
#helpContent td:first-child { color: #ff0; width: 140px; }
#helpContent hr { border: none; border-top: 1px solid #333; margin: 12px 0; }


/* Light background overlay adjustments (for X-rays, etc.) */
.panel.light-bg .overlay-patient,
.panel.light-bg .overlay-accession,
.panel.light-bg .overlay-study-desc,
.panel.light-bg .overlay-cardiac,
.panel.light-bg .overlay-datetime,
.panel.light-bg .overlay-institution {
	color: rgba(0,0,0,0.7);
	text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.panel.light-bg .overlay-series {
	color: #007B73;
	text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.panel.light-bg .overlay-slice {
	color: rgba(0,0,0,0.9);
	text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.panel.light-bg .overlay-slice-total {
	color: rgba(0,0,0,0.5);
}
.panel.light-bg .overlay-pos,
.panel.light-bg .overlay-thickness {
	color: rgba(0,0,0,0.7);
	text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.panel.light-bg .overlay-orient {
	color: rgba(0,0,0,0.7);
	text-shadow: 0 1px 3px rgba(255,255,255,0.9);
}
.panel.light-bg .overlay-wl {
	background: rgba(255,255,255,0.6);
	border-color: rgba(0,0,0,0.2);
}
.panel.light-bg .overlay-wl-label {
	color: rgba(0,0,0,0.5);
}
.panel.light-bg .overlay-wl-value {
	color: rgba(0,0,0,0.9);
}

/* Tape-measure tool (replaces the old click-drag rectangle) */
.rect-overlay { display: none !important; }
#rectInfo { display: none !important; }
.tape-overlay {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	overflow: visible;
	z-index: 8;
}
.tape-overlay .tape-line {
	stroke: #00F3E4;
	stroke-width: 1.5;
}
.tape-overlay .tape-dot {
	fill: #00F3E4;
}
.tape-label {
	position: absolute;
	transform: translateY(-50%);
	background: rgba(0, 0, 0, 0.72);
	color: #00F3E4;
	font: 700 13px ui-monospace, "SF Mono", Menlo, monospace;
	padding: 1px 6px;
	border-radius: 3px;
	white-space: nowrap;
	pointer-events: none;
	z-index: 9;
}
