body {
    background-image: url('https://source.unsplash.com/1600x900/?abstract,geometric');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    padding: 20px;
    color: white;
    position: relative;
    transition: background-image 1s ease-in-out; 
}
.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}
.heading-container {
    text-align: center;
    background-color: rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 12px;
    max-width: 90%;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1; 
}
.heading-container h1 {
    margin: 0;
    font-size: 1.8rem;
}
.heading-container p {
    margin: 5px 0;
    font-size: 1rem;
    opacity: 0.9;
}
.calculator {
    background-color: #fad609;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    width: 450px;
    z-index: 5;
}
.utility-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
#angle-mode {
    font-weight: bold;
    color: #fff;
    background-color: #be2828;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}
#angle-mode.deg {
    background-color: #0d8327;
}
#display {
    width: 100%;
    height: 65px;
    background-color: #121212;
    color: #fff;
    border: none;
    text-align: right;
    font-size: 2rem;
    padding: 0 15px;
    box-sizing: border-box;
    outline: none;
    border-radius: 8px;
    box-shadow: inset 0 0 8px rgba(235, 2, 91, 0.7);
}
.scientific-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); 
    gap: 8px; 
    margin-top: 15px;
}
button {
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(228, 4, 4, 0.2);
    background: #333333;
}
button:hover {
    background-color: #10d341;
    transform: scale(1.03);
}
button:active {
    transform: scale(0.98);
    background-color: #3709dd;
}
button.active-key {
    background-color: #fff !important;
    color: #333 !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.9);
}
.small-btn {
    font-size: 1rem;
    height: 48px;
}
.large-btn {
    font-size: 1.5rem;
    height: 60px;
    grid-column: span 1;
}
.large-btn:nth-child(n+25) { 
    grid-column: span 1; 
}
.equals-btn {
    background: #00bcd4;
    color: #000;
    font-weight: bold;
    grid-column: 5 / span 2;
    grid-row: 6 / span 3;
}
.equals-btn:hover {
    background-color: #00e5ff;
}
.equals-plus {
    grid-column: 4 / span 1;
}
.span-two-cols {
    grid-column: span 2; 
}
.scientific-grid button:nth-child(n+7):nth-child(-n+24):nth-child(odd) {
    background-color: #057e05;
}
.mem-btn {
    background-color: #33a7d4 !important;
}
.equals-btn, .equals-btn:hover, .equals-btn:active {
    background: #00bcd4!important; 
    color: #000!important;
}
#menu-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    padding: 10px 15px;
    border-radius: 8px;
    z-index: 110;
    transition: background 0.3s;
}
#menu-button:hover {
    background: rgba(255, 255, 255, 0.8);
    color: #333;
}
.history-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100%; 
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px); 
    color: white;
    padding: 20px;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.7);
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1); 
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.history-panel.open {
    transform: translateX(0);
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.history-header button {
    background: #ff4500;
    color: white;
    padding: 5px 10px;
    font-size: 0.9rem;
    border-radius: 5px;
}
#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; 
    overflow-y: auto;
}
.utility-section {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 15px;
    margin-top: 20px;
    flex-shrink: 0;
}
.utility-section h3 {
    margin-top: 0;
    color: #00bcd4;
    font-size: 1.1rem;
}
.util-btn {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    box-shadow: none;
    transition: background 0.2s, color 0.2s;
}
.util-btn:hover {
    background: #00bcd4;
    color: #333;
    transform: none;
}
#history-list li {
    padding: 8px 0;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
    cursor: pointer;
}
#history-list li:hover {
    background: rgba(255, 255, 255, 0.1);
}
.history-expression {
    font-size: 0.9rem;
    opacity: 0.7;
    word-wrap: break-word;
}
.history-result {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fad609;
}
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 48px;
    margin-right: 10px;
}
.theme-switch input {
    display:none;
}
.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
}
.slider:before {
    background-color: #fff;
    bottom: 4px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    height: 16px;
    content: "";
}
input:checked + .slider {
    background-color: #2196F3;
}
input:checked + .slider:before {
    transform: translateX(24px);
}
.slider.round {
    border-radius: 24px;
}
.slider.round:before {
    border-radius: 50%;
}
body.light-theme {
    background-image: none !important; 
    background-color: #f7f7f7 !important; 
    background-blend-mode: saturation;
}
body.light-theme .calculator {
    background-color: #e0e0e0; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
body.light-theme #display {
    background-color: #fff;
    color: #333;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1);
}
body.light-theme .heading-container {
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
}
body.light-theme .scientific-grid button {
    background-color: #c9c9c9;
    color: #333;
}
body.light-theme .scientific-grid button:nth-child(n+7):nth-child(-n+24):nth-child(odd) {
    background-color: #a4a4a4;
}
body.light-theme .mem-btn {
    background-color: #5abde7 !important;
}
body.light-theme .equals-btn {
    background: #00bcd4!important; 
    color: #000!important;
}
body.light-theme .history-panel {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
}
body.light-theme .history-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}
body.light-theme #history-list li {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}
body.light-theme .history-result {
    color: #e44d26;
}
body.light-theme .util-btn {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}
body.light-theme .util-btn:hover {
    background: #00bcd4;
    color: #fff;
}
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.overlay-content {
    background-color: #1a1a1a;
    color: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    max-width: 400px;
    text-align: center;
}
.overlay-content h2 {
    border-bottom: 2px solid #00bcd4;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
}
#dec-input {
    width: 80%;
    padding: 10px;
    margin-bottom: 20px;
    border: none;
    border-radius: 5px;
    font-size: 1.2rem;
    text-align: center;
    background: #333;
    color: white;
}
#bin-output, #hex-output {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fad609;
    word-break: break-all;
}
.converter-input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.converter-input-group label {
    flex-basis: 30%;
    font-size: 1.1rem;
}
#input-value, #input-unit {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #555;
    font-size: 1rem;
    color: white;
    background-color: #333;
}
#input-value {
    flex-basis: 30%;
    text-align: right;
}
#input-unit {
    flex-basis: 35%;
}
.unit-result {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fad609;
    margin-left: 10px;
}
.overlay-content button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #ff4500;
    font-size: 1rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.overlay-content button:hover {
    background-color: #df3d00;
}
.ai-chat-overlay {
    justify-content: flex-end;
    pointer-events: none;
}
.ai-chat-overlay .overlay-content {
    background-color: #1a1a1a;
    color: white;
    width: 400px;
    max-width: 90vw;
    height: 100%;
    max-height: 70vh;
    border-radius: 10px;
    padding: 0;
    margin: 30px;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    overflow: hidden;
}
.ai-chat-header {
    background: linear-gradient(to right, #00bcd4, #0d8327);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ai-chat-header h2 {
    margin: 0;
    font-size: 1.2rem;
}
.ai-chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.ai-chat-header button:hover {
    background: rgba(255, 255, 255, 0.2);
}
.ai-chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
}
.message.sent {
    background-color: #0084ff;
    align-self: flex-end;
}
.message.received {
    background-color: #333;
    align-self: flex-start;
}
.ai-chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #333;
    background: #222;
}
#ai-user-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 20px;
    background: #333;
    color: white;
    resize: none;
    font-family: inherit;
}
#ai-user-input:focus {
    outline: none;
    border-color: #00bcd4;
}
.ai-chat-input-area button {
    margin-left: 10px;
    padding: 10px 15px;
    background-color: #00bcd4;
    color: black;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.ai-chat-input-area button:hover {
    background-color: #00e5ff;
}
.ai-chat-note {
    font-size: 0.7rem;
    text-align: center;
    padding: 5px;
    color: #aaa;
    border-top: 1px dashed #444;
}
