/* --- Global Styles & Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&display=swap');

:root {
    --font-primary: 'Noto Sans KR', sans-serif;
    --color-blue-600: #2563eb;
    --color-blue-700: #1d4ed8;
    --color-slate-900: #0f172a;
    --color-slate-800: #1e293b;
    --color-slate-600: #475569;
    --color-slate-500: #64748b;
    --color-slate-200: #e2e8f0;
    --color-slate-100: #f1f5f9;
    --color-slate-50: #f8fafc;
    --color-green-50: #f0fdf4;
    --color-green-100: #dcfce7;
    --color-green-700: #15803d;
    --color-orange-50: #fff7ed;
    --color-orange-100: #ffedd5;
    --color-orange-700: #c2410c;
    --color-red-500: #ef4444;
    --color-white: #ffffff;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-slate-900);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.hidden { display: none !important; }

/* --- App Layout --- */
.app-container {
    width: 100%;
    max-width: 448px; /* max-w-md */
    min-height: 100vh;
    background-color: var(--color-white);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 50;
    border-bottom: 1px solid var(--color-slate-50);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.logo-box {
    width: 2.25rem;
    height: 2.25rem;
    background-color: var(--color-blue-600);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    font-weight: 900;
    font-style: italic;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--color-slate-900);
    letter-spacing: -0.05em;
    margin: 0;
}

.user-button {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-slate-50);
    border-radius: 9999px;
    color: var(--color-slate-500);
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}
.user-button:hover { color: var(--color-blue-600); }

.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem 6rem;
}

/* --- View Management --- */
.view { display: none; }
.view.active { display: flex; flex-direction: column; align-items: center; text-align: center; animation: fadeIn 0.5s; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Home View --- */
.intro-text { margin-top: 3rem; margin-bottom: 4rem; text-align: left; width: 100%; }
.badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.75rem; border-radius: 9999px; background-color: #eff6ff; color: #2563eb; font-size: 0.75rem; font-weight: 700; margin-bottom: 1rem; }
.intro-text h2 { font-size: 2.25rem; font-weight: 900; color: var(--color-slate-900); line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.05em; word-break: keep-all; }
.intro-text .highlight { color: var(--color-blue-600); }
.intro-text p { color: var(--color-slate-500); font-weight: 500; margin: 0; word-break: keep-all; }

.upload-section { display: flex; flex-direction: column; align-items: center; }
.upload-button { position: relative; width: 14rem; height: 14rem; background-color: var(--color-blue-600); border-radius: 9999px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--color-white); border: none; cursor: pointer; transition: background-color 0.2s; box-shadow: 0 25px 50px -12px rgb(59 130 246 / 0.5); }
.upload-button:hover { background-color: var(--color-blue-700); }
.upload-button:active { transform: scale(0.95); }
.upload-button i { width: 64px; height: 64px; margin-bottom: 0.75rem; }
.upload-button span { font-size: 1.25rem; font-weight: 900; }
.upload-button-border { position: absolute; inset: 0; border-radius: 9999px; border: 8px solid rgba(255, 255, 255, 0.1); transition: transform 0.5s; }
.upload-button:hover .upload-button-border { transform: scale(1.1); }

.gallery-button { margin-top: 2rem; font-size: 0.875rem; color: var(--color-slate-500); text-decoration: underline; text-underline-offset: 4px; font-weight: 700; background: none; border: none; cursor: pointer; transition: color 0.2s; }
.gallery-button:hover { color: var(--color-slate-800); }

.bottom-banner { position: absolute; bottom: 1.5rem; left: 1.5rem; right: 1.5rem; padding: 1rem; background-color: var(--color-slate-900); color: var(--color-white); border-radius: 1rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5); border: 1px solid rgba(255, 255, 255, 0.1); }
.banner-icon { width: 2.5rem; height: 2.5rem; background-color: rgba(59, 130, 246, 0.2); border-radius: 9999px; display: flex; align-items: center; justify-content: center; color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.banner-subtitle { font-size: 0.625rem; color: var(--color-slate-500); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; font-style: italic; margin: 0; }
.banner-title { font-size: 0.875rem; font-weight: 700; margin: 0; word-break: keep-all; }

/* --- Analysis & Error Views --- */
#analysis-view, #error-view { justify-content: center; min-height: 60vh; }
.spinner { width: 64px; height: 64px; color: var(--color-blue-600); animation: spin 1s linear infinite; margin-bottom: 2rem; }
#analysis-view h3, #error-view h3 { font-size: 1.25rem; font-weight: 900; color: var(--color-slate-900); margin: 0 0 0.5rem; }
#analysis-view p, #error-view p { color: var(--color-slate-500); text-align: center; padding: 0 2rem; line-height: 1.5; word-break: keep-all; }
.error-icon { color: var(--color-red-500); width: 48px; height: 48px; margin-bottom: 1rem; }
.retry-button { width: 100%; padding: 1rem 1.5rem; border-radius: 1rem; background-color: var(--color-blue-600); color: var(--color-white); font-weight: 700; border: none; cursor: pointer; box-shadow: 0 10px 15px -3px rgb(59 130 246 / 0.3); }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- Hint View --- */
#hint-view { align-items: stretch; text-align: left; }
.hint-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding: 0 0.5rem; }
.hint-header h3 { font-size: 1.125rem; font-weight: 900; color: var(--color-slate-800); letter-spacing: -0.025em; margin: 0; }
.hint-header button { padding: 0.5rem; background-color: var(--color-slate-100); border-radius: 9999px; border: none; cursor: pointer; transition: background-color 0.2s; }
.hint-header button:hover { background-color: var(--color-slate-200); }

.problem-image-container { background-color: var(--color-slate-50); border-radius: 1.5rem; border: 2px dashed var(--color-slate-200); padding: 1rem; margin-bottom: 1.5rem; }
#problem-image { width: 100%; height: 12rem; object-fit: contain; background-color: var(--color-white); border-radius: 1rem; box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05); margin-bottom: 0.75rem; }
.tags { display: flex; gap: 0.5rem; }
.tags span { padding: 0.25rem 0.5rem; font-size: 10px; font-weight: 700; border-radius: 0.25rem; }
.tag-blue { background-color: var(--color-blue-600); color: var(--color-white); }
.tag-slate { background-color: var(--color-slate-200); color: var(--color-slate-600); }

.chat-area { display: flex; flex-direction: column; gap: 1rem; }
.bot-message-container { display: flex; gap: 0.75rem; text-align: left; }
.bot-icon { width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: 9999px; background-color: var(--color-blue-600); display: flex; align-items: center; justify-content: center; color: var(--color-white); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); }
.bot-message { background-color: var(--color-white); padding: 1.25rem; border-radius: 1rem; border-top-left-radius: 0; box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1); border: 1px solid var(--color-slate-100); flex: 1; font-size: 0.875rem; color: var(--color-slate-800); line-height: 1.6; white-space: pre-wrap; word-break: keep-all; }
.bot-message .katex { font-size: 1.1em; }
.concept-button { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.625rem; margin: 0 0.25rem; border-radius: 0.75rem; background-color: #e0f2fe; color: #0369a1; font-weight: 900; font-size: 0.75rem; border: 1px solid #bae6fd; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); cursor: pointer; transition: all 0.2s; }
.concept-button:hover { background-color: #e0f2fe; }
.concept-button:active { transform: scale(0.95); }

.follow-up-actions { margin-left: 3.25rem; margin-top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.action-button { width: 100%; padding: 1rem 1.5rem; border-radius: 1rem; font-weight: 700; transition: all 0.2s; display: flex; justify-content: space-between; align-items: center; cursor: pointer; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.action-button:active { transform: scale(0.95); }
.action-button { background-color: var(--color-white); border: 2px solid var(--color-slate-200); color: var(--color-slate-600); }
.action-button:hover { border-color: var(--color-blue-600); color: var(--color-blue-600); }
.action-button.slate { background-color: var(--color-slate-100); color: var(--color-slate-700); border: none; }
.action-button.slate:hover { background-color: var(--color-slate-200); }

.feedback-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--color-slate-100); text-align: center; }
.feedback-section p { font-size: 0.875rem; font-weight: 700; color: var(--color-slate-400); margin: 0 0 1rem; }
.feedback-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.5rem; }
.feedback-button { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: 0.75rem; font-weight: 700; border: 1px solid transparent; cursor: pointer; transition: all 0.2s; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.feedback-button.green { background-color: var(--color-green-50); color: var(--color-green-700); border-color: var(--color-green-100); }
.feedback-button.green:hover { background-color: var(--color-green-100); }
.feedback-button.orange { background-color: var(--color-orange-50); color: var(--color-orange-700); border-color: var(--color-orange-100); }
.feedback-button.orange:hover { background-color: var(--color-orange-100); }

.control-buttons { display: flex; flex-direction: column; gap: 0.75rem; }
.control-button-slate { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: 0.75rem; font-weight: 700; background-color: transparent; border: 2px solid var(--color-slate-200); color: var(--color-slate-600); cursor: pointer; transition: all 0.2s; }
.control-buttons > div { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;}
.control-button-slate:hover { background-color: var(--color-slate-50); }
.control-button-blue { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem 1rem; border-radius: 1rem; font-weight: 900; background-color: var(--color-blue-600); color: var(--color-white); border: none; cursor: pointer; transition: background-color 0.2s; box-shadow: 0 10px 15px -3px rgb(59 130 246 / 0.2); }
.control-button-blue:hover { background-color: var(--color-blue-700); }

/* --- Modal --- */
.modal-container { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-end; justify-content: center; padding: 1rem; background-color: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); }
.modal-container.active { display: flex; animation: fadeIn 0.3s; }
.modal-content { background-color: var(--color-white); width: 100%; max-width: 24rem; border-radius: 1.5rem; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25); overflow: hidden; animation: slideInFromBottom 0.5s; }
@keyframes slideInFromBottom { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem; border-bottom: 1px solid var(--color-slate-50); background-color: #eff6ff; }
.modal-header h4 { font-weight: 900; color: #1e3a8a; display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.modal-header button { padding: 0.5rem; border-radius: 9999px; border: none; background: none; cursor: pointer; transition: background-color 0.2s; }
.modal-header button:hover { background-color: var(--color-white); }
.modal-body { padding: 1.5rem; max-height: 60vh; overflow-y: auto; color: var(--color-slate-700); font-weight: 500; line-height: 1.6; white-space: pre-wrap; word-break: keep-all; }
.modal-body .katex { font-size: 1.1em; }
.modal-footer { padding: 1rem; background-color: var(--color-slate-50); }
.modal-footer button { width: 100%; padding: 0.75rem; background-color: var(--color-blue-600); color: var(--color-white); font-weight: 900; border-radius: 0.75rem; border: none; cursor: pointer; transition: transform 0.2s; }
.modal-footer button:active { transform: scale(0.95); }

i[data-lucide] {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}
