:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
}

.container-math {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.left-panel, .right-panel {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.left-panel {
    flex: 1;
    min-width: min(300px, 100%);
}

.right-panel {
    flex: 2;
    min-width: min(500px, 100%);
}

.formula {
    font-size: clamp(1.1em, 3vw, 1.5em);
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    word-wrap: break-word;
}

.properties {
    margin: 20px 0;
}

.property {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    transition: transform 0.2s;
}

.property:hover {
    transform: translateY(-2px);
}

.definition {
    background-color: #e8f4fc;
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    border-left: 4px solid var(--primary-color);
}

.definition-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.sliders {
    margin-top: 30px;
}

.slider-container {
    margin-bottom: 20px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    /* Better touch target */
    padding: 8px 0;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.examples {
    margin-top: 30px;
}

.example-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.example-btn {
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    flex-grow: 1;
    min-width: 120px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.16);
    /* Touch-friendly */
    min-height: 44px;
    font-size: 0.9rem;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.example-btn:hover,
.example-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.example-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.16);
}

.example-btn.secondary {
    background: #95a5a6;
}

.example-btn.secondary:hover,
.example-btn.secondary:focus {
    background: #7f8c8d;
}

.zero-point, .y-intercept {
    margin-top: 15px;
    padding: 15px;
    background-color: #e8f4fc;
    border-radius: 5px;
    border-left: 4px solid var(--primary-color);
}

.math-value {
    font-weight: bold;
    color: var(--secondary-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    /* Touch-friendly tap target */
    padding: 8px;
    margin: -8px -8px 0 0;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover,
.close:focus {
    color: #000;
    outline: 2px solid rgba(0,0,0,0.1);
    border-radius: 4px;
}

.close:active {
    color: #333;
}

/* Highlight active note in notes list */
.active-note {
  background: #e0f0ff !important;
  font-weight: bold !important;
}

/* Tablet styles */
@media (max-width: 1024px) {
    .container-math {
        gap: 15px;
    }
    
    .right-panel {
        min-width: 100%;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .container-math {
        flex-direction: column;
        gap: 15px;
    }
    
    .left-panel, .right-panel {
        min-width: 100%;
        padding: 15px;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .example-btn {
        min-width: calc(50% - 5px);
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    .formula {
        font-size: 1.2em;
        padding: 12px;
    }
    
    .property, .definition, .zero-point, .y-intercept {
        padding: 12px;
    }
    
    .slider-container {
        margin-bottom: 18px;
    }
    
    .modal-content {
        margin: 10% auto 5%;
        padding: 20px;
        width: 95%;
        max-height: 80vh;
    }
}

/* Small mobile styles */
@media (max-width: 480px) {
    .left-panel, .right-panel {
        padding: 12px;
        border-radius: 6px;
    }
    
    .example-btn {
        min-width: 100%;
        font-size: 0.9rem;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .formula {
        font-size: 1em;
        padding: 10px;
    }
    
    .property, .definition, .zero-point, .y-intercept {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .slider-label {
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 15px;
        margin: 5% auto;
        border-radius: 8px;
    }
    
    .close {
        font-size: 24px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .left-panel, .right-panel {
        padding: 10px;
    }
    
    .chart-container {
        height: 220px;
    }
    
    .example-buttons {
        gap: 8px;
    }
    
    .example-btn {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

/* Landscape orientation for phones */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        margin: 2% auto;
        max-height: 95vh;
        padding: 15px;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .property, .definition {
        padding: 8px;
    }
}

/* Task list styles */
#tasks-section { 
    margin-top: 18px; 
}

.task-item {
    background: #fafbfd;
    padding: 12px 14px;
    border-left: 4px solid var(--primary-color, #3498db);
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(10,20,40,0.03);
    transition: box-shadow 0.2s;
}

.task-item:active {
    box-shadow: 0 1px 3px rgba(10,20,40,0.1);
}

.task-meta { 
    display: flex; 
    justify-content: space-between; 
    gap: 12px; 
    align-items: center; 
    flex-wrap: wrap; 
}

.task-desc { 
    margin-top: 8px; 
    color: #222; 
    font-size: 0.95rem;
    line-height: 1.5;
}

.task-actions { 
    margin-top: 10px; 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
}

.step { 
    margin: 10px 0; 
    padding: 10px 12px; 
    background: #f6fbff; 
    border-radius: 6px; 
    border-left: 3px solid var(--primary-color, #3498db);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.step p { 
    margin: 6px 0;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .task-item {
        padding: 10px 12px;
    }
    
    .task-desc {
        font-size: 0.9rem;
    }
    
    .task-actions button {
        flex: 1;
        min-width: calc(50% - 4px);
    }
}

@media (max-width: 520px) {
    .modal-content { 
        margin-top: 8%; 
        padding: 15px; 
    }
    
    .task-meta {
        flex-direction: column; 
        align-items: flex-start;
        gap: 8px;
    }
    
    .task-item {
        padding: 10px;
    }
    
    .task-actions button {
        width: 100%;
        min-width: 100%;
    }
    
    .step {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .task-desc {
        font-size: 0.85rem;
    }
    
    .step {
        font-size: 0.85rem;
    }
}
