:root {
    --bg-color: #0c0c0c;
    --card-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #007aff;
    --success-color: #34c759;
    --error-color: #ff3b30;
    --border-color: #333333;
    --header-height: 60px;
    --nav-height: 75px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(12, 12, 12, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.logo .accent {
    color: var(--accent-color);
}

.status-indicator {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(52, 199, 89, 0.2);
    color: var(--success-color);
}

/* Screens */
main {
    flex: 1;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 20px);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Welcome Screen */
.hero {
    margin-top: 40px;
    margin-bottom: 60px;
    text-align: center;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.hero .highlight {
    color: var(--accent-color);
}

.hero p {
    color: #888;
    font-size: 0.95rem;
}

.empty-msg {
    text-align: center;
    color: #555;
    margin-top: 40px;
}

/* Result Screen */
.image-preview-container {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    border-radius: 16px;
    overflow: hidden;
}

#scanned-image {
    width: 100%;
    display: block;
    max-height: 200px;
    object-fit: cover;
}

.btn-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Result Cards */
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.result-card:active {
    transform: scale(0.98);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.badge-success { background: rgba(52, 199, 89, 0.2); color: var(--success-color); }
.badge-error { background: rgba(255, 59, 48, 0.2); color: var(--error-color); }

.card-body {
    font-size: 1rem;
    overflow-x: auto;
}

/* Navigation */
.bottom-nav {
    height: var(--nav-height);
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(20px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    background: none;
    border: none;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
}

.nav-item .icon { font-size: 1.4rem; margin-bottom: 2px; }

.fab-container {
    position: relative;
    top: -20px;
}

.fab {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--accent-color), #0056b3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 30px rgba(0, 122, 255, 0.4);
    cursor: pointer;
}

.fab .icon { font-size: 1.8rem; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 85vh;
    background: var(--bg-color);
    border-radius: 20px 20px 0 0;
    padding: 30px 20px;
    overflow-y: auto;
}

.btn-close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
}

/* Spinner */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 300;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #222;
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 400;
    transition: 0.3s ease-in-out;
    padding: 20px;
}

.settings-panel.active { right: 0; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #888;
}

.setting-group input {
    width: 100%;
    padding: 12px;
    background: #1a1a1a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    outline: none;
}

.btn-save {
    width: 100%;
    padding: 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
}

/* Markdown & Content Formatting */
.math-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.math-render {
    word-break: break-word;
    font-size: 0.95rem;
}

.math-render p {
    margin-bottom: 12px;
}


.detail-section {
    margin-bottom: 25px;
}

.detail-section h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
}

.detail-section b {
    color: #fff;
    font-weight: 700;
}

