/* CLS - 통합 다크 테마 */
:root, :host {
	--cls-bg: #0c0c0e;
	--cls-bg-elevated: #141416;
	--cls-bg-card: #1a1a1e;
	--cls-card: #1a1a1e;
	--cls-border: #27272a;
	--cls-border-hover: #3f3f46;
	--cls-text: #fafafa;
	--cls-text-secondary: #a1a1aa;
	--cls-text-muted: #71717a;
	--cls-text-dim: #52525b;
	--cls-accent: #3b82f6;
	--cls-accent-hover: #60a5fa;
	--cls-accent-muted: rgba(59, 130, 246, 0.12);
	--cls-success: #22c55e;
	--cls-error: #ef4444;
	--cls-warning: #f59e0b;
	--cls-radius-sm: 6px;
	--cls-radius: 8px;
	--cls-radius-lg: 12px;
	--cls-shadow: 0 4px 24px rgba(0,0,0,0.4);
	--cls-shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
	/* 호환 */
	--aniq-bg: var(--cls-bg);
	--aniq-card: var(--cls-card);
	--aniq-border: var(--cls-border);
	--aniq-border-hover: var(--cls-border-hover);
	--aniq-text: var(--cls-text);
	--aniq-text-muted: var(--cls-text-muted);
	--aniq-text-dim: var(--cls-text-dim);
	--aniq-accent: var(--cls-accent);
	--aniq-accent-hover: var(--cls-accent-hover);
	--aniq-success: var(--cls-success);
	--aniq-error: var(--cls-error);
	--aniq-warning: var(--cls-warning);
}

/* === 리셋/베이스 === */
*, ::after, ::before { box-sizing: border-box; }
body {
	margin: 0;
	font-family: "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 0.875rem;
	line-height: 1.5;
	color: var(--aniq-text);
	background: var(--aniq-bg);
	color-scheme: dark;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.2; color: var(--cls-text); }
h1 { font-size: 2rem; }
h4 { font-size: 1.25rem; }
h6 { font-size: 0.875rem; }
a { color: var(--aniq-accent); text-decoration: none; }
a:hover { color: var(--aniq-accent-hover); text-decoration: none; }

/* === 그리드 === */
.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 1rem; }
.row { display: flex; flex-wrap: wrap; margin: 0 -0.5rem; }
.row > * { padding: 0 0.5rem; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 768px) {
	.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
	.col-md-6 { flex: 0 0 50%; max-width: 50%; }
	.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
	.col-md-12 { flex: 0 0 100%; max-width: 100%; }
}
@media (min-width: 1200px) {
	.col-xl-4 { flex: 0 0 33.333%; max-width: 33.333%; }
	.col-xl-6 { flex: 0 0 50%; max-width: 50%; }
	.col-xl-8 { flex: 0 0 66.666%; max-width: 66.666%; }
}
@media (min-width: 1400px) {
	.col-xxl-3 { flex: 0 0 25%; max-width: 25%; }
	.col-xxl-9 { flex: 0 0 75%; max-width: 75%; }
}

/* === 플렉스/여백/텍스트 유틸리티 === */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow-1 { flex-grow: 1; }
.flex-grow-2 { flex-grow: 2; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.text-muted { color: var(--aniq-text-muted); }
.text-secondary { color: var(--aniq-text-dim); }
.text-center { text-align: center; }
.text-primary { color: var(--aniq-accent); }
.fw-bold { font-weight: 700; }
.small { font-size: 0.8em; }
.w-100 { width: 100%; }
.mx-0 { margin-left: 0; margin-right: 0; }
.mx-auto { margin-left: auto; margin-right: auto; }
.img-fluid { max-width: 100%; height: auto; }
.display-none { display: none; }
@media (min-width: 768px) {
	.flex-md-row { flex-direction: row; }
	.mb-md-0 { margin-bottom: 0; }
	.mt-md-3 { margin-top: 1rem; }
}
@media (min-width: 1200px) { .mt-xl-0 { margin-top: 0; } }

/* === collapse / dropdown === */
.collapse { display: none; }
.collapse.show { display: block; }
.dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; background: none; border: none; padding: 0; }
.dropdown-menu {
	display: none;
	position: absolute;
	z-index: 1000;
	min-width: 10rem;
	padding: 0.5rem;
	background: var(--aniq-card);
	border: 1px solid var(--aniq-border);
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.dropdown.show .dropdown-menu { display: block; }

/* === 스피너 === */
.spinner-border {
	display: inline-block;
	width: 2rem;
	height: 2rem;
	border: 0.2em solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: cls-spin 0.75s linear infinite;
}
@keyframes cls-spin { to { transform: rotate(360deg); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.border-top { border-top: 1px solid var(--aniq-border); }
.icon-lg { width: 1.5rem; height: 1.5rem; }

/* === 앱 컨테이너 === */
.aniq-theme .app {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--aniq-bg);
}
.app-body {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	max-width: 1600px;
	margin: 0 auto;
	width: 100%;
	padding: 0 2rem;
}
.app-main {
	flex: 1;
	padding: 2rem 0;
}

/* === 1차 메뉴 헤더 === */
.app-header {
	position: relative;
	background: var(--cls-bg-elevated);
	border-bottom: 1px solid var(--cls-border);
	flex-shrink: 0;
}
.app-header-row {
	display: flex;
	align-items: center;
	height: 64px;
	padding: 0 1.5rem;
	max-width: 1600px;
	margin: 0 auto;
}
.app-header-logo {
	flex-shrink: 0;
	font-weight: 700;
	font-size: 1.0625rem;
	letter-spacing: -0.025em;
	color: var(--cls-text);
	text-decoration: none;
	transition: color 0.2s;
}
.app-header-logo:hover { color: var(--cls-accent); }
.app-header-nav {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	flex: 1;
	justify-content: center;
	padding: 0 2rem;
}
.app-nav-tab {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.5rem 1rem;
	color: var(--cls-text-muted);
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 500;
	border: none;
	background: none;
	font-family: inherit;
	cursor: pointer;
	border-radius: 6px;
	transition: color 0.2s, background 0.2s;
}
.app-nav-tab:hover {
	color: var(--cls-text);
	background: rgba(255,255,255,0.04);
}
.app-nav-tab.active {
	color: var(--cls-accent);
	background: var(--cls-accent-muted);
}
.app-nav-chevron {
	width: 12px;
	height: 12px;
	opacity: 0.6;
	transition: transform 0.2s;
}
.app-nav-group.open .app-nav-chevron { transform: rotate(180deg); }
.app-nav-group { position: relative; }
.app-nav-group.open .app-nav-trigger {
	color: var(--cls-accent);
	background: var(--cls-accent-muted);
}
.app-header-right {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 1rem;
	padding-left: 1rem;
	border-left: 1px solid var(--cls-border);
}
.app-header-user {
	font-size: 0.8125rem;
	color: var(--cls-text-muted);
	font-weight: 500;
}
.app-header-logout {
	font-size: 0.8125rem;
	color: var(--cls-text-muted);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s;
}
.app-header-logout:hover { color: var(--cls-accent); }

/* 메가 메뉴 - nav-group 바로 아래 (갭 없이 연결) */
.app-mega-panel {
	display: none;
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -50vw;
	width: 100vw;
	background: var(--cls-bg);
	border-bottom: 1px solid rgba(255,255,255,0.06);
	z-index: 200;
	animation: mega-in 0.15s ease;
}
@keyframes mega-in {
	from { opacity: 0; }
	to { opacity: 1; }
}
.app-nav-group.open .app-mega-panel { display: block; }
.app-mega-inner {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 1.5rem 2rem;
	max-width: 1600px;
	margin: 0 auto;
	padding: 1.5rem 1.5rem;
}
.app-mega-column {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}
.app-mega-col-header {
	font-size: 0.6875rem;
	font-weight: 600;
	color: var(--cls-text-dim);
	letter-spacing: 0.05em;
	text-transform: uppercase;
	margin-bottom: 0.25rem;
}
.app-mega-link {
	display: block;
	padding: 0.35rem 0;
	color: var(--cls-text-muted);
	text-decoration: none;
	font-size: 0.8125rem;
	font-weight: 500;
	transition: color 0.15s;
}
.app-mega-link:hover { color: var(--cls-text); }
.app-mega-link.active { color: var(--cls-text); font-weight: 600; }

@media (max-width: 768px) {
	.app-mega-inner {
		grid-template-columns: 1fr;
		padding: 1.25rem 1.5rem;
		gap: 1rem;
	}
}
@media (max-width: 640px) {
	.app-header-row { padding: 0 1rem; height: 56px; }
	.app-header-nav { padding: 0 0.75rem; }
	.app-nav-tab { padding: 0.4rem 0.75rem; font-size: 0.8125rem; }
	.app-header-right { border-left: none; padding-left: 0; }
	.app-header-user { display: none; }
}

/* === 본문 === */
.app-main {
	flex: 1;
	min-width: 0;
	background: var(--cls-bg);
	display: flex;
	flex-direction: column;
}
.app-main .page-content {
	flex: 1;
	padding: 0;
	width: 100%;
	box-sizing: border-box;
}
.app-main .page-content h4 {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--cls-text);
	letter-spacing: -0.03em;
	margin-bottom: 1.25rem;
}
.app-main .page-content .card-title {
	font-weight: 600;
	font-size: 0.9375rem;
	color: var(--cls-text);
}
.app-main .card {
	border: 1px solid var(--cls-border);
	border-radius: var(--cls-radius-lg);
	background: var(--cls-card);
	box-shadow: none;
}
.app-main .card-body { padding: 1.5rem 1.75rem; }

/* === 푸터 === */
.app-footer {
	flex-shrink: 0;
	margin-top: auto;
	padding: 1rem 0;
	border-top: 1px solid var(--cls-border);
	background: var(--cls-bg-elevated);
}
.app-footer-inner {
	max-width: 1600px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
}
.app-footer-copy {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--cls-text-muted);
	font-weight: 500;
}

/* === 그리드/카드 === */
.grid-margin { margin-bottom: 1.5rem; }
@media (min-width: 992px) { .grid-margin-lg-0 { margin-bottom: 0; } }
.stretch-card { display: flex; align-items: stretch; justify-content: stretch; }
.stretch-card > .card { width: 100%; min-width: 100%; }

/* === 공통 === */
.sub-menu-link { color: var(--aniq-text-muted); line-height: 1; font-weight: 500; }
.sub-menu-link.active { color: var(--aniq-accent); }
.btn-primary, .btn-primary:hover {
	background-color: var(--aniq-accent) !important;
	border-color: var(--aniq-accent) !important;
	color: #fff !important;
}

/* === 툴팁 === */
.tooltip { position: absolute; z-index: 1070; display: block; }
.tooltip .tooltip-inner {
	max-width: 200px;
	padding: 0.4rem 0.75rem;
	color: #fff;
	background: var(--aniq-card);
	border: 1px solid var(--aniq-border);
	border-radius: 8px;
	font-size: 0.8rem;
	white-space: pre-wrap;
}

/* === 모달 === */
.modal {
	display: none;
	position: fixed;
	top: 0; left: 0;
	z-index: 1055;
	width: 100%; height: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	outline: 0;
}
.modal-dialog { position: relative; width: auto; margin: 0.5rem; margin-left: auto !important; margin-right: auto !important; }
.modal-content {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--aniq-card);
	border: 1px solid var(--aniq-border);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-backdrop {
	position: fixed;
	top: 0; left: 0;
	z-index: 1050;
	width: 100vw;
	height: 100vh;
	background: rgba(0,0,0,0.7);
}
.modal.show { display: flex; align-items: center; justify-content: center; }

/* === 스크롤바 === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
	background-color: rgba(113, 113, 122, 0.5);
	border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(113, 113, 122, 0.7); }

/* === 404 레이아웃 (공통 클래스) === */
.main-wrapper { display: flex; }
.main-wrapper .page-wrapper {
	min-height: 100vh;
	width: 100%;
	margin-left: 0;
	display: flex;
	flex-direction: column;
}
.main-wrapper .page-wrapper .page-content { flex-grow: 1; padding: 28px; }
.main-wrapper .page-wrapper.full-page { width: 100%; margin-left: 0; }
.main-wrapper .page-wrapper.full-page .page-content { margin-top: 0; }
.auth-page { max-width: 400px; }
.mb-22 { margin-bottom: 1.5rem; }
.tx-80 { font-size: 5rem; }

#text-measurer, #text-measurer2 { position: absolute; visibility: hidden; white-space: pre; }

/* === 미디어 모달 === */
.media-modal {
	display: none;
	position: fixed;
	top: 0; left: 0;
	width: 100%; height: 100%;
	background-color: rgba(0,0,0,0.9);
	z-index: 1055;
	justify-content: center;
	align-items: center;
}
.media-modal.active { display: flex; }
.media-container {
	position: relative;
	width: 95%;
	height: 90vh;
	display: flex;
	justify-content: center;
	align-items: center;
	background: transparent;
	overflow: hidden;
}
.media-container img {
	max-width: 100%;
	max-height: 90vh;
	height: auto;
	display: block;
	transform-origin: center;
	cursor: zoom-in;
	object-fit: contain;
	will-change: transform;
}
.media-container img.zoomed { cursor: grab; }
.media-container img.zoomed:active { cursor: grabbing; }
.media-container video { max-width: 100%; max-height: 90vh; width: auto; height: auto; display: block; }
.close-media {
	position: fixed;
	top: 30px;
	right: 30px;
	color: #fff;
	font-size: 28px;
	cursor: pointer;
	background: none;
	border: none;
	padding: 0;
	z-index: 1056;
	transition: opacity 0.2s;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.close-media:hover { opacity: 0.7; }
.zoom-controls {
	position: fixed;
	bottom: 40px;
	left: 50%;
	transform: translateX(-50%);
	display: none;
	gap: 16px;
	z-index: 1056;
	padding: 10px 20px;
	background: var(--aniq-card);
	border: 1px solid var(--aniq-border);
	border-radius: 8px;
}
.zoom-controls.active { display: flex; }
.zoom-controls button {
	background: var(--aniq-accent);
	border: none;
	color: #fff;
	padding: 8px 14px;
	cursor: pointer;
	border-radius: 8px;
	font-size: 0.875rem;
	font-weight: 500;
	transition: background 0.2s;
	min-width: 50px;
}
.zoom-controls button:hover { background: var(--aniq-accent-hover); }
