* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
    font-size: 18px;
}

body.dark {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    min-height: 100vh;
}

.calculator-main {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .calculator-main {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 5px;
}

.mode-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    user-select: none;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-btn {
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    min-width: 44px;
    min-height: 44px;
    user-select: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(1px);
    background: rgba(255, 255, 255, 0.05);
}

.display {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    font-family: 'Courier New', monospace;
}

.input-line {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.5rem;
    min-height: 30px;
}

.input-content {
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.input-content::-webkit-scrollbar {
    display: none;
}

.result {
    font-size: 2.5rem;
    font-weight: bold;
    color: #00ff88;
    text-align: right;
    margin-top: 10px;
    word-wrap: break-word;
}

.error {
    color: #ff6b6b;
}

.keypad {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.basic-keypad {
    grid-template-columns: repeat(4, 1fr);
}

.scientific-keypad {
    grid-template-columns: repeat(6, 1fr);
}

.programming-keypad {
    grid-template-columns: repeat(5, 1fr);
}

.key {
    padding: 20px;
    border: none;
    border-radius: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.key:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.key:active {
    transform: translateY(2px);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.key.operator {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.3);
}

.key.operator:hover {
    background: rgba(255, 107, 107, 0.4);
}

.key.function {
    background: rgba(74, 144, 226, 0.2);
    border-color: rgba(74, 144, 226, 0.3);
    font-size: 1rem;
}

.key.function:hover {
    background: rgba(74, 144, 226, 0.4);
}

.key.wide {
    grid-column: span 2;
}

.key.tall {
    grid-row: span 2;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.dark .panel {
    background: rgba(0, 0, 0, 0.3);
}

.panel h3 {
    margin-bottom: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-item, .memory-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover, .memory-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.memory-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.memory-btn {
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    user-select: none;
}

.memory-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* System Mode Buttons */
.sys-mode-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    user-select: none;
}

.sys-mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.graph-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.graph-input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.graph-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.conversion-panel {
    display: none;
}

.conversion-panel.active {
    display: block;
}

.conversion-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.conversion-input, .conversion-select {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.conversion-input:focus, .conversion-select:focus, .graph-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    outline: none;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.conversion-select option {
    background: #2c3e50;
    color: white;
    padding: 10px;
}

.conversion-select {
    cursor: pointer;
}

.number-base-display {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.base-label {
    font-weight: bold;
    min-width: 50px;
}

.base-value {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 6px;
    font-family: monospace;
    word-break: break-all;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .calculator-main {
        padding: 20px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .mode-selector {
        flex-wrap: wrap;
    }
    
    .keypad {
        gap: 8px;
    }
    
    .key {
        padding: 15px;
        font-size: 1.1rem;
        min-height: 50px;
    }

    .matrix-dimensions {
        flex-direction: column;
        align-items: stretch;
    }
}

.hidden {
    display: none !important;
}

.fraction-mode {
    font-style: italic;
    color: #ffd700;
}

.matrix-input {
    display: grid;
    gap: 5px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    justify-content: center;
    align-content: center;
}

.matrix-row {
    display: flex;
    gap: 5px;
}

.matrix-cell {
    width: 60px;
    padding: 5px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    font-family: monospace;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.matrix-cell:focus {
    background: rgba(255, 255, 255, 0.25);
    outline: none;
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Add to your style.css file */
/* Add to your style.css file */
.matrix-panel {
    display: none; /* Initially hidden */
    /* Styles inherited from .panel */
}

/* Ensure active panels are visible */
.panel.active {
    display: block;
    animation: slideUp 0.4s ease-out;
}

.matrix-panel.active {
    display: block;
}

.matrix-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 1rem 0 20px 0;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
  }
  
  .matrix-controls h4 {
    margin-bottom: 0.5rem;
  }
  
  .matrix-input-grid {
    display: grid;
    gap: 5px;
    margin: 0.5rem 0 20px 0;
  }
  
  .matrix-input-grid input {
    width: 50px;
    padding: 4px;
    text-align: center;
  }
  .scientific-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  
  /* Numbers feel like a table */
  .scientific-keypad .num {
    font-weight: 600;
  }
  
  /* 0 spans two columns */
  .scientific-keypad .wide {
    grid-column: span 2;
  }
  
  /* = spans vertically */
  .scientific-keypad .operator.tall {
    grid-row: span 3;
  }
  
  .base-btn {
    opacity: 0.6;
  }
  
  .base-btn.active {
    opacity: 1;
    border: 2px solid #00ff88;
    color: #00ff88;
  }
  
  .hex-key.hidden {
    display: none;
  }
  
  .matrix-cell:disabled {
    background: rgba(255, 255, 255, 0.15);
    color: rgb(255, 255, 255);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: bold;
  }
  
  .matrix-scalar-result {
    margin-top: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
  }
  .matrix-dimensions {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
  }
  
  .matrix-dimensions fieldset {
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 10px 15px;
    background: rgba(0,0,0,0.1);
  }
  
  .matrix-dimensions legend {
    padding: 0 8px;
    font-weight: 600;
  }
  
  .matrix-dimensions label {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
  }
  
  .matrix-input {
    justify-content: start;
  }
  
  .matrix-cell {
    border-radius: 6px;
  }
  .matrix-dimensions legend {
    padding: 0 8px;
    font-weight: 600;
  }
  
  .matrix-dimensions label {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
  }
  
  .matrix-input {
    justify-content: start;
  }
  
  .matrix-cell {
    border-radius: 6px;
  }
  