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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.header .version {
    font-size: 12px;
    font-weight: 500;
    color: #999;
    margin-left: 8px;
}

.clear-btn {
    padding: 8px 16px;
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.clear-btn.disabled,
.clear-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    pointer-events: none;
}

/* List container */
.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 140px;
    -webkit-overflow-scrolling: touch;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state .hint {
    font-size: 14px;
    color: #bbb;
}

/* List items */
.list-item {
    background: white;
    margin-bottom: 8px;
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.list-item.purchased {
    opacity: 0.5;
    background: #f0f0f0;
}

.list-item.purchased .item-text {
    text-decoration: line-through;
    color: #999;
}

.list-item .checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 50%;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.list-item.purchased .checkbox {
    background: #34c759;
    border-color: #34c759;
}

.list-item.purchased .checkbox::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.item-text {
    flex: 1;
    font-size: 19px;
    color: #333;
}

/* Voice button container */
.voice-button-container {
    padding: 12px;
    padding-bottom: env(safe-area-inset-bottom);
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1200; /* above banners */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* FAB container (floating) */
.fab-container {
    position: fixed;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 1300;
    pointer-events: none; /* only the button handles clicks */
}

.voice-button {
    width: 80px;
    height: 80px;
    background: #007aff;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 48px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    touch-action: none; /* reduce accidental scroll/move cancels */
    box-shadow: 0 8px 16px rgba(0,0,0,0.24), 0 2px 6px rgba(0,0,0,0.16);
    pointer-events: auto;
}

.voice-button:active {
    transform: scale(0.9);
    background: #0051d5;
}

.voice-button.recording {
    background: #ff3b30;
    animation: pulse 1.5s infinite;
}

.voice-button.processing {
    background: #ff9500;
}

.voice-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(255, 59, 48, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
    }
}

.voice-hint {
    text-align: right;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 12px;
    max-width: 70vw;
}

.voice-status {
    text-align: right;
    background: rgba(0,0,0,0.6);
    color: #ddd;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    min-height: 0;
    max-width: 70vw;
}

/* Hide status chip when empty */
.voice-status:empty { display: none; }

/* Processing indicator */
.processing-item {
    background: #f0f0f0;
    margin-bottom: 8px;
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.processing-item .dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite;
}

.processing-item .dot:nth-child(1) { animation-delay: -0.32s; }
.processing-item .dot:nth-child(2) { animation-delay: -0.16s; }
.processing-item .dot:nth-child(3) { animation-delay: 0; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.3);
    }
}

/* Undo snackbar */
.undo-snackbar {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.undo-snackbar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.undo-btn {
    background: none;
    border: none;
    color: #007aff;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

/* Keep undo text on a single line */
.undo-snackbar #undoText { white-space: nowrap; }

/* Update banner for PWA */
.update-banner {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 10px 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1100;
    pointer-events: none; /* let touches pass through except buttons */
}

.update-banner.show, .update-banner[style*="display: flex"] {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.update-btn {
    background: #007aff;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto; /* clickable even if banner ignores events */
}
.update-btn:disabled {
    background: #9fc2ff;
    cursor: default;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 320px;
    text-align: center;
}

.modal h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.modal p {
    color: #666;
    margin-bottom: 24px;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.modal-btn.cancel {
    background: #f0f0f0;
    color: #333;
}

.modal-btn.confirm {
    background: #007aff;
    color: white;
}

/* Debug overlay */
#debugOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.debug-panel {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    width: 92%;
    max-width: 360px;
    font-size: 14px;
}
.debug-panel h3 { margin-bottom: 8px; font-size: 18px; }
.debug-row { margin: 6px 0; color: #333; }
.debug-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.debug-actions button {
    flex: 1 1 auto;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    color: #333;
    font-weight: 500;
}
