html, body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7fb;
  color: #1f2937;
  overflow: hidden;
}

.container {
  max-width: 720px;
  height: 100vh;
  margin: 0 auto;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.header {
  text-align: center;
  margin-bottom: 0;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  color: #1e3a8a;
}

.section {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

.section-label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.container > .section:nth-of-type(3),
.container > .section:nth-of-type(4) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

textarea {
  width: 100%;
  min-height: 0;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  resize: none;
  font-size: 16px;
  line-height: 1.5;
  outline: none;
}

textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.button-row,
.quick-language-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0) scale(0.97);
}

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.primary-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #2f6fee, #1d4ed8);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.22);
}

.icon-btn {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.icon-btn:hover {
  background: #e2e8f0;
}

.input-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.input-card textarea {
  border: none;
  background: transparent;
  padding: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.input-card textarea:focus {
  border: none;
  box-shadow: none;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-shrink: 0;
}

.char-count {
  margin-right: auto;
  font-size: 13px;
  color: #94a3b8;
}

.char-count.char-count-limit {
  color: #dc2626;
  font-weight: 700;
}

.result-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.result-lang-label {
  font-size: 14px;
  font-weight: 700;
  color: #475569;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.speak-btn {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid transparent;
}

.speak-btn:hover {
  background: #ddd6fe;
}

.language-select {
  width: 100%;
  padding: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  font-size: 16px;
  background: #ffffff;
}

.quick-language-row button {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid transparent;
}

.quick-language-row button:hover {
  background: #ddd6fe;
}

.quick-language-row button.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

.quick-language-row button.active:hover {
  background: #1d4ed8;
}

.result-text {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  cursor: default;
  user-select: text;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1f2937;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .container {
    padding: 12px 12px 10px;
  }

  .header h1 {
    font-size: 18px;
  }

  .section {
    padding: 10px 12px;
    border-radius: 14px;
  }

  button {
    flex: 1;
    padding: 10px 8px;
    font-size: 13px;
  }

  .quick-language-row button {
    flex: 1 1 30%;
  }
}