/* Base Styles */
:root {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
    --shadow-color: rgba(0, 0, 0, 0.1);
  }
  
  [data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --shadow-color: rgba(0, 0, 0, 0.3);
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.5;
  }
  
  .app {
    min-height: 100vh;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
  }
  
  /* Header */
  .header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
  }
  
  .header h1 {
    font-size: 1.5rem;
    font-weight: bold;
  }
  
  .header-buttons {
    display: flex;
    gap: 1rem;
  }
  
  .icon-button {
    padding: 0.5rem;
    border: none;
    background: none;
    color: var(--text-primary);
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .icon-button:hover {
    background-color: var(--border-color);
  }
  
  /* Calculator */
  .calculator {
    max-width: 24rem;
    margin: 1rem auto;
    padding: 1rem;
  }
  
  .display {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px var(--shadow-color);
  }
  
  .previous-result {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-height: 1.25rem;
  }
  
  .current-display {
    font-size: 1.875rem;
    font-family: monospace;
    text-align: right;
  }
  
  .keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  
  .key {
    padding: 1rem;
    font-size: 1.25rem;
    border: none;
    border-radius: 0.5rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px var(--shadow-color);
  }
  
  .key:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px var(--shadow-color);
  }
  
  .key:active {
    transform: scale(0.95);
  }
  
  .equals {
    background-color: var(--accent-color);
    color: white;
  }
  
  .equals:hover {
    background-color: #2563eb;
  }
  
  .history-button {
    width: 100%;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .history-button:hover {
    background-color: var(--border-color);
  }
  
  /* Modal */
  .modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  
  .modal.active {
    opacity: 1;
    pointer-events: auto;
  }
  
  .modal-content {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    max-width: 28rem;
    width: 100%;
    transform: scale(0.95);
    transition: transform 0.3s;
  }
  
  .modal.active .modal-content {
    transform: scale(1);
  }
  
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
  }
  
  .modal-header h2 {
    font-size: 1.25rem;
    font-weight: bold;
  }
  
  .close-button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
  }
  
  .modal-body {
    max-height: 24rem;
    overflow-y: auto;
  }
  
  .history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .history-item {
    padding: 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .history-item:hover {
    background-color: var(--border-color);
  }
  
  .history-expression {
    font-size: 0.875rem;
    color: var(--text-secondary);
  }
  
  .history-result {
    font-size: 1.125rem;
  }
  
  /* Footer */
  .footer {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
  }
  
  /* Scroll to Top */
  .scroll-top {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px var(--shadow-color);
  }
  
  .scroll-top:hover {
    background-color: #2563eb;
  }
  
  .hidden {
    display: none;
  }
  
  /* Animations */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(0.625rem);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
  }