/* ===== 테마 변수 (라이트 기본 / 다크: [data-theme="dark"]) ===== */
:root {
    --bg-1: #eef2ff;
    --bg-2: #f5f3ff;
    --surface: #ffffff;
    --surface-2: #f5f6fa;
    --surface-3: #eceef5;
    --border: #e0e3ee;
    --text: #1f2430;
    --text-muted: #666d80;
    --accent: #6366f1;
    --accent-hover: #4f52d9;
    --accent-2: #06b6d4;
    --on-accent: #ffffff;
    --user-bubble: #6366f1;
    --assistant-bubble: #eceef5;
    --error-bg: #fee;
    --error-text: #c33;
    --shadow: 0 20px 60px rgba(60, 60, 120, 0.18);
    --hero-from: #4f46e5;
    --hero-via: #7c3aed;
    --hero-to: #0ea5e9;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg-1: #0b0e1a;
    --bg-2: #121631;
    --surface: #161a2c;
    --surface-2: #1d2238;
    --surface-3: #262c47;
    --border: #2d3454;
    --text: #e6e9f5;
    --text-muted: #9aa3c2;
    --accent: #818cf8;
    --accent-hover: #a5b0ff;
    --accent-2: #22d3ee;
    --on-accent: #0b0e1a;
    --user-bubble: #4f46e5;
    --assistant-bubble: #262c47;
    --error-bg: #3a1c24;
    --error-text: #ff8a8a;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    --hero-from: #1e1b4b;
    --hero-via: #312e81;
    --hero-to: #0e4a6b;
    color-scheme: dark;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: background 0.3s, border-color 0.3s;
}

/* ===== 표지(히어로) ===== */
header.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: linear-gradient(120deg, var(--hero-from) 0%, var(--hero-via) 55%, var(--hero-to) 100%);
    color: #fff;
    padding: 56px 30px 46px;
    text-align: center;
}

/* 빛번짐 효과 */
header.hero::before,
header.hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
}

header.hero::before {
    width: 340px;
    height: 340px;
    top: -120px;
    left: -80px;
    background: #22d3ee;
    animation: float 9s ease-in-out infinite;
}

header.hero::after {
    width: 380px;
    height: 380px;
    bottom: -160px;
    right: -100px;
    background: #f472b6;
    animation: float 11s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, 20px); }
}

.theme-toggle {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
}

.theme-toggle:active {
    transform: scale(0.96);
}

.hero-badge {
    display: inline-block;
    padding: 6px 16px;
    margin-bottom: 18px;
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
}

.hero-logo {
    font-size: 3.4em;
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}

header.hero h1 {
    font-size: 2.8em;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

header.hero h1 span {
    background: linear-gradient(90deg, #a5f3fc, #fbcfe8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header.hero p.hero-sub {
    opacity: 0.92;
    font-size: 1.15em;
    max-width: 640px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.hero-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.hero-chips span {
    padding: 8px 16px;
    font-size: 0.92em;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    backdrop-filter: blur(6px);
}

/* ===== 탭 ===== */
.tabs {
    display: flex;
    background: var(--surface-2);
    border-bottom: 2px solid var(--border);
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: var(--surface-3);
}

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--surface);
}

.tab-content {
    display: none;
    padding: 30px;
    min-height: 500px;
}

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

/* 채팅 스타일 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 20px;
}

.message {
    margin-bottom: 15px;
    padding: 12px 18px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
}

.message.user {
    background: var(--user-bubble);
    color: #fff;
    margin-left: auto;
    text-align: right;
}

.message.assistant {
    background: var(--assistant-bubble);
    color: var(--text);
}

.message-header {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.message-content {
    line-height: 1.6;
}

.usage-info {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

.chat-input-container input,
.input-section textarea,
.web-container input[type="url"] {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s, background 0.3s;
}

.chat-input-container input::placeholder,
.input-section textarea::placeholder,
.web-container input[type="url"]::placeholder {
    color: var(--text-muted);
}

.chat-input-container input {
    flex: 1;
    padding: 12px 18px;
    border-radius: 25px;
}

.chat-input-container input:focus,
.input-section textarea:focus,
.web-container input[type="url"]:focus {
    border-color: var(--accent);
}

.chat-input-container button {
    padding: 12px 24px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.chat-input-container button:hover {
    background: var(--accent-hover);
}

.chat-input-container button:active {
    transform: scale(0.98);
}

/* 멀티모달 스타일 */
.multimodal-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-section textarea {
    padding: 12px;
    border-radius: 10px;
    font-family: inherit;
    resize: vertical;
}

.file-upload-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-label {
    padding: 10px;
    background: var(--surface-2);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    transition: background 0.3s;
}

.file-label:hover {
    background: var(--surface-3);
}

.file-upload-section input[type="file"] {
    display: none;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
}

.button-group {
    display: flex;
    gap: 10px;
}

.button-group button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.button-group button:first-child {
    background: var(--accent);
    color: var(--on-accent);
}

.button-group button:first-child:hover {
    background: var(--accent-hover);
}

.button-group button:last-child {
    background: var(--surface-2);
    color: var(--text-muted);
}

.button-group button:last-child:hover {
    background: var(--surface-3);
}

.multimodal-response {
    padding: 20px;
    background: var(--surface-2);
    border-radius: 12px;
    max-height: 500px;
    overflow-y: auto;
}

/* 웹 요약 스타일 */
.web-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.web-container .input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.web-container input[type="url"] {
    padding: 12px;
    border-radius: 10px;
}

.web-container button {
    padding: 12px 24px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.web-container button:hover {
    background: var(--accent-hover);
}

.web-response {
    padding: 20px;
    background: var(--surface-2);
    border-radius: 12px;
    line-height: 1.8;
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--error-text);
}

footer {
    background: var(--surface-2);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
    border-top: 1px solid var(--border);
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .multimodal-container {
        grid-template-columns: 1fr;
    }

    .message {
        max-width: 90%;
    }

    header.hero {
        padding: 64px 20px 36px;
    }

    header.hero h1 {
        font-size: 2em;
    }

    .hero-logo {
        font-size: 2.6em;
    }
}

@media (prefers-reduced-motion: reduce) {
    header.hero::before,
    header.hero::after {
        animation: none;
    }
}
