:root {
  --bg-gradient: linear-gradient(-45deg, #0a0a0a, #141414, #1e1e1e, #323232);
  --card-bg: rgba(30, 41, 59, 0.85);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --telegram: #0088cc;
  --toggle-bg: #334155;
  --toggle-bg-active: #1e40af;
  --secondary-btn: #475569;
  --secondary-btn-hover: #64748b;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(20px); opacity: 0; }
}

@keyframes generatePulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes loadingDots {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes telegramPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
  background-size: 300% 300%;
  animation: gradientBG 15s ease infinite;
  color: var(--text);
  padding: 10px;
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  max-width: 480px;
  padding: 15px;
}

.password-generator {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

h1 {
  font-size: 1.4rem;
  margin-bottom: 1.2rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.password-display {
  position: relative;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
}

#passwordOutput {
  width: 100%;
  padding: 0.8rem 3.5rem 0.8rem 0.8rem;
  background-color: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--text-secondary);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  word-break: break-word;
  transition: all 0.3s ease;
}

#passwordOutput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

#passwordOutput.generating {
  animation: generatePulse 0.5s ease-in-out;
}

.icon-button {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease, transform 0.2s ease;
  z-index: 2;
}

.icon-button:hover {
  color: var(--primary);
  transform: translateY(-50%) scale(1.1);
}

.generate-animation {
  position: absolute;
  right: 2.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  z-index: 1;
}

.generate-animation.visible {
  display: block;
}

.loading-dots {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.loading-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--primary);
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

.password-strength {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.strength-bar {
  flex: 1;
  height: 6px;
  background-color: var(--toggle-bg);
  border-radius: 3px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.strength-fill.weak { width: 33%; background-color: var(--danger); }
.strength-fill.medium { width: 66%; background-color: var(--warning); }
.strength-fill.strong { width: 100%; background-color: var(--success); }

.strength-text {
  font-size: 0.8rem;
  font-weight: 500;
  min-width: 60px;
  text-align: center;
}

.length-control {
  margin-bottom: 1.2rem;
}

.length-control label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

#passwordLength {
  width: 100%;
  margin-top: 0.5rem;
  accent-color: var(--primary);
  transition: accent-color 0.3s ease;
}

.checkboxes {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.slider {
  position: relative;
  width: 50px;
  height: 26px;
  background-color: var(--toggle-bg);
  transition: .4s cubic-bezier(0.23, 1, 0.32, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s cubic-bezier(0.23, 1, 0.32, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--toggle-bg-active);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--text);
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.generate-btn {
  width: 100%;
  padding: 0.9rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: 
    background-color 0.3s ease, 
    transform 0.2s ease,
    box-shadow 0.3s ease;
  margin-bottom: 0.8rem;
}

.generate-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.generate-btn:active {
  transform: translateY(0);
}

.menu-btn {
  width: 100%;
  padding: 0.9rem;
  background-color: var(--secondary-btn);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: 
    background-color 0.3s ease, 
    transform 0.2s ease,
    box-shadow 0.3s ease;
}

.menu-btn:hover {
  background-color: var(--secondary-btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.copied {
  color: var(--success) !important;
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.2); }
  100% { transform: translateY(-50%) scale(1); }
}

.telegram-promo {
  background: linear-gradient(135deg, rgba(0, 136, 204, 0.1) 0%, rgba(0, 136, 204, 0.2) 100%);
  border: 1px solid rgba(0, 136, 204, 0.3);
  border-radius: 0.75rem;
  padding: 1rem;
  margin: 1.5rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.telegram-promo::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shimmer 3s infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) rotate(45deg); }
  100% { transform: translateX(100%) rotate(45deg); }
}

.telegram-promo-content {
  position: relative;
  z-index: 2;
}

.telegram-promo h3 {
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.telegram-promo p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.telegram-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background-color: var(--telegram);
  color: white;
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
  animation: telegramPulse 2s infinite;
}

.telegram-btn:hover {
  background-color: #0077b3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
  animation: none;
}

.security-tips {
  margin: 1.5rem 0;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #334155;
}

.security-tips details summary {
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
}

.security-tips details ul {
  margin-top: 0.8rem;
  padding-left: 1.5rem;
}

.security-tips details li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.modal {
  display: none;
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(2px);
  background: rgba(20, 20, 20, 0.85);
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.modal-content {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 1.5rem;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  position: relative;
  text-align: center;
  animation: slideUp 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding: 0.8rem 0 1rem 0;
  border-bottom: 1px solid #334155;
  position: relative;
  min-height: 50px;
}

.modal-header h2,
.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  text-align: center;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
  position: relative;
  top: 2px;
  gap: 0.5rem;
}

.back-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 45px;
  height: 45px;
  margin: 0;
}

.back-btn:hover {
  color: #ffffff;
}

.modal-body {
  margin-bottom: 1.5rem;
  text-align: left;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.modal-btn {
  padding: 0.5rem 1.5rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.modal-btn:hover {
  background-color: var(--primary-hover);
}

.modal.closing {
  animation: fadeOut 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.modal-content.closing {
  animation: slideDown 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.close-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  font-size: 2rem;
  font-weight: bold;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.3s ease;
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
}

.close-btn:hover {
  color: #ffffff;
}

.settings-content, .contacts-content, .menu-content {
  text-align: left;
  margin: 1.5rem 0;
}

.settings-content p, .contacts-content p {
  margin-bottom: 1rem;
}

.contacts-content ul {
  list-style: none;
  padding-left: 0;
}

.contacts-content li {
  margin-bottom: 0.8rem;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.contacts-content li:hover {
  transform: translateX(5px);
}

.contacts-content a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.contacts-content a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.menu-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-item {
  width: 100%;
  padding: 1rem;
  background-color: var(--secondary-btn);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  transition: 
    background-color 0.3s ease, 
    transform 0.2s ease,
    box-shadow 0.3s ease;
  text-align: left;
}

.menu-item:hover {
  background-color: var(--secondary-btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.copyright {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.4;
}

.copyright p {
  margin-bottom: 0.5rem;
}

.copyright a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.copyright a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

@media (max-width: 768px) {
  .password-generator {
    padding: 1.2rem;
  }
  
  .menu-item {
    padding: 0.9rem;
  }

  .copyright {
    font-size: 0.75rem;
    margin-top: 1rem;
  }
  
  .modal-header h2,
  .modal-header h3 {
    font-size: 1.2rem;
  }
  
  .back-btn,
  .close-btn {
    width: 40px;
    height: 40px;
  }
  
  .back-btn {
    font-size: 1.5rem;
  }
  
  .close-btn {
    font-size: 1.8rem;
  }
  
  .modal-header {
    padding: 0.7rem 0 0.9rem 0;
    min-height: 45px;
  }
  
  .security-tips {
    padding: 0.8rem;
  }
  
  .security-tips details ul {
    padding-left: 1.2rem;
  }
  
  .telegram-promo {
    padding: 0.8rem;
    margin: 1.2rem 0;
  }
  
  .telegram-promo h3 {
    font-size: 1rem;
  }
  
  .telegram-promo p {
    font-size: 0.85rem;
  }
  
  .telegram-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}