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

:root {
  --card-radius: 20px;
  --radius: 12px;
  --border: #e6e6e6;
  --text: #222;
  --muted: #666;
  --bg1: #667eea;
  --bg2: #764ba2;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--text);
}

.container {
  width: 100%;
  max-width: 860px;
}

.app-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 34px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.5s ease-in;
}

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

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

h1 {
  font-size: 2.3rem;
  color: var(--bg1);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.4;
}

.input-section {
  margin: 18px 0 22px;
}

textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--bg1);
}

textarea::placeholder {
  color: #9a9a9a;
}

/* Controls */
.controls-section {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.control-group:nth-child(1) {
  grid-column: span 12;
}

.control-group:nth-child(2),
.control-group:nth-child(3),
.control-group:nth-child(4) {
  grid-column: span 4;
}

@media (max-width: 760px) {
  .control-group:nth-child(2),
  .control-group:nth-child(3),
  .control-group:nth-child(4) {
    grid-column: span 12;
  }
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-group label {
  font-weight: 700;
  color: #444;
  font-size: 0.95rem;
}

select {
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

select:focus {
  outline: none;
  border-color: var(--bg1);
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e9e9e9;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg1);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg1);
  cursor: pointer;
  border: none;
}

.hint {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Actions */
.actions {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.actions-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.actions-row .btn {
  grid-column: span 4;
}

.actions-row:first-child .btn {
  grid-column: span 6;
}

@media (max-width: 760px) {
  .actions-row .btn,
  .actions-row:first-child .btn {
    grid-column: span 12;
  }
}

.btn {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  min-height: 44px;
}

.btn-icon {
  font-size: 1.15rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  color: #fff;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-success {
  background: #28a745;
  color: #fff;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.download-note {
  font-size: 0.95rem;
  color: #333;
  background: #f6f7ff;
  border: 1px solid #e1e6ff;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.35;
}

/* Help */
.help {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.help summary {
  cursor: pointer;
  font-weight: 800;
  color: #333;
}

.help-content {
  margin-top: 10px;
  color: #333;
}

.help-content h3 {
  margin: 12px 0 6px;
  color: #444;
}

.help-content ul {
  margin-left: 18px;
  display: grid;
  gap: 6px;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--bg1);
  font-weight: 800;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}

.link-btn:hover {
  background: rgba(102, 126, 234, 0.12);
}

/* Status */
.status {
  margin-top: 14px;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  font-weight: 650;
  min-height: 20px;
  transition: all 0.2s ease;
}

.status.speaking {
  background: #d4edda;
  color: #155724;
}

.status.success {
  background: #d1ecf1;
  color: #0c5460;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
}

.status.paused {
  background: #fff3cd;
  color: #856404;
}

/* Accessibility helper */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
