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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

header {
  background: #2c3e50;
  color: #fff;
  text-align: center;
  padding: 16px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

.container {
  display: flex;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

.panel {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #2c3e50;
}

/* 번역기 */
.direction-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dir-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid #3498db;
  background: #fff;
  color: #3498db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.dir-btn.active {
  background: #3498db;
  color: #fff;
}

.dir-swap-btn {
  padding: 8px 12px;
  border: 2px solid #3498db;
  background: #fff;
  color: #3498db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.2s;
  flex-shrink: 0;
}

.dir-swap-btn:hover {
  background: #eaf4fd;
}

.translator-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.input-area, .output-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: #3498db;
}

#translate-btn, #dict-btn {
  padding: 10px 20px;
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.2s;
}

#translate-btn:hover, #dict-btn:hover {
  background: #2980b9;
}

#translate-btn:disabled, #dict-btn:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
}

.result-box {
  min-height: 120px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.input-actions {
  display: flex;
  gap: 8px;
}

.tts-btn {
  padding: 10px 16px;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}

.tts-btn:hover {
  background: #219a52;
}

.tts-btn.speaking {
  background: #e74c3c;
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-info {
  font-size: 0.75rem;
  color: #7f8c8d;
  background: #f0f2f5;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.speed-label {
  font-size: 0.8rem;
  color: #555;
  margin-right: 4px;
}

.speed-btn {
  padding: 4px 8px;
  border: 1px solid #ddd;
  background: #f8f9fa;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  color: #555;
  transition: all 0.15s;
}

.speed-btn:hover {
  background: #e8e8e8;
}

.speed-btn.active {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
}

#swap-btn {
  width: 100%;
  padding: 6px;
  background: #ecf0f1;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #555;
  transition: background 0.2s;
}

#swap-btn:hover {
  background: #d5dbdb;
  color: #2c3e50;
}

.result-box:empty::before {
  content: attr(placeholder);
  color: #adb5bd;
}

.clickable-word {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}

.clickable-word:hover {
  background: #d4eafc;
  color: #2471a3;
}

/* 사전 모드 토글 */
.dict-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dict-mode-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid #3498db;
  background: #fff;
  color: #3498db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.dict-mode-btn.active {
  background: #3498db;
  color: #fff;
}

/* 사전 */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

.search-bar input:focus {
  outline: none;
  border-color: #3498db;
}

.dict-result-box {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.dict-word-header {
  margin-bottom: 12px;
}

.dict-word-header .word {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2c3e50;
}

.dict-word-header .word-arrow {
  font-size: 1.3rem;
  color: #3498db;
  margin: 0 8px;
}

.dict-word-header .phonetic {
  color: #7f8c8d;
  font-size: 0.95rem;
  margin-top: 2px;
}

.dict-word-header .korean-meaning {
  margin-top: 8px;
  padding: 8px 12px;
  background: #eaf4fd;
  border-radius: 6px;
  color: #2980b9;
  font-weight: 600;
}

.dict-meaning {
  margin-bottom: 16px;
}

.dict-meaning .part-of-speech {
  font-weight: 700;
  color: #e74c3c;
  font-size: 0.9rem;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.dict-definition {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.dict-definition .definition {
  margin-bottom: 4px;
  line-height: 1.5;
}

.dict-definition .definition-en {
  color: #95a5a6;
  font-size: 0.85rem;
  margin-bottom: 4px;
  line-height: 1.4;
}

.dict-definition .example {
  color: #7f8c8d;
  font-style: italic;
  font-size: 0.9rem;
  margin-top: 4px;
}

.dict-error, .translate-error {
  color: #e74c3c;
  padding: 12px;
  text-align: center;
}

.loading {
  color: #7f8c8d;
  text-align: center;
  padding: 20px;
}

.audio-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  margin-left: 8px;
  vertical-align: middle;
}

/* 반응형: 모바일 */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .panel {
    padding: 16px;
  }

  header h1 {
    font-size: 1.2rem;
  }
}
