:root {
--primary: #4361ee;
--secondary: #7209b7;
--success: #06d6a0;
--danger: #ef476f;
--warning: #ffd166;
--dark-bg: #0b0f2b;
--dark-card: rgba(25, 30, 60, 0.85);
--dark-text: #e2e8f0;
--light-bg: #f0f2f5;
--light-card: rgba(255, 255, 255, 0.95);
--light-text: #333;
--transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
--shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
--radius: 16px;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
user-select: none;
-webkit-tap-highlight-color: transparent;
}

body {
overflow-x: hidden;
touch-action: manipulation;
background: var(--dark-bg);
color: var(--dark-text);
transition: var(--transition);
min-height: 100vh;
position: relative;
-webkit-overflow-scrolling: touch;
background-image: radial-gradient(circle at 25% 30%, rgba(67, 97, 238, 0.1) 0%, transparent 55%),
radial-gradient(circle at 75% 70%, rgba(114, 9, 183, 0.1) 0%, transparent 55%);
}

body.light-theme {
background: var(--light-bg);
color: var(--light-text);
background-image: radial-gradient(circle at 25% 30%, rgba(67, 97, 238, 0.05) 0%, transparent 55%),
radial-gradient(circle at 75% 70%, rgba(114, 9, 183, 0.05) 0%, transparent 55%);
}

/* Анимации */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
from { transform: scale(0.9); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}

@keyframes float {
0% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
100% { transform: translateY(0px); }
}

/* Космические элементы */
.space-element {
position: fixed;
z-index: 0;
pointer-events: none;
}

.planet {
width: 180px;
height: 180px;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, #3a86ff, #6f42c1);
box-shadow: 0 0 50px rgba(58, 134, 255, 0.4);
top: 15%;
right: 5%;
animation: float 12s infinite ease-in-out;
}

.comet {
width: 120px;
height: 4px;
background: linear-gradient(90deg, transparent, #06d6a0);
top: 25%;
left: -120px;
border-radius: 2px;
animation: cometFly 25s linear infinite;
filter: blur(1px);
}

@keyframes cometFly {
0% { transform: translateX(0) translateY(0); opacity: 0; }
10% { opacity: 1; }
100% { transform: translateX(100vw) translateY(300px); opacity: 0; }
}

.star {
position: absolute;
background: white;
border-radius: 50%;
animation: twinkle var(--duration, 5s) infinite var(--delay, 0s);
}

@keyframes twinkle {
0%, 100% { opacity: 0.2; transform: scale(1); }
50% { opacity: 1; transform: scale(1.2); box-shadow: 0 0 10px white; }
}

/* Основная структура */
.container {
max-width: 1400px;
margin: 0 auto;
padding: 20px;
position: relative;
z-index: 10;
}

.calculator-app {
display: flex;
flex-direction: column;
gap: 30px;
}

.main-content {
display: flex;
flex-direction: column;
gap: 30px;
}

@media (min-width: 992px) {
.main-content {
flex-direction: row;
}
}

/* Заголовок и навигация */
.app-header {
text-align: center;
margin-bottom: 30px;
animation: fadeIn 0.8s ease-out;
}

.app-title {
font-size: 2.8rem;
margin-bottom: 10px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 800;
letter-spacing: -0.5px;
}

.app-subtitle {
font-size: 1.2rem;
color: var(--dark-text);
opacity: 0.8;
max-width: 600px;
margin: 0 auto 25px;
}

.light-theme .app-subtitle {
color: var(--light-text);
}

/* Калькулятор */
.calculator-container {
background: var(--dark-card);
backdrop-filter: blur(12px);
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
transition: var(--transition);
animation: scaleIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
flex: 1;
}

.light-theme .calculator-container {
background: var(--light-card);
}

.calculator-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
position: relative;
}

.calculator-header::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.calculator-title {
display: flex;
align-items: center;
gap: 12px;
font-size: 1.4rem;
font-weight: 600;
}

.calculator-controls {
display: flex;
gap: 12px;
}

.theme-toggle {
background: rgba(255, 255, 255, 0.2);
border: none;
width: 44px;
height: 44px;
border-radius: 12px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 1.2rem;
transition: var(--transition);
border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-toggle:hover {
background: rgba(255, 255, 255, 0.3);
transform: rotate(15deg);
}

.calculator-content {
padding: 20px;
}

.calculator-display {
padding: 25px;
background: rgba(15, 20, 50, 0.4);
border-radius: 14px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}

.light-theme .calculator-display {
background: rgba(240, 242, 245, 0.6);
}

.calculator-history {
min-height: 24px;
color: rgba(160, 174, 192, 0.9);
font-size: 0.95rem;
margin-bottom: 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
transition: var(--transition);
}

.light-theme .calculator-history {
color: rgba(102, 102, 102, 0.9);
}

.calculator-preview {
min-height: 24px;
color: rgba(160, 174, 192, 0.9);
font-size: 0.95rem;
margin-bottom: 15px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: right;
transition: var(--transition);
}

.light-theme .calculator-preview {
color: rgba(102, 102, 102, 0.9);
}

.calculator-input {
    font-size: 3.2rem;
    font-weight: 500;
    width: 100%;
    border: none;
    background: transparent;
    color: #000; /* или var(--dark-text) если достаточно контрастно */
    text-align: right;
    outline: none;
    padding: 16px 0;
    pointer-events: none;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    transition: var(--transition);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}


.light-theme .calculator-input {
color: var(--light-text);
}

.calculator-buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}

.calc-btn {
background: rgba(67, 97, 238, 0.1);
border: none;
border-radius: 14px;
min-height: 60px;
font-size: 1.3rem;
font-weight: 500;
color: var(--dark-text);
cursor: pointer;
transition: var(--transition);
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.calc-btn::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.1);
opacity: 0;
transition: var(--transition);
}

.calc-btn:hover::after {
opacity: 1;
}

.light-theme .calc-btn {
background: rgba(67, 97, 238, 0.05);
color: var(--light-text);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.calc-btn:active {
transform: scale(0.95);
transition: transform 0.1s;
}

.operator {
background: rgba(67, 97, 238, 0.3);
color: white;
}

.function {
background: rgba(114, 9, 183, 0.3);
color: white;
}

.equals {
background: rgba(6, 214, 160, 0.3);
color: white;
}

.clear, .delete {
background: rgba(239, 71, 111, 0.3);
color: white;
}

.memory {
background: rgba(255, 209, 102, 0.3);
color: #1a202c;
}

.calculator-section {
display: none;
animation: fadeIn 0.5s ease;
}

.calculator-section.active {
display: block;
}

/* История */
.history-panel {
background: rgba(67, 97, 238, 0.1);
padding: 20px;
border-radius: var(--radius);
box-shadow: var(--shadow);
transition: var(--transition);
animation: fadeIn 0.8s ease;
width: 100%;
max-height: 300px;
}

@media (min-width: 992px) {
.history-panel {
width: 350px;
max-height: none;
height: 100%;
}
}

.light-theme .history-panel {
background: rgba(67, 97, 238, 0.05);
}

.history-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}

.history-title {
display: flex;
align-items: center;
gap: 10px;
color: var(--primary);
font-size: 1.3rem;
font-weight: 600;
}

.clear-history {
background: rgba(239, 71, 111, 0.2);
color: var(--danger);
border: none;
padding: 8px 15px;
border-radius: 10px;
cursor: pointer;
transition: var(--transition);
font-size: 0.9rem;
}

.clear-history:hover {
background: rgba(239, 71, 111, 0.3);
}

.history-list {
display: flex;
flex-direction: column;
gap: 12px;
max-height: 200px;
overflow-y: auto;
padding-right: 5px;
}

.history-item {
padding: 15px;
background: rgba(15, 20, 50, 0.4);
border-radius: 12px;
font-size: 0.95rem;
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid rgba(255, 255, 255, 0.1);
cursor: pointer;
transition: var(--transition);
animation: fadeIn 0.4s ease;
}

.history-item:hover {
transform: translateX(5px);
background: rgba(67, 97, 238, 0.15);
}

.light-theme .history-item {
background: rgba(240, 242, 245, 0.8);
border: 1px solid rgba(0, 0, 0, 0.05);
}

.light-theme .history-item:hover {
background: rgba(67, 97, 238, 0.08);
}

.history-expression {
color: rgba(160, 174, 192, 0.9);
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.light-theme .history-expression {
color: rgba(102, 102, 102, 0.9);
}

.history-result {
font-weight: 700;
color: var(--success);
margin-left: 15px;
}

/* Особенности */
.features-section {
margin-top: 50px;
animation: fadeIn 0.8s ease;
}

.section-title {
text-align: center;
font-size: 2rem;
margin-bottom: 40px;
color: var(--dark-text);
position: relative;
display: inline-block;
left: 50%;
transform: translateX(-50%);
}

.section-title::after {
content: '';
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 4px;
background: linear-gradient(90deg, var(--primary), var(--secondary));
border-radius: 2px;
}

.light-theme .section-title {
color: var(--light-text);
}

.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 25px;
}

.feature-tile {
background: var(--dark-card);
backdrop-filter: blur(10px);
border-radius: var(--radius);
padding: 25px;
box-shadow: var(--shadow);
transition: var(--transition);
animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-tile:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.light-theme .feature-tile {
background: var(--light-card);
border: 1px solid rgba(0, 0, 0, 0.03);
}

.feature-tile h3 {
font-size: 1.4rem;
margin-bottom: 15px;
color: var(--primary);
display: flex;
align-items: center;
gap: 10px;
}

.feature-tile p, .feature-tile ul {
color: var(--dark-text);
line-height: 1.6;
font-size: 1rem;
}

.light-theme .feature-tile p, .light-theme .feature-tile ul {
color: var(--light-text);
}

.feature-tile ul {
padding-left: 20px;
margin-top: 10px;
}

.feature-tile li {
margin-bottom: 8px;
position: relative;
}

.feature-tile li::before {
content: '•';
color: var(--primary);
position: absolute;
left: -15px;
}

/* Плитки калькуляторов */
.calculator-tabs {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
margin-bottom: 20px;
}

@media (min-width: 768px) {
.calculator-tabs {
grid-template-columns: repeat(7, 1fr);
}
}

.calc-tab {
background: rgba(67, 97, 238, 0.1);
border: none;
border-radius: 12px;
padding: 12px 8px;
text-align: center;
cursor: pointer;
transition: var(--transition);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 0.9rem;
color: var(--dark-text);
border: 1px solid rgba(255, 255, 255, 0.1);
}

.calc-tab i {
font-size: 1.2rem;
margin-bottom: 5px;
}

.calc-tab:hover {
background: rgba(67, 97, 238, 0.2);
transform: translateY(-3px);
}

.calc-tab.active {
background: var(--primary);
color: white;
box-shadow: 0 4px 15px rgba(67, 97, 238, 0.4);
}

.light-theme .calc-tab {
background: rgba(67, 97, 238, 0.05);
color: var(--light-text);
border: 1px solid rgba(0, 0, 0, 0.05);
}

.light-theme .calc-tab:hover {
background: rgba(67, 97, 238, 0.1);
}

.light-theme .calc-tab.active {
background: var(--primary);
color: white;
}

/* Формы */
.form-group {
margin-bottom: 20px;
animation: fadeIn 0.4s ease;
}

.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: var(--dark-text);
font-size: 1rem;
display: flex;
align-items: center;
gap: 8px;
}

.light-theme .form-group label {
color: var(--light-text);
}

.form-control {
width: 100%;
padding: 14px 18px;
border-radius: 14px;
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(15, 20, 50, 0.4);
color: var(--dark-text);
font-size: 16px;
transition: var(--transition);
backdrop-filter: blur(5px);
}

.light-theme .form-control {
background: rgba(240, 242, 245, 0.7);
border: 1px solid rgba(0, 0, 0, 0.08);
color: var(--light-text);
}

.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.2);
}

.input-group {
display: flex;
gap: 10px;
}

.input-group .form-control {
flex: 1;
}

.btn-calculate {
background: var(--success);
color: white;
border: none;
padding: 16px;
border-radius: 14px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
width: 100%;
transition: var(--transition);
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
margin-top: 10px;
box-shadow: 0 4px 15px rgba(6, 214, 160, 0.3);
}

.btn-calculate:hover {
background: #05b98a;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(6, 214, 160, 0.4);
}

/* Результаты */
.result-box {
background: rgba(67, 97, 238, 0.1);
border-radius: 14px;
padding: 20px;
margin-top: 20px;
display: none;
border-left: 4px solid var(--primary);
animation: fadeIn 0.5s ease;
}

.light-theme .result-box {
background: rgba(67, 97, 238, 0.05);
}

.result-box.active {
display: block;
}

.result-title {
font-weight: 600;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
color: var(--success);
font-size: 1.2rem;
}

.result-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
font-size: 1rem;
}

.light-theme .result-item {
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.result-value {
font-weight: 700;
color: var(--primary);
}

/* Футер */
.app-footer {
text-align: center;
padding: 30px 0;
color: var(--dark-text);
opacity: 0.7;
font-size: 0.9rem;
margin-top: 50px;
animation: fadeIn 1s ease;
}

.light-theme .app-footer {
color: var(--light-text);
}

/* Адаптивность */
@media (max-width: 768px) {
.app-title {
font-size: 2.2rem;
}

.calculator-header {
flex-direction: column;
gap: 15px;
align-items: flex-start;
}

.calculator-controls {
width: 100%;
justify-content: space-between;
}

.calc-btn {
min-height: 60px;
font-size: 1.2rem;
}

.feature-grid {
grid-template-columns: 1fr;
}
}

@media (max-width: 480px) {
.app-title {
font-size: 1.8rem;
}

.calculator-input {
font-size: 2rem;
}

.calculator-buttons {
gap: 5px;
}

.calc-btn {
min-height: 55px;
font-size: 1.1rem;
}

.form-control {
padding: 12px 15px;
}

.calculator-tabs {
grid-template-columns: repeat(2, 1fr);
}
}
.gagarin-quote {
font-style: italic;
margin-top: 40px;
color: #ecf0f1;
font-size: 1.rem;
max-width: 900px;
margin: 40px auto 0;
padding: 25px;
border-left: 4px solid #3498db;
background: rgba(25, 25, 35, 0.6);
border-radius: 10px;
position: relative;
box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
}

.gagarin-quote::before {
content: """;
position: absolute;
top: -30px;
left: -20px;
font-size: 8rem;
color: rgba(52, 152, 219, 0.2);
font-family: Georgia, serif;
}

/* Стили для контейнера истории */
.history-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
border-bottom: 1px solid #eee;
transition: background 0.3s;
}

.history-item:hover {
background: rgba(255, 255, 255, 0.05);
}

.history-text {
flex: 1;
min-width: 0;
}

/* Стили для кнопок шаринга */
.share-buttons {
display: flex;
gap: 8px;
margin-left: 15px;
opacity: 0.7;
transition: opacity 0.3s;
}

.history-item:hover .share-buttons {
opacity: 1;
}

.share-btn {
width: 32px;
height: 32px;
border-radius: 50%;
border: none;
background: #444;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
}

.share-btn:hover {
transform: scale(1.1);
}

.share-btn.whatsapp { background: #25D366; }
.share-btn.telegram { background: #0088cc; }
.share-btn.copy { background: #555; }

/* Уведомления */
.calc-notification {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
padding: 12px 20px;
border-radius: 8px;
background: #333;
color: white;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
z-index: 1000;
transition: opacity 0.3s;
}

.calc-notification.success {
background: #4CAF50;
}

.calc-notification.error {
background: #F44336;
}

.calc-notification.info {
background: #2196F3;
}