:root {
    --bg-paper: #F8F7F4;
    --ink-black: #1A1A1A;
    --accent: #2A2A2A;
    --border-w: 1.5px;
}

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

body {
    background-color: #E6E1D6;
    /* Desktop background showing the phone app over it */
    color: var(--ink-black);
    font-family: 'Inter', -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* The Mobile Phone Container */
#app {
    width: 100%;
    height: 100vh;
    background: var(--bg-paper);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media(min-width: 500px) {
    #app {
        height: 90vh;
        max-height: 850px;
        max-width: 414px;
        /* iPhone Max Width */
        border-radius: 44px;
        border: 4px solid var(--ink-black);
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.15);
    }
}

/* Views Handling */
.view {
    display: none;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
}

.view.active {
    display: flex;
}

/* App Navbar */
.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) 20px 16px;
    background: var(--bg-paper);
    border-bottom: 2px solid var(--ink-black);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-title {
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-btn {
    font-size: 16px;
    font-weight: 600;
    background: none;
    border: none;
    color: var(--ink-black);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn-right {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border: 2px solid var(--ink-black);
    border-radius: 20px;
    background: var(--bg-paper);
}

/* Scroll Area for Content */
.content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 120px;
    /* Space for sticky bottom button */
}

/* Sketch Cards (Setup Options) */
.sketch-section {
    background: #FFF;
    border: var(--border-w) solid var(--ink-black);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.15);
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    color: var(--ink-black);
}

/* Frame Grid */
.frame-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.frame-item {
    aspect-ratio: 0.85;
    border: 2px solid rgba(26, 26, 26, 0.2);
    border-radius: 8px;
    background: var(--bg-paper);
    display: flex;
    flex-direction: column;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.frame-item.active {
    border-width: 2.5px;
    border-color: var(--ink-black);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #FFF;
}

.frame-preview {
    flex: 1;
    background: #E5E5E5;
    border: 1px solid var(--ink-black);
}

.frame-label {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin-top: 6px;
}

/* Filter Line / Toggle Row */
.sketch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.sketch-divider {
    height: 1px;
    background: rgba(26, 26, 26, 0.15);
}

/* Sketch Input */
.sketch-input {
    width: 100%;
    border: 2px solid rgba(26, 26, 26, 0.3);
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    background: var(--bg-paper);
    outline: none;
    transition: all 0.2s;
}

.sketch-input:focus {
    border-color: var(--ink-black);
    background: #FFF;
    box-shadow: 4px 4px 0px rgba(26, 26, 26, 0.1);
}

/* Toggles */
.toggle-group {
    display: flex;
    border: 2px solid var(--ink-black);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-paper);
}

.toggle-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: transparent;
    transition: background 0.2s;
    border-left: 1px solid var(--ink-black);
}

.toggle-btn:first-child {
    border-left: none;
}

.toggle-btn.active {
    background: #E5E5E5;
}

/* Sticky Bottom Button */
.sticky-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, var(--bg-paper) 70%, transparent);
    z-index: 50;
}

.action-btn {
    width: 100%;
    padding: 18px;
    background: var(--ink-black);
    color: #FFF;
    font-size: 18px;
    font-weight: 700;
    border-radius: 14px;
    border: 3px solid var(--ink-black);
    box-shadow: 0 6px 18px rgba(26, 26, 26, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

.action-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px rgba(26, 26, 26, 0.2);
}

/* Camera Screen (CaptureView) */
.camera-wrapper {
    margin: 0 20px;
    border: 3px solid var(--ink-black);
    border-radius: 12px;
    background: #FFF;
    overflow: hidden;
    position: relative;
    aspect-ratio: 3/4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    background: #222;
}

/* Camera Overlays */
#flash-overlay {
    position: absolute;
    inset: 0;
    background: #FFF;
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.1s ease-out;
}

.camera-ready {
    position: absolute;
    inset: 0;
    background: rgba(248, 247, 244, 0.9);
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.camera-ready h2 {
    font-size: 32px;
    font-weight: 800;
    font-family: -apple-system, sans-serif;
}

.camera-ready button {
    width: auto;
    padding: 12px 30px;
    font-size: 16px;
}

#countdown-text {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 160px;
    font-weight: 800;
    color: #FFF;
    text-shadow: 0 6px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Photo Slots */
.photo-slots {
    display: flex;
    justify-content: space-between;
    margin: 24px 20px;
    gap: 12px;
}

.photo-slot {
    flex: 1;
    aspect-ratio: 3/4;
    border: 2px solid var(--ink-black);
    border-radius: 8px;
    background: #FFF;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    color: rgba(26, 26, 26, 0.2);
    box-shadow: 4px 4px 0px rgba(26, 26, 26, 0.1);
    overflow: hidden;
}

.photo-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Result View */
.result-canvas-container {
    padding: 10px 30px 30px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#final-canvas {
    width: 100%;
    height: auto;
    border: 2px solid rgba(26, 26, 26, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.btn-group-row {
    display: flex;
    gap: 16px;
    margin: 0 20px;
}

.btn-secondary {
    flex: 1;
    padding: 16px;
    background: #FFF;
    font-size: 17px;
    font-weight: 700;
    border: 3px solid var(--ink-black);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-primary {
    flex: 1;
    padding: 16px;
    background: var(--accent);
    font-size: 17px;
    font-weight: 800;
    border: 3px solid var(--ink-black);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    color: #FFF;
}