 @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

 :root {
     --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     --card: rgba(255, 255, 255, 0.1);
     --card-border: rgba(255, 255, 255, 0.2);
     --accent: #fbbf24;
     --accent-hover: #f59e0b;
     --muted: rgba(255, 255, 255, 0.7);
     --glass: rgba(255, 255, 255, 0.1);
     --text-primary: #ffffff;
     --text-secondary: rgba(255, 255, 255, 0.8);
     --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
     --button-hover: rgba(255, 255, 255, 0.15);
     font-family: 'Inter', system-ui, Arial, sans-serif;
 }

 [data-theme="dark"] {
     --bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
     --card: rgba(30, 41, 59, 0.8);
     --card-border: rgba(148, 163, 184, 0.1);
     --accent: #10b981;
     --accent-hover: #059669;
     --muted: rgba(148, 163, 184, 0.8);
     --glass: rgba(255, 255, 255, 0.05);
     --text-primary: #f1f5f9;
     --text-secondary: rgba(203, 213, 225, 0.8);
     --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
     --button-hover: rgba(255, 255, 255, 0.1);
 }

 [data-theme="light"] {
     --bg: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
     --card: rgba(255, 255, 255, 0.95);
     --card-border: rgba(148, 163, 184, 0.2);
     --accent: #3b82f6;
     --accent-hover: #2563eb;
     --muted: rgba(71, 85, 105, 0.7);
     --glass: rgba(59, 130, 246, 0.1);
     --text-primary: #0f172a;
     --text-secondary: rgba(15, 23, 42, 0.8);
     --shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
     --button-hover: rgba(59, 130, 246, 0.1);
 }

 [data-theme="ocean"] {
     --bg: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
     --card: rgba(255, 255, 255, 0.15);
     --card-border: rgba(255, 255, 255, 0.3);
     --accent: #fbbf24;
     --accent-hover: #f59e0b;
     --muted: rgba(255, 255, 255, 0.75);
     --glass: rgba(255, 255, 255, 0.12);
     --text-primary: #ffffff;
     --text-secondary: rgba(255, 255, 255, 0.85);
     --shadow: 0 20px 60px rgba(14, 165, 233, 0.4);
     --button-hover: rgba(255, 255, 255, 0.2);
 }

 [data-theme="purple"] {
     --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     --card: rgba(255, 255, 255, 0.1);
     --card-border: rgba(255, 255, 255, 0.2);
     --accent: #fbbf24;
     --accent-hover: #f59e0b;
     --muted: rgba(255, 255, 255, 0.7);
     --glass: rgba(255, 255, 255, 0.1);
     --text-primary: #ffffff;
     --text-secondary: rgba(255, 255, 255, 0.8);
     --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
     --button-hover: rgba(255, 255, 255, 0.15);
 }

 * {
     box-sizing: border-box;
     margin: 0;
     padding: 0;
 }

 html,
 body {
     height: 100%;
 }

 body {
     display: flex;
     justify-content: center;
     align-items: center;
     background: var(--bg);
     color: var(--text-primary);
     transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
     position: relative;
     overflow: hidden;
     padding: 20px;
 }

 body::before {
     content: '';
     position: absolute;
     top: -50%;
     left: -50%;
     width: 200%;
     height: 200%;
     background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
     background-size: 50px 50px;
     animation: drift 20s linear infinite;
     pointer-events: none;
 }

 @keyframes drift {
     0% {
         transform: translate(0, 0);
     }

     100% {
         transform: translate(50px, 50px);
     }
 }

 .calculator-container {
     display: flex;
     gap: 20px;
     align-items: flex-start;
     position: relative;
     z-index: 1;
     max-width: 900px;
     width: 100%;
     flex-wrap: wrap;
     justify-content: center;
 }

 .calculator {
     width: 380px;
     background: var(--card);
     backdrop-filter: blur(20px);
     -webkit-backdrop-filter: blur(20px);
     border-radius: 24px;
     box-shadow: var(--shadow);
     padding: 24px;
     border: 1px solid var(--card-border);
     transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
     flex-shrink: 0;
 }

 .calculator:hover {
     transform: translateY(-2px);
     box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
 }

 .display {
     background: var(--glass);
     backdrop-filter: blur(10px);
     border-radius: 16px;
     padding: 20px;
     min-height: 100px;
     margin-bottom: 16px;
     word-break: break-all;
     border: 1px solid var(--card-border);
     box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
 }

 .preview {
     font-size: 16px;
     color: var(--muted);
     min-height: 24px;
     margin-bottom: 8px;
     font-weight: 500;
 }

 .result {
     font-size: 32px;
     font-weight: 700;
     color: var(--text-primary);
     text-align: right;
     line-height: 1.2;
 }

 .numbers {
     display: grid;
     grid-template-columns: repeat(5, 1fr);
     gap: 10px;
     margin-bottom: 0;
 }

 button {
     height: 56px;
     border-radius: 12px;
     border: none;
     cursor: pointer;
     font-size: 17px;
     font-weight: 600;
     background: var(--glass);
     color: var(--text-primary);
     transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
     position: relative;
     overflow: hidden;
     border: 1px solid var(--card-border);
 }

 button::before {
     content: '';
     position: absolute;
     top: 50%;
     left: 50%;
     width: 0;
     height: 0;
     border-radius: 50%;
     background: rgba(255, 255, 255, 0.2);
     transform: translate(-50%, -50%);
     transition: width 0.3s, height 0.3s;
 }

 button:hover::before {
     width: 200px;
     height: 200px;
 }

 button:hover {
     background: var(--button-hover);
     transform: translateY(-2px);
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
 }

 button:active {
     transform: translateY(0) scale(0.98);
 }

 button span {
     position: relative;
     z-index: 1;
 }

 .btn-clear {
     background: linear-gradient(135deg, #ef4444, #dc2626);
     color: #ffffff;
     border: none;
 }

 .btn-clear:hover {
     background: linear-gradient(135deg, #dc2626, #b91c1c);
 }

 .btn-operator {
     background: var(--glass);
     font-weight: 700;
 }

 .btn-equal {
     background: linear-gradient(135deg, var(--accent), var(--accent-hover));
     color: #ffffff;
     grid-column: span 2;
     font-size: 20px;
     font-weight: 700;
     border: none;
     box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
 }

 .btn-equal:hover {
     background: linear-gradient(135deg, var(--accent-hover), var(--accent));
     box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
 }

 .history-panel {
     width: 320px;
     background: var(--card);
     backdrop-filter: blur(20px);
     -webkit-backdrop-filter: blur(20px);
     border-radius: 24px;
     box-shadow: var(--shadow);
     padding: 24px;
     border: 1px solid var(--card-border);
     transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
     flex-shrink: 0;
     display: flex;
     flex-direction: column;
     max-height: calc(100vh - 40px);
 }

 .history-panel:hover {
     transform: translateY(-2px);
     box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
 }

 .history-header {
     font-size: 20px;
     font-weight: 700;
     color: var(--text-primary);
     margin-bottom: 16px;
     display: flex;
     align-items: center;
     gap: 8px;
 }

 .history {
     flex: 1;
     overflow-y: auto;
     font-size: 14px;
     background: var(--glass);
     padding: 16px;
     border-radius: 12px;
     color: var(--muted);
     border: 1px solid var(--card-border);
     min-height: 400px;
 }

 .history::-webkit-scrollbar {
     width: 8px;
 }

 .history::-webkit-scrollbar-track {
     background: transparent;
     border-radius: 4px;
 }

 .history::-webkit-scrollbar-thumb {
     background: var(--muted);
     border-radius: 4px;
 }

 .history::-webkit-scrollbar-thumb:hover {
     background: var(--text-primary);
 }

 .history div {
     padding: 10px 0;
     border-bottom: 1px solid var(--card-border);
     transition: all 0.2s;
     cursor: pointer;
 }

 .history div:hover {
     color: var(--text-primary);
     padding-left: 8px;
 }

 .history div:last-child {
     border-bottom: none;
 }

 .history-empty {
     text-align: center;
     color: var(--muted);
     padding: 40px 20px;
     font-style: italic;
 }

 .mode-change {
     text-align: right;
     margin-bottom: 16px;
     display: flex;
     justify-content: flex-end;
     gap: 8px;
 }

 .theme-toggle button {
     background: var(--glass);
     backdrop-filter: blur(10px);
     padding: 8px 14px;
     border-radius: 10px;
     font-size: 18px;
     border: 1px solid var(--card-border);
     transition: all 0.2s;
 }

 .theme-toggle button:hover {
     background: var(--button-hover);
     transform: rotate(15deg) scale(1.1);
 }

 .theme-selector {
     display: flex;
     gap: 6px;
     margin-bottom: 12px;
 }

 .theme-btn {
     flex: 1;
     height: 32px;
     border-radius: 8px;
     font-size: 12px;
     font-weight: 600;
     opacity: 0.7;
     transition: all 0.2s;
 }

 .theme-btn.active {
     opacity: 1;
     background: var(--accent);
     color: #ffffff;
 }

 @media (max-width: 768px) {
     .calculator-container {
         flex-direction: column;
         align-items: center;
     }

     .history-panel {
         width: 380px;
         max-height: 300px;
     }

     .history {
         min-height: 200px;
     }
 }