* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { 
    margin: 0; 
    padding: 0; 
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: manipulation;
    background: #f5f0e6;
    color: #3d3229;
}
body { padding: 10px; padding-bottom: 100px; background: #f5f0e6; color: #3d3229; }
h2 { margin: 10px 0; font-size: 24px; text-align: center; color: #3d3229; }

/* Camera container */
#camera-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 15px;
}
#reader {
    width: 100%;
    height: 300px;
    background: #222;
    border-radius: 12px;
    overflow: hidden;
    display: none; /* Hidden by default */
    position: relative;
}
#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
/* Scanner UI overrides */
#reader__dashboard_section_csr span {
    display: none !important; /* Hide the status text spam */
}
/* Camera wrapper for positioning guide */
.camera-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}
/* Tap-to-focus overlay */
.focus-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    cursor: pointer;
}
.focus-indicator {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid #4CAF50;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s ease-out;
    z-index: 60;
}
.focus-indicator.active {
    transform: translate(-50%, -50%) scale(1);
}
.focus-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
/* Barcode guide overlay */
.barcode-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 150px;
    border: 3px dashed #4CAF50;
    border-radius: 8px;
    pointer-events: none;
    z-index: 100;
    display: none;
}
.barcode-guide.active { display: block !important; }
.barcode-guide::before {
    content: "ALIGN BARCODE HERE";
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: #4CAF50;
    font-size: 12px;
    font-weight: bold;
    background: rgba(0,0,0,0.7);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Camera button */
.camera-btn {
    width: 100%;
    padding: 20px;
    font-size: 18px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
}
.camera-btn:active { background: #1976D2; }
.camera-btn.stop { background: #f44336; }
.camera-btn.stop:active { background: #d32f2f; }

/* Manual entry */
.manual-entry { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 15px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.manual-entry input { 
    flex: 1; 
    padding: 15px; 
    font-size: 18px;
    border: 2px solid #e8e0d0;
    border-radius: 10px;
    -webkit-appearance: none;
    background: #fffbf5;
    color: #3d3229;
}
.manual-entry input:focus {
    outline: none;
    border-color: #8b5a2b;
}
.manual-entry button { 
    padding: 15px 25px;
    font-size: 18px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}
.manual-entry button:active { background: #388E3C; }

/* Export button */
.export-btn {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 10px;
    display: block;
    padding: 18px;
    font-size: 18px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
}
.export-btn:active { background: #F57C00; }
.export-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Clear button */
.clear-btn {
    width: 100%;
    max-width: 500px;
    margin: 10px auto 10px;
    display: block;
    padding: 12px;
    font-size: 16px;
    background: #f5f5f5;
    color: #666;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
}
.clear-btn:active {
    background: #e0e0e0;
}

.stats { 
    text-align: center;
    font-size: 14px; 
    color: #8b7355;
    margin-bottom: 15px;
}
.stats span { font-weight: bold; color: #3d3229; }

/* Book list */
#list {
    max-width: 500px;
    margin: 0 auto;
}
.book { 
    padding: 15px; 
    border-bottom: 1px solid #e8e0d0; 
    font-size: 16px;
    background: #fffbf5;
}
.book.new { 
    background: #f0e6d6;
    border-left: 4px solid #8b5a2b;
}
.book-title { font-weight: 600; margin-bottom: 4px; }
.book-author { color: #8b7355; font-size: 14px; }
.book-isbn { color: #a09075; font-size: 12px; }

/* Book actions */
.book-actions { 
    margin-top: 10px; 
    display: flex; 
    gap: 8px; 
}
.book-actions button {
    padding: 6px 12px;
    font-size: 13px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
.btn-edit {
    background: #f0e6d6;
    color: #6d4620;
}
.btn-edit:active { background: #bbdefb; }
.btn-delete {
    background: #ffebee;
    color: #c62828;
}
.btn-delete:active { background: #ffcdd2; }

/* Edit modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fffbf5;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
}
.modal h3 { margin-top: 0; }
.modal input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e8e0d0;
    border-radius: 8px;
    margin-bottom: 12px;
    box-sizing: border-box;
    background: #fffbf5;
    color: #3d3229;
}
.modal input:focus {
    outline: none;
    border-color: #8b5a2b;
}
.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-buttons button {
    padding: 10px 20px;
    font-size: 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}
.btn-save {
    background: #6b8e4e;
    color: white;
}
.btn-save:active { background: #5a7a40; }
.btn-cancel {
    background: #f0e6d6;
    color: #6d4620;
}
.btn-cancel:active { background: #e0d6c6; }

/* Manual add modal */
.manual-isbn-display {
    background: #f0e6d6;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #6d4620;
    font-family: monospace;
}
.manual-isbn-display span {
    color: #333;
    font-weight: 600;
}

/* Empty state */
.empty {
    text-align: center;
    color: #8b7355;
    padding: 40px;
    font-size: 16px;
}

/* Scan feedback */
.scan-flash {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(76, 175, 80, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
}
.scan-flash.active { opacity: 1; }

/* Photo scan button */
.photo-scan {
    margin-top: 10px;
    text-align: center;
}
.photo-btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    background: #9C27B0;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}
.photo-btn:active {
    background: #7B1FA2;
}

/* Hamburger Menu */
.hamburger {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    min-width: auto;
    flex: none;
    background: #fffbf5;
    border: 1px solid #e8e0d0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 0;
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: #333;
    transition: all 0.3s;
    border-radius: 2px;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: #fffbf5;
    box-shadow: -2px 0 10px rgba(61,50,41,0.1);
    z-index: 1200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-nav.open {
    right: 0;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid #e8e0d0;
}

.nav-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-nav {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #666;
    padding: 0.25rem;
}

.mobile-nav ul {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.mobile-nav li a {
    display: block;
    padding: 1rem 1.25rem;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.mobile-nav li a:hover {
    background: #f0e6d6;
}

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1150;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.nav-overlay.open {
    opacity: 1;
    visibility: visible;
}
