* {
    -webkit-tap-highlight-color: transparent !important;
}

/* Prevent horizontal screen drift globally */
html { overflow-x: hidden; }

/* Restored exactly to your original working layout */
body { font-family: system-ui, -apple-system, sans-serif; background: #f4f5f7; margin: 0; padding: 20px; color: #172b4d; overflow-x: hidden; }
button, a, .card, .tab, .clickable-title, .icon-btn, .clickable-crumb { -webkit-tap-highlight-color: transparent; }

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.header-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button { background: #0052cc; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; font-family: inherit; transition: background 0.1s; }
button:hover { background: #0043a6; }
button.secondary { background: #dfe1e6; color: #172b4d; }
button.secondary:hover { background: #c1c7d0; }
button.danger { background: transparent; color: #de350b; padding: 4px 8px; font-size: 12px; margin: 0; }
button.danger:hover { background: #ffebe6; }
button.danger-solid { background: #de350b; color: white; }
button.danger-solid:hover { background: #bf2608; }
button.edit { background: transparent; color: #5e6c84; padding: 4px 8px; font-size: 12px; margin: 0; }
button.edit:hover { background: #ebecf0; }
button.action-success { background: transparent; color: #36b37e; padding: 4px 8px; font-size: 12px; margin: 0; }
button.action-success:hover { background: #e3fcef; }
button.action-primary { background: transparent; color: #0052cc; padding: 4px 8px; font-size: 12px; margin: 0; }
button.action-primary:hover { background: #e6fcff; }
button.action-warning { background: transparent; color: #ff991f; padding: 4px 8px; font-size: 12px; margin: 0; }
button.action-warning:hover { background: #fff5e6; }

.clickable-title { cursor: pointer; transition: color 0.2s; user-select: none; }
.clickable-title:hover { color: #0052cc; }

.gear-btn { background: transparent; color: #5e6c84; font-size: 20px; padding: 4px 8px; line-height: 1; }
.gear-btn:hover { background: #ebecf0; color: #172b4d; }

/* FIX: flex-wrap nowrap prevents screen widening, flex-shrink 0 allows perfect swiping */
.project-tabs { display: flex; gap: 8px; margin-bottom: 15px; border-bottom: 2px solid #dfe1e6; padding-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.tab { display: flex; align-items: center; gap: 8px; background: transparent; color: #5e6c84; border: none; padding: 8px 16px; border-radius: 4px; cursor: grab; font-weight: bold; font-size: 14px; transition: opacity 0.2s ease; flex-shrink: 0; white-space: nowrap; }
.tab:active { cursor: grabbing; }
.tab:hover { background: #ebecf0; }
.tab.active { background: #0052cc; color: white; }
.tab.add-new { color: #0052cc; border: 1px dashed #0052cc; cursor: pointer; }
.tab.add-new:hover { background: #e6fcff; }
.tab.dragging-tab { opacity: 0.4; transform: scale(0.98); } 
.delete-project { background: rgba(255,255,255,0.2); border-radius: 50%; width: 20px; height: 20px; display: inline-flex; justify-content: center; align-items: center; font-size: 14px; line-height: 1; padding: 0; margin-left: 5px; cursor: pointer;}
.delete-project:hover { background: #de350b; color: white; }

.tools-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
.view-toggles { display: flex; background: #dfe1e6; border-radius: 6px; padding: 4px; flex-wrap: wrap; gap: 2px; }
.view-toggle { background: transparent; color: #42526e; border-radius: 4px; padding: 6px 16px; margin: 0; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.view-toggle:hover { background: rgba(255,255,255,0.5); }
.view-toggle.active { background: white; color: #172b4d; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.view-toggle.active-blue { background: #e6fcff; color: #0052cc; font-weight: bold; box-shadow: 0 1px 2px rgba(0,82,204,0.15); border: 1px solid #b3d4ff; }

.search-badge { background: #de350b; color: white; font-size: 11px; padding: 2px 6px; border-radius: 10px; font-weight: bold; line-height: 1; }

.filters-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters-bar input[type="text"], .filters-bar select { padding: 6px 10px; border: 1px solid #dfe1e6; border-radius: 4px; outline: none; font-family: inherit; font-size: 14px; box-sizing: border-box; }
.filters-bar input:focus, .filters-bar select:focus { border-color: #4c9aff; }

.icon-btn { background: white; border: 1px solid #dfe1e6; border-radius: 4px; padding: 6px 12px; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; font-size: 16px; height: 35px; }
.icon-btn:hover { background: #ebecf0; border-color: #c1c7d0; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.board { display: flex; gap: 20px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.column { flex: 1; min-width: 260px; background: #ebecf0; padding: 12px; border-radius: 6px; min-height: 400px; display: flex; flex-direction: column; }
.column-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.column-header h2 { font-size: 14px; text-transform: uppercase; color: #5e6c84; margin: 0; }
.add-icon { background: transparent; color: #5e6c84; padding: 2px 8px; font-size: 18px; line-height: 1; }
.add-icon:hover { background: #dfe1e6; color: #172b4d; }
.task-list { flex: 1; min-height: 100px; display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; }

.single-column-board { display: none; max-width: 800px; margin: 0 auto; width: 100%; }
.single-column-board .column { background: transparent; padding: 0; min-height: auto; }
.single-column-board .column-header { border-bottom: 2px solid #dfe1e6; padding-bottom: 10px; margin-bottom: 20px; }

.dot { height: 10px; width: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.low { background-color: #36b37e; }
.dot.medium { background-color: #ff991f; }
.dot.high { background-color: #de350b; }
.badge { background: #e6fcff; color: #006644; border-radius: 12px; font-weight: bold; display: inline-flex; align-items: center; gap: 4px; }
.badge.subtask-badge { background: #eae6ff; color: #403294; }
.date-badge { font-size: 12px; color: #5e6c84; display: inline-flex; align-items: center; gap: 4px; background: #f4f5f7; padding: 2px 6px; border-radius: 4px; border: 1px solid #dfe1e6; }

/* Task Cards */
.card { background: white; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); border: 1px solid #dfe1e6; cursor: pointer; transition: box-shadow 0.2s ease, border-color 0.2s ease; display: flex; flex-direction: column; position: relative; }
.card:hover { border-color: #b3d4ff; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.card.dragging { opacity: 0.4; cursor: grabbing; box-shadow: 0 8px 16px rgba(0,0,0,0.15); transform: scale(1.02); }

.card-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px;}
.card h3 { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: #172b4d; line-height: 1.2; word-break: break-word; flex: 1; }
.card p { color: #42526e; line-height: 1.4; margin: 0; word-break: break-word; }

.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.meta-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; pointer-events: none; }

.card .actions { opacity: 0; transition: opacity 0.2s ease; display: flex; gap: 2px; pointer-events: auto; }
.card:hover .actions { opacity: 1; }

.context-crumb { font-size: 10px; color: #8993a4; margin-bottom: 4px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; }
.clickable-crumb { cursor: pointer; transition: color 0.2s ease; display: inline-block; }
.clickable-crumb:hover { color: #0052cc; text-decoration: underline; }

/* SIZES */
.board-container.size-big .card { padding: 16px; gap: 12px; }
.board-container.size-big .card h3 { font-size: 16px; pointer-events: none; }
.board-container.size-big .card p { font-size: 14px; }
.board-container.size-big .badge { font-size: 12px; padding: 4px 8px; }
.board-container.size-big .card-footer { border-top: 1px solid #ebecf0; padding-top: 12px; }

.board-container.size-medium .card { padding: 12px; gap: 8px; }
.board-container.size-medium .card h3 { font-size: 14px; pointer-events: none; }
.board-container.size-medium .card p { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.board-container.size-medium .badge { font-size: 11px; padding: 3px 6px; }

.board-container.size-small .card { padding: 8px 12px; gap: 6px; }
.board-container.size-small .card h3 { font-size: 13px; pointer-events: none;}
.board-container.size-small .card p { display: none; } 
.board-container.size-small .badge { font-size: 10px; padding: 2px 5px; }

.custom-context-menu { display: none; position: fixed; background: white; border: 1px solid #dfe1e6; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-radius: 6px; z-index: 10000; overflow: hidden; min-width: 140px; padding: 4px 0; }
.custom-context-menu button { display: block; width: 100%; text-align: left; background: transparent; color: #172b4d; border: none; padding: 8px 16px; font-size: 14px; border-radius: 0; cursor: pointer; font-weight: normal; }
.custom-context-menu button:hover { background: #ebecf0; }
.custom-context-menu button.danger-text { color: #de350b; }
.custom-context-menu button.success-text { color: #36b37e; }

/* Modals / Forms */
dialog { border: none; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); padding: 24px; width: 100%; max-width: 380px; box-sizing: border-box; }
dialog::backdrop { background: rgba(9, 30, 66, 0.54); }
.modal-header-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; border-bottom: 2px solid #ebecf0; padding-bottom: 12px; }
.modal-header-row h2 { margin: 0; flex: 1; font-size: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 14px; }
.form-group input[type="text"], .form-group input[type="date"], .form-group input[type="email"], .form-group textarea, .form-group select { width: 100%; padding: 8px; border: 2px solid #dfe1e6; border-radius: 4px; box-sizing: border-box; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: #4c9aff; outline: none; }
.checkbox-group { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; margin: 0; }
.list-container { border: 1px solid #dfe1e6; border-radius: 4px; padding: 8px; background: #fafbfc; max-height: 140px; overflow-y: auto; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 6px; font-size: 13px; background: white; padding: 6px; border: 1px solid #ebecf0; border-radius: 4px; cursor: pointer; transition: all 0.2s ease; }
.list-item input[type="checkbox"] { cursor: pointer; margin: 0; }
.list-item .title { flex: 1; word-break: break-word; pointer-events: none; }
.list-item .meta { font-size: 11px; color: #5e6c84; font-weight: normal; margin-left: 6px; }
.list-actions { opacity: 0; transition: opacity 0.2s ease; display: flex; gap: 4px; }
.list-item:hover .list-actions { opacity: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.settings-section-title { font-size: 12px; text-transform: uppercase; color: #5e6c84; font-weight: bold; margin-bottom: 10px; border-bottom: 1px solid #dfe1e6; padding-bottom: 4px; margin-top: 24px; }

.mobile-fab { display: none; } 
.card-menu-btn { display: none; } 

/* Global Indicator for Background Timers */
#global-timer-indicator {
    display: none; position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #172b4d; color: white; padding: 10px 24px; border-radius: 30px; font-weight: bold; 
    font-size: 14px; z-index: 9999; box-shadow: 0 8px 16px rgba(0,0,0,0.2); cursor: pointer;
    align-items: center; gap: 8px; border: 2px solid #ffffff; transition: transform 0.2s ease;
}
#global-timer-indicator:hover { transform: translateX(-50%) scale(1.05); }

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #ebecf0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}

.modal-tab {
    background: transparent;
    color: #5e6c84;
    font-weight: bold;
    font-size: 14px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 8px 12px;
    margin-bottom: -2px; 
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.modal-tab:hover {
    color: #172b4d;
    background: #fafbfc;
}

.modal-tab.active {
    color: #0052cc;
    border-bottom: 2px solid #0052cc;
}

.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }

/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 768px) {
    body { padding: 10px; }
    .header { flex-direction: column; align-items: stretch; gap: 15px; }
    .header-controls { justify-content: flex-end; width: 100%; flex-wrap: nowrap; }
    
    .tools-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .filters-bar { flex-direction: column; width: 100%; align-items: stretch; gap: 10px; }
    
    .mobile-fab {
        display: flex; position: fixed; bottom: 24px; right: 24px;
        width: 56px; height: 56px; border-radius: 50%;
        background: #0052cc; color: white;
        justify-content: center; align-items: center; font-size: 28px;
        box-shadow: 0 4px 12px rgba(0,82,204,0.4);
        z-index: 1000; cursor: pointer; border: none;
    }

    #global-timer-indicator { bottom: 90px; } 

    .card .actions { display: none !important; } 
    .card-menu-btn { 
        display: flex; align-items: center; justify-content: center;
        width: 32px; height: 32px; border-radius: 4px;
        background: transparent; color: #5e6c84; font-size: 20px; font-weight: bold;
        margin: -4px -8px 0 0; cursor: pointer;
    }
    .card-menu-btn:active { background: #ebecf0; }

    .board { scroll-snap-type: x mandatory; padding-bottom: 20px; margin: 0 -10px; padding: 0 10px 20px 10px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
    .column { min-width: 88vw; scroll-snap-align: center; margin-right: 10px; }
    .board::after { content: ''; padding-right: 2vw; }
    
    .custom-context-menu {
        position: fixed !important; bottom: 0 !important; top: auto !important; left: 0 !important;
        width: 100% !important; border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2); padding: 10px 0 30px 0;
        animation: slideUp 0.2s ease-out;
    }
    .custom-context-menu button { padding: 16px; font-size: 16px; text-align: center; border-bottom: 1px solid #ebecf0; }
    
    dialog { 
        position: fixed !important; 
        top: 0 !important; 
        bottom: 0 !important; 
        left: 0 !important;
        margin: 0 !important; 
        width: 100% !important; 
        max-width: 100% !important; 
        height: 100% !important; 
        max-height: 100% !important; 
        border-radius: 0 !important; 
        overflow-y: auto; 
        -webkit-overflow-scrolling: touch; 
        padding: 20px 20px 100px 20px !important; 
        box-sizing: border-box;
        animation: slideUp 0.2s ease-out;
    }

    .form-group input, .form-group textarea, .form-group select { padding: 12px !important; font-size: 16px !important; }
    
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}
