/* ═══════════════════════════════════════════════════════════
   KarmoLab — Observatory
   관측실 톤 · 별빛 액센트 · 종이/잉크 다크 베이스
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */

:root {
    /* Observatory (관측실) 다크 베이스 — body는 무채색 어두움, 카드/패널은 paper/ink 톤 유지 */
    --bg-void: #08080a;        /* night sky — body 배경, 무채색 */
    --bg-primary: #12151c;     /* paper */
    --bg-secondary: #171a22;   /* paper-2 */
    --bg-tertiary: #1f242d;    /* line */
    --bg-hover: #2a3040;       /* line-2 */
    --bg-active: #3d4557;      /* line-3 */

    --glass: rgba(18, 21, 28, 0.96);
    --glass-hover: rgba(23, 26, 34, 0.98);
    --glass-strong: rgba(11, 13, 18, 0.98);
    --glass-blur: blur(14px);

    --text-primary: #f2f2ee;   /* ink */
    --text-secondary: #9a9a94; /* ink-2 */
    --text-tertiary: #55555a;  /* ink-3 */

    /* Typography tokens */
    --font-size-2xs: 12px;
    --font-size-xs: 14px;
    --font-size-sm: 16px;
    --font-size-md: 18px;
    --font-size-lg: 22px;

    /* Observatory accents (별빛) */
    --accent: #d4a849;         /* antique brass — gold leaf in dim observatory */
    --accent-hover: #e6c068;
    --accent-dim: rgba(212, 168, 73, 0.15);
    --accent-subtle: rgba(212, 168, 73, 0.08);
    --accent-glow: rgba(212, 168, 73, 0.30);

    --secondary: #7fa6d4;      /* cool starlight */
    --secondary-hover: #95b7df;
    --secondary-subtle: rgba(127, 166, 212, 0.08);
    --secondary-glow: rgba(127, 166, 212, 0.25);

    --success: #22C55E;
    --success-subtle: rgba(34, 197, 94, 0.08);
    --error: #ED4245;
    --error-subtle: rgba(237, 66, 69, 0.08);
    --warning: #F59E0B;
    --warning-subtle: rgba(245, 158, 11, 0.08);

    --border: rgba(242, 242, 238, 0.06);
    --border-hover: rgba(242, 242, 238, 0.12);
    --border-strong: rgba(232, 217, 168, 0.4);

    /* Observatory: 직각에 가까운 라디우스 (종이/도감 톤) */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 8px;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* 위젯 내부 툴 사이드바 폭 (이미지 편집 등; 앱 메인 내비와 무관) */
    --sidebar-width: 224px;
    --sidebar-collapsed-width: 56px;
    --transition: 180ms ease;
    --transition-fast: 100ms ease;
    --transition-slow: 350ms ease;

    --font-sans: 'Noto Sans KR', 'Inter', 'Malgun Gothic', 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Noto Serif KR', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', 'Liberation Mono', monospace;

    --grid-color: rgba(242, 242, 238, 0.015);
    --glow-text: none;
    --glow-box: none;
    --shadow-float: 0 1px 0 rgba(0, 0, 0, 0.25);

    /* 헤더 줄 + 메가메뉴 패널 동일 표면 (토스형: 위아래 한 장의 글래스) */
    --header-shell-glass: color-mix(in srgb, var(--glass) 35%, transparent);
    /* 메가 패널 max-height와 헤더 ::after 확장 높이를 반드시 동일하게 */
    --header-mega-max-h: min(44vh, 320px);
}

/* ── Light Theme ── */

[data-theme="light"] {
    /* Observatory paper — warm cream paper, dark ink, burnt sienna accent */
    --bg-void: #ebe1c6;        /* parchment shadow */
    --bg-primary: #f4eee0;     /* paper */
    --bg-secondary: #faf5e8;   /* paper light (cards) */
    --bg-tertiary: #ebe1c6;    /* divider */
    --bg-hover: #e0d5b8;
    --bg-active: #d6c89e;

    --glass: rgba(244, 238, 224, 0.85);
    --glass-hover: rgba(250, 245, 232, 0.92);
    --glass-strong: rgba(244, 238, 224, 0.96);

    --text-primary: #2d2520;   /* ink */
    --text-secondary: #5c4f44; /* mid brown */
    --text-tertiary: #8a7d6f;  /* sand */

    --accent: #a85b3e;         /* burnt sienna */
    --accent-hover: #c66e4d;
    --accent-dim: rgba(168, 91, 62, 0.14);
    --accent-subtle: rgba(168, 91, 62, 0.07);
    --accent-glow: rgba(168, 91, 62, 0.22);

    --secondary: #4a6b8a;      /* faded blue ink */
    --secondary-hover: #5c80a5;
    --secondary-subtle: rgba(74, 107, 138, 0.08);
    --secondary-glow: rgba(74, 107, 138, 0.22);

    --success: #4a6b3a;        /* moss */
    --success-subtle: rgba(74, 107, 58, 0.08);
    --error: #a83a2e;          /* deep red ink */
    --error-subtle: rgba(168, 58, 46, 0.08);
    --warning: #b8763d;        /* warm amber */
    --warning-subtle: rgba(184, 118, 61, 0.08);

    --border: rgba(45, 37, 32, 0.10);
    --border-hover: rgba(45, 37, 32, 0.18);
    --border-strong: rgba(168, 91, 62, 0.4);

    --grid-color: rgba(45, 37, 32, 0.025);
    --glow-text: none;
    --glow-box: none;
    --shadow-float: 0 1px 0 rgba(45, 37, 32, 0.10);

    --header-shell-glass: color-mix(in srgb, var(--glass) 35%, transparent);
}
[data-theme="light"] .spinner { border-color: rgba(0,0,0,0.08); border-top-color: var(--accent); }
[data-theme="light"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235865F2' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    color-scheme: light;
}
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.18); }

/* ── Reset ── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ── Body & Layout ── */

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    background-color: var(--bg-void);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    margin: 0;
    min-height: 100vh;
}

/* 배경 테마: 관측실 (기본) — 그리드 + 어두운 vignette만 (채도 0, 최소 톤) */
html:not([data-bg]) body,
html[data-bg="observatory"] body {
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px),
        radial-gradient(ellipse at 50% 50%, transparent 20%, rgba(0, 0, 0, 0.5) 100%);
    background-size: 48px 48px, 48px 48px, auto;
}

/* 배경 테마: 블루 매젠타 */
html[data-bg="blue-magenta"] body { background-image:
    radial-gradient(at 20% 30%, rgba(59, 130, 246, 0.18) 0px, transparent 50%),
    radial-gradient(at 80% 20%, rgba(217, 70, 239, 0.14) 0px, transparent 45%),
    radial-gradient(at 0% 80%, rgba(99, 102, 241, 0.1) 0px, transparent 40%),
    radial-gradient(at 70% 70%, rgba(192, 38, 211, 0.08) 0px, transparent 55%);
}

/* 배경 테마: 메쉬 도트 */
html[data-bg="mesh-dots"] body {
    background-image:
        radial-gradient(circle at 30% 40%, rgba(99, 102, 241, 0.12) 0px, transparent 1px),
        radial-gradient(circle at 70% 60%, rgba(217, 70, 239, 0.1) 0px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.06) 0px, transparent 1px);
    background-size: 48px 48px, 64px 64px, 80px 80px;
}

/* 배경 테마: 오로라 */
html[data-bg="aurora"] body {
    background-image:
        radial-gradient(ellipse 80% 50% at 10% 20%, rgba(34, 197, 94, 0.14) 0px, transparent 50%),
        radial-gradient(ellipse 60% 40% at 90% 80%, rgba(59, 130, 246, 0.16) 0px, transparent 45%),
        radial-gradient(ellipse 70% 50% at 50% 50%, rgba(99, 102, 241, 0.1) 0px, transparent 55%);
}

/* 배경 테마: 은은한 */
html[data-bg="subtle"] body {
    background-image:
        radial-gradient(at 50% 50%, rgba(99, 102, 241, 0.1) 0px, transparent 70%);
}

/* 배경 테마: 미니멀 */
html[data-bg="minimal"] body {
    background-image: none;
}

.app-layout {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}
.app-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.main-content { margin-left: 0; }

/* ═══════════════════════════════════════
   INTRO OVERLAY
   ═══════════════════════════════════════ */

.intro-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.intro-overlay.done {
    opacity: 0;
    pointer-events: none;
}
.intro-overlay.hidden {
    display: none;
}
.intro-title {
    font-size: clamp(36px, 8vw, 64px);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1;
    animation: intro-title-appear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: scale(0.85);
}
@keyframes intro-title-appear {
    0% {
        opacity: 0;
        transform: scale(0.85);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════
   HEADER NAV — 토스/금융앱형 상단 메가메뉴 (호버로 전체 폭 패널)
   ═══════════════════════════════════════ */

.header-bar-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    justify-self: start;
    min-width: 0;
}

/* overflow-x: auto는 세로 overflow까지 잘라 드롭다운이 안 보임 → 스크롤은 .header-nav-scroll에서만 (또는 생략) */
.header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    position: relative;
    z-index: 120;
}

.header-nav-scroll {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    max-width: min(100vw - 240px, 720px);
    overflow: visible;
}

.header-nav-group {
    position: relative;
    flex-shrink: 0;
}

.header-nav-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    min-height: 32px;
    padding: 4px 10px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.02em;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}
.header-nav-trigger:hover,
.header-nav-group.is-open .header-nav-trigger {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.header-nav-trigger-label { pointer-events: none; }

.header-nav-panel {
    z-index: 200;
}
.header-nav-panel[hidden] {
    display: none !important;
}
.header-nav-panel:not([hidden]) {
    display: block;
}

/*
 * 메가 패널: 배경·블러 없음 — 실제 글래스는 .header-bar::after 한 겹만 (뒤 픽셀이 달라도 색이 같게 보임)
 */
.header-nav-panel--mega {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    min-height: 0;
    max-height: var(--header-mega-max-h);
    overflow: hidden auto;
    padding: var(--space-sm) var(--space-lg) var(--space-md);
    margin: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.header-nav-panel-inner {
    max-width: 880px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 4px 10px;
    align-content: start;
}

.header-nav-panel--mega .nav-item {
    padding: 7px 8px 7px 28px;
    border-left: none;
    border-radius: var(--radius-sm);
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: 500;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: background var(--transition), color var(--transition);
}
.header-nav-panel--mega .nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    box-shadow: none;
}
.header-nav-panel--mega .nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
    box-shadow: none;
}
.header-nav-panel--mega .nav-icon {
    left: 8px;
    width: 15px;
    height: 15px;
}

.header-dev-link {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}
.header-dev-link:hover {
    color: var(--accent);
    background: var(--accent-subtle);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px 7px 34px;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    text-decoration: none;
    user-select: none;
    border-left: 2px solid transparent;
    border-radius: 4px;
    margin: 1px 0;
    position: relative;
}
.nav-item:hover {
    color: var(--text-primary);
    background: var(--accent-subtle);
}
.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-subtle);
    font-weight: 600;
}
.nav-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }
.nav-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════
   HEADER BAR (글래스 배경, 좌측 로고·우측 액션)
   ═══════════════════════════════════════ */

.header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-md);
    padding: 0 var(--space-lg);
    height: 52px;
    overflow: visible;
    isolation: isolate;
    background: transparent;
    border-bottom: none;
}

/* 단일 글래스 레이어: 헤더 줄 + 열린 메가 영역까지 동일 backdrop (패널에 또 깔면 뒤가 달라져 색이 어긋남) */
.header-bar::after {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 52px;
    z-index: 0;
    background: var(--header-shell-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    pointer-events: none;
}
.header-bar:has(.header-nav-group.is-open)::after {
    height: calc(52px + var(--header-mega-max-h));
}

.header-bar > * {
    position: relative;
    z-index: 1;
}

.karmolab-desktop-chrome {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.karmolab-open-browser {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
    transition: color var(--transition), background var(--transition);
}
.karmolab-open-browser:hover {
    color: var(--text-primary);
    background: var(--accent-dim);
}

.karmolab-desktop-badge {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--secondary);
    background: var(--secondary-subtle);
    border: 1px solid color-mix(in srgb, var(--secondary) 35%, transparent);
    user-select: none;
}

.header-logo {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    font-family: var(--font-sans);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: color var(--transition);
    flex-shrink: 0;
}
.header-logo:hover {
    color: var(--accent);
}
.header-logo.active {
    color: var(--accent);
}

.header-bar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    gap: 4px;
    flex-shrink: 0;
}

.content-header {
    padding: 0;
    min-height: 0;
    display: none;
    flex-shrink: 0;
}

.content-header > div:first-child {
    display: none;
}

.content-title {
    display: none;
}

.header-btn.user-btn,
.theme-toggle {
    width: 36px; height: 36px; padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
}
.header-btn.user-btn:hover,
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.header-btn.user-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}
.header-btn.user-btn svg,
.theme-toggle .theme-icon {
    width: 18px; height: 18px;
}
.theme-toggle .theme-icon { color: inherit; }

[data-theme="dark"] .theme-toggle .sun, [data-theme="light"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun, [data-theme="dark"] .theme-toggle .moon { display: block; }

/* ── 윈도우 컨트롤 (카모랩 데스크톱 전용) ─────────────────────────────────
   Tauri decorations:false로 OS 헤더를 끄고 헤더 우측에 minimize/maximize/close 직접 표시.
   브라우저에서는 display:none. 데스크톱일 때만 toolbox.ts가 unhide. */
.window-controls {
    display: none;
    align-items: stretch;
    margin-left: 4px;
    align-self: stretch;
}
.wc-btn {
    width: 46px;
    min-height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition);
    color: var(--text-secondary);
    flex-shrink: 0;
}
.wc-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.wc-close:hover { background: #e81123; color: #fff; }
.wc-btn:active { filter: brightness(0.9); }
.wc-btn svg { width: 12px; height: 12px; display: block; }
.wc-icon-restore { display: none; }
.window-controls[data-maximized="true"] .wc-icon-max { display: none; }
.window-controls[data-maximized="true"] .wc-icon-restore { display: block; }

.prism-theme-select {
    min-width: 0; width: 130px; padding: 5px 24px 5px 8px;
    font-size: var(--font-size-xs);
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-tertiary); cursor: pointer;
    font-family: var(--font-mono); appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235865F2' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 6px center;
    transition: all var(--transition);
}
.prism-theme-select:hover, .prism-theme-select:focus {
    color: var(--text-primary); border-color: var(--accent); outline: none;
    box-shadow: 0 0 8px var(--accent-dim);
}

/* ── Breadcrumb (Discord-style) ── */

.breadcrumb {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--font-size-xs); color: var(--text-tertiary);
    font-family: var(--font-sans); font-weight: 500;
}
.breadcrumb-sep {
    opacity: 0.4; color: var(--text-tertiary);
}
.breadcrumb-link {
    color: var(--text-tertiary); text-decoration: none; cursor: pointer;
    transition: color var(--transition); background: none; border: none;
    font: inherit; font-size: inherit; padding: 0; font-family: inherit;
}
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-current { color: var(--text-secondary); font-weight: 600; }

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */

.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; position: relative; min-height: 0; }
.content-body {
    padding: var(--space-lg) var(--space-xl) var(--space-2xl);
    flex: 0 0 auto;
    min-height: 100%;
    display: flex; flex-direction: column;
    padding-top: calc(52px + var(--space-lg));
}

/* layout-full 페이지가 활성화되면 스크롤 비활성화 및 flex fill 모드로 전환 */
.main-content:has(.tool-page.layout-full.active) {
    overflow: hidden;
}
.content-body:has(.tool-page.layout-full.active) {
    flex: 1;
    min-height: 0;
    padding: 0;
    padding-top: 52px; /* 헤더바 높이만 */
}

/* ═══════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════ */

.landing-page {
    display: none; flex-direction: column;
    padding: var(--space-xl) var(--space-2xl) var(--space-2xl);
    flex: 0 0 auto;
    max-width: 960px; margin: 0 auto; width: 100%;
    justify-content: center;
}
.landing-page.active { display: flex; }

/* ── Hero ── */

.landing-hero {
    padding: var(--space-2xl) 0 var(--space-xl);
    margin-bottom: var(--space-xl);
    position: relative;
    text-align: center;
}
.landing-hero::after {
    content: '';
    display: block;
    width: 48px;
    height: 2px;
    margin: var(--space-lg) auto 0;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

.landing-subtitle {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
}

.landing-title {
    font-family: var(--font-serif);
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}
.landing-title .accent { color: var(--accent); }

.landing-tagline {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.04em;
}

/* ── Landing CTA ── */

.landing-cta {
    display: flex; flex-direction: column; align-items: center; gap: var(--space-lg);
    padding: var(--space-xl) 0; text-align: center;
}
.landing-cta-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
}
.landing-cta-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 18px 16px 16px;
    min-width: 200px;
    max-width: 220px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), background var(--transition);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    border-radius: var(--radius-sm);
    text-align: left;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
}
.landing-cta-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-tertiary);
}
.landing-cta-card:hover .landing-cta-card-icon { color: var(--accent); }
.landing-cta-card:hover .landing-cta-card-title { color: var(--accent); }
a.landing-cta-card:hover { color: inherit; }
.landing-cta-card-icon {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    transition: all var(--transition);
}
.landing-cta-card-icon svg { width: 100%; height: 100%; }
.landing-cta-card-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.landing-cta-card-desc {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    line-height: 1.5;
    letter-spacing: 0.01em;
}
.landing-cta-hint {
    font-size: var(--font-size-xs); color: var(--text-tertiary);
    letter-spacing: 0.02em;
}
.landing-dev-links {
    margin-top: var(--space-md);
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
}
.landing-dev-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
}
.landing-dev-link-btn:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* 홈 화면에서 마스코트 크기 축소 */
body:has(#page-home.active) .mdd-container .mdd-char {
    width: 64px; height: 70px;
}

/* ═══════════════════════════════════════
   TOAST
   ═══════════════════════════════════════ */

.status-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 10000;
    font-size: var(--font-size-xs); font-weight: 600; padding: 5px 12px;
    opacity: 0; transition: opacity var(--transition-slow);
    pointer-events: none; font-family: var(--font-mono);
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-float);
}
.status-toast.visible { opacity: 1; }
.status-toast.success {
    background: var(--success-subtle); color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}
.status-toast.error {
    background: var(--error-subtle); color: var(--error);
    border-color: rgba(239, 68, 68, 0.2);
}
.status-toast.has-detail { cursor: default; pointer-events: auto; padding: 8px 12px; max-width: 90vw; display: flex; align-items: center; gap: 8px; }
.status-toast-copy {
    flex-shrink: 0; padding: 4px 8px; font-size: 12px; background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; cursor: pointer;
    color: inherit; font-family: inherit;
}
.status-toast-copy:hover { background: rgba(255,255,255,0.25); }
.status-toast-detail {
    display: none; margin-top: 6px; font-size: var(--font-size-2xs); font-weight: 400;
    opacity: 0.9; white-space: pre-wrap; word-break: break-word;
    max-height: 100px; overflow-y: auto;
}
.status-toast-detail.open { display: block; }

/* ═══════════════════════════════════════
   TOOL PAGES
   ═══════════════════════════════════════ */

.tool-page-hero {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}
.tool-page-hero-title {
    font-family: var(--font-serif);
    font-size: 40px; font-weight: 900; letter-spacing: -0.02em;
    line-height: 1; color: var(--text-primary); margin-bottom: 10px;
}
.tool-page-hero-desc {
    font-size: var(--font-size-sm); color: var(--text-tertiary); letter-spacing: 0.01em;
}
.layout-full .tool-page-hero {
    padding: var(--space-md) 0 var(--space-sm);
    margin-bottom: var(--space-sm);
}
.layout-full .tool-page-hero-title { font-size: 28px; }

.tool-page {
    display: none;
    position: relative;
}
.tool-page.active {
    display: block;
    flex: 0 0 auto;
    animation: fadeIn 200ms ease;
}
.tool-page.layout-full { display: none; }
.tool-page.layout-full.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tool-page.layout-full > .tab-row { flex-shrink: 0; }
.tool-page.layout-full > .tab-panel { display: none; }
.tool-page.layout-full > .tab-panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tool-page.layout-form {
    max-width: 900px; margin: 0 auto var(--space-2xl);
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    position: relative;
}
.tool-page.layout-wide { max-width: 1200px; margin: 0 auto var(--space-2xl); width: 100%; }
.tool-page.layout-wide .tool-page-hero { margin-bottom: var(--space-xl); }

/* ── Tabs ── */

.tab-row {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
    padding: 0 var(--space-xs);
    position: relative;
}
.tab-row::after { display: none; }
.tab-btn {
    padding: 10px 18px; font-size: var(--font-size-xs); font-weight: 700;
    color: var(--text-tertiary); background: transparent; border: none;
    border-bottom: 2px solid transparent; cursor: pointer;
    transition: all var(--transition); font-family: var(--font-mono);
    margin-bottom: -1px; letter-spacing: 0.08em;
    text-transform: uppercase;
    position: relative;
}
.tab-btn:hover {
    color: var(--text-primary);
    background: var(--accent-subtle);
}
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--accent-subtle);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 탭 다수: 세로 목록 (문서 위젯 `tabLayout: 'sidebar'`) ── */
.tool-tab-sidebar-layout {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
    width: 100%;
}
.tool-page.layout-wide .tool-tab-sidebar-layout {
    max-width: 100%;
}
.tool-page.layout-wide .tab-row.tab-row--sidebar {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 0 var(--space-md) 0 0;
    margin-bottom: 0;
    min-width: min(200px, 30vw);
    max-width: 260px;
    flex-shrink: 0;
    max-height: min(72vh, 640px);
    overflow-x: hidden;
    overflow-y: auto;
    gap: 4px;
    align-items: stretch;
}
.tool-page.layout-wide .tab-row--sidebar .tab-btn {
    text-align: left;
    justify-content: flex-start;
    border-bottom: none;
    border-left: 3px solid transparent;
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0.03em;
    font-weight: 600;
    font-size: var(--font-size-2xs);
    width: 100%;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    white-space: normal;
    word-break: break-word;
}
.tool-page.layout-wide .tab-row--sidebar .tab-btn.active {
    border-left-color: var(--accent);
    border-bottom-color: transparent;
}
.tool-tab-sidebar-layout .tab-panels-column {
    flex: 1;
    min-width: 0;
}
.tool-page.layout-wide .tool-tab-sidebar-layout .tab-panel.active {
    overflow-x: auto;
}

@media (max-width: 720px) {
    .tool-tab-sidebar-layout {
        flex-direction: column;
        gap: var(--space-md);
    }
    .tool-page.layout-wide .tab-row.tab-row--sidebar {
        flex-direction: row;
        flex-wrap: nowrap;
        max-width: none;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0 0 var(--space-sm) 0;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .tool-page.layout-wide .tab-row--sidebar .tab-btn {
        flex: 0 0 auto;
        width: auto;
        max-width: 11rem;
        border-left: none;
        border-bottom: 2px solid transparent;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .tool-page.layout-wide .tab-row--sidebar .tab-btn.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }
}

/* ═══════════════════════════════════════
   FORMS
   ═══════════════════════════════════════ */

.field-group {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    position: relative;
    border-radius: var(--radius-sm);
}
.field-label {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.field-row { display: flex; align-items: center; justify-content: space-between; }

textarea, input[type="password"], input[type="text"] {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 2px solid transparent;
    padding: 10px 14px;
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
    resize: vertical;
}
textarea:focus, input[type="password"]:focus, input[type="text"]:focus {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 1px var(--accent-dim);
}
textarea::placeholder, input::placeholder { color: var(--text-tertiary); }
textarea { min-height: 120px; line-height: 1.6; }

select {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 2px solid transparent;
    padding: 10px 14px;
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235865F2' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
select:focus {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 1px var(--accent-dim);
}
select option { background: var(--bg-secondary); color: var(--text-primary); }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

/* 즐겨찾기 검색창 너비 제한 */
.fav-top-row .landing-search-wrap {
    flex: none !important;
    width: 220px !important;
    max-width: 220px !important;
}
.range-value {
    font-size: var(--font-size-xs); font-weight: 700; color: var(--accent);
    font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; font-size: var(--font-size-xs); font-weight: 600; font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer; transition: all var(--transition); user-select: none;
    letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: var(--bg-void);
    padding: 12px 18px; margin-top: var(--space-md);
    border-color: var(--accent); font-weight: 800;
    border-radius: var(--radius-sm);
    text-shadow: none;
    font-family: var(--font-mono);
    letter-spacing: 0.1em; text-transform: uppercase;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ghost {
    background: none; color: var(--text-secondary);
    padding: 4px 10px; font-size: var(--font-size-xs); border-color: transparent;
}
.btn-ghost:hover { color: var(--accent); background: var(--accent-subtle); }
.random-count-preset.active { color: var(--accent); background: var(--accent-subtle); }

.btn-accent {
    background: var(--accent); color: var(--bg-void);
    border-color: var(--accent); font-weight: 700;
    border-radius: var(--radius-sm);
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-danger {
    background: none; color: var(--error); border-color: var(--border);
    border-radius: var(--radius-sm);
}
.btn-danger:hover { background: var(--error-subtle); border-color: var(--error); }

.btn-secondary {
    background: var(--secondary); color: var(--bg-void);
    border-color: var(--secondary); font-weight: 700;
    border-radius: var(--radius-sm);
}
.btn-secondary:hover { background: var(--secondary-hover); }

/* ── Collapsible ── */

.collapsible-trigger {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--font-size-2xs); font-weight: 700; color: var(--text-tertiary);
    cursor: pointer; padding: 6px 10px; margin-bottom: 6px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-left: 2px solid var(--accent-dim);
    font-family: var(--font-mono); letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: all var(--transition);
}
.collapsible-trigger:hover {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-subtle);
}
.collapsible-trigger .chevron { width: 12px; height: 12px; transition: transform var(--transition); }
.collapsible-trigger.open .chevron { transform: rotate(90deg); }
.collapsible-trigger.open {
    color: var(--accent);
    border-left-color: var(--accent);
}
.collapsible-body {
    display: none; padding: 8px 0 12px;
    border-left: 1px solid var(--border);
    margin-left: 8px; padding-left: 12px;
}
.collapsible-body.open { display: block; }

/* ── Result Box ── */

.result-box {
    margin-top: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    overflow: hidden; display: none;
    position: relative;
}
.result-box::before, .result-box::after { display: none; }
.result-box.visible {
    display: block;
    animation: fadeInUp 250ms ease;
    box-shadow: var(--shadow-float);
}

.result-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    position: relative;
}
.result-header::after { display: none; }
.result-label {
    font-size: var(--font-size-2xs); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--text-tertiary);
    font-family: var(--font-mono);
    display: flex; align-items: center; gap: 6px;
}
.result-label.success { color: var(--success); }
.result-label.error { color: var(--error); }
.result-content {
    padding: 14px; font-size: var(--font-size-xs); line-height: 1.7;
    color: var(--text-primary); white-space: pre-wrap; word-break: break-all;
    font-family: var(--font-mono); max-height: 320px; overflow-y: auto;
}
.mono-input { font-family: var(--font-mono); font-size: var(--font-size-xs); }


/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }


.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(124, 58, 237, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ═══════════════════════════════════════
   SIDEBAR NAV (data-nav="sidebar" 모드)
   ═══════════════════════════════════════ */

.sidebar { display: none; }

html[data-nav="sidebar"] .header-nav { display: none !important; }
html[data-nav="sidebar"] .header-bar-right { grid-column: 3; }

html[data-nav="sidebar"] .sidebar {
    display: flex;
    position: fixed;
    top: 52px; /* header-bar 높이 */
    left: 0;
    bottom: 0;
    width: var(--sidebar-collapsed-width);
    background: var(--glass-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--border);
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition-slow);
    z-index: 50;
}

html[data-nav="sidebar"] .sidebar:hover {
    width: var(--sidebar-width);
}

html[data-nav="sidebar"] .main-content {
    margin-left: var(--sidebar-collapsed-width);
    transition: margin-left var(--transition-slow);
}

html[data-nav="sidebar"]:has(.sidebar:hover) .main-content {
    margin-left: var(--sidebar-width);
}

.sidebar-nav {
    padding: var(--space-md) var(--space-sm);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: var(--space-sm);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    min-height: 40px;
    position: relative;
}

.sidebar-dev-links {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
}

.sidebar-dev-links:hover { color: var(--accent); }

.sidebar-dev-links-icon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-tertiary);
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    color: var(--text-tertiary);
}

.sidebar-group { margin-top: var(--space-sm); }

.sidebar-group-trigger {
    display: flex;
    gap: 6px;
    width: 100%;
    padding: 6px 10px 6px 30px;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color var(--transition);
    text-align: left;
    position: relative;
    cursor: pointer;
    background: none;
    border: none;
}

.sidebar-group-trigger:hover { color: var(--text-secondary); }

.sidebar-group-trigger .chevron {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    width: 8px;
    height: 8px;
    transition: transform var(--transition);
}

.sidebar-group-trigger .chevron::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 2px;
    width: 4px;
    height: 4px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
}

.sidebar-group-trigger.open .chevron { transform: translateY(-50%) rotate(90deg); }

.sidebar-group-body { display: none; overflow: hidden; }
.sidebar-group-body.open { display: block; }

/* 텍스트는 항상 한 줄 — 사이드바 overflow:hidden 이 클리핑 담당 */
html[data-nav="sidebar"] .sidebar .nav-item-text,
html[data-nav="sidebar"] .sidebar .sidebar-group-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    flex-shrink: 0;
    transition: opacity var(--transition-slow);
}

/* 접힌 상태: opacity로만 숨김 (width 조작 없음 → reflow/줄바꿈 없음) */
html[data-nav="sidebar"] .sidebar:not(:hover) .sidebar-group-label,
html[data-nav="sidebar"] .sidebar:not(:hover) .nav-item-text {
    opacity: 0;
    pointer-events: none;
}

/* 펼친 상태: 텍스트 페이드인 */
html[data-nav="sidebar"] .sidebar:hover .sidebar-group-label,
html[data-nav="sidebar"] .sidebar:hover .nav-item-text {
    opacity: 1;
}

html[data-nav="sidebar"] .sidebar:not(:hover) .sidebar-dev-links-icon { display: flex; }
html[data-nav="sidebar"] .sidebar:not(:hover) .sidebar-dev-links-text { display: none; }
html[data-nav="sidebar"] .sidebar:hover .sidebar-dev-links-icon { display: flex; }
html[data-nav="sidebar"] .sidebar:hover .sidebar-dev-links-text { display: inline; }

@media (max-width: 768px) {
    html[data-nav="sidebar"] .sidebar { display: none; }
    html[data-nav="sidebar"] .main-content { margin-left: 0; }
}

/* ── Scrollbar ── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.08); }
::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.18); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 768px) {
    .header-nav { display: none !important; }
    .main-content { margin-left: 0; }
    .header-bar {
        left: 0;
        padding: 0 var(--space-md);
        grid-template-columns: auto 1fr;
        gap: var(--space-sm);
    }
    .mobile-nav { display: flex !important; }
    .content-body { padding: var(--space-md); }
    .landing-page { padding: var(--space-md); }
    .landing-title { font-size: 32px; }
    .landing-hero { padding: var(--space-lg) 0 var(--space-md); }
    .prism-theme-select { width: 100px; font-size: var(--font-size-2xs); }
    .tool-page-hero { padding: var(--space-md) 0 var(--space-sm); }
    .tool-page-hero-title { font-size: 28px; }
    .field-group { padding: var(--space-sm); }
    .tool-page.layout-form { padding: var(--space-sm); }
}

.mobile-nav {
    display: none; overflow-x: auto; gap: 2px;
    padding: 6px var(--space-md);
    border-bottom: 1px solid var(--border);
    background: var(--glass-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: blur(14px);
    flex-shrink: 0;
}
.mobile-nav .nav-item {
    white-space: nowrap; font-size: var(--font-size-xs); padding: 5px 10px;
    border-left: none;
}

/* ── 랜덤 생성기 Wide 레이아웃 ── */

.randomgen-wide {
    display: flex;
    flex-direction: column;
    min-height: 400px;
    min-width: 0;
    padding: var(--space-md);
}

.randomgen-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

.randomgen-footer {
    flex-shrink: 0;
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.randomgen-bottom-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.randomgen-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.randomgen-row-main {
    justify-content: center;
}

.randomgen-row-options {
    justify-content: center;
}

.randomgen-icon-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.randomgen-icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.randomgen-icon-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.randomgen-icon-btn svg {
    width: 18px;
    height: 18px;
}

.randomgen-icon-btn#randomTopicBtn {
    padding: 0 10px 0 8px;
}

.randomgen-icon-btn:not(#randomTopicBtn) {
    padding: 0;
    width: 36px;
}

.randomgen-icon-btn .randomgen-topic-label {
    font-size: 11px;
    margin-left: 4px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.randomgen-count-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.randomgen-count-wrap input[type="number"] {
    width: 44px;
    height: 36px;
    padding: 0 8px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
    -moz-appearance: textfield;
}
.randomgen-count-wrap input[type="number"]::-webkit-outer-spin-button,
.randomgen-count-wrap input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.randomgen-count-wrap input[type="number"]:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--accent-dim);
}

.randomgen-presets {
    display: flex;
    gap: 4px;
}

.randomgen-presets .random-count-preset {
    min-width: 32px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-tertiary);
    transition: all var(--transition);
}
.randomgen-presets .random-count-preset:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}
.randomgen-presets .random-count-preset.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.randomgen-footer-links {
    font-size: 11px;
    color: var(--text-tertiary);
}

.randomgen-popup.randomgen-topic-popup-large {
    position: relative;
    max-width: 920px;
    width: 90vw;
    max-height: 85vh;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.randomgen-topic-popup-large .randomgen-topic-popup-tabs {
    flex-shrink: 0;
}

.randomgen-topic-popup-large .randomgen-topic-tab-panel {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.randomgen-topic-close-fab {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all var(--transition);
}
.randomgen-topic-close-fab:hover {
    color: var(--accent);
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.randomgen-topic-popup-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

.randomgen-topic-tab {
    padding: 10px 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all var(--transition);
}
.randomgen-topic-tab:hover {
    color: var(--text-secondary);
}
.randomgen-topic-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.randomgen-topic-tab-panel {
    display: none;
}
.randomgen-topic-tab-panel.active {
    display: block;
}

.randomgen-topic-popup-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.randomgen-topic-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 50vh;
    overflow-y: auto;
}

.randomgen-topic-actions {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.randomgen-topic-special {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-sm);
}

.randomgen-topic-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.randomgen-topic-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 6px;
}

.randomgen-topic-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    overflow: visible;
}

.randomgen-topic-card:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.randomgen-topic-card.active,
.randomgen-topic-mode.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

.randomgen-topic-card.randomgen-topic-custom.selected {
    border-color: var(--secondary);
    background: var(--secondary-subtle);
    color: var(--secondary);
}

.randomgen-topic-card.randomgen-topic-custom.pinned {
    border-color: var(--secondary);
    background: var(--secondary-subtle);
    color: var(--secondary);
}

.randomgen-topic-card.randomgen-topic-custom.pinned::before {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 24px;
    height: 24px;
    background: linear-gradient(225deg, var(--secondary) 50%, transparent 50%);
    border-radius: 0 var(--radius-md) 0 0;
    box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.randomgen-topic-custom {
    cursor: pointer;
    display: flex;
}

.randomgen-topic-options-wrap {
    margin-top: var(--space-sm);
}

.randomgen-topic-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    min-height: 32px;
}

.randomgen-topic-selected-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    background: var(--secondary-subtle);
    color: var(--secondary);
    border: 1px solid var(--secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    overflow: visible;
}
.randomgen-topic-selected-chip:hover {
    opacity: 0.9;
}

.randomgen-topic-selected-chip.pinned {
    border-color: var(--secondary);
    background: var(--secondary-subtle);
    color: var(--secondary);
}

.randomgen-topic-selected-chip.pinned::before {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    background: linear-gradient(225deg, var(--secondary) 50%, transparent 50%);
    border-radius: 0 var(--radius-md) 0 0;
    box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.randomgen-topic-pin {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition);
}

.randomgen-topic-pin:hover {
    color: var(--accent);
    background: var(--accent-subtle);
}

.randomgen-topic-selected-chip.pinned .randomgen-topic-pin {
    color: var(--accent);
}

.randomgen-topic-pin svg {
    width: 14px;
    height: 14px;
}

.randomgen-topic-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
}

.randomgen-topic-selected-empty {
    font-size: 12px;
    color: var(--text-tertiary);
}

.randomgen-topic-card-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.randomgen-topic-info {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
}

.randomgen-topic-info:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.randomgen-topic-tab-panel[data-tab="add"] {
    max-width: 520px;
    padding-top: var(--space-xs);
}

.randomgen-add-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.randomgen-add-header {
    margin-bottom: 2px;
}

.randomgen-add-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.randomgen-add-desc {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    margin: 0;
}

.randomgen-add-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.randomgen-add-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.randomgen-add-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.randomgen-add-field-id {
    margin-top: 2px;
}

.randomgen-add-label {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.randomgen-add-hint {
    font-weight: 400;
    color: var(--text-tertiary);
}

.randomgen-add-form .field-input {
    padding: 8px 12px;
    font-size: var(--font-size-xs);
    min-height: 0;
}

.randomgen-add-form textarea.field-input {
    min-height: 88px;
    resize: vertical;
}

.randomgen-add-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: 4px;
}

.randomgen-add-actions .btn-primary {
    width: auto;
    margin-top: 0;
    padding: 8px 18px;
}

.randomgen-add-msg {
    font-size: 11px;
    color: var(--text-tertiary);
}

@media (max-width: 480px) {
    .randomgen-add-row {
        grid-template-columns: 1fr;
    }
}

.randomgen-table-popup {
    max-width: 480px;
}

.randomgen-table-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.randomgen-table-tag {
    display: inline-block;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}

/* ── 생성 버튼 (작게) ── */
.randomgen-gen-btn {
    width: auto !important;
    padding: 8px 20px !important;
    font-size: 13px !important;
    margin-top: 0 !important;
}

.randomgen-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.randomgen-popup-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.randomgen-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    max-width: 420px;
    max-height: 80vh;
    width: 100%;
    box-shadow: var(--shadow-float);
    display: flex;
    flex-direction: column;
}

.randomgen-popup-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.randomgen-info-content {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.6;
}
.randomgen-info-content p {
    margin: 0 0 var(--space-sm);
}
.randomgen-info-content p:last-child {
    margin-bottom: 0;
}

.randomgen-empty {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
}

.randomgen-exclude-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 6px 12px;
    max-height: 320px;
    overflow-y: auto;
    padding: 0;
}

@media (max-width: 900px) {
    .randomgen-display {
        min-height: 220px;
    }

    .randomgen-row-options {
        justify-content: center;
    }

    .randomgen-count-wrap {
        justify-content: center;
    }
}

/* ── Lightbox ── */

.tb-lightbox-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.tb-lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }

.karmolab-update-banner {
    position: fixed; top: 16px; right: 16px;
    z-index: 9998;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--bg-elevated, var(--bg-secondary));
    color: var(--text-primary);
    border: 1px solid var(--accent, var(--border));
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    font-size: var(--font-size-sm);
    max-width: 420px;
}
.karmolab-update-banner-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.karmolab-update-banner-msg { line-height: 1.4; }
.karmolab-update-banner-msg code {
    font-family: ui-monospace, monospace;
    background: var(--bg-tertiary); padding: 1px 5px; border-radius: 4px;
    font-size: 0.95em;
}
.karmolab-update-banner-notes {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-decoration: none;
    align-self: flex-start;
}
.karmolab-update-banner-notes:hover { color: var(--accent); text-decoration: underline; }
.karmolab-update-banner-progress {
    width: 100%; height: 6px;
    -webkit-appearance: none; appearance: none;
    border: none; border-radius: 3px;
    background: var(--bg-tertiary);
    overflow: hidden;
}
.karmolab-update-banner-progress::-webkit-progress-bar { background: var(--bg-tertiary); border-radius: 3px; }
.karmolab-update-banner-progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; transition: width 120ms linear; }
.karmolab-update-banner-progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
.karmolab-update-banner-install {
    flex-shrink: 0;
    padding: 6px 12px;
    background: var(--accent); color: var(--accent-contrast, white);
    border: none; border-radius: var(--radius-sm);
    font-weight: 600; font-size: var(--font-size-xs);
    cursor: pointer;
    min-width: 88px;
}
.karmolab-update-banner-install:hover { filter: brightness(1.1); }
.karmolab-update-banner-install:disabled { opacity: 0.7; cursor: progress; }
.karmolab-update-banner-restart {
    background: var(--success, #22c55e);
}
.karmolab-update-banner-close {
    flex-shrink: 0; align-self: flex-start;
    width: 24px; height: 24px;
    background: transparent; color: var(--text-tertiary);
    border: none; border-radius: var(--radius-sm);
    font-size: 16px; line-height: 1; cursor: pointer;
    padding: 0;
}
.karmolab-update-banner-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.karmolab-update-completed-toast {
    position: fixed; top: 16px; right: 16px;
    z-index: 9998;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px 8px 12px;
    background: var(--bg-elevated, var(--bg-secondary));
    color: var(--text-primary);
    border: 1px solid var(--success, #22c55e);
    border-left: 3px solid var(--success, #22c55e);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    font-size: var(--font-size-sm);
    max-width: 380px;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 200ms ease, transform 200ms ease;
}
.karmolab-update-completed-toast-leaving {
    opacity: 0;
    transform: translateX(20px);
}
.karmolab-update-completed-toast-msg { line-height: 1.4; flex: 1; min-width: 0; }
.karmolab-update-completed-toast-msg code {
    font-family: ui-monospace, monospace;
    background: var(--bg-tertiary); padding: 1px 5px; border-radius: 4px;
    font-size: 0.95em;
}
.karmolab-update-completed-toast-close {
    flex-shrink: 0;
    width: 22px; height: 22px;
    background: transparent; color: var(--text-tertiary);
    border: none; border-radius: var(--radius-sm);
    font-size: 15px; line-height: 1; cursor: pointer;
    padding: 0;
}
.karmolab-update-completed-toast-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
