:root {
  --bg: #0b0d12;
  --surface: #151922;
  --surface-2: #1b2029;
  --input-bg: #12161f;
  --output-bg: #181d27;
  --text: #e7e9ee;
  --muted: #8b93a7;
  --dim: #5b6478;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --border: #262b3a;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  background:
    radial-gradient(circle at 12% -5%, rgba(34, 211, 238, 0.07), transparent 45%),
    radial-gradient(circle at 88% 10%, rgba(74, 222, 128, 0.06), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 28px 20px 60px;
  min-height: 100vh;
}
.wrap { max-width: 1080px; margin: 0 auto; }

/* ---------- Header ---------- */
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.back:hover { color: var(--accent-2); }
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  font-size: 1.45rem;
  margin-bottom: 22px;
}
.brand__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}

/* ---------- Pill tabs ---------- */
.tabs { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--dim); }
.tab.active {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.1);
}
.tab svg { width: 18px; height: 18px; }

/* ---------- Language bar ---------- */
.langbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.lang {
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 4px;
}
.lang--src { color: var(--muted); }
.lang--dst { color: var(--accent); text-align: right; }
.swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.swap:hover { background: rgba(34, 211, 238, 0.12); transform: rotate(180deg); }
.swap svg { width: 18px; height: 18px; }

/* ---------- Two-pane layout ---------- */
.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
@media (max-width: 720px) {
  .panes { grid-template-columns: 1fr; }
  .pane--in { border-right: none; border-bottom: 1px solid var(--border); }
}
.pane {
  position: relative;
  padding: 20px;
  min-height: 230px;
  display: flex;
  flex-direction: column;
}
.pane--in { background: var(--input-bg); border-right: 1px solid var(--border); }
.pane--out { background: var(--output-bg); }

textarea {
  width: 100%;
  flex: 1;
  min-height: 150px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1.55;
  padding: 0 28px 0 0;
}
textarea::placeholder { color: var(--dim); }

.output {
  flex: 1;
  font-size: 1.25rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.output.placeholder { color: var(--dim); }
.output.loading { color: var(--muted); }

.pane__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  min-height: 26px;
}
.counter { color: var(--dim); font-size: 0.82rem; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.iconbtn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn--clear { position: absolute; top: 16px; right: 14px; }
.iconbtn.copied { color: var(--accent); }

.error { color: var(--danger); font-size: 0.88rem; margin: 12px 4px 0; min-height: 1.1em; }
.muted { color: var(--muted); font-size: 0.85rem; }
.hint { color: var(--dim); font-size: 0.8rem; margin: 10px 4px 0; }

/* ---------- Image tab ---------- */
.dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--accent-2); background: rgba(34, 211, 238, 0.06); }
.dropzone__text { color: var(--muted); font-size: 0.92rem; }
.pick-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--accent-2); }
.btn:active { transform: scale(0.98); }
.btn svg { width: 17px; height: 17px; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06210f;
  border: none;
}
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Camera: nút chụp nổi ngay trên khung hình, luôn thấy được, không cần cuộn */
.camera { position: relative; display: flex; flex-direction: column; }
#cameraVideo {
  width: 100%;
  max-height: min(52vh, 380px);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
  object-fit: cover;
}
.shutter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s;
}
.shutter:hover { transform: translateX(-50%) scale(1.05); }
.shutter:active { transform: translateX(-50%) scale(0.94); }
.camera__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
}
.camera__close svg { width: 17px; height: 17px; }
.preview { position: relative; display: inline-block; width: 100%; }
#previewImg {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}
.preview__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
}
.preview__close:hover { background: rgba(248, 113, 113, 0.85); }
.preview__close svg { width: 16px; height: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.out-label {
  color: var(--dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.out-block + .out-block { margin-top: 18px; }
#renderedImg {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
a.btn { text-decoration: none; }
.out-text { font-size: 1.05rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.out-text.placeholder { color: var(--dim); font-size: 0.95rem; }
[hidden] { display: none !important; }
