/* CSS Reset & Base */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* Accessibility - Visually Hidden */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

:root {
	/* Light Mode Colors */
	--primary-color: #6366f1;
	--primary-hover: #4f46e5;
	--primary-light: #eef2ff;
	--secondary-color: #8b5cf6;
	--secondary-hover: #7c3aed;
	--secondary-light: #f5f3ff;
	--info: #0ea5e9;
	--info-light: #e0f2fe;
	--success: #10b981;
	--success-light: #d1fae5;
	--error: #ef4444;
	--error-light: #fee2e2;
	--warning: #f59e0b;
	--warning-light: #fef3c7;

	/* Background & Surface */
	--background: #ffffff;
	--surface: #ffffff;
	--surface-hover: #f8fafc;
	--bg-secondary: #f8fafc;
	--border: #e2e8f0;
	--border-light: #f1f5f9;

	/* Text Colors - WCAG AAA Compliant */
	--text-primary: #0f172a;
	--text-secondary: #475569;
	--text-tertiary: #94a3b8;
	--text-muted: #cbd5e1;

	/* Shadows */
	--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

	/* Focus Ring */
	--focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.15);
	--focus-ring-offset: 2px;

	/* Spacing Tokens */
	--space-xs: 4px;
	--space-sm: 8px;
	--space-md: 12px;
	--space-lg: 16px;
	--space-xl: 24px;
	--space-2xl: 32px;
	--space-3xl: 40px;
	--space-4xl: 48px;

	/* Border Radius */
	--radius-sm: 4px;
	--radius-md: 6px;
	--radius-lg: 8px;
	--radius-xl: 12px;
	--radius-2xl: 16px;
	--radius-full: 9999px;

	/* Layout */
	--gnb-height: 64px;
	--lnb-height: 48px;
	--header-height: calc(var(--gnb-height) + var(--lnb-height));
	--sidebar-width: 280px;

	/* Transitions */
	--transition-fast: 0.15s ease;
	--transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	--transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	--transition: var(--transition-normal);
}

[data-theme="dark"] {
	/* Dark Mode Colors - Enhanced Contrast */
	--primary-color: #818cf8;
	--primary-hover: #6366f1;
	--primary-light: #312e81;
	--secondary-color: #a78bfa;
	--secondary-hover: #8b5cf6;
	--secondary-light: #3730a3;
	--info: #38bdf8;
	--info-light: #0c4a6e;
	--success: #34d399;
	--success-light: #064e3b;
	--error: #f87171;
	--error-light: #7f1d1d;
	--warning: #fbbf24;
	--warning-light: #78350f;

	/* Background & Surface - Better Contrast */
	--background: #0f172a;
	--surface: #1e293b;
	--surface-hover: #334155;
	--bg-secondary: #334155;
	--border: #334155;
	--border-light: #1e293b;

	/* Text Colors - Enhanced Readability */
	--text-primary: #f1f5f9;
	--text-secondary: #cbd5e1;
	--text-tertiary: #94a3b8;
	--text-muted: #64748b;

	/* Shadows - Deeper for Dark Mode */
	--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
	--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
	--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
	--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

	/* Focus Ring for Dark Mode */
	--focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.25);
}

/* System Color Scheme Preference */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		/* Dark Mode Colors - Enhanced Contrast */
		--primary-color: #818cf8;
		--primary-hover: #6366f1;
		--primary-light: #312e81;
		--secondary-color: #a78bfa;
		--secondary-hover: #8b5cf6;
		--secondary-light: #3730a3;
		--info: #38bdf8;
		--info-light: #0c4a6e;
		--success: #34d399;
		--success-light: #064e3b;
		--error: #f87171;
		--error-light: #7f1d1d;
		--warning: #fbbf24;
		--warning-light: #78350f;

		/* Background & Surface - Better Contrast */
		--background: #0f172a;
		--surface: #1e293b;
		--surface-hover: #334155;
		--bg-secondary: #334155;
		--border: #334155;
		--border-light: #1e293b;

		/* Text Colors - Enhanced Readability */
		--text-primary: #f1f5f9;
		--text-secondary: #cbd5e1;
		--text-tertiary: #94a3b8;
		--text-muted: #64748b;

		/* Shadows - Deeper for Dark Mode */
		--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
		--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
		--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
		--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

		/* Focus Ring for Dark Mode */
		--focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.25);
	}
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	background-color: var(--background);
	color: var(--text-primary);
	line-height: 1.6;
	transition: background-color var(--transition-normal), color var(--transition-normal);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	padding-top: var(--header-height);
}

/* ============================================
   Focus Visible - Enhanced Accessibility
   ============================================ */

/* Remove default focus outline */
*:focus {
	outline: none;
}

/* Add visible focus ring only for keyboard navigation */
*:focus-visible {
	outline: 2px solid var(--primary-color);
	outline-offset: var(--focus-ring-offset);
	border-radius: var(--radius-sm);
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
	box-shadow: var(--focus-ring);
	outline: 2px solid var(--primary-color);
	outline-offset: var(--focus-ring-offset);
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* Header */

.header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: var(--header-height);
	background-color: var(--surface);
	border-bottom: 1px solid var(--border);
	z-index: 100;
	box-shadow: var(--shadow-sm);
	display: flex;
	flex-direction: column;
}

.gnb {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 24px;
	height: var(--gnb-height);
	border-bottom: 1px solid var(--border);
	width: 100%;
	box-sizing: border-box;
}

.lnb {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 24px;
	height: var(--lnb-height);
	width: 100%;
	box-sizing: border-box;
}

.logo {
	font-size: 24px;
	font-weight: 700;
	background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
}

.header-actions {
	display: flex;
	gap: 12px;
}

.gnb-left,
.gnb-right,
.lnb-left,
.lnb-right {
	display: flex;
	align-items: center;
	gap: 12px;
}

.gnb-left {
	flex: 1;
	gap: 20px;
	min-width: 0;
}

.gnb-right {
	flex-shrink: 0;
	gap: 12px;
}

.lnb-left {
	gap: 16px;
	flex-shrink: 0;
}

.lnb-right {
	flex: 1;
}

/* Page Navigation */
.global-nav,
.section-nav {
	display: flex;
	gap: 8px;
	flex-wrap: nowrap;
	align-items: center;
}

.global-nav {
	gap: 4px;
}

.global-nav-link,
.section-nav-link {
	color: var(--text-primary);
	text-decoration: none;
	padding: 0.5rem 0.75rem;
	border-radius: var(--radius-md);
	transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
	white-space: nowrap;
	font-size: 14px;
	font-weight: 500;
	position: relative;
}

.global-nav-link:hover,
.section-nav-link:hover {
	background: var(--surface-hover);
	transform: translateY(-1px);
}

.global-nav-link:active,
.section-nav-link:active {
	transform: translateY(0);
}

.global-nav-link.active,
.section-nav-link.active {
	background: var(--primary-color);
	color: white;
}

.global-nav-link:focus-visible,
.section-nav-link:focus-visible {
	box-shadow: var(--focus-ring);
}

/* Container */
.container {
	display: flex;
	min-height: calc(100vh - var(--header-height));
	flex: 1;
}

/* Sidebar */
.sidebar {
	position: sticky;
	top: var(--header-height);
	width: var(--sidebar-width);
	height: calc(100vh - var(--header-height));
	background-color: var(--surface);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	overflow-y: auto;
	transition: var(--transition);
	flex-shrink: 0;
	align-self: flex-start;
}

.sidebar-header {
	padding: 20px;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.tool-list {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
}

/* Main Content */
.main-content {
	flex: 1;
	overflow-y: auto;
	background-color: var(--background);
	min-width: 0;
}

.tool-content {
	display: none;
	padding: 40px;
	max-width: 1200px;
	margin: 0 auto;
	animation: fadeIn 0.3s ease-in-out;
}

.tool-content.active {
	display: block;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px) translateZ(0);
	}
	to {
		opacity: 1;
		transform: translateY(0) translateZ(0);
	}
}

.tool-header {
	margin-bottom: 32px;
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	align-items: flex-start;
	justify-content: space-between;
}

.tool-header-content {
	flex: 1;
	min-width: 0;
}

.tool-header h2 {
	font-size: 32px;
	font-weight: 700;
	margin-bottom: 8px;
	color: var(--text-primary);
}

.tool-description {
	font-size: 16px;
	color: var(--text-secondary);
}

.tool-share-slot {
	align-self: flex-start;
	flex-shrink: 0;
}

.tool-body {
	position: relative;
	display: grid;
	gap: 24px;
	padding: 40px;
	max-width: 1200px;
	margin: 0 auto;
}

#gradientColors {
	position: relative;
}

/* Scrollbar */
::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: var(--surface);
}

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

::-webkit-scrollbar-thumb:hover {
	background: var(--text-secondary);
}

/* Selection */
::selection {
	background-color: var(--primary-color);
	color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
	.sidebar {
		width: 240px;
	}

	.tool-content {
		padding: 24px;
	}
}

@media (max-width: 768px) {
	.gnb,
	.lnb {
		padding: 0 12px;
	}

	.gnb {
		height: 60px;
	}

	.lnb {
		height: 44px;
	}

	:root {
		--gnb-height: 60px;
		--lnb-height: 44px;
		--header-height: calc(var(--gnb-height) + var(--lnb-height));
	}

	.logo {
		font-size: 18px;
	}

	.gnb-left {
		gap: 12px;
	}

	.global-nav {
		display: none;
	}

	.gnb-right {
		gap: 8px;
	}

	.lnb-left {
		gap: 12px;
	}

	.section-nav {
		gap: 6px;
	}

	.section-nav-link {
		padding: 0.4rem 0.6rem;
		font-size: 13px;
	}

	.language-select {
		height: 34px;
		padding: 0 6px;
		font-size: 12px;
		min-width: auto;
		width: auto;
	}

	.theme-toggle {
		width: 34px;
		height: 34px;
	}

	.theme-toggle svg {
		width: 16px;
		height: 16px;
	}

	.mobile-menu-toggle {
		width: 34px;
		height: 34px;
	}

	/* 공유 버튼 텍스트 숨기기 (모바일에서) */
	.share-button span {
		display: none;
	}

	.sidebar {
		position: fixed;
		left: -280px;
		top: var(--header-height);
		height: calc(100vh - var(--header-height));
		z-index: 90;
		box-shadow: var(--shadow-lg);
		overflow-y: auto;
		overflow-x: hidden;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
	}

	.sidebar.active {
		left: 0;
	}

	.main-content {
		width: 100%;
		margin-left: 0;
	}

	.tool-content {
		padding: 20px;
	}

	.tool-header h2 {
		font-size: 24px;
	}
}

@media (max-width: 640px) {
	.tool-header h2 {
		font-size: clamp(1.5rem, 5vw, 1.75rem);
	}

	.tool-description {
		font-size: 15px;
	}
}

@media (max-width: 480px) {
	.gnb,
	.lnb {
		padding: 0 var(--space-sm);
	}

	.logo {
		font-size: 15px;
	}

	.gnb-left {
		gap: var(--space-sm);
	}

	.gnb-right {
		gap: var(--space-xs);
	}

	.language-select {
		height: 32px;
		padding: 0 var(--space-xs);
		font-size: 10px;
		min-width: 50px;
	}

	.theme-toggle {
		width: 32px;
		height: 32px;
	}

	.theme-toggle svg {
		width: 14px;
		height: 14px;
	}

	.mobile-menu-toggle {
		width: 32px;
		height: 32px;
	}

	.tool-content {
		padding: var(--space-lg);
	}

	.tool-header h2 {
		font-size: 1.5rem;
	}

	.tool-header {
		gap: var(--space-lg);
	}
}

@media (max-width: 400px) {
	.tool-content {
		padding: var(--space-md);
	}

	.tool-header {
		gap: var(--space-md);
	}

	.gnb,
	.lnb {
		padding: 0 var(--space-xs);
	}
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
	/* Increase touch targets for mobile */
	.btn {
		min-height: 44px;
		padding: 12px 24px;
	}

	.btn-icon {
		min-width: 44px;
		min-height: 44px;
	}

	.global-nav-link,
	.section-nav-link {
		min-height: 44px;
		padding: 0.75rem 1rem;
	}

	/* Disable hover effects on touch devices */
	.btn:hover,
	.color-card:hover,
	.global-nav-link:hover,
	.section-nav-link:hover {
		transform: none;
	}

	/* Enable touch scroll optimization */
	.sidebar {
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
	}

	/* Larger tap targets for inputs */
	.search-input,
	.language-select,
	.theme-toggle,
	.mobile-menu-toggle {
		min-height: 44px;
	}
}

/* Error Page Styles */
.error-main {
	padding: 2rem;
	min-height: calc(100vh - var(--header-height));
}

.error-page-container {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 4rem;
	max-width: 1000px;
	margin: 4rem auto;
	padding: 2rem;
	min-height: 60vh;
}

.error-content {
	flex: 1;
	min-width: 300px;
}

.error-code {
	font-size: clamp(4rem, 15vw, 8rem);
	font-weight: 900;
	background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	line-height: 1;
	margin-bottom: 1rem;
}

.error-page-container h1 {
	font-size: 2.5rem;
	margin-bottom: 0.5rem;
	color: var(--text-primary);
}

.error-subtitle {
	font-size: 1.1rem;
	color: var(--text-secondary);
	margin-bottom: 2rem;
	line-height: 1.6;
}

.error-suggestions {
	margin-bottom: 2rem;
}

.error-suggestions p {
	margin-bottom: 1rem;
	font-weight: 600;
	color: var(--text-primary);
}

.error-suggestions ul {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 0.5rem;
}

.error-suggestions li {
	margin: 0;
}

.error-link {
	display: block;
	padding: 0.75rem 1rem;
	background: var(--surface-hover);
	border: 1px solid var(--border);
	border-radius: 8px;
	text-decoration: none;
	color: var(--primary-color);
	font-weight: 500;
	transition: var(--transition);
	text-align: center;
}

.error-link:hover {
	background: var(--primary-color);
	color: white;
	border-color: var(--primary-color);
}

.error-search {
	background: var(--surface);
	padding: 1.5rem;
	border-radius: 12px;
	border: 1px solid var(--border);
}

.error-search p {
	margin-bottom: 1rem;
	font-weight: 600;
	color: var(--text-primary);
}

.error-search-input {
	width: 100%;
	padding: 0.75rem 1rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--background);
	color: var(--text-primary);
	font-size: 1rem;
	transition: var(--transition);
	margin-bottom: 1rem;
}

.error-search-input:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.error-search-results {
	max-height: 300px;
	overflow-y: auto;
}

.error-search-results-item {
	padding: 0.75rem;
	background: var(--background);
	border-radius: 6px;
	margin-bottom: 0.5rem;
	cursor: pointer;
	transition: var(--transition);
	border: 1px solid transparent;
}

.error-search-results-item:hover {
	background: var(--bg-secondary);
	border-color: var(--primary-color);
}

.error-search-results-item a {
	display: block;
	color: var(--primary-color);
	text-decoration: none;
	font-weight: 500;
}

.error-illustration {
	flex: 1;
	display: none;
	align-items: center;
	justify-content: center;
}

.error-svg {
	width: 100%;
	max-width: 300px;
	height: auto;
	opacity: 0.8;
}

/* Error Modal */
.error-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	animation: fadeIn 0.3s ease;
}

.error-modal {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	box-shadow: var(--shadow-lg);
	max-width: 500px;
	width: 90%;
	max-height: 90vh;
	overflow-y: auto;
	position: relative;
	animation: slideUp 0.3s ease;
}

.error-modal-close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	width: 32px;
	height: 32px;
	border: none;
	background: transparent;
	color: var(--text-secondary);
	font-size: 24px;
	cursor: pointer;
	transition: var(--transition);
}

.error-modal-close:hover {
	color: var(--text-primary);
}

.error-modal-content {
	padding: 2rem;
	text-align: center;
}

.error-modal-content .error-code {
	margin-bottom: 1rem;
}

.error-modal-content h1 {
	font-size: 1.8rem;
	margin-bottom: 0.5rem;
	white-space: nowrap;
}

.error-modal-content > p {
	color: var(--text-secondary);
	margin-bottom: 2rem;
}

.error-modal-actions {
	display: flex;
	gap: 1rem;
	margin-bottom: 2rem;
	flex-wrap: wrap;
	justify-content: center;
}

.error-modal-details {
	text-align: left;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1rem;
}

.error-modal-details summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--text-primary);
	padding: 0.5rem;
}

.error-modal-details pre {
	margin: 1rem 0 0;
	padding: 1rem;
	background: var(--background);
	border-radius: 6px;
	overflow-x: auto;
	font-size: 0.875rem;
	color: var(--text-secondary);
	white-space: pre-wrap;
	word-break: break-all;
}

/* Error Notification */
.error-notification {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	background: var(--error);
	color: white;
	border-radius: 8px;
	padding: 1rem 1.5rem;
	box-shadow: var(--shadow-lg);
	animation: slideUp 0.3s ease;
	max-width: 400px;
	z-index: 1000;
}

.error-notification-content {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
}

.error-icon {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	margin-top: 2px;
}

.error-notification-text strong {
	display: block;
	margin-bottom: 0.25rem;
}

.error-notification-text p {
	margin: 0;
	font-size: 0.95rem;
}

.error-notification.fade-out {
	animation: fadeOut 0.3s ease;
}

@media (min-width: 768px) {
	.error-illustration {
		display: flex;
	}
}

@media (max-width: 600px) {
	.error-page-container {
		flex-direction: column;
		gap: 2rem;
		margin: 2rem auto;
		padding: 1rem;
	}

	.error-code {
		font-size: 4rem;
	}

	.error-page-container h1 {
		font-size: 1.8rem;
	}

	.error-suggestions ul {
		grid-template-columns: 1fr;
	}

	.error-modal {
		width: 95%;
		max-height: 95vh;
	}

	.error-notification {
		left: 1rem;
		right: 1rem;
		bottom: 1rem;
		max-width: none;
	}
}

@keyframes slideUp {
	from {
		transform: translateY(30px) translateZ(0);
		opacity: 0;
	}
	to {
		transform: translateY(0) translateZ(0);
		opacity: 1;
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateZ(0);
	}
	to {
		opacity: 1;
		transform: translateZ(0);
	}
}

@keyframes fadeOut {
	from {
		opacity: 1;
		transform: translateZ(0);
	}
	to {
		opacity: 0;
		transform: translateZ(0);
	}
}
