:root {
  --bg: #1e1e1e;
  --bg-2: #262626;
  --bg-3: #2f2f2f;
  --fg: #e0e0e0;
  --fg-dim: #9a9a9a;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --border: #3a3a3a;
  --ok: #60a5fa;
  --err: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
  gap: 14px;
  height: 100dvh;
}

/* Header */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}
h1 span { color: var(--accent); font-weight: 600; }

.status {
  font-size: 0.8rem;
  color: var(--fg-dim);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status[data-state="ready"]   { color: var(--ok); border-color: #27436b; }
.status[data-state="translating"] { color: var(--accent); }
.status[data-state="error"]   { color: var(--err); border-color: #6b2727; }

/* Language bar */
.langbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.field { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--fg-dim); }

select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.05rem;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.swap {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.swap:active { background: var(--accent-2); transform: scale(0.96); }

/* Text boxes */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.box {
  flex: 1;
  width: 100%;
  padding: 16px;
  font-size: 1.15rem;
  line-height: 1.5;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  resize: none;
  outline: none;
}
.box:focus { border-color: var(--accent); }
#target { background: var(--bg-3); color: var(--fg); }

/* Footer buttons */
footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn {
  padding: 12px 22px;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { transform: scale(0.97); }

/* Voice buttons */
.btn.voice {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 18px;
  font-size: 1.05rem;
  min-height: 52px;
  width: 100%;
}
.vicon { font-size: 1.35rem; line-height: 1; }
.vlabel { font-weight: 600; letter-spacing: 0.2px; }
.vlang {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}
.btn.voice.mic { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.voice.mic:active { background: var(--accent-2); }
.btn.voice.speak { background: var(--bg-2); border-color: #27436b; color: var(--ok); }
.btn.voice.mic.active {
  background: #7f1d1d;
  border-color: #b91c1c;
  color: #fff;
  animation: pulse 1.5s ease-in-out infinite;
}
.btn.voice.mic.active .vlang { border-color: rgba(255, 255, 255, 0.4); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(185, 28, 28, 0); }
}

@media (max-width: 480px) {
  body { padding: 12px; gap: 10px; }
  .box { font-size: 1.05rem; padding: 14px; }
  h1 { font-size: 1.2rem; }
}
