:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f3f4f6;
    --toolbar-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    
    /* Tool colors */
    --pen-color: #ef4444;
    --highlight-color: rgba(253, 224, 71, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent text selection while interacting */
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Strict no scrolling */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    touch-action: none; /* Prevent browser gestures on the whole app */
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --- Header --- */
#lesson-header {
    height: 50px;
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
}

#lesson-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.nav-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
}
.nav-btn:active { background-color: var(--bg-color); }

/* --- Workspace --- */
#workspace {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

#content-container {
    position: relative;
    /* Maintain aspect ratio roughly, bounded by parent */
    width: 100%;
    height: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lesson-background {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    background: white;
}

/* Layers over the background */
#hotspots-layer, #annotation-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* These will be sized by JS to exactly match the image rendering size */
}

/* Canvas needs pointer-events to draw, but might need to pass clicks in interact mode */
#annotation-layer {
    z-index: 10;
    touch-action: none;
}

/* Hotspots */
#hotspots-layer {
    z-index: 5;
    pointer-events: none; /* Let canvas capture everything, we'll delegate */
}

.hotspot {
    position: absolute;
    border: 2px dashed rgba(37, 99, 235, 0.5);
    background: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    opacity: 0; /* Hidden until interact mode, or revealed */
}

.hotspot.revealed {
    opacity: 1;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.hotspot-label {
    font-weight: bold;
    color: var(--primary);
    font-size: 0.9rem;
    pointer-events: none;
    text-align: center;
    padding: 2px 4px;
}

/* --- Toolbar --- */
#toolbar {
    height: 60px;
    background-color: var(--toolbar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
    gap: 8px;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom); /* For iOS devices with notch */
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: #4b5563;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.tool-btn:active { transform: scale(0.95); }

.tool-btn.active {
    background-color: var(--primary);
    color: white;
}

.tool-btn.danger { color: #ef4444; }
.tool-btn.danger:active { background-color: #fee2e2; }

.divider {
    width: 1px;
    height: 30px;
    background-color: var(--border-color);
    margin: 0 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin: 0;
}

.modal-header button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px auto;
}

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

/* AI Mockup Styles */
.ai-suggestion {
    margin-bottom: 20px;
    font-size: 1.05rem;
}

.mockup-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
}

.mockup-container h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.chat-bubble.user {
    background: #e0f2fe;
    color: #0369a1;
    border-bottom-left-radius: 2px;
    margin-right: 20px;
}

.chat-bubble.ai {
    background: white;
    border: 1px solid #e2e8f0;
    color: #334155;
    border-bottom-right-radius: 2px;
    margin-left: 20px;
}

/* Show hotspots visually when in interact mode */
body.mode-interact .hotspot:not(.revealed) {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.02); opacity: 0.8; }
    100% { transform: scale(1); opacity: 0.5; }
}