* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-color: #1f2937;
    --bg-color: #f9fafb;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    overscroll-behavior: none;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background: var(--success-color);
    animation: none;
}

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

/* Input Container */
.input-container {
    margin-bottom: 20px;
}

#taskInput {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

#taskInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons Grid */


.action-btn {
    min-height: 88px;
    padding: 16px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.2s;
    box-shadow: var(--shadow);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.action-btn .emoji {
    font-size: 32px;
    line-height: 1;
}

.action-btn .label {
    font-size: 14px;
}

.action-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

.action-btn.recording {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* More Button */
.more-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.more-btn:active {
    transform: scale(0.98);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}

.overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin: 16px;
    max-width: 400px;
    width: 100%;
    position: relative;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-content h2 {
    margin-bottom: 16px;
    font-size: 20px;
}

/* Recording Overlay */
.recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s;
}

.recording-overlay.hidden {
    display: none;
}

.recording-content {
    text-align: center;
    color: white;
}

.mic-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.cancel-icon {
    font-size: 80px;
    margin-bottom: 20px;
    color: var(--danger-color);
}

.cancel-icon.hidden {
    display: none;
}

#recordingText {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
}

.recording-wave {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.recording-wave span {
    width: 4px;
    height: 20px;
    background: white;
    border-radius: 2px;
    animation: wave 1s infinite ease-in-out;
}

.recording-wave span:nth-child(2) { animation-delay: 0.1s; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(2); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-color);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s, slideOut 0.3s 2.7s;
    pointer-events: auto;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* Queue Indicator */
.queue-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 100;
}

.queue-indicator.hidden {
    display: none;
}

#queueCount {
    font-weight: 700;
}

/* Safe Area Insets for iOS */
@supports (padding: max(0px)) {
    body {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Responsive */
@media (max-width: 380px) {
    .action-btn {
        min-height: 76px;
        padding: 12px;
    }
    
    .action-btn .emoji {
        font-size: 28px;
    }
    
    .action-btn .label {
        font-size: 12px;
    }
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-screen.hidden {
    display: none;
}

.login-container {
    width: 90%;
    max-width: 400px;
    padding: 32px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.login-container h1 {
    text-align: center;
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 24px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#loginForm input {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

#loginForm input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--primary-hover);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-error {
    color: var(--danger-color);
    font-size: 14px;
    text-align: center;
    padding: 8px;
    background: #fee;
    border-radius: 6px;
}

.login-error.hidden {
    display: none;
}

/* Success Animation */
.success-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
}

.success-animation.hidden {
    display: none;
}

.success-checkmark {
    font-size: 80px;
    color: #22c55e;
    animation: fadeInOut 1.5s ease-in-out;
}

@keyframes fadeInOut {
    0% { 
        opacity: 0; 
        transform: scale(0.8);
    }
    20% { 
        opacity: 1; 
        transform: scale(1);
    }
    80% { 
        opacity: 1; 
        transform: scale(1);
    }
    100% { 
        opacity: 0; 
        transform: scale(1.2);
    }
}

/* Date Picker Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #1e293b;
}

.modal-content input[type="datetime-local"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 16px;
}

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

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:active {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:active {
    background: #cbd5e1;
}

/* Main buttons grid: 2x2 layout */




/* Hide iOS QuickType bar */
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    -webkit-user-select: text;
}

/* Prevent iOS zoom on input focus */
input,
textarea,
select {
    font-size: 16px !important;
}

/* Override: Make main buttons half height */


/* Update for 5 main buttons - flexible grid */



/* Black title */
h1 {
    color: #000000 !important;
}

.app-title {
    color: #000000 !important;
}

/* Minimal Recording Indicator */
.recording-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.recording-indicator.hidden {
    display: none;
}

.recording-dot {
    animation: pulse 1.5s infinite;
}

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

/* Button pressed state */
.action-btn.recording {
    transform: scale(0.95);
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3) !important;
    background: #1d4ed8 !important;
}


/* Clean 3x2 Grid Layout - FINAL */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
}

.buttons-grid .action-btn {
    aspect-ratio: 1 / 1 !important;
    font-size: 14px !important;
}

/* Status Indicator - Hidden by default, breathing during recording */
.status-indicator {
    display: none !important;
}

.status-indicator.recording {
    display: block !important;
    animation: breathe 2s ease-in-out infinite !important;
}

@keyframes breathe {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.4);
        opacity: 0.7;
    }
}

/* Photo Buttons Container */
.input-container {
    position: relative;
}

.photo-buttons {
    position: absolute;
    right: 8px;
    top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.photo-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-btn:active {
    transform: scale(0.95);
    background: #f1f5f9;
}

.photo-btn.has-photo {
    border-color: #10b981;
    background: #ecfdf5;
}

.photo-icon {
    font-size: 24px;
}

/* Photo Preview */
.photo-preview {
    margin: 12px 0;
    position: relative;
    border: 2px solid #10b981;
    border-radius: 8px;
    padding: 8px;
    background: #ecfdf5;
}

.photo-preview.hidden {
    display: none;
}

.photo-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-photo:active {
    background: rgba(220, 38, 38, 1);
}

/* Make textarea narrower to accommodate photo buttons */
.input-container textarea {
    padding-right: 60px !important; /* Space for photo buttons */
}

/* Multi-Photo Preview Container */
.photo-preview-container {
    margin: 12px 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.photo-preview-container.hidden {
    display: none;
}

.photo-preview-item {
    position: relative;
    border: 2px solid #10b981;
    border-radius: 8px;
    overflow: hidden;
    background: #ecfdf5;
    aspect-ratio: 1;
}

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

.remove-photo-item {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-photo-item:active {
    background: rgba(220, 38, 38, 1);
}

/* Fix Input Container Layout - Flexbox */
.input-container {
    display: flex !important;
    gap: 8px !important;
    align-items: flex-start !important;
}

.input-container textarea {
    flex: 1 !important;
    padding-right: 12px !important; /* Reset padding */
    min-width: 0 !important; /* Allow shrinking */
}

.photo-buttons {
    position: static !important; /* Not absolute anymore */
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    flex-shrink: 0 !important; /* Don't shrink */
}

/* Add spacing above More button */
.more-btn {
    margin-top: 12px !important;
}
