* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

:root {
	--bg: #f8f8f6;
	--bg-secondary: #e6e6e6;
	--bg-tertiary: #f7f7f7;
	--text: #1a1a1a;
	--text-muted: #666;
	--highlight: #d4edda;
	--highlight-border: #a8d5b1;
	--control-bg: #f8f8f6;
	--control-hover: #eee;
	--word-bg: #ffffff;
	--word-border: rgba(0, 0, 0, 0.1);
	--drawer-bar: #ccc;
	--shadow: rgba(0, 0, 0, 0.08);
	--shadow-hover: rgba(0, 0, 0, 0.12);
	--shadow-strong: rgba(0, 0, 0, 0.1);
	--scrollbar-track: transparent;
	--scrollbar-thumb: #ddd;
	--scrollbar-thumb-hover: #ccc;
	--lightbox-bg: rgba(0, 0, 0, 0.95);
	--lightbox-close-bg: rgba(255, 255, 255, 0.1);
	--lightbox-close-hover: rgba(255, 255, 255, 0.2);
}

body.dark-mode {
	--bg: #1a1a1a;
	--bg-secondary: #2a2a2a;
	--bg-tertiary: #222222;
	--text: #f8f8f6;
	--text-muted: #999;
	--highlight: #2d5a3d;
	--highlight-border: #3d7a4d;
	--control-bg: #2a2a2a;
	--control-hover: #333;
	--word-bg: #2a2a2a;
	--word-border: rgba(255, 255, 255, 0.1);
	--drawer-bar: #555;
	--shadow: rgba(0, 0, 0, 0.3);
	--shadow-hover: rgba(0, 0, 0, 0.4);
	--shadow-strong: rgba(0, 0, 0, 0.5);
	--scrollbar-track: transparent;
	--scrollbar-thumb: #444;
	--scrollbar-thumb-hover: #555;
	--lightbox-bg: rgba(0, 0, 0, 0.98);
	--lightbox-close-bg: rgba(255, 255, 255, 0.15);
	--lightbox-close-hover: rgba(255, 255, 255, 0.25);
}

html,
body {
	height: 100%;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
		Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
	overflow: hidden;
}

/* Loading */
.loading {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg);
	z-index: 1000;
	font-size: 1rem;
	color: var(--text-muted);
}

.loading.hidden {
	display: none;
}

/* Controls */
.controls {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 50;
	display: flex;
	justify-content: space-between;
	padding: 1.5rem 2rem;
	pointer-events: none;
}

.controls-left,
.controls-right {
	display: flex;
	gap: 0.5rem;
	pointer-events: auto;
}

.control-btn {
	width: 40px;
	height: 40px;
	border: none;
	background: var(--control-bg);
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
	box-shadow: 0 2px 8px var(--shadow);
}

.control-btn:hover {
	background: var(--control-hover);
}

.control-btn .icon {
	width: 20px;
	height: 20px;
	color: var(--text);
}

/* Icon visibility states */
.control-btn .icon-asc,
.control-btn .icon-grid,
.control-btn .icon-panel-hide,
.control-btn .icon-light {
	display: none;
}

/* Sort button states */
body.sort-asc .control-btn .icon-desc {
	display: none;
}
body.sort-asc .control-btn .icon-asc {
	display: block;
}

/* View button states */
body.view-grid .control-btn .icon-list {
	display: none;
}
body.view-grid .control-btn .icon-grid {
	display: block;
}

/* Panel button states */
body.panel-hidden .control-btn .icon-panel-show {
	display: none;
}
body.panel-hidden .control-btn .icon-panel-hide {
	display: block;
}

/* Theme button states */
body.dark-mode .control-btn .icon-dark {
	display: none;
}
body.dark-mode .control-btn .icon-light {
	display: block;
}

/* Container - full viewport, no scroll */
.container {
	display: flex;
	height: 100vh;
	overflow: hidden;
}

/* Left column: Images - scrollable, takes 75% */
.images-column {
	width: 67%;
	height: 100vh;
	overflow-y: auto;
	padding: 5rem 2rem 4rem;
	background-color: var(--bg-secondary);
	scroll-snap-type: y mandatory;
	transition: width 0.3s ease;
}

/* Panel hidden state - images take full width */
body.panel-hidden .images-column {
	width: 100%;
}

body.panel-hidden .info-panel {
	transform: translateX(100%);
	opacity: 0;
	pointer-events: none;
}

.images-list {
	display: flex;
	flex-direction: column;
	gap: 12rem;
	padding-top: 12rem;
	padding-bottom: 12rem;
	max-width: 500px;
	margin: 0 auto;
}

/* List view */
.image-item {
	width: 100%;
	aspect-ratio: 3 / 4;
	background: var(--bg);
	overflow: hidden;
	box-shadow: 0 4px 24px var(--shadow);
	border-radius: 4px;
	scroll-snap-align: center;
	cursor: pointer;
	transition:
		transform 0.3s ease-out,
		box-shadow 0.2s ease;
}

.image-item:hover {
	box-shadow: 0 8px 32px var(--shadow-hover);
}

.image-item.active {
	transform: scale(1.1);
}

.image-item.selected {
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.image-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.image-item img.loaded {
	opacity: 1;
}

/* Grid view */
body.view-grid .images-column {
	scroll-snap-type: none;
	padding-top: 5rem;
}

body.view-grid .images-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 1rem;
	max-width: 100%;
	padding-top: 0;
	padding-bottom: 2rem;
}

body.view-grid .image-item {
	scroll-snap-align: none;
	transform: none;
}

body.view-grid .image-item.active {
	transform: none;
}

body.view-grid .image-item.selected {
	outline: 3px solid var(--text);
	outline-offset: 2px;
}

body.view-grid.panel-hidden .images-list {
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Right column: Info panel - fixed, takes 25% */
.info-panel {
	width: 33%;
	background-color: var(--bg-tertiary);
	height: 100vh;
	position: fixed;
	top: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	transition:
		transform 0.3s ease,
		opacity 0.3s ease;
	box-shadow: 0px 0px 88px var(--shadow-strong);
}

.info-content {
	width: 100%;
	max-width: 500px;
}

/* Edition number */
.edition-number {
	font-size: 1rem;
	font-weight: 400;
	letter-spacing: -0.02em;
	margin-bottom: 2rem;
	color: var(--text);
}

/* Trigger summary */
.trigger-summary {
	font-size: 0.9rem;
	color: var(--text-muted);
	margin-bottom: 3rem;
	line-height: 1.6;
}

.trigger-summary .address {
	font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", monospace;
	font-size: 0.85rem;
}

.trigger-summary .word-change {
	display: block;
	margin-top: 0.25rem;
	text-transform: capitalize;
}

.trigger-summary .old-word {
	text-decoration: line-through;
	opacity: 0.6;
}

.trigger-summary .new-word {
	font-weight: 500;
}

.trigger-summary .arrow {
	margin: 0 0.35rem;
	opacity: 0.4;
}

/* Genesis */
.genesis-label {
	font-size: 0.9rem;
	color: var(--text-muted);
	margin-bottom: 3rem;
	font-style: italic;
}

/* Words grid */
.words-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.word-item {
	padding: 0.5rem 0.75rem;
	font-size: 1.2rem;
	text-transform: capitalize;
	background: var(--word-bg);
	border-bottom: 1px solid var(--word-border);
	transition: background 0.2s ease;
	border-radius: 4px;
}

.word-item.highlighted {
	background: var(--highlight);
	border-radius: 4px;
}

/* Links */
.links {
	margin-top: 2rem;
	display: flex;
	gap: 1rem;
}

.links a {
	font-size: 0.85rem;
	color: var(--text-muted);
	text-decoration: none;
	transition: color 0.2s ease;
}

.links a:hover {
	color: var(--text);
}

/* Mobile drawer */
.drawer {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: var(--bg);
	border-top-left-radius: 16px;
	border-top-right-radius: 16px;
	box-shadow: 0 -4px 20px var(--shadow-strong);
	z-index: 100;
	transform: translateY(calc(100% - 80px));
	transition: transform 0.3s ease;
	max-height: 80vh;
	flex-direction: column;
}

.drawer.open {
	transform: translateY(0);
}

.drawer-handle {
	display: flex;
	justify-content: center;
	padding: 1rem;
	cursor: pointer;
	flex-shrink: 0;
}

.drawer-bar {
	width: 40px;
	height: 4px;
	background: var(--drawer-bar);
	border-radius: 2px;
}

.drawer-content {
	padding: 0 1.5rem 2rem;
	overflow-y: auto;
	flex: 1;
}

.drawer .edition-number {
	font-size: 1.5rem;
	margin-bottom: 1rem;
	position: sticky;
	top: 0;
	background: var(--bg);
	padding: 0.5rem 0;
	z-index: 10;
	border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.drawer .trigger-summary,
.drawer .genesis-label {
	font-size: 0.8rem;
	margin-bottom: 1.5rem;
}

/* Mobile styles */
@media (max-width: 768px) {
	body {
		overflow: hidden;
	}

	.controls {
		padding: 1rem;
		position: fixed;
		z-index: 50;
	}

	.container {
		display: block;
		height: 100vh;
		overflow: hidden;
	}

	.images-column {
		width: 100%;
		height: 100vh;
		padding: 5rem 1rem 100px;
		overflow-y: auto;
		overflow-x: hidden;
		-webkit-overflow-scrolling: touch;
	}

	.images-list {
		max-width: 100%;
		gap: 2rem;
		padding-top: 0;
		padding-bottom: 2rem;
	}

	.image-item.active {
		transform: none;
	}

	body.view-grid .images-column {
		padding-top: 5rem;
		padding-bottom: 100px;
	}

	body.view-grid .images-list {
		grid-template-columns: repeat(2, 1fr);
		gap: 1rem;
	}

	.info-panel {
		display: none;
	}

	.drawer {
		display: flex;
	}

	body.panel-hidden .images-column {
		width: 100%;
	}

	.controls-right #panel-btn {
		display: none;
	}
}

/* Scrollbar styling - only on images column now */
.images-column::-webkit-scrollbar {
	width: 8px;
}

.images-column::-webkit-scrollbar-track {
	background: var(--scrollbar-track);
}

.images-column::-webkit-scrollbar-thumb {
	background: var(--scrollbar-thumb);
	border-radius: 4px;
}

.images-column::-webkit-scrollbar-thumb:hover {
	background: var(--scrollbar-thumb-hover);
}

.drawer-content::-webkit-scrollbar {
	width: 8px;
}

.drawer-content::-webkit-scrollbar-track {
	background: var(--scrollbar-track);
}

.drawer-content::-webkit-scrollbar-thumb {
	background: var(--scrollbar-thumb);
	border-radius: 4px;
}

.drawer-content::-webkit-scrollbar-thumb:hover {
	background: var(--scrollbar-thumb-hover);
}

/* Lightbox */
.lightbox {
	display: none;
	position: fixed;
	inset: 0;
	background: var(--lightbox-bg);
	z-index: 200;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.lightbox.open {
	display: flex;
	animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
	to {
		opacity: 1;
	}
}

.lightbox-close {
	position: absolute;
	top: 2rem;
	right: 2rem;
	width: 48px;
	height: 48px;
	border: none;
	background: var(--lightbox-close-bg);
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
	z-index: 201;
}

.lightbox-close:hover {
	background: var(--lightbox-close-hover);
}

.lightbox-close .icon,
.lightbox-close svg {
	color: white;
	width: 24px;
	height: 24px;
}

.lightbox-content {
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
	animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
	from {
		transform: scale(0.8);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

.lightbox-content img {
	max-width: 100%;
	max-height: 90vh;
	object-fit: contain;
	border-radius: 8px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
