* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary-color: #f59e0b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.header {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--primary-light) 100%
  );
  color: white;
  padding: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.03) 2px,
    rgba(255, 255, 255, 0.03) 4px
  );
  animation: shimmer 20s linear infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.header .subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.main-content {
  padding: 32px;
  display: grid;
  gap: 24px;
}

.input-section,
.output-section {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px;
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
}

.input-section:focus-within,
.output-section:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 16px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.3s ease;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.controls {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px;
  border: 2px solid var(--border-color);
}

.controls-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  cursor: pointer;
  user-select: none;
}

.checkbox-item:hover {
  background: #f1f5f9;
  border-color: var(--primary-light);
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.checkbox-item label {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-color), #059669);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-color), #dc2626);
  color: white;
}

.btn:active {
  transform: translateY(0);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.stat-card {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-align: center;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.info-panel {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #0ea5e9;
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
}

.info-panel h3 {
  color: #0c4a6e;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.info-panel p {
  color: #0369a1;
  font-size: 0.95rem;
  line-height: 1.6;
}

.warning-panel {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 16px;
  padding: 20px;
  margin-top: 16px;
}

.warning-panel h3 {
  color: #92400e;
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.warning-panel p {
  color: #a16207;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success-color);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  font-weight: 500;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: var(--danger-color);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.preset-btn {
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-secondary);
}

.preset-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.character-preview {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  max-height: 300px;
  overflow-y: auto;
}

.character-preview h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.character-preview h4 {
  color: var(--text-secondary);
  margin: 16px 0 8px;
  font-size: 1rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 4px;
}

.char-mapping {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.char-mapping:hover {
  background: var(--bg-secondary);
}

.char-mapping:last-child {
  border-bottom: none;
}

.char-mapping span:first-child {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 60px;
}

.char-mapping span:last-child {
  color: var(--primary-color);
  font-weight: 500;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Loading animations */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    margin: 10px;
    border-radius: 16px;
  }

  .header {
    padding: 24px 20px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .main-content {
    padding: 20px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .header .subtitle {
    font-size: 1rem;
  }

  .main-content {
    padding: 16px;
    gap: 16px;
  }

  .input-section,
  .output-section,
  .controls {
    padding: 16px;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .toast {
    right: 10px;
    left: 10px;
    transform: translateY(-100%);
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
  }

  body {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  }

  .info-panel {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border-color: #3b82f6;
  }

  .info-panel h3,
  .info-panel p {
    color: #dbeafe;
  }

  .warning-panel {
    background: linear-gradient(135deg, #92400e 0%, #a16207 100%);
    border-color: #f59e0b;
  }

  .warning-panel h3,
  .warning-panel p {
    color: #fef3c7;
  }
}

/* Focus indicators for accessibility */
.btn:focus-visible,
.preset-btn:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Animation for smooth transitions */
.checkbox-item,
.stat-card,
.btn,
.preset-btn {
  will-change: transform;
}

/* Print styles */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .container {
    box-shadow: none;
    border-radius: 0;
  }

  .header {
    background: var(--text-primary);
    color: white;
  }

  .btn,
  .preset-btn {
    display: none;
  }
}
