/* Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; width: 100%; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #ffffff;
    color: #222222;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    padding: 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 6px 8px 6px;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 100;
    max-width: 100vw;
    overflow: hidden;
    margin: 0 0 12px 0;
}
.logo {
    height: 42px;
    width: auto;
    object-fit: contain;
}
.time-context {
    margin-top: 4px;
    margin-right: 10px;
    display: flex;
    gap: 6px;
    flex-shrink: 1;
    overflow-x: auto;
    max-width: 70%;
}
.time-badge { 
    background: #32CD32 !important; 
    color: #fff !important;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Card view (portrait) */
#tasks-container { padding: 0 8px; }
.task-card {
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.task-card.urgent { border-left: 4px solid #e74c3c; }
.task-card.important { border-left: 4px solid #f39c12; }
.task-card.urgent.important { border-left: 4px solid #e74c3c; box-shadow: inset 0 0 0 1px #f39c12; }
.task-description { 
    font-size: 1rem; 
    margin-bottom: 8px;
    line-height: 1.4;
    color: #000;
}
.task-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.7rem;
}
.task-meta span {
    background: #eee;
    padding: 2px 8px;
    border-radius: 3px;
}
.urgency-high { background: #ffebee !important; color: #c62828; }
.urgency-medium { background: #fff3e0 !important; color: #e65100; }
.urgency-medium-high { background: #fff3e0 !important; color: #d84315; }
.importance-high { background: #e8f5e9 !important; color: #2e7d32; }
.locale { background: #e3f2fd !important; color: #1565c0; }
.next-action {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

/* Table view (landscape) */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}
.task-table th, .task-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.task-table th {
    user-select: none;
    -webkit-user-select: none;
    background: #777;
    color: #fff !important;
    text-transform: capitalize;
    white-space: nowrap;
}
.task-table tr:nth-child(even) { background: #fafafa; }
.task-table tr:hover { background: #f0f0f0; }

/* Empty states */
.empty-bucket, .empty-table {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Landscape mode */
@media (orientation: landscape) {
    body { padding: 0; }
    .header {
        padding: 2px 12px;
        margin: 0;
    }
    .logo { height: 40px; }
    .time-badge {
        font-size: 0.85rem;
        padding: 5px 11px;
    }
}
/* Filter popup */
.filterable {
    cursor: pointer;
    position: relative;
}
.filterable:hover {
    background: #666;
}
.filter-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 200;
    min-width: 120px;
}
.filter-option {
    padding: 8px 12px;
    cursor: pointer;
    color: #333;
}
.filter-option:hover {
    background: #f0f0f0;
}
.filter-option.disabled {
    color: #ccc;
    cursor: default;
}
.filter-option.disabled:hover {
    background: #fff;
}
.filter-divider {
    border-top: 1px solid #ddd;
    margin: 4px 0;
}
.filterable.filtered {
    background: #555;
}
/* Edit popup */
.editable {
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    position: relative;
}
.editable:hover {
    background: #e8f5e9;
}
.edit-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 200;
    min-width: 120px;
}
.edit-option {
    padding: 8px 12px;
    cursor: pointer;
    color: #333;
}
.edit-option:hover {
    background: #e8f5e9;
}
/* Text edit input */
.edit-input {
    border: 2px solid #32CD32;
    padding: 6px;
    font-size: 0.7rem;
    font-family: inherit;
    z-index: 200;
    box-sizing: border-box;
}
/* Prevent wrapping on most columns */
.task-table td {
    white-space: nowrap;
}
.task-table td:nth-child(2),
.task-table td:nth-child(15) {
    white-space: normal;
    min-width: 200px;
}
/* Multi-select filter */
.filter-option.selectable {
    cursor: pointer;
}
.filter-option.selected, .filter-option.selectable.selected {
    background: #32CD32 !important;
    color: #fff !important;
}
.filter-buttons {
    display: flex;
    gap: 4px;
    padding: 8px;
}
.filter-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    background: #32CD32 !important;
    color: #fff !important;
}
.filter-btn.clear {
    background: #999;
}
.filter-btn:hover {
    opacity: 0.9;
}
/* Quick win dot */
.quick-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #32CD32;
    border-radius: 50%;
    margin-left: 6px;
    border: 1px solid #228B22;
    vertical-align: -2px;
}
/* Locale popup */
.locale-popup {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 200;
    min-width: 120px;
}
/* ============ VOICE MIC BAR ============ */
.voice-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #ddd;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 500;
}

.mic-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mode-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: #f0f0f0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 1;
    overflow-x: auto;
    max-width: 70%;
    transition: all 0.2s;
}
.mode-btn:hover { background: #e8e8e8; }
.mode-btn.active {
    background: #32CD32;
    color: #fff;
    border-color: #32CD32;
}

.mic-bar {
    flex: 1;
    height: 56px;
    border-radius: 28px;
    border: 1px solid #bbb;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.mic-bar.idle { background: #f0f0f0; color: #666; }
.mic-bar.listening {
    background: linear-gradient(135deg, #32CD32, #228B22);
    color: #fff;
    animation: pulse 1.5s ease-in-out infinite;
}
.mic-bar.processing { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.mic-bar.speaking { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.02); opacity: 0.9; }
}

.mic-icon { width: 24px; height: 24px; fill: currentColor; }

.wave-bars { display: flex; gap: 3px; align-items: center; height: 24px; }
.wave-bar {
    width: 4px;
    background: #fff;
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}
.wave-bar:nth-child(1) { height: 8px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 12px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 14px; animation-delay: 0.4s; }

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

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.model-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 1;
    overflow-x: auto;
    max-width: 70%;
}

#voiceInput { position: absolute; opacity: 0; pointer-events: none; }

body { padding-bottom: 90px; }

@media (orientation: landscape) {
    .voice-section { padding: 8px 16px; }
    .mic-bar { height: 48px; }
    body { padding-bottom: 70px; }
}

/* Archived section */
.archived-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #444;
}
.archived-header {
    color: #666;
    font-size: 14px;
    padding: 10px;
    cursor: pointer;
}
.archived-header:hover {
    color: #888;
}
.task-card.archived {
    
    
}
.task-card.completed {
    opacity: 0.7;
    text-decoration: line-through;
}

.archived-row td {
    
    
}
.archived-row td { color: #888 !important; font-style: italic; }
.task-card.archived { color: #888 !important; font-style: italic; }
