:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --background: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(120deg, #18122B 0%, #393053 60%, #443C68 100%);
    position: relative;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    background: url('data:image/svg+xml;utf8,<svg width="100%25" height="100%25" viewBox="0 0 1920 1080" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="200" cy="200" r="2" fill="%23fff" opacity="0.7"/><circle cx="400" cy="800" r="1.5" fill="%23fff" opacity="0.5"/><circle cx="1700" cy="300" r="2.5" fill="%23fff" opacity="0.8"/><circle cx="1200" cy="900" r="1.2" fill="%23fff" opacity="0.6"/><circle cx="900" cy="400" r="1.8" fill="%23fff" opacity="0.7"/><circle cx="1500" cy="700" r="1.3" fill="%23fff" opacity="0.5"/><line x1="200" y1="200" x2="400" y2="800" stroke="%23fff" stroke-width="0.5" opacity="0.2"/><line x1="400" y1="800" x2="900" y2="400" stroke="%23fff" stroke-width="0.5" opacity="0.2"/><line x1="1700" y1="300" x2="1500" y2="700" stroke="%23fff" stroke-width="0.5" opacity="0.2"/><line x1="1200" y1="900" x2="900" y2="400" stroke="%23fff" stroke-width="0.5" opacity="0.2"/></svg>');
    background-repeat: no-repeat;
    background-size: cover;
    opacity: 0.45;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    padding-bottom: 120px;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.spread-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.option-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.option-btn.active {
    background: var(--primary-color);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.card-container {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 3rem;
    padding: 1.5rem 0.5rem 1rem 0.5rem;
    justify-content: center;
    position: relative;
}
.card-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0;
    margin-bottom: 0.2rem;
    overflow-x: visible;
}
.card {
    width: 48px;
    height: 72px;
    min-width: 48px;
    min-height: 72px;
    max-width: 48px;
    max-height: 72px;
    margin-left: -18px;
    background: var(--card-bg);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: box-shadow 0.3s, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.2s;
    position: relative;
    overflow: hidden;
    background: #1a1a2e;
    box-shadow: 0 2px 8px 0 rgba(0,0,0,0.10);
}
.card:first-child {
    margin-left: 0;
}
.card:hover, .card.flipped {
    z-index: 10;
    transform: scale(1.18) translateY(-10px);
    box-shadow: 0 8px 24px 0 rgba(99,102,241,0.18);
}
.card.flipped {
    border: 2px solid var(--primary-color);
}
@media (max-width: 900px) {
    .card {
        width: 38px;
        height: 57px;
        min-width: 38px;
        min-height: 57px;
        max-width: 38px;
        max-height: 57px;
        margin-left: -10px;
    }
}
@media (max-width: 600px) {
    .card-container {
        flex-direction: column;
        padding-bottom: 0.5rem;
    }
    .card-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-bottom: 0.3rem;
        justify-content: flex-start;
        padding-left: 8px;
        gap: 0.1rem;
    }
    .card {
        width: 28px;
        height: 42px;
        min-width: 28px;
        min-height: 42px;
        max-width: 28px;
        max-height: 42px;
        margin-left: -4px;
    }
    .container {
        padding-bottom: 60px;
    }
    .selected-result img {
        width: 60px;
        height: 90px;
        padding: 1px;
    }
    .selected-result {
        margin-bottom: 120px !important;
        padding-bottom: 16px;
        gap: 0.7rem;
        padding: 12px 0 8px 0;
    }
    .bottom-panel {
        padding: 0.3rem 0 0.1rem 0;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        min-height: 38px;
        max-height: 120px;
    }
    .extra-question-section {
        max-width: 98vw;
        margin-bottom: 0.5rem;
    }
    .extra-question-input {
        font-size: 0.92rem;
        padding: 0.5rem;
        min-height: 32px;
        max-height: 48px;
    }
    .bottom-panel .controls {
        margin-bottom: 0.5rem;
    }
    .result-btns button,
    .extra-question-btn,
    .shuffle-btn {
        font-size: 0.95rem;
        padding: 0.7rem 1.2rem;
        min-width: 90px;
    }
}
@media (max-width: 400px) {
    .card {
        width: 20px;
        height: 30px;
        min-width: 20px;
        min-height: 30px;
        max-width: 20px;
        max-height: 30px;
        margin-left: -2px;
    }
    .selected-result img {
        width: 36px;
        height: 54px;
        padding: 0px;
    }
    .extra-question-input {
        font-size: 0.85rem;
        padding: 0.3rem;
        min-height: 24px;
        max-height: 36px;
    }
}

.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2a4a 0%, #1a1a2e 100%);
    border-radius: 20px;
    transition: all 0.4s ease;
    overflow: hidden;
}

.card-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml;utf8,<svg width='100%' height='100%' viewBox='0 0 200 300' fill='none' xmlns='http://www.w3.org/2000/svg'><rect width='200' height='300' rx='18' fill='%230a0a0a'/><rect x='8' y='8' width='184' height='284' rx='14' stroke='%23D4AF37' stroke-width='2' fill='none'/><rect x='18' y='18' width='164' height='264' rx='10' stroke='%23D4AF37' stroke-width='1.2' fill='none'/><g><g><g id='starburst'><g><circle cx='100' cy='150' r='38' fill='none' stroke='%23D4AF37' stroke-width='1.2' opacity='0.3'/></g><g><g><g><path d='M100 80 L104 120 L100 110 L96 120 Z' fill='%23D4AF37' /><path d='M100 220 L104 180 L100 190 L96 180 Z' fill='%23D4AF37' /><path d='M60 150 L100 154 L90 150 L100 146 Z' fill='%23D4AF37' /><path d='M140 150 L100 146 L110 150 L100 154 Z' fill='%23D4AF37' /><g opacity='0.7'><path d='M80 110 L100 150 L90 120 Z' fill='%23D4AF37'/><path d='M120 110 L100 150 L110 120 Z' fill='%23D4AF37'/><path d='M80 190 L100 150 L90 180 Z' fill='%23D4AF37'/><path d='M120 190 L100 150 L110 180 Z' fill='%23D4AF37'/></g></g></g></g><circle cx='100' cy='150' r='8' fill='none' stroke='%23D4AF37' stroke-width='1.2'/></g></g></g><g id='top-ornament'><circle cx='100' cy='38' r='6' fill='%23D4AF37' opacity='0.8'/><path d='M100 32 L102 44 L98 44 Z' fill='%23D4AF37'/><circle cx='100' cy='28' r='2' fill='%23D4AF37'/><g opacity='0.7'><path d='M90 44 Q100 24 110 44' stroke='%23D4AF37' stroke-width='1.2' fill='none'/><path d='M80 48 Q100 18 120 48' stroke='%23D4AF37' stroke-width='1' fill='none'/></g><g opacity='0.5'><ellipse cx='70' cy='52' rx='6' ry='2' fill='none' stroke='%23D4AF37' stroke-width='1'/><ellipse cx='130' cy='52' rx='6' ry='2' fill='none' stroke='%23D4AF37' stroke-width='1'/></g></g><g id='bottom-ornament'><circle cx='100' cy='262' r='6' fill='%23D4AF37' opacity='0.8'/><path d='M100 268 L102 256 L98 256 Z' fill='%23D4AF37'/><circle cx='100' cy='272' r='2' fill='%23D4AF37'/><g opacity='0.7'><path d='M90 256 Q100 276 110 256' stroke='%23D4AF37' stroke-width='1.2' fill='none'/><path d='M80 252 Q100 282 120 252' stroke='%23D4AF37' stroke-width='1' fill='none'/></g><g opacity='0.5'><ellipse cx='70' cy='248' rx='6' ry='2' fill='none' stroke='%23D4AF37' stroke-width='1'/><ellipse cx='130' cy='248' rx='6' ry='2' fill='none' stroke='%23D4AF37' stroke-width='1'/></g></g><g id='cracks'><path d='M40 60 Q60 100 80 120 Q90 130 100 150 Q110 170 120 180 Q130 190 140 200' stroke='%23D4AF37' stroke-width='0.5' opacity='0.18' fill='none'/><path d='M160 60 Q140 100 120 120 Q110 130 100 150 Q90 170 80 180 Q70 190 60 200' stroke='%23D4AF37' stroke-width='0.5' opacity='0.18' fill='none'/></g></svg>");
    background-size: cover;
    background-position: center;
    opacity: 1;
    z-index: 1;
}

.card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 20px;
    transform: rotateY(180deg);
    backface-visibility: hidden;
}

.card::after {
    content: attr(data-number);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::after {
    opacity: 1;
}

.card.flipped {
    background-image: none;
    background: var(--card-bg);
}

.card.flipped::after {
    opacity: 1;
}

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

.memo-section {
    max-width: 800px;
    margin: 0 auto 2rem;
}

.memo-input {
    width: 100%;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.memo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.instructions {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-secondary);
}

.shuffle-btn {
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1.5rem;
    position: relative;
    overflow: hidden;
}

.shuffle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(236, 72, 153, 0.3);
}

.shuffle-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: 0.5s;
}

.shuffle-btn:hover::after {
    transform: rotate(45deg) translate(50%, 50%);
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .card-container {
        grid-template-columns: 1fr;
        max-width: 400px;
        margin: 0 auto 2rem;
    }

    .spread-options, .controls {
        gap: 0.5rem;
    }

    .option-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.card-count-select .count-btn {
    padding: 0.7em 1.3em;
    margin: 0 0.3em;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.card-count-select .count-btn.active {
    background: var(--primary-color);
    color: #fff;
}
.selected-result {
    background: #18122B !important;
    border-radius: 16px;
    padding: 24px 0 16px 0;
    display: flex;
    justify-content: center;
    gap: 2.2rem;
    flex-wrap: wrap;
    flex-direction: column;
    margin-bottom: 2.5rem;
}
.selected-result img {
    width: 160px;
    height: 240px;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 4px 16px 0 rgba(0,0,0,0.18);
    background: #18122B;
    padding: 8px;
    display: block;
}
@media (max-width: 900px) {
    .selected-result img {
        width: 110px;
        height: 165px;
        padding: 5px;
    }
}
@media (max-width: 600px) {
    .selected-result img {
        width: 70px;
        height: 105px;
        padding: 2px;
    }
}

.card.deal {
    animation: cardDeal 0.38s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes cardDeal {
    0% { opacity: 0; transform: translateY(-40px) scale(0.7) rotate(-8deg); }
    80% { opacity: 1; transform: translateY(8px) scale(1.05) rotate(2deg); }
    100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
.card.shuffle-anim {
    animation: cardShuffle 0.5s cubic-bezier(0.4,0,0.2,1);
}
@keyframes cardShuffle {
    0% { transform: scale(1) rotate(0); }
    20% { transform: scale(1.08) rotate(-6deg); }
    40% { transform: scale(0.95) rotate(7deg); }
    60% { transform: scale(1.1) rotate(-4deg); }
    80% { transform: scale(0.98) rotate(3deg); }
    100% { transform: scale(1) rotate(0); }
}

/* 하단 고정 패널 */
.bottom-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: rgba(30, 25, 60, 0.92);
    box-shadow: 0 -4px 32px 0 rgba(0,0,0,0.18);
    padding: 1.2rem 0 0.7rem 0;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100vw;
    max-width: 100vw;
    min-height: 90px;
    max-height: 240px;
    transition: padding 0.2s, min-height 0.2s;
    overflow-y: auto;
}
.extra-question-section {
    max-width: 700px;
    margin: 0 auto 0.7rem auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.extra-question-input {
    width: 100%;
    max-width: 600px;
    min-width: 0;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    min-height: 48px;
    max-height: 160px;
    margin: 0 auto 0.5rem auto;
    display: block;
}
.extra-question-btn-row {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
}
.extra-question-btn,
.shuffle-btn {
    font-size: 1rem;
    padding: 0.7rem 1.2rem;
    min-width: 0;
    border-radius: 10px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: #fff;
    font-weight: 600;
    border: none;
    white-space: nowrap;
    flex: 1 1 0;
    margin: 0;
}
@media (max-width: 600px) {
    .bottom-panel {
        padding: 0.2rem 0 0.2rem 0;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        min-height: 60px;
        max-height: 40vh;
        height: auto;
        overflow-y: auto;
    }
    .extra-question-section {
        max-width: 98vw;
        margin-bottom: 0.3rem;
        padding: 0 4px;
    }
    .extra-question-input {
        font-size: 0.98rem;
        padding: 0.7rem 0.7rem;
        min-height: 38px;
        max-height: 120px;
        border-radius: 10px;
        margin-bottom: 0.4rem;
    }
    .extra-question-btn-row {
        max-width: 98vw;
        gap: 6px;
    }
    .extra-question-btn,
    .shuffle-btn {
        font-size: 0.98rem;
        padding: 0.7rem 0.2rem;
        border-radius: 10px;
    }
}

#ai_chat {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 160px;
}
.ai-section {
    margin-bottom: 1.2em;
    padding: 1em 0;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}
.ai-section b, .ai-section strong {
    color: var(--primary-color);
}
.ai-section ul, .ai-section ol {
    margin: 0.5em 0 0.5em 1.2em;
    padding: 0;
}
.ai-section li {
    margin-bottom: 0.3em;
}
.ai-section hr {
    border: none;
    border-top: 1px solid #6366f1;
    margin: 1em 0;
}
.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7em;
    margin: 2em 0;
}
.ai-loading .card {
    width: 24px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    border-radius: 6px;
    margin-right: 0.2em;
    animation: cardFlip 1.2s infinite;
    display: inline-block;
}
.ai-loading .card:nth-child(2) { animation-delay: 0.2s; }
.ai-loading .card:nth-child(3) { animation-delay: 0.4s; }
@keyframes cardFlip {
    0%, 100% { transform: rotateY(0); opacity: 1; }
    50% { transform: rotateY(180deg); opacity: 0.5; }
}
.ai-loading .loading-text {
    font-size: 1.1em;
    color: var(--primary-color);
    font-weight: bold;
    margin-left: 1em;
    letter-spacing: 0.05em;
}
.ai-block {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    padding: 1.2rem 1rem 1.2rem 1.2rem;
    box-shadow: 0 2px 8px 0 rgba(0,0,0,0.08);
    word-break: break-word;
}
.ai-q {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.7rem;
    font-size: 1.08rem;
}
.ai-a {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.7;
}
.ai-block ul, .ai-block ol {
    margin: 0.5em 0 0.5em 1.2em;
    padding: 0;
}
.ai-block li {
    margin-bottom: 0.3em;
}
.ai-block b, .ai-block strong {
    color: var(--primary-color);
}
.ai-block hr {
    border: none;
    border-top: 1px solid #6366f1;
    margin: 1em 0;
}
.result-btns button,
.extra-question-btn,
.shuffle-btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    margin: 0 0.7rem;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px 0 rgba(99,102,241,0.10);
    min-width: 160px;
    display: inline-block;
}
.result-btns button:hover,
.extra-question-btn:hover,
.shuffle-btn:hover {
    background: linear-gradient(45deg, var(--accent-color), var(--primary-color));
    box-shadow: 0 4px 16px 0 rgba(236, 72, 153, 0.18);
}
.result-btns {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
}
.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.ai-block {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    padding: 1.2rem 1rem 1.2rem 1.2rem;
    box-shadow: 0 2px 8px 0 rgba(0,0,0,0.08);
    word-break: break-word;
}
.ai-block ul, .ai-block ol {
    margin: 0.5em 0 0.5em 1.2em;
    padding: 0;
}
.ai-block li {
    margin-bottom: 0.3em;
}
.ai-block b, .ai-block strong {
    color: var(--primary-color);
}
.ai-block hr {
    border: none;
    border-top: 1px solid #6366f1;
    margin: 1em 0;
}

.question-section {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.question-input {
    width: 100%;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.question-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.selected-question {
    text-align: center;
    margin: 1.5rem 0 0 0;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.original-question {
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.refined-question {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 1.1rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.main-btn {
    width: 200px;
    min-width: 0;
    padding: 1rem 0;
    font-size: 1.1rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    margin: 0 0.7rem;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px 0 rgba(99,102,241,0.10);
    display: inline-block;
}
.main-btn:hover {
    background: linear-gradient(45deg, var(--accent-color), var(--primary-color));
    box-shadow: 0 4px 16px 0 rgba(236, 72, 153, 0.18);
}
.result-btns, .controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
}
.ai-block {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    padding: 1.2rem 1rem 1.2rem 1.2rem;
    box-shadow: 0 2px 8px 0 rgba(0,0,0,0.08);
    word-break: break-word;
}
.ai-q {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.7rem;
    font-size: 1.08rem;
}
.ai-a {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.7;
}
.ai-block ul, .ai-block ol {
    margin: 0.5em 0 0.5em 1.2em;
    padding: 0;
}
.ai-block li {
    margin-bottom: 0.3em;
}
.ai-block b, .ai-block strong {
    color: var(--primary-color);
}
.ai-block hr {
    border: none;
    border-top: 1px solid #6366f1;
    margin: 1em 0;
}
.selected-result:empty,
#ai_chat:empty,
.selected-question:empty {
    display: none !important;
}
.bottom-panel .controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
    z-index: 102;
}
@media (max-width: 600px) {
    .bottom-panel .controls {
        flex-direction: row;
        gap: 0.5rem;
        margin-top: 0.2rem;
    }
    .result-btns {
        flex-direction: row;
        gap: 0.5rem;
        margin-top: 0.7rem;
    }
}

.loading-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    background: rgba(60, 40, 120, 0.18);
    border-radius: 16px;
    margin: 1.5rem auto;
    box-shadow: 0 4px 24px 0 rgba(80, 60, 180, 0.12);
    position: relative;
    overflow: hidden;
}
.loading-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #a5b4fc;
    border-top: 4px solid #ec4899;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.1rem;
}
@keyframes spin {
    0% { transform: rotate(0deg);}
    100% { transform: rotate(360deg);}
}
.loading-message {
    font-size: 1.1rem;
    color: #fff;
    margin-top: 0.2rem;
    text-align: center;
    animation: fadein 1.2s;
}
@keyframes fadein {
    from { opacity: 0;}
    to { opacity: 1;}
}


#pwa-install-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #18122B;
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
  }
  .pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
  #pwa-banner-close {
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    font-size: 1rem;
  }

/* PWA 설치 모달 오버레이 */
#pwa-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pwa-modal-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 18, 43, 0.85);
  backdrop-filter: blur(2px);
  z-index: 0;
}
.pwa-modal-content {
  position: relative;
  z-index: 1;
  background: #23203b;
  color: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 2.2rem 1.5rem 1.5rem 1.5rem;
  min-width: 270px;
  max-width: 90vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}
.pwa-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
#pwa-add-btn {
  background: linear-gradient(90deg, #6366f1 60%, #ec4899 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.2rem;
  transition: background 0.2s;
}
#pwa-add-btn:hover {
  background: linear-gradient(90deg, #6366f1 40%, #8b5cf6 100%);
}
#pwa-modal-close {
  background: none;
  color: #aaa;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.2rem;
  padding: 0.2rem 0.8rem;
  border-radius: 6px;
  transition: background 0.2s;
}
#pwa-modal-close:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.pwa-modal-desc {
  font-size: 0.98rem;
  color: #bdb7d6;
  margin-top: 0.2rem;
  line-height: 1.6;
}
@media (max-width: 600px) {
  .pwa-modal-content {
    min-width: 0;
    width: 92vw;
    padding: 1.2rem 0.5rem 1.2rem 0.5rem;
  }
  .pwa-modal-title {
    font-size: 1.05rem;
  }
  #pwa-add-btn {
    font-size: 1rem;
    padding: 0.6rem 1.1rem;
  }
}