/* ─── Reset & Variables ─────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary:      #222222;
    --primary-dark: #000000;
    --background:   #F5F5F5;
    --surface:      #FFFFFF;
    --text-primary: #111111;
    --text-secondary: #666666;
    --border:       #D9D9D9;
    --shadow-sm:    0 1px 2px rgba(0,0,0,0.06);
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:    0 8px 24px rgba(0,0,0,0.12);
    --transition:   all 0.2s ease;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ─── Loading ───────────────────────────────────────── */
.loading-screen {
    position: fixed; inset: 0;
    background: #f9fafb;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-bar-wrap {
    width: 200px; height: 3px;
    background: #e5e7eb;
    border-radius: 2px; overflow: hidden;
}
.loading-bar-fill {
    height: 100%; width: 0%;
    background: #374151; border-radius: 2px;
    transition: width 0.15s ease;
}
.loading-screen p {
    color: #6b7280; font-size: 13px; margin-top: 12px;
}

/* ─── Header ────────────────────────────────────────── */
.header {
    background: #1d1d1d;
    border-bottom: none;
    position: sticky; top: 0; z-index: 100;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.header-content {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 6px 0; gap: 6px;
}
.logo {
    font-size: 15px; font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 32px; height: 32px;
    border: none;
    background: transparent; border-radius: 3px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: var(--transition); color: rgba(255,255,255,0.7);
    position: relative;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.icon-btn.active {
    background: var(--primary); color: #fff;
}
/* AI 챗봇 버튼 — 식별성 강화 (텍스트 라벨 + 밝은 pill 형태) */
.ai-chat-btn {
    width: auto;
    padding: 0 12px 0 10px;
    gap: 6px;
    background: #ffffff;
    color: #111111;
    border-radius: 16px;
    font-weight: 700;
}
.ai-chat-btn:hover {
    background: #e8e8e8;
    color: #000000;
}
.ai-chat-btn.active {
    background: var(--primary); color: #fff;
}
.ai-chat-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    font-family: inherit;
}
.cart-icon-btn { position: relative; }
.cart-badge {
    position: absolute; top: -4px; right: -4px;
    background: #EF4444; color: #fff;
    font-size: 9px; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 3px; padding: 0 3px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #111111;
}

/* ─── Main Viewer ───────────────────────────────────── */
.viewer-main {
    height: calc(100vh - 44px - 62px);
    display: flex; flex-direction: column;
    overflow: hidden;
    background: #303030;  /* InDesign Publish Online 배경 톤 */
    /* turn.js가 페이지에 부여하는 높은 z-index를 뷰어 내부에 가둔다 (모달·패널 위로 새어나오는 것 방지) */
    position: relative; z-index: 1; isolation: isolate;
}
.catalog-viewer {
    flex: 1; display: flex;
    align-items: center; justify-content: center;
    padding: 4px;
    overflow: hidden;
    touch-action: none;
    position: relative;
    background: #1a1a1a;
}
/* Flipbook */
#flipbook {
    box-shadow: 0 30px 60px rgba(0,0,0,0.35);
    border-radius: 2px;
}
#flipbook .page {
    background: #fff;
    overflow: hidden;
}
#flipbook .page canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    image-rendering: auto;
}
#flipbook .page.hard {
    background: #f8f8f8;
}
/* 좌우 페이지 이동 화살표 (InDesign Publish Online 스타일) */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px; height: 48px;
    border: none; border-radius: 50%;
    background: rgba(30,30,30,0.45);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0.45;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.nav-arrow-left  { left: 18px; }
.nav-arrow-right { right: 18px; }
.viewer-main:hover .nav-arrow { opacity: 0.85; }
.nav-arrow:hover { opacity: 1 !important; background: rgba(30,30,30,0.75); }
.nav-arrow.hidden { display: none; }
@media (max-width: 768px) {
    .nav-arrow { width: 38px; height: 38px; }
    .nav-arrow-left  { left: 6px; }
    .nav-arrow-right { right: 6px; }
}

/* ─── Normal Catalog 등급 (edition: 'normal') ──────────
   Pro 대비 다운그레이드: 구식 밝은 UI, 고급 기능 숨김 */
body.edition-normal {
    font-family: Dotum, '돋움', Arial, sans-serif;
}
body.edition-normal .header {
    background: #f2f2f2;
    border-bottom: 1px solid #c8c8c8;
}
body.edition-normal .logo { color: #333333; font-weight: 600; }
body.edition-normal .icon-btn { color: #555555; }
body.edition-normal .icon-btn:hover { background: rgba(0,0,0,0.08); color: #222; }
body.edition-normal .viewer-main { background: #dcdcdc; }
body.edition-normal .catalog-viewer { background: #dcdcdc; }
body.edition-normal .controls-bar {
    background: #f2f2f2;
    border-top: 1px solid #c8c8c8;
}
body.edition-normal .control-btn { color: #444444; }
body.edition-normal .control-btn:hover:not(:disabled) { background: rgba(0,0,0,0.08); color: #111; }
body.edition-normal .page-indicator { color: #333333; }
body.edition-normal #flipbook { box-shadow: none; border: 1px solid #aaaaaa; }
/* 고급 기능 숨김: 화살표·스크러버·줌·AI펜 (AI 챗봇은 Normal 에서도 유지) */
body.edition-normal .nav-arrow,
body.edition-normal .page-scrubber,
body.edition-normal #btn-zoom-in,
body.edition-normal #btn-zoom-out,
body.edition-normal #zoom-level,
body.edition-normal .controls-divider,
body.edition-normal #ai-pen-fab,
body.edition-normal .ai-pen-toolbar,
body.edition-normal .magnifier { display: none !important; }
/* Normal 밝은 헤더에서 AI 상담 pill 이 보이도록 톤 변경 */
body.edition-normal .ai-chat-btn { background: #333333; color: #ffffff; }
body.edition-normal .ai-chat-btn:hover { background: #111111; color: #ffffff; }

/* AI 상담 pill — 좁은 화면 미디어쿼리(.icon-btn width:28px)에 눌리지 않게 고정 */
.icon-btn.ai-chat-btn { width: auto; min-width: 0; padding: 0 12px 0 10px; }

.error-message {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface); border: 1px solid #FECACA;
    color: #DC2626; padding: 24px 40px; border-radius: 4px;
    font-size: 14px; text-align: center;
    box-shadow: var(--shadow-lg);
}

/* ─── Controls Bar ──────────────────────────────────── */
.controls-bar {
    background: rgba(29,29,29,0.96);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 4px 0;
    position: sticky; bottom: 0; z-index: 100;
}
.controls-content {
    display: flex; align-items: center;
    justify-content: center; gap: 10px;
}
.control-btn {
    width: 33px; height: 32px;
    border: none;
    background: transparent; border-radius: 4px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: var(--transition); color: #ebebeb;
}
.control-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.control-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.controls-divider {
    width: 1px; height: 28px; background: var(--border); margin: 0 6px;
}
.page-info { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.page-indicator {
    font-size: 13px; font-weight: 500; color: #ebebeb;
    min-width: 60px; text-align: center;
}

/* Page Scrubber */
.page-scrubber {
    position: relative;
    padding: 4px 12px 6px;
}
.scrubber-track {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.30);
    border-radius: 3px;
    cursor: pointer;
    transition: height 0.15s;
}
.scrubber-track:hover, .scrubber-track.active {
    height: 10px;
}
.scrubber-fill {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    background: #ffffff;
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s;
}
.scrubber-thumb {
    position: absolute;
    top: 50%;
    width: 16px; height: 16px;
    background: #fff;
    border: 2px solid #555555;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.scrubber-track:hover .scrubber-thumb,
.scrubber-track.active .scrubber-thumb {
    opacity: 1;
}
.scrubber-thumb:active, .scrubber-track.active .scrubber-thumb {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}
.scrubber-tooltip {
    position: absolute;
    top: -30px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    transform: translateX(-50%);
}
.zoom-level {
    font-size: 12px; font-weight: 600;
    color: rgba(255,255,255,0.6); min-width: 48px; text-align: center;
}

/* ─── Side Panels ───────────────────────────────────── */
.side-panel {
    position: fixed; top: 0; right: -420px;
    width: 420px; height: 100vh;
    background: var(--surface);
    box-shadow: -8px 0 32px rgba(0,0,0,0.12);
    z-index: 500;
    display: flex; flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
}
.side-panel.open { right: 0; }
.panel-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 490;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.panel-overlay.active { opacity: 1; visibility: visible; }
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-header h2 { font-size: 17px; font-weight: 700; }
.count-badge {
    background: rgba(0,0,0,0.06); color: var(--primary);
    font-size: 12px; font-weight: 600;
    padding: 2px 8px; border-radius: 3px;
}
.panel-close-btn {
    width: 32px; height: 32px; border: none; background: none;
    cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    border-radius: 3px; transition: var(--transition);
}
.panel-close-btn:hover { background: var(--background); color: var(--text-primary); }
.panel-body {
    flex: 1; overflow-y: auto; padding: 20px 24px;
    display: flex; flex-direction: column; gap: 16px;
}

/* ─── Chat Panel ────────────────────────────────────── */
.chat-panel-body { padding: 0 !important; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px 24px;
    display: flex; flex-direction: column; gap: 12px;
    min-height: 200px;
}
.chat-welcome {
    display: flex; flex-direction: column;
    align-items: center; text-align: center;
    padding: 40px 20px;
}
.chat-welcome-icon { font-size: 48px; margin-bottom: 16px; }
.chat-welcome h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.chat-welcome p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggestion-chip {
    padding: 8px 14px; border-radius: 3px;
    background: rgba(0,0,0,0.04); color: var(--primary);
    font-size: 12px; font-weight: 500; cursor: pointer;
    transition: var(--transition); border: none; font-family: inherit;
}
.suggestion-chip:hover { background: var(--primary); color: #fff; }

.chat-message { display: flex; }
.chat-message-user { justify-content: flex-end; }
.chat-message-ai .message-content {
    max-width: 85%; padding: 10px 14px;
    background: var(--background); color: var(--text-primary);
    border-radius: 4px;
    font-size: 14px; line-height: 1.55;
}
.chat-message-user .message-content {
    max-width: 85%; padding: 10px 14px;
    background: var(--primary); color: #fff;
    border-radius: 4px;
    font-size: 14px; line-height: 1.55;
}
.chat-message-system .message-content {
    background: #F5F5F5; color: #333;
    border-radius: 3px; font-size: 13px;
    text-align: center; padding: 10px 14px;
}
.system-message {
    background: #F5F5F5 !important; color: #333 !important;
    border-radius: 3px !important; text-align: center;
}
.message-avatar { font-size: 11px; font-weight: 700; flex-shrink: 0; width: 24px; color: #666; letter-spacing: -0.5px; }
.message-text { white-space: pre-wrap; word-wrap: break-word; }
.btn-add-to-cart-from-chat {
    display: block; margin-top: 8px; padding: 6px 12px;
    background: rgba(0,0,0,0.06); color: var(--primary);
    border: 1px solid var(--primary); border-radius: 3px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: var(--transition); font-family: inherit;
}
.btn-add-to-cart-from-chat:hover { background: var(--primary); color: #fff; }
.btn-add-to-cart-from-chat:disabled { background: #F0F0F0; color: #444; border-color: #D9D9D9; cursor: default; }

.chat-product-card { margin-top: 8px; border: 1px solid #E5E7EB; border-radius: 3px; overflow: hidden; background: #FAFAFA; }
.chat-product-image-wrapper { padding: 8px; text-align: center; background: #fff; min-height: 60px; display: flex; align-items: center; justify-content: center; }
.chat-product-image { max-width: 100%; max-height: 160px; border-radius: 2px; object-fit: contain; }
.chat-product-image-loading { font-size: 11px; color: #9CA3AF; padding: 20px 0; }
.chat-product-image-none { font-size: 11px; color: #D1D5DB; padding: 10px 0; }
.chat-product-card .btn-add-to-cart-from-chat { margin-top: 0; border: none; border-top: 1px solid #E5E7EB; border-radius: 0 0 3px 3px; width: 100%; }

/* 시공 사례 갤러리 */
.chat-case-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 8px;
}
.chat-case-item {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #E5E7EB;
    background: #fff;
    transition: box-shadow 0.2s;
}
.chat-case-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.chat-case-image {
    width: 100%;
    height: 90px;
    object-fit: cover;
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}
.chat-case-image:hover {
    opacity: 0.85;
}
.chat-case-tags {
    font-size: 10px;
    color: #6B7280;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 시공 사례 라이트박스 */
.case-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.case-lightbox-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
}
.case-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}
.case-lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    display: block;
}
.case-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: #374151;
}
.case-lightbox-close:hover {
    background: #F3F4F6;
}

.chat-typing-indicator { display: flex; gap: 8px; align-items: flex-end; }
.typing-dots {
    display: flex; gap: 4px; padding: 14px;
    background: var(--background); border-radius: 4px;
}
.typing-dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-secondary); animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.chat-input-area {
    display: flex; gap: 8px; padding: 12px 24px;
    border-top: 1px solid var(--border); align-items: center;
}
.chat-textarea {
    flex: 1; resize: none; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 3px;
    font-size: 14px; line-height: 1.3; outline: none;
    transition: var(--transition); font-family: inherit;
    max-height: 100px; height: 36px;
}
.chat-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,0,0,0.06); }
.chat-send-btn {
    width: 36px; height: 36px; background: var(--primary);
    border: none; border-radius: 3px; cursor: pointer; color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:disabled { opacity: 0.5; }

/* ─── Chat Image Attach ─────────────────────────────── */
.chat-attach-buttons { display: flex; gap: 4px; flex-shrink: 0; }
.chat-attach-btn {
    width: 32px; height: 32px; background: none;
    border: 1px solid var(--border); border-radius: 3px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: var(--transition);
}
.chat-attach-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(0,0,0,0.02); }
.chat-image-preview {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 24px; border-top: 1px solid var(--border); background: #f9fafb;
}
.chat-image-preview img { max-height: 80px; max-width: 120px; border-radius: 4px; object-fit: cover; }
.chat-preview-remove {
    width: 22px; height: 22px; border-radius: 50%; border: none;
    background: rgba(0,0,0,0.5); color: #fff; font-size: 14px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-preview-remove:hover { background: rgba(0,0,0,0.7); }
.chat-user-image { max-width: 200px; border-radius: 6px; margin-bottom: 6px; display: block; }
.suggestion-chip-image { border-style: dashed; }

/* ─── Cart Panel ────────────────────────────────────── */
.cart-items { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cart-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 0; color: var(--text-secondary); }
.cart-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.cart-empty-hint { font-size: 12px; color: #9CA3AF; line-height: 1.6; margin-top: 4px; }

.cart-item {
    display: flex; flex-direction: column; gap: 6px;
    padding: 12px; border: 1px solid var(--border);
    border-radius: 3px; background: var(--surface);
    transition: var(--transition);
}
.cart-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.cart-item-header { display: flex; justify-content: space-between; align-items: flex-start; }
.cart-item-name { font-size: 14px; font-weight: 600; flex: 1; }
.cart-item-delete {
    width: 28px; height: 28px; border: none; background: none;
    cursor: pointer; color: #9CA3AF; display: flex;
    align-items: center; justify-content: center;
    border-radius: 3px; transition: var(--transition); font-size: 16px;
}
.cart-item-delete:hover { color: #EF4444; background: #FEF2F2; }
.cart-item-spec { font-size: 12px; color: var(--text-secondary); }
.cart-item-g2b { font-size: 11px; color: var(--primary); }
.cart-item-row { display: flex; align-items: center; justify-content: space-between; }
.cart-item-qty { display: flex; align-items: center; gap: 4px; }
.qty-btn {
    width: 28px; height: 28px; border: 1px solid var(--border);
    background: var(--surface); border-radius: 2px; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: var(--transition);
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-input {
    width: 48px; height: 28px; text-align: center; border: 1px solid var(--border);
    border-radius: 3px; font-size: 13px; font-weight: 600;
    font-family: inherit; outline: none;
    -moz-appearance: textfield;
}
.qty-input::-webkit-inner-spin-button, .qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.qty-unit { font-size: 11px; color: var(--text-secondary); margin-left: 2px; }
.cart-item-price { text-align: right; }
.unit-price { font-size: 11px; color: var(--text-secondary); }
.subtotal-price { font-size: 14px; font-weight: 700; color: var(--primary); }
.cart-item-note { font-size: 11px; color: var(--text-secondary); font-style: italic; padding-top: 4px; border-top: 1px dashed var(--border); }

.cart-footer { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.cart-summary { display: flex; flex-direction: column; gap: 4px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }
.summary-total { font-weight: 700; font-size: 16px; color: var(--text-primary); padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); }
.quote-btn {
    width: 100%; padding: 13px; background: var(--primary); color: #fff;
    border: none; border-radius: 3px; font-size: 15px; font-weight: 700;
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit;
}
.quote-btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.cart-action-btn {
    width: 100%; padding: 10px; border-radius: 3px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: var(--transition); font-family: inherit;
}
.cart-action-btn.outline {
    background: var(--surface); color: var(--primary);
    border: 2px solid var(--border);
}
.cart-action-btn.outline:hover { border-color: var(--primary); }
.cart-action-btn.text-danger {
    background: none; border: none; color: #EF4444; font-size: 12px;
}
.cart-action-btn.text-danger:hover { background: #FEF2F2; }

/* ─── Modals ────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--surface); border-radius: 4px;
    width: 90%; max-width: 520px; max-height: 85vh;
    overflow: hidden; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}
.modal-overlay.open .modal-content { transform: translateY(0); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 16px 24px; border-top: 1px solid var(--border);
}
.btn-outline-modal {
    padding: 10px 20px; border: 2px solid var(--border);
    background: var(--surface); border-radius: 3px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    color: var(--text-secondary); transition: var(--transition);
    font-family: inherit;
}
.btn-outline-modal:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary-modal {
    padding: 10px 20px; border: none;
    background: var(--primary); border-radius: 3px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    color: #fff; transition: var(--transition);
    font-family: inherit;
}
.btn-primary-modal:hover { background: var(--primary-dark); }

/* Settings tabs */
.settings-tabs {
    display: flex; border-bottom: 1px solid var(--border); padding: 0 24px;
}
.settings-tab-btn {
    padding: 12px 16px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); border: none; background: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; transition: var(--transition); font-family: inherit;
}
.settings-tab-btn:hover { color: var(--primary); }
.settings-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text-primary); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--border); border-radius: 3px;
    font-size: 14px; font-family: inherit;
    color: var(--text-primary); background: var(--surface);
    outline: none; transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: #9CA3AF; }
.form-group select { cursor: pointer; }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-hint { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--background); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Scroll mode */
.pdf-scroll-container {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column;
    align-items: center; gap: 16px; padding: 24px;
}
.pdf-scroll-container .pdf-page-wrapper {
    box-shadow: 0 20px 50px rgba(0,0,0,0.25); border-radius: 4px;
}

/* ─── Search Panel ──────────────────────────────────── */
.search-input-wrap { display: flex; gap: 8px; }
.search-input {
    flex: 1; padding: 10px 14px;
    border: 2px solid var(--border); border-radius: 3px;
    font-size: 14px; outline: none; transition: var(--transition);
    background: var(--surface); color: var(--text-primary); font-family: inherit;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,0.06); }
.search-btn {
    padding: 10px 16px; background: var(--primary); color: #fff;
    border: none; border-radius: 3px; cursor: pointer; transition: var(--transition);
    display: flex; align-items: center;
}
.search-btn:hover { background: var(--primary-dark); }
.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-hint { color: var(--text-secondary); font-size: 14px; text-align: center; padding: 32px 0; }
.search-result-item {
    border: 1px solid var(--border); border-radius: 3px;
    padding: 12px; cursor: pointer; transition: var(--transition);
}
.search-result-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.search-result-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.search-result-info { font-size: 12px; color: var(--text-secondary); }
.search-result-page {
    display: inline-block; font-size: 11px; font-weight: 600;
    background: rgba(0,0,0,0.06); color: var(--primary);
    padding: 2px 8px; border-radius: 2px; margin-top: 4px;
}
.search-no-results { color: var(--text-secondary); font-size: 13px; text-align: center; padding: 24px 0; }

/* ─── Magnifier ─────────────────────────────────────── */
.magnifier {
    position: fixed;
    width: 180px; height: 180px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    overflow: hidden;
    pointer-events: none;
    z-index: 800;
    display: none;
    background: #fff;
}
.magnifier canvas {
    display: block;
}

/* ─── Pinch Zoom wrapper ────────────────────────────── */
.catalog-viewer.zoomed {
    overflow: auto;
    touch-action: pan-x pan-y;
    cursor: grab;
}
.catalog-viewer.zoomed:active { cursor: grabbing; }
#flipbook.scaled {
    transform-origin: center center;
    transition: transform 0.1s ease;
}

/* ─── AI 펜 ────────────────────────────────────────── */
body.ai-pen-mode #flipbook .page { cursor: crosshair; }
body.ai-pen-mode #flipbook .ai-pen-overlay { pointer-events: auto; }

.ai-pen-overlay {
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.ai-pen-toolbar {
    position: fixed;
    left: 50%;
    top: 70px;
    transform: translate(-50%, -16px);
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}
.ai-pen-toolbar.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.ai-pen-toolbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #1e293b;
    color: #fff;
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    max-width: calc(100vw - 32px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.ai-pen-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    white-space: nowrap;
}
.ai-pen-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff2d55;
    box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.2);
    animation: ai-pen-pulse 1.6s ease-in-out infinite;
    flex-shrink: 0;
}
.ai-pen-dot.busy {
    background: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
    animation: ai-pen-pulse-busy 0.9s ease-in-out infinite;
}
@keyframes ai-pen-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.2); }
    50% { box-shadow: 0 0 0 7px rgba(255, 45, 85, 0.08); }
}
@keyframes ai-pen-pulse-busy {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.08); }
}
.ai-pen-overlay polyline {
    transition: stroke 0.25s ease, opacity 0.4s ease;
}
.ai-pen-overlay polyline.ai-pen-analyzing {
    animation: ai-pen-stroke-pulse 1s ease-in-out infinite;
}
.ai-pen-overlay polyline.ai-pen-consumed {
    opacity: 0 !important;
}
@keyframes ai-pen-stroke-pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 0.35; }
}
.ai-pen-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-pen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.ai-pen-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}
.ai-pen-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-pen-btn-analyze {
    background: #ff2d55;
    border-color: #ff2d55;
    color: #fff;
}
.ai-pen-btn-analyze:hover:not(:disabled) {
    background: #e61f46;
    border-color: #e61f46;
}
.ai-pen-btn-close {
    width: 28px;
    height: 28px;
    padding: 0;
    justify-content: center;
    font-size: 14px;
}
.ai-pen-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-pen-spin 0.8s linear infinite;
}
@keyframes ai-pen-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .ai-pen-toolbar { top: 56px; width: calc(100vw - 16px); }
    .ai-pen-toolbar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 12px;
    }
    .ai-pen-hint { white-space: normal; font-size: 12px; line-height: 1.4; }
    .ai-pen-actions { justify-content: flex-end; }
    .ai-pen-btn { padding: 8px 12px; font-size: 12px; }
}

/* ─── 수신자 정보 상태 뱃지 ─────────────── */
.recipient-status {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    background: #f3f4f6;
    color: #9ca3af;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}
.recipient-status.set {
    background: #dcfce7;
    color: #166534;
}

/* ─── 견적서 프리뷰 모달 ─────────────── */
.qprev-modal {
    max-width: 860px;
    width: calc(100% - 32px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.qprev-footer {
    display: flex !important;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.qprev-footer-spacer { flex: 1; }
.qprev-action-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px !important;
}
.qprev-body {
    max-height: calc(90vh - 130px);
    overflow-y: auto;
    background: #f9fafb;
    padding: 16px !important;
}
.qprev-wrap {
    background: #fff;
    padding: 28px 24px;
    max-width: 700px;
    margin: 0 auto;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    font-size: 11px;
    color: #111;
}
.qprev-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 4px;
}
.qprev-meta {
    text-align: right;
    font-size: 10px;
    color: #666;
    margin-bottom: 4px;
}
.qprev-hr { border-top: 1px solid #000; margin: 6px 0 10px; }
.qprev-info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.qprev-info-box {
    flex: 1;
    border: 1px solid #000;
}
.qprev-info-title {
    background: #ececec;
    font-weight: 700;
    text-align: center;
    padding: 4px;
    border-bottom: 1px solid #000;
    font-size: 11px;
}
.qprev-info-box table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}
.qprev-info-box th,
.qprev-info-box td {
    border: 1px solid #000;
    padding: 4px 6px;
    text-align: left;
}
.qprev-info-box th {
    background: #fafafa;
    font-weight: 600;
    width: 80px;
    text-align: center;
}
.qprev-total-banner {
    background: #ececec;
    border: 1px solid #000;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 12px;
}
.qprev-vat { float: right; font-size: 10px; color: #555; }
.qprev-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin-bottom: 10px;
}
.qprev-items th,
.qprev-items td {
    border: 1px solid #000;
    padding: 4px 6px;
}
.qprev-items thead th {
    background: #ececec;
    text-align: center;
    font-weight: 600;
}
.qprev-items tfoot td {
    background: #f7f7f7;
    font-weight: 600;
}
.qprev-items tr.qprev-sum td { background: #ececec; }
.qprev-notes {
    font-size: 10px;
    color: #333;
    line-height: 1.6;
    padding: 8px 4px;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    .side-panel { width: 100%; right: -100%; }
    .header-content { padding: 4px 0; }
    .logo { font-size: 13px; }
    .icon-btn { width: 28px; height: 28px; }
    .icon-btn svg { width: 16px; height: 16px; }
    .control-btn { width: 28px; height: 28px; }
    .controls-content { gap: 3px; }
    .controls-divider { display: none; }
    .catalog-viewer { padding: 2px; }
    .magnifier { width: 140px; height: 140px; }
    .page-indicator { font-size: 12px; min-width: 50px; }
    .qprev-wrap { padding: 16px 12px; }
    .qprev-info-row { flex-direction: column; }
    .qprev-items { font-size: 9px; }
    .qprev-items th, .qprev-items td { padding: 3px; }
}
