/* Base styles and reset */
:root {
  --primary-color: #4A90E2;
  --secondary-color: #2C3E50;
  --footer-bg: #4A90E2;
  --footer-text: #E5E7EB;
  --background-color: #F5F7FA;
  --text-color: #333333;
  --error-color: #E74C3C;
  --success-color: #2ECC71;
  --border-radius: 8px;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
}

/* Layout */
header {
  background-color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
}

nav {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  gap: 2rem;
}

main {
  margin-top: 4rem;
  min-height: calc(100vh - 8rem);
  padding: 2rem 1rem;
}

footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  padding: 2.5rem 1rem;
  position: relative;
  overflow: hidden;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
      rgba(74, 144, 226, 0) 0%,
      rgba(74, 144, 226, 0.3) 50%,
      rgba(74, 144, 226, 0) 100%);
}

/* Navigation */
.logo a {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
  text-decoration: none;
}

/* Navigation links */
.nav-links a {
  color: white;
  text-decoration: none;
  margin-left: 1.5rem;
  transition: opacity var(--transition-speed);
}

.nav-links a:hover {
  opacity: 0.8;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  border-radius: var(--border-radius);
  text-decoration: none;
  transition: all var(--transition-speed);
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background-color: #2e62af;
  color: white;
}

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

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-outline {
  border: 2px solid var(--secondary-color);
  color: var(--secondary-color);
  background-color: transparent;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#generate-btn {
  font-size: 0.9rem;
}

/* Word Input Styles */
.word-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.word-input {
  flex: 1;
}

.remove-word-btn {
  background: var(--error-color);
  color: white;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: opacity var(--transition-speed);
}

.remove-word-btn:hover {
  opacity: 0.8;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

.word-input:invalid {
  border-color: var(--error-color);
}

/* Forms */
.form-group {
  margin-bottom: 2rem;
}

.form-field {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

select,
input {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 1rem;
}

.form-help {
  display: block;
  color: #666;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.generation-notice {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
  font-style: italic;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.alert-error {
  background-color: #FDE8E7;
  color: var(--error-color);
}

.alert-success {
  background-color: #E8F8F1;
  color: var(--success-color);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 1rem;
  background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
  color: white;
  border-radius: var(--border-radius);
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.hero-description {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

/* Features Section */
.features {
  padding: 2rem 0;
}

.features h2 {
  text-align: center;
  margin-bottom: 2rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.feature-card {
  background-color: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Reading Page */
.reading-section {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.reading-container {
  background-color: white;
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
}

@media (max-width: 768px) {
  .reading-section {
    padding: 0;
    max-width: 100%;
  }

  .reading-container {
    padding: 1rem 0.25rem;
    margin: 0 0 1.5rem 0;
    border-radius: 0;
    width: 100%;
    box-shadow: none;
  }
}

.text-section {
  margin-bottom: 2rem;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.text-section h2 {
  margin-bottom: 1rem;
  color: var(--secondary-color);
}

.english-text,
.japanese-text {
  line-height: 1.65;
  font-size: 1.1rem;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  padding: 0 0.5rem;
}

@media (max-width: 768px) {
  .english-text,
  .japanese-text {
    font-size: 1rem;
    padding: 0 0.25rem;
    text-align: left;
    width: 100%;
  }

  .text-section {
    margin-bottom: 1.5rem;
    padding: 0 0.25rem;
  }

  .text-section h2 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    padding: 0 0.25rem;
  }
}

.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 0 1rem;
}

/* Loading state */
.loading-text {
  display: inline-flex;
  align-items: center;
}

.loading-text::after {
  content: '';
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-right-color: transparent;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Footer */
.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links a {
  color: var(--footer-text);
  text-decoration: none;
  margin-left: 1.5rem;
  position: relative;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--primary-color);
}

.footer-links a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 1px;
  bottom: -2px;
  left: 0;
  background-color: var(--primary-color);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.footer-links a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .footer-links a {
    margin: 0 0.75rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}