@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&family=Inter:wght@400;700&family=Courier+Prime:wght@400;700&display=swap');

:root {
    --bg-dark: #0a0a0c;
    --bg-card: rgba(28, 28, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-cyan: #00f2ff;
    --accent-purple: #7000ff;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --success: #00ff88;
    --danger: #ff4b4b;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* === GLASSMORPHISM CARDS === */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

.brand-container {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-tag {
    font-size: 9px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

#connectBtn {
    background: var(--accent-cyan);
    color: #000;
    border: none;
    padding: 8px 18px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

#connectBtn.connected {
    background: var(--success);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

/* === MAIN CANVAS AREA (LANDSCAPE) === */
.canvas-wrapper {
    position: relative;
    width: calc(100% - 10px);
    /* Larger canvas */
    aspect-ratio: 1.5 / 1;
    /* Horizontal Force */
    margin: 5px auto 25px auto;
    /* More compact margins */
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    flex-grow: 0;
    /* Don't grow vertically, maintain ratio */
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
}

#canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* === FLOATING ACTIONS === */
.floating-top-right {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 50;
}

#modeSelector {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
    font-size: 12px;
    outline: none;
}

.action-btn {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    cursor: pointer;
}

/* === ZOOM CONTROLS === */
#zoomControls {
    position: absolute;
    bottom: 20px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 50;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: #fff;
    border-radius: 14px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

/* === CAPTURES BAR === */
.captures-bar {
    height: 80px;
    padding: 10px 15px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    border-top: 1px solid var(--glass-border);
    scrollbar-width: none;
}

.captures-bar::-webkit-scrollbar {
    display: none;
}

.thumb {
    height: 60px;
    min-width: 60px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    object-fit: contain;
}

/* === FOOTER NAV === */
.footer-nav {
    height: auto;
    min-height: 85px;
    /* Taller footer */
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-top: 10px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
    /* Stronger lift */
    background: rgba(10, 10, 12, 0.9);
    border-top: 1px solid var(--glass-border);
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent-cyan);
}

.nav-icon {
    font-size: 22px;
}

/* === SETTINGS PAGE === */
#settingsPage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding: 30px 20px;
    overflow-y: auto;
}

#settingsPage.open {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

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

.settings-header h1 {
    font-size: 24px;
    font-weight: 600;
}

#closeSettings {
    background: var(--bg-card);
    border: none;
    color: var(--accent-cyan);
    padding: 8px 20px;
    border-radius: 12px;
    font-weight: 600;
}

.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 5px 20px;
    margin-bottom: 25px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--glass-border);
}

.settings-row:last-child {
    border-bottom: none;
}

/* IOS SWITCH */
.ios-switch {
    width: 44px;
    height: 24px;
    position: relative;
    display: inline-block;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3a3a3c;
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* SELECT / INPUT */
.ios-select {
    background: transparent;
    color: var(--accent-cyan);
    border: none;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    text-align: right;
}

/* === OCR TOAST === */
#ocrResult {
    position: fixed;
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 242, 255, 0.95);
    color: #000;
    padding: 10px 25px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 500;
    display: none;
    animation: bounceIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes bounceIn {
    from {
        transform: translateX(-50%) scale(0.5);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* === PRINT OVERLAY === */
#printOverlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    font-size: 72px;
    color: #000;
    font-weight: 700;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#printOverlay.show {
    opacity: 0.9;
    transform: translate(-50%, -52%) scale(1.05);
}

/* === DEBUG PANEL === */
#debug {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: rgba(10, 10, 12, 0.95);
    border-top: 1px solid var(--glass-border);
    color: #00ff88;
    font-family: monospace;
    font-size: 11px;
    padding: 15px;
    overflow-y: auto;
    z-index: 3000;
    display: none;
}