:root {
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1a253f;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.4);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --pt-color: #10b981;
  --pt-glow: rgba(16, 185, 129, 0.25);
  --ja-color: #ef4444;
  --ja-glow: rgba(239, 68, 68, 0.25);
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 12px;
  user-select: none;
}

.app-container {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(19, 27, 46, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.brand-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.flag-icon {
  font-size: 1.1rem;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.status-pill.busy {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
}

.status-pill.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-pill.recording .status-dot {
  animation: pulse 1s infinite alternate;
}

/* Buttons Section */
.buttons-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.ptt-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.ptt-btn:active {
  transform: scale(0.98);
}

.pt-btn:hover {
  border-color: rgba(16, 185, 129, 0.5);
  background: var(--bg-card-hover);
}

.ja-btn:hover {
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--bg-card-hover);
}

.btn-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-flag {
  font-size: 2.2rem;
  line-height: 1;
}

.btn-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.btn-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.btn-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-action-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.rec-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background-color 0.2s;
}

.action-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-grow: 1;
  margin-left: 8px;
}

/* Sound wave animation */
.soundwave {
  display: none;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.wave-bar {
  width: 3px;
  height: 6px;
  border-radius: 3px;
  background-color: currentColor;
}

/* Button Active / Recording States */
.ptt-btn.recording {
  box-shadow: 0 0 25px var(--glow);
  transform: scale(1.01);
}

.pt-btn.recording {
  --glow: var(--pt-glow);
  border-color: var(--pt-color);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), var(--bg-card));
}

.ja-btn.recording {
  --glow: var(--ja-glow);
  border-color: var(--ja-color);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), var(--bg-card));
}

.ptt-btn.recording .rec-led {
  background: #ef4444;
  animation: pulse 0.8s infinite alternate;
}

.ptt-btn.recording .action-label {
  color: #f8fafc;
  font-weight: 700;
}

.ptt-btn.recording .soundwave {
  display: flex;
}

.pt-btn.recording .soundwave { color: var(--pt-color); }
.ja-btn.recording .soundwave { color: var(--ja-color); }

.ptt-btn.recording .wave-bar:nth-child(1) { animation: wave 0.8s infinite ease-in-out 0.1s; }
.ptt-btn.recording .wave-bar:nth-child(2) { animation: wave 0.8s infinite ease-in-out 0.2s; }
.ptt-btn.recording .wave-bar:nth-child(3) { animation: wave 0.8s infinite ease-in-out 0.3s; }
.ptt-btn.recording .wave-bar:nth-child(4) { animation: wave 0.8s infinite ease-in-out 0.4s; }
.ptt-btn.recording .wave-bar:nth-child(5) { animation: wave 0.8s infinite ease-in-out 0.5s; }

@keyframes wave {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

@keyframes pulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.2); }
}

/* =======================================================
   MANUAL TEXT INPUT SECTION (Igual fabio.hanashi.online)
   ======================================================= */
.manual-input-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manual-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.manual-toggle-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.3);
}

.manual-toggle-icon {
  font-size: 1rem;
  margin-right: 8px;
}

.toggle-arrow {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.manual-toggle-btn[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

.manual-input-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.manual-input-wrapper:focus-within {
  border-color: var(--border-active);
}

.manual-textarea {
  width: 100%;
  height: 75px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  user-select: text;
}

.manual-textarea::placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.manual-input-divider {
  height: 1px;
  background: var(--border-color);
}

.manual-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spacer {
  flex-grow: 1;
}

.manual-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.manual-clear-btn:hover {
  color: #f87171;
}

.manual-btn-translate {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.pt-translate-btn {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.pt-translate-btn:hover {
  background: rgba(16, 185, 129, 0.3);
}

.ja-translate-btn {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.ja-translate-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* Status Bar */
.status-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.status-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-icon {
  font-size: 1rem;
}

.status-bar.busy {
  border-color: var(--border-active);
  background: rgba(56, 189, 248, 0.05);
}

.status-bar.busy .status-text {
  color: var(--accent-cyan);
  font-weight: 600;
}

.stop-audio-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.stop-audio-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* Translation Cards */
.translation-card-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.translation-box {
  border-color: rgba(56, 189, 248, 0.2);
  background: linear-gradient(180deg, rgba(19, 27, 46, 0.9), var(--bg-card));
}

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-buttons-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.lang-tag.target {
  color: var(--accent-cyan);
}

.copy-text-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-text-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.replay-btn {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.replay-btn:hover {
  background: rgba(56, 189, 248, 0.2);
}

.text-content {
  font-size: 1.05rem;
  line-height: 1.5;
  color: #ffffff;
  word-break: break-word;
  user-select: text;
}

.text-content.placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* Romaji Guide */
.romaji-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 4px;
}

.romaji-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.romaji-content {
  font-size: 0.95rem;
  font-weight: 500;
  color: #fde047;
  letter-spacing: 0.02em;
  user-select: text;
}

/* History Section */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.clear-history-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.clear-history-btn:hover {
  color: #f87171;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.history-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

.history-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.history-orig {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.history-trans {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
}

.history-romaji {
  font-size: 0.75rem;
  color: #fde047;
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 10px 0;
}

@media (min-width: 500px) {
  .buttons-grid {
    grid-template-columns: 1fr 1fr;
  }
}
