:root {
    --bg-main: #ffffff;
    --bg-card: #ffffff;
    --bg-sub: #f8f8f8;
    --primary: #000000;
    --primary-hover: #333333;
    --text-main: #000000;
    --text-muted: #666666;
    --border: #000000;
    --border-light: #e0e0e0;
    --accent: #222222;
    --shadow: none;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    height: 100%;
    background-color: var(--bg-card);
    position: relative;
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

@media (max-width: 600px) {
    .app-container { max-width: 100%; border: none; }
}

.ui-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    z-index: 10;
}

.ui-screen.hidden { display: none; }
.ui-screen.active { display: flex; }

/* Header */
.main-header {
    height: 80px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--border);
    z-index: 100;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

/* Updated Button with Label */
.icon-label-btn {
    background: transparent;
    border: 1.5px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
}

.icon-label-btn span {
    font-size: 0.75rem;
    font-weight: 800;
}

.icon-label-btn:hover {
    background: #f0f0f0;
}

.icon-label-btn svg {
    pointer-events: none;
}

.icon-label-btn.vertical {
    flex-direction: column;
    gap: 2px;
    padding: 0.6rem;
    min-width: 64px;
    border: none;
}

.header-left { display: flex; gap: 0.4rem; }

/* Viewport Content */
.viewport-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.camera-card {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

#video, #photoPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted); text-align: center;
}

.focus-guide {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 200px; height: 200px; pointer-events: none;
}

.guide-line { position: absolute; width: 24px; height: 24px; border: 2px solid var(--border); }
.tl { top:0; left:0; border-right:none; border-bottom:none; }
.tr { top:0; right:0; border-left:none; border-bottom:none; }
.bl { bottom:0; left:0; border-right:none; border-top:none; }
.br { bottom:0; right:0; border-left:none; border-top:none; }

/* Tabs */
.subject-nav { width: 100%; overflow-x: auto; }
.subject-nav::-webkit-scrollbar { display: none; }
.tabs-scroll { display: flex; gap: 0.6rem; padding-bottom: 0.5rem; }
.tab-btn {
    padding: 0.6rem 1.2rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-main);
    font-weight: 800;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
}
.tab-btn.active {
    background: var(--primary);
    color: #ffffff;
}

/* Footer */
.action-footer {
    padding: 1rem 1.5rem 2rem;
    border-top: 2px solid var(--border);
}

.bottom-tools {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.shutter-outer {
    width: 80px; height: 80px; border-radius: 50%; border: 4px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}

.shutter-btn {
    width: 85%; height: 85%; border-radius: 50%; background: var(--primary); border: none; cursor: pointer;
}

/* Result Screen */
.result-header {
    padding: 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--border);
}
.back-link {
    background: transparent; border: 1.5px solid var(--border); padding: 0.4rem 0.8rem; border-radius: 4px;
    font-weight: 800; display: flex; align-items: center; gap: 0.4rem; cursor: pointer;
}
.db-badge {
    background: #000000; color: #ffffff; padding: 0.4rem 0.8rem; border-radius: 2px; font-size: 0.75rem; font-weight: 800;
}

.result-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.answer-hero { background: #ffffff; padding: 1.5rem; border: 2px solid var(--border); margin-bottom: 2rem; }
.hero-label { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); letter-spacing: 2px; margin-bottom: 0.4rem; display: block; }
#mainAnswerText { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 800; }

.details-section h3 { font-size: 0.8rem; font-weight: 800; color: var(--text-muted); margin-bottom: 1rem; }
.markdown-body { font-size: 1.05rem; line-height: 1.7; }

/* Chat */
.chat-area { margin-top: 3rem; padding-top: 2rem; border-top: 2px solid var(--border); }
.chat-container { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.bot-msg, .user-msg { padding: 1rem; border-radius: 4px; border: 1px solid var(--border); font-size: 0.95rem; }
.bot-msg { background: #f9f9f9; align-self: flex-start; }
.user-msg { background: #000000; color: #ffffff; align-self: flex-end; }
.chat-bar { display: flex; gap: 0.4rem; border: 2px solid var(--border); padding: 0.3rem; border-radius: 4px; }
.chat-bar input { flex: 1; border: none; padding: 0.6rem; outline: none; }
.chat-bar button { background: #000000; color: #ffffff; width: 40px; border: none; border-radius: 2px; cursor: pointer; }

/* Overlays */
.full-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
    z-index: 1000; display: flex; justify-content: center; align-items: center; padding: 1rem;
}
.overlay-modal {
    width: 480px; max-width: 100%; background: #ffffff; border: 4px solid var(--border); padding: 2rem;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h2 { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; }
.close-overlay { background: transparent; border: none; font-size: 1.2rem; cursor: pointer; font-weight: 800; }

.primary-btn { width: 100%; padding: 1.2rem; background: #000000; color: #ffffff; border: none; font-weight: 800; font-size: 1rem; cursor: pointer; }
.text-btn { background: transparent; border: none; text-decoration: underline; margin-top: 1rem; cursor: pointer; font-weight: 700; width: 100%; }

#timerDisplay { font-family: 'Outfit', sans-serif; font-size: 4rem; font-weight: 800; text-align: center; margin: 1.5rem 0; }

.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); background: #000000; color: #ffffff; padding: 1rem 2rem; font-weight: 800; z-index: 2000; }
.toast.hidden { display: none; }
.hidden { display: none !important; }
