* {margin: 0;padding: 0;box-sizing: border-box;}

/* Variables for colors and theming */
:root {
  --bg: #222831;
  --panel: #2b3136;
  --button: #1e2327;
  --yellow: #f6e96b;
  --accent: #ff5c38;
  --border: rgba(255,255,255,0.1);
  --text: #e8e8e8;
  --display-bg: rgba(0,0,0,0.15);
  --memory-color: #6dd5ed;
}

/* Light Theme */
body.light-mode {
  background: linear-gradient(180deg, #e8f4f8, #d4e7f0);
}

body.light-mode .calc-wrap {
  background: linear-gradient(180deg, #ffffff, #f5f7fa);
  border: 2px solid rgba(0,0,0,0.1);
  box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

body.light-mode .logo span {
  color: #2c3e50;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

body.light-mode .logo svg path{fill: #2c3e50;}

body.light-mode .solar {
  background: linear-gradient(145deg, #e0e0e0, #ffffff);
  border: 1.5px solid #c0c0c0;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15), inset 0 -2px 4px rgba(0,0,0,0.1);
}

body.light-mode .display {
  background: linear-gradient(145deg, #f0f4f8, #ffffff);
  border: 1.5px solid rgba(0,0,0,0.15);
  color: #2c3e50;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1), inset 0 2px 4px rgba(0,0,0,0.05);
}

body.light-mode .display .small {color: rgba(44,62,80,0.6);}

body.light-mode .display .main {color: #2c3e50;}

body.light-mode .memory-indicator {color: #3498db;}

body.light-mode .key {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  color: #2c3e50;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15), inset 0 -2px 4px rgba(0,0,0,0.1);
}

body.light-mode .key:active {box-shadow: 0 2px 4px rgba(0,0,0,0.2) inset;}

body.light-mode .key[data-action="clear"],
body.light-mode .key[data-action="delete"] {
  color: #e67e22;
  font-weight: 700;
}

body.light-mode .key.op {
  color: #f39c12;
  font-weight: 600;
}

body.light-mode .key.memory {color: #3498db;}

body.light-mode .key.eq {
  background: linear-gradient(145deg, #ff6b6b, #ee5a52);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(238,90,82,0.4), inset 0 2px 4px rgba(255,255,255,0.3);
}

body.light-mode header {
  background: linear-gradient(180deg, #ffffff, #e6e6e6d7);
  border: 2px solid rgba(0,0,0,0.1);
  box-shadow: 0 15px 32px rgba(0,0,0,0.10);
}

body.light-mode nav a {color: hsl(43 1% 0%);}

body.light-mode .icon-btn {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border: 1.5px solid rgba(0,0,0,0.15);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

body.light-mode .icon-btn svg {fill: #2c3e50;}

body.light-mode .icon-btn.theme-toggle svg {fill: #f39c12;}

body.light-mode .side-panel {
  background: linear-gradient(180deg, #ffffff, #f5f7fa);
  box-shadow: -5px 0 20px rgba(0,0,0,0.15);
  border-left: 2px solid rgba(0,0,0,0.1);
}

body.light-mode .panel-header {border-bottom: 2px solid rgba(0,0,0,0.1);}

body.light-mode .panel-title {color: #2c3e50;}

body.light-mode .close-panel {color: #2c3e50;}

body.light-mode .close-panel:hover {background: rgba(0,0,0,0.1);}

body.light-mode .history-item {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .history-item:hover {background: rgba(52,152,219,0.1);}

body.light-mode .history-expr {color: #2c3e50;}

body.light-mode .history-result {color: #3498db;}

body.light-mode .empty-state {color: #2c3e50;}

body.light-mode .shortcut-item {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .shortcut-key {
  background: #3498db;
  color: white;
}

body.light-mode .shortcut-desc {color: #2c3e50;}
    
html, body {
  width: 100%;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg,#0d1113,#1a1f22);
  color: var(--text);
  transition: background 0.3s;
}

header {
  background: linear-gradient(180deg,#2e3539,#1f2326);
  border: 1px solid rgba(44, 44, 44, 0.4);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.10);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-logo svg {
  height: 50px;
  width: auto;
} 

.brand-logo svg path {fill: var(--text);} 

nav {
  display: flex;
  gap: 2rem;
}

nav a {
  color: hsl(43 1% 0%);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
  position: relative;
  font-size: 1.8rem;
  text-shadow: 1px 1px 2px hsla(0, 0%, 100%, 0.205), 0 0 1px hsla(0, 0%, 0%, 0.3);
}

nav a:hover {
  text-decoration: underline;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.icon-btn {
  background: rgba(0,0,0,0.3);
  border: 1.5px solid rgba(255,255,255,0.2);
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  width: 45px;
  height: 45px;
}

.icon-btn:hover {transform: scale(1.1);}

.icon-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4) inset;
}

.icon-btn svg {
  fill: #e3e3e3;
  transition: transform 0.3s;
  width: 24px;
  height: 24px;
}

.icon-btn:hover svg {transform: rotate(20deg);}

.container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: calc(100vh - 70px);
  padding: 2rem 1rem;
  gap: 1.5rem;
}

.calc-wrap {
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg,#2e3539,#1f2326);
  border-radius: 22px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.7);
  padding: 1.5rem;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-calc {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.logo svg {
  width: 100px;
  height: 50px;
}

.logo svg path {fill: var(--text);}

.logo span {
  color: hsl(43 1% 0%);
  font-size: 1.2rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 2px;
  text-shadow: 1px 1px 2px hsla(0, 0%, 100%, 0.2), 0 0 1px hsla(0, 0%, 0%, 0.3);
}

.panels {
  display: flex;
  gap: 0;
  align-items: center;
}

.solar {
  width: 70px;
  height: 50px;
  border-radius: 4px;
  border: 1.5px solid hsl(0,0%,30%);
  background: hsl(210, 10%, 13%);
  box-shadow: 0 5px 10px rgba(0,0,0,0.10), inset 0 -4px 6px rgba(0,0,0,0.4);
}

.display {
  padding: 1.5rem;
  border-radius: 14px;
  background: var(--display-bg);
  border: 1.5px solid rgba(255,255,255,0.1);
  box-shadow: 0 5px 10px rgba(0,0,0,0.4), inset 0 -4px 6px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-height: 100px;
  position: relative;
  overflow: hidden;
  color: #fff;
}

.display .small {
  font-size: 0.9rem;
  opacity: 0.5;
  margin-bottom: 0.3rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.display-actions {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;  
  display: flex;
  gap: 0.5rem;
}

.memory-indicator {
  color: var(--memory-color);
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.memory-indicator.active {opacity: 1;}

.display .main {
  font-size: 2rem;
  font-weight: 600;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  cursor: text;
  outline: none;
  user-select: text;
}

.display .main:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent) inset;
  border-radius: 8px;
}

.display .main:empty:before {
  content: '0';
  opacity: 0.5;
}
    
.display .main::-webkit-scrollbar {height: 4px;}

.display .main::-webkit-scrollbar-track {background: transparent;}

.display .main::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

.keys {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, 1fr);
}

button.key {
  border: 0;
  padding: 1.1rem 0.5rem;
  font-size: 1rem;
  border-radius: 50%;
  cursor: pointer;
  background: var(--button);
  box-shadow: 0 5px 10px rgba(0,0,0,0.4), inset 0 -4px 6px rgba(0,0,0,0.5);
  color: var(--text);
  width: 100%;
  transition: all 0.2s;
  font-weight: 500;
  user-select: none;
  aspect-ratio: 1;
}
    
button.key:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16,24,40,0.15);
}

button.key:active {
  transform: translateY(2px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5) inset;
}

.key[data-action="clear"],
.key[data-action="delete"] {
  color: var(--yellow);
  font-weight: 700;
}

.op {
  color: var(--yellow);
  font-weight: 600;
}

.memory {
  color: var(--memory-color);
  font-weight: 600;
  font-size: 0.9rem;
}

.eq {
  grid-column: span 6;
  height: 80px;
  width: 80%; 
  background: linear-gradient(180deg, #ff6b3a, #ff3b1f);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: inset 0 4px 8px hsla(0, 100%, 50%, 0.5), 0 4px 10px rgba(255,90,50,0.4);
  border-radius: 12px;
}

.eq:hover {
  background: linear-gradient(180deg, #ff7b4a, #ff4b2f);
}
    
/* Side Panel Styles */
.side-panel {
  position: fixed;
  right: -350px;
  top: 70px;
  width: 320px;
  height: calc(100vh - 70px);
  background: var(--panel);
  box-shadow: -5px 0 20px rgba(0,0,0,0.5);
  padding: 1.5rem;
  overflow-y: auto;
  transition: right 0.3s ease;
  z-index: 1000;
  border-left: 2px solid var(--border);
}

.side-panel.active {right: 0;}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(255,255,255,0.1);
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--yellow);
}

.close-panel {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #fff;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.close-panel:hover {
  background: rgba(255,255,255,0.1);
  transform: rotate(90deg);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.history-item {
  background: rgba(0,0,0,0.2);
  padding: 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(255,255,255,0.1);
}

.history-item:hover {
  background: rgba(246,233,107,0.2);
  transform: translateX(-5px);
}

.history-expr {
  font-size: 0.9rem;
  opacity: 0.7;
  margin-bottom: 0.3rem;
  color: #fff;
}
    
.history-result {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--yellow);
}

.clear-history {
  background: rgba(255,0,0,0.2);
  color: #ff6b6b;
  border: none;
  padding: 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 1rem;
  width: 100%;
  transition: all 0.2s;
}

.clear-history:hover {background: rgba(255,0,0,0.3);}

.empty-state {
  text-align: center;
  padding: 2rem;
  opacity: 0.5;
  color: #fff;
}

.shortcuts-grid {
  display: grid;
  gap: 0.8rem;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.shortcut-key {
  background: var(--yellow);
  color: #222831;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: monospace;
}

.shortcut-desc {
  font-size: 0.9rem;
  color: #fff;
}

/* Footer CSS */
footer {
  background: linear-gradient(180deg, #1f2326, #0d1113);
  border-top: 2px solid rgba(255,255,255,0.1);
  padding: 40px 20px 20px;
  margin-top: 60px;
}

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
}

/* Light Mode Footer */
body.light-mode footer {
  background: linear-gradient(180deg, #2c3e50, #1a252f);
}

/* Responsive adjustments */
@media(max-width: 900px) {
  .container {
    flex-direction: column;
    align-items: center;
  }
  .side-panel {
    max-width: 520px;
    width: 100%;
    right: -100%;
  }
}
    
@media(max-width: 600px) {
  header {
    padding: 1rem;
  }
  nav {
    gap: 1rem;
  }
  nav a {
    font-size: 1.2em;
  }
  .brand-logo svg {
    height: 30px;
  }
}
    
@media(max-width: 500px) {
  .calc-wrap {
    max-width: 95vw;
    padding: 1rem;
  }
  .display .main {
    font-size: 1.6rem;
  }
  button.key {
    padding: 0.9rem 0.4rem;
    font-size: 0.9rem;
  }
  .icon-btn {
    padding: 0.4rem;
    width: 35px;
    height: 35px;
  }
  .solar {
    width: 50px;
    height: 35px;
  }
}

@media(max-width: 430px) {
  .icon-btn {
    padding: 0.4rem;
    width: 30px;
    height: 30px;
  }
}

@media(max-width: 380px) {
  button.key {
    padding: 0.8rem 0.3rem;
    font-size: 0.75rem;
  }
  .icon-btn {
    padding: 0.3rem;
    width: 25px;
    height: 25px;
  }
  nav a {
    font-size: 0.9rem;
  }
}
