 :root {
            --background: #f8f9fa;
            --surface: #ffffff;
            --primary-text: #202124;
            --secondary-text: #5f6368;
            --border-color: #e0e2e6;
            --accent-color: #8a63d2; 
            --accent-color-light: #e9e1f8;  
            --error-color: #d93025;
            --key-bg: #f1f3f4;
            --key-bg-special: #e8eaed;
            --key-shadow: 0 1px 1px rgba(0,0,0,0.1);
            --keyboard-height: 265px;  
        }
        * { box-sizing: border-box; }
        body { font-family: 'Inter', sans-serif; margin: 0; background-color: #ffffff; display: flex; justify-content: center; align-items: center; min-height: 100vh; color: var(--primary-text); }
        .calculator-container { width: 100%; max-width: 1100px; height: 95vh; max-height: 850px; display: flex; flex-direction: column; border: 1px solid black; border-radius: 0px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.08); background-color: var(--surface); position: relative; }
        .main-content { display: flex; flex-grow: 1; overflow: hidden; height: 100%; transition: height 0.3s ease-in-out; animation: slideUpAndFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
        .keyboard-visible .main-content { height: calc(100% - var(--keyboard-height)); }
        .expressions-panel { width: 420px; border-right: 1px solid var(--border-color); padding: 16px; display: flex; flex-direction: column; background-color: var(--surface); transition: width 0.3s ease; }
        .panel-header { font-size: 1.25em; font-weight: 600; color: var(--primary-text); margin: 0 0 16px 4px; padding: 0; }
        
         
        .expressions-list {
            flex-grow: 1;
            overflow-y: auto;            
            border-top: 1px solid var(--border-color);
            border-left: 1px solid var(--border-color);
            border-right: 1px solid var(--border-color);
            border-radius: 8px;
        }

        .expression-item {
            display: grid;
            grid-template-columns: 60px 1fr;             
            border-bottom: 1px solid var(--border-color);
        }

        .expression-cell {
            display: flex;
            align-items: center;
            padding: 8px;
        }

        .color-cell {
            justify-content: center;
            border-right: 1px solid var(--border-color);
        }

        .input-cell {
            position: relative;
            gap: 6px;
        }

        .color-dot {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            cursor: pointer;
            flex-shrink: 0;
            border: 2px solid;
            transition: transform 0.2s;
        }
        .color-dot:hover {
            transform: scale(1.1);
        }
        
        .func-label {
            font-size: 1.1em;
            font-weight: 500;
            color: var(--secondary-text);
            white-space: nowrap;
        }

        .expression-item math-field {
            flex-grow: 1;
            font-size: 1.1em;
            border: none;
            outline: none;
            padding: 8px 4px;
            border-radius: 6px;
            transition: background-color 0.2s, box-shadow 0.2s;
            line-height: 1.5;
            background-color: transparent;
            --caret-color: var(--accent-color);
            --selection-background-color: var(--accent-color-light);
        }         
        
        .expression-item math-field:focus, .expression-item math-field.is-focused { background-color: var(--accent-color-light); box-shadow: 0 0 0 2px var(--accent-color) inset; outline: none; }
        .expression-item math-field.error-indicator { box-shadow: 0 0 0 2px var(--error-color) inset; }
        .delete-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: none; background-color: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 50%; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s, background-color 0.2s; }
        .input-cell:hover .delete-btn, math-field.is-focused ~ .delete-btn { opacity: 1; visibility: visible; }
        .delete-btn:hover { background-color: #e8eaed; }
        .delete-btn svg { width: 20px; height: 20px; min-width: 20px; min-height: 20px; fill: var(--secondary-text); }
        .add-item-button { display: flex; align-items: center; justify-content: center; padding: 12px 8px; cursor: pointer; border-radius: 8px; border: 2px dashed var(--border-color); margin-top: 12px; transition: border-color 0.2s, background-color 0.2s; }
        .add-item-button:hover { border-color: var(--accent-color); background-color: var(--accent-color-light); }
        .add-item-button .placeholder { color: var(--secondary-text); font-size: 1.1em; font-weight: 500; }
        .graph-container { flex-grow: 1; position: relative; background-color: #fff; cursor: grab; }
        .graph-container:active { cursor: grabbing; }
        #graphCanvas { width: 100%; height: 100%; display: block; }
        .zoom-controls { position: absolute; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 4px; z-index: 10; }
        .zoom-controls button { width: 40px; height: 40px; border: 1px solid var(--border-color); background-color: var(--surface); border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: 20px; cursor: pointer; color: var(--secondary-text); display: flex; align-items: center; justify-content: center; }
        .zoom-controls button:hover { background-color: var(--key-bg); }
        .keyboard-container { position: fixed; bottom: 0; left: 0; right: 0; width: 100%; background-color: #e8eaed; padding: 8px; z-index: 100; height: var(--keyboard-height); transform: translateY(100%); transition: transform 0.3s ease-in-out; }
        .keyboard-visible .keyboard-container { transform: translateY(0); }
        .keyboard-tabs { display: flex; justify-content: center; margin-bottom: 8px; background-color: #d3d6da; border-radius: 8px; padding: 4px; }
        .keyboard-tabs button { flex-grow: 1; border: none; background-color: transparent; padding: 6px 12px; font-size: 0.9em; font-weight: 600; color: var(--secondary-text); cursor: pointer; border-radius: 6px; transition: background-color 0.2s, color 0.2s; }
        .keyboard-tabs button.active { background-color: var(--accent-color); color: var(--surface); box-shadow: none; }
        .keyboard-panels { position: relative; height: calc(var(--keyboard-height) - 50px); }
        .keyboard-panel { position: absolute; top: 0; left: 0; right: 0; visibility: hidden; opacity: 0; display: flex; flex-direction: column; gap: 5px; transition: opacity 0.15s ease-in-out, visibility 0.15s; }
        .keyboard-panel.active { visibility: visible; opacity: 1; }
        .keyboard-row { display: flex; gap: 5px; justify-content: center; }
        .keyboard-panel button { flex: 1 1 0px; padding: 12px 0; font-size: 1.1em; border-radius: 8px; border: none; background-color: var(--key-bg); color: var(--primary-text); box-shadow: var(--key-shadow); cursor: pointer; min-width: 44px; font-weight: 500; transition: transform 0.1s, box-shadow 0.1s; }
        .keyboard-panel button.special, .keyboard-panel button.utility { background-color: var(--key-bg-special); }
        .keyboard-panel button:active { transform: scale(0.96); box-shadow: none; }
        @media (max-width: 768px) { .expressions-panel { width: 100%; height: 40%; border-right: none; border-bottom: 1px solid var(--border-color); } .main-content { flex-direction: column; } .calculator-container { height: 100vh; max-height: none; border-radius: 0; overflow: hidden; } .keyboard-visible .main-content { height: calc(100vh - var(--keyboard-height)); } }
        math-field::part(menu-toggle),
        math-field::part(virtual-keyboard-toggle) { display: none !important; }
         
.icon-power-btn {
    display: flex;
    align-items: flex-start; 
    justify-content: center;
    gap: 2px;
    padding-top: 6px;  
}
 
.icon-box {
    width: 13px;
    height: 13px;
    border: 2px dashed var(--primary-text);
    align-self: flex-end; 
}
 
.icon-power-exponent-box {
    width: 9px;
    height: 9px;
    border: 2px dashed var(--primary-text);
}
        .icon-sqrt-btn { display: flex; align-items: center; justify-content: center; gap: 0; }
        .sqrt-svg-symbol { width: 24px; height: 24px; flex-shrink: 0; }
        .sqrt-svg-symbol path { stroke: currentColor; stroke-width: 2; }
        .sqrt-placeholder-box { width: 10px; height: 10px; flex-shrink: 0; border: 2px dashed var(--primary-text); margin-left: -9px; margin-top: 3px; }
        .icon-abs-btn { display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 1.3em; font-weight: 300; line-height: 1; }
        .abs-placeholder-box { width: 10px; height: 10px; flex-shrink: 0; border: 2px dashed var(--primary-text); }
        .icon-nth-root-btn { display: flex; align-items: center; justify-content: center; gap: 0; }
        .nth-root-index-box { width: 8px; height: 8px; flex-shrink: 0; border: 2px dashed var(--primary-text); margin-right: -2px; transform: translateY(-7px); }
    
.icon-fraction-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;  
    padding: 10px 0 !important;  
}

.fraction-placeholder-box {
    width: 12px;
    height: 12px;
    border: 2px dashed var(--primary-text);
}

.fraction-bar {
    width: 24px;
    height: 2px;
    background-color: var(--primary-text);
} 
 
.icon-log-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;  
}

.log-placeholder-box {
    width: 12px;
    height: 12px;
    border: 2px dashed var(--primary-text);
}
 
.icon-log-base-btn {
    display: flex;
    align-items: flex-end;  
    justify-content: center;
    gap: 2px;  
    padding-bottom: 8px;  
}

.log-base-box {
    width: 9px;
    height: 9px;
    border: 2px dashed var(--primary-text);
    margin-bottom: -2px; 
}

.log-arg-box {
    width: 12px;
    height: 12px;
    border: 2px dashed var(--primary-text);
    margin-bottom: 8px;
}

.icon-derivative-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 6px 0 !important;
    font-size: 1em;
    font-weight: 600;
    line-height: 1;
}

.icon-derivative-btn .frac-d {
    margin-bottom: -2px;
}

.icon-derivative-btn .frac-dx {
    margin-top: -2px;
    font-size: 0.9em;
}

.icon-derivative-btn .fraction-bar {
    width: 24px;
    height: 2px;
    background-color: var(--primary-text);
}

@media (min-width: 769px) {
    .keyboard-container {
        position: absolute;  
    }
}


#keyboard-toast {  
  display: flex;
  align-items: center;
  gap: 12px;   
  position: absolute;
  top: 50%;
  left: 50%; 
  background: #202124; 
  color: #e8eaed; 
  padding: 12px 18px;
  border-radius: 8px;  
  font-size: 0.95em;
  font-weight: 500;    
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.1);
  z-index: 200; 
  transform: translate(-50%, -50%) translateY(-10px) scale(0.98);
  transition: transform 0.35s cubic-bezier(0.215, 0.610, 0.355, 1), 
              opacity 0.35s cubic-bezier(0.215, 0.610, 0.355, 1);
}

.toast-shown { 
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast-hidden {  
  opacity: 0;  
  pointer-events: none; 
}

@media (max-width: 450px) {
  #keyboard-toast {   
    width: auto !important;    
    left: 22px !important;
    right: 22px !important;
    transform: translate(0, -50%) scale(1) !important;
  }

  #keyboard-toast.toast-hidden, #keyboard-toast:not(.toast-shown) {
      transform: translate(0, -50%) translateY(-10px) scale(0.98) !important;
  }
}

.icon-backspace-svg {
    width: 24px;
    height: 24px;
}

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