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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  padding: 40px;
  max-width: 800px;
  width: 100%;
  animation: slideUp 0.6s ease-out;
}

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

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

.logo {
  font-size: 2.5rem;
  font-weight: bold;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.subtitle {
  color: #666;
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.brand {
  color: #999;
  font-size: 0.9rem;
  font-style: italic;
}

.input-section {
  margin-bottom: 30px;
}

.input-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: #333;
}

.text-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.3s ease;
}

.text-input:focus {
  outline: none;
  border-color: #667eea;
}

.controls {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

.select-input {
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  transition: border-color 0.3s ease;
  width: 120px;
}

.select-input:focus {
  outline: none;
  border-color: #667eea;
}

.chop-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  align-self: flex-end;
  margin-left: auto;
}

.chop-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.chop-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.loading {
  display: none;
  text-align: center;
  margin: 20px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.results {
  display: none;
}

.results-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.segments-container {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.segment {
  display: inline-block;
  background: white;
  padding: 8px 12px;
  margin: 4px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  font-size: 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
  min-width: 40px;
  text-align: center;
}

.segment:hover {
  background: #667eea;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.segment-punctuation {
  display: inline-block;
  background: white;
  padding: 8px 12px;
  margin: 4px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  font-size: 1rem;
  color: #999;
  cursor: default;
  min-width: 40px;
  text-align: center;
  transition: all 0.2s ease;
}

.segment-punctuation:hover {
  background: #f5f5f5;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.segment-simple {
  display: inline-block;
  background: white;
  padding: 8px 12px;
  margin: 4px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.segment-simple:hover {
  background: #667eea;
  color: white;
  transform: translateY(-1px);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background-color: white;
  margin: 10% auto;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
  animation: slideDown 0.3s ease-out;
}

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

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

.modal-character {
  font-size: 3rem;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 15px;
}

.modal-pinyin {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 15px;
  font-style: italic;
}

.modal-translation {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 15px;
  line-height: 1.4;
}

.modal-pos {
  font-size: 0.9rem;
  color: #888;
  background: #f0f0f0;
  padding: 5px 10px;
  border-radius: 15px;
  display: inline-block;
  margin-bottom: 20px;
}

.modal-close {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: #5a6fd8;
}

.modal-loading {
  color: #667eea;
  font-style: italic;
}

/* Grammar Analysis Modal */
.grammar-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.grammar-modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  text-align: center;
}

.grammar-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

.grammar-progress {
  margin-top: 20px;
  font-size: 1.1rem;
  color: #667eea;
}

.grammar-note {
  margin-top: 15px;
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
}

/* Export Button */
.export-button {
  background: #28a745;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 10px;
}

.export-button:hover {
  background: #218838;
  transform: translateY(-1px);
}

.export-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
}

/* Grammar Results */
.grammar-results {
  margin-top: 20px;
  display: none;
}

.grammar-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.grammar-rule {
  background: #f8f9fa;
  border-left: 4px solid #667eea;
  padding: 15px;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
}

.grammar-rule-title {
  font-weight: bold;
  color: #667eea;
  margin-bottom: 5px;
}

.grammar-rule-text {
  color: #333;
  line-height: 1.4;
}

.stats {
  display: flex;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.stat {
  background: white;
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}

.error {
  display: none;
  background: #fee;
  color: #c33;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #c33;
  margin: 20px 0;
}

@media (max-width: 600px) {
  .container {
    padding: 20px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .chop-button {
    align-self: stretch;
    margin-left: 0;
  }
}
