/* Natural, handcrafted styling */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "System UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #2d3748;
  background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
  min-height: 100vh;
  padding: 20px;
}

/* Header styling */
.header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 20px;
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
}

.title {
  font-size: 2.5rem;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
}

.tagline {
  font-size: 1.1rem;
  color: #4a5568;
  margin-bottom: 6px;
  font-style: italic;
}

.subtitle {
  font-size: 0.95rem;
  color: #718096;
}

/* Main container */
.main {
  display: flex;
  justify-content: center;
}

.app-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 32px;
  width: 100%;
  max-width: 900px;
  border: 1px solid #e2e8f0;
  position: relative;
}

.app-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #8b5a3c;
  border-radius: 12px 12px 0 0;
}

/* Form styling */
.input-form {
  margin-bottom: 0;
}

.form-header {
  margin-bottom: 24px;
}

.form-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
}

.form-help {
  color: #718096;
  font-size: 0.95rem;
}

.textarea-wrapper {
  position: relative;
  margin-bottom: 24px;
}

.text-area {
  width: 100%;
  padding: 16px;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  background: #f7fafc;
  transition: all 0.2s ease;
}

.text-area:focus {
  outline: none;
  border-color: #8b5a3c;
  background: white;
  box-shadow: 0 0 0 3px rgba(139, 90, 60, 0.1);
}

.counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.85rem;
  color: #a0aec0;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  border-radius: 4px;
}

/* Button styling */
.action-btn {
  width: 100%;
  padding: 14px 24px;
  background: #8b5a3c;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.action-btn:hover:not(:disabled) {
  background: #7c4a2e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 90, 60, 0.3);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

/* Spinner animation */
.btn-spinner {
  display: flex;
  gap: 3px;
}

.spinner-dot {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

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

/* Results styling */
.results {
  animation: slideIn 0.3s ease;
}

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

.results-header {
  margin-bottom: 28px;
  text-align: center;
}

.results-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
}

.results-subtitle {
  color: #718096;
  font-size: 0.95rem;
}

/* Comparison styling */
.comparison {
  margin-bottom: 32px;
}

.text-block {
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.text-block.original {
  border-left: 4px solid #e53e3e;
}

.text-block.simplified {
  border-left: 4px solid #38a169;
}

.block-header {
  background: #f7fafc;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
}

.block-label {
  font-weight: 500;
  color: #2d3748;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.original-dot {
  background: #e53e3e;
}

.simplified-dot {
  background: #38a169;
}

.grade {
  background: #edf2f7;
  color: #4a5568;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.grade.improved {
  background: #c6f6d5;
  color: #2f855a;
}

.text-content {
  padding: 20px;
  background: white;
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.7;
  font-size: 1.05rem;
}

/* Stats styling */
.stats {
  margin: 24px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #f0fff4 0%, #f7fafc 100%);
  border: 1px solid #9ae6b4;
  border-radius: 8px;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-info {
  flex: 1;
}

.stat-label {
  color: #4a5568;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.stat-number {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2d3748;
}

.stat-unit {
  font-size: 0.9rem;
  color: #718096;
  font-weight: 400;
}

/* Back button */
.back-btn {
  width: 100%;
  padding: 12px 20px;
  background: white;
  color: #8b5a3c;
  border: 2px solid #8b5a3c;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 16px;
}

.back-btn:hover {
  background: #8b5a3c;
  color: white;
}

/* Clickable words */
.clickable-word {
  cursor: pointer;
  padding: 2px 0px;
  border-radius: 3px;
  transition: all 0.15s ease;
  display: inline-block;
}

.clickable-word:hover {
  background: #fef5e7;
  color: #d69e2e;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Error styling */
.error {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #fed7d7;
  border: 1px solid #feb2b2;
  border-radius: 8px;
  margin-top: 20px;
}

.error-icon {
  font-size: 1.2rem;
}

.error-text {
  color: #c53030;
  font-weight: 500;
}

/* Modal styling */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2d3748;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #a0aec0;
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f7fafc;
  color: #4a5568;
}

.modal-body {
  padding: 24px;
  max-height: calc(80vh - 80px);
  overflow-y: auto;
}

/* Dictionary content */
.modal-loading {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
}

.loading-dots {
  margin-bottom: 8px;
}

.loading-dots span {
  display: inline-block;
  animation: dotPulse 1.4s infinite ease-in-out;
  margin: 0 1px;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.word-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: #8b5a3c;
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
}

.phonetic {
  color: #718096;
  font-style: italic;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.meaning-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.meaning-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.part-of-speech {
  font-size: 1rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 12px;
  font-style: italic;
  text-transform: capitalize;
}

.definition-item {
  margin-bottom: 12px;
  padding-left: 16px;
  border-left: 2px solid #cbd5e0;
  position: relative;
}

.definition-item::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 8px;
  width: 4px;
  height: 4px;
  background: #8b5a3c;
  border-radius: 50%;
}

.definition-text {
  margin-bottom: 4px;
  line-height: 1.6;
}

.example {
  color: #718096;
  font-style: italic;
  font-size: 0.9rem;
  margin-top: 4px;
}

.synonyms,
.antonyms {
  margin-top: 8px;
  font-size: 0.9rem;
}

.synonyms span,
.antonyms span {
  font-weight: 600;
  color: #4a5568;
}

.dict-error {
  text-align: center;
  padding: 40px 20px;
  color: #e53e3e;
}

.dict-error h4 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.dict-error p {
  margin-bottom: 4px;
  color: #718096;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .title {
    font-size: 2rem;
  }

  .app-card {
    padding: 24px;
  }

  .text-area {
    padding: 14px;
  }

  .comparison {
    margin-bottom: 24px;
  }

  .stat-item {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .modal {
    padding: 16px;
  }

  .modal-content {
    max-height: 85vh;
  }

  .modal-body {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .title {
    font-size: 1.75rem;
  }

  .app-card {
    padding: 20px;
  }

  .block-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
  }

  .text-content {
    padding: 16px;
  }

  .modal-header {
    padding: 16px 20px 12px;
  }
}

#simplifiedGrade,
#originalGrade,
.stats {
  display: none;
}
