:root {
  color-scheme: dark;
  --bg: #07111f;
  --card: rgba(10, 18, 34, .92);
  --muted: #90a0b7;
  --text: #eef4ff;
  --line: #22314a;
  --accent: #6d6bff;
  --accent-2: #4b8dff;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #172554 0%, var(--bg) 40%);
  color: var(--text);
}

a { color: inherit; }
.hidden { display: none !important; }

.shell {
  width: min(1200px, calc(100% - 24px));
  margin: 12px auto 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .2);
}

.compact-card { padding: 14px; margin-bottom: 12px; }

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

.topbar-main, .topbar-actions, .brand-row, .toolbar-row, .toolbar-group, .section-head, .progress-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-actions, .toolbar-row, .section-head { justify-content: space-between; }
.toolbar-row, .section-head, .topbar { flex-wrap: wrap; }
.right-group { margin-left: auto; }

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  letter-spacing: .04em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 30px rgba(109, 107, 255, .35);
}
.logo-badge.small { width: 36px; height: 36px; border-radius: 10px; }

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
}
.sub, .section-sub, .status, .auth-sub, .auth-error {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.section-title, .label {
  font-size: 13px;
  font-weight: 800;
}

.uploader-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) minmax(120px, .7fr) minmax(160px, .8fr);
  gap: 12px;
}

input[type="file"], input[type="password"], select {
  width: 100%;
  border: 1px solid #31425f;
  border-radius: 12px;
  padding: 11px 12px;
  background: #07111f;
  color: var(--text);
  min-height: 42px;
}

button, .ghost, .single-download, .download-all, .result-actions a, .history-actions a {
  border: 1px solid #31425f;
  background: #0c1628;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 40px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
button:hover, .ghost:hover, .single-download:hover, .download-all:hover, .result-actions a:hover, .history-actions a:hover {
  border-color: var(--accent);
}
button:disabled { opacity: .7; cursor: wait; }
.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
}
.wide { width: 100%; }
.download-all { background: #083f33; border-color: #0a6d58; }
.download-all.disabled { pointer-events: none; opacity: .45; }
.mini-pill {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: #d9e6ff;
  background: #07111f;
}

.languages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.compact-languages { margin-top: 8px; }
.lang {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #2a3a56;
  border-radius: 12px;
  padding: 9px 10px;
  background: #07111f;
  min-height: 42px;
}
.lang input { width: 16px; height: 16px; accent-color: var(--accent); }
.lang span { font-size: 13px; font-weight: 700; }

.progress-track {
  height: 10px;
  background: #07111f;
  border: 1px solid #2a3a56;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 14px;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width .25s ease;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 12px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.result-row, .history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 14px;
  border: 1px solid #2a3a56;
  background: #07111f;
  padding: 10px;
}
.result-row.active { border-color: var(--accent); }
.result-row.done { border-color: rgba(34, 197, 94, .6); }
.result-row.error { border-color: rgba(239, 68, 68, .6); }
.result-row.translating, .result-row.running { border-color: rgba(245, 158, 11, .7); }

.result-main, .history-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.result-main strong, .history-main strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-main span, .history-main span {
  color: var(--muted);
  font-size: 12px;
}
.result-actions, .history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.result-actions button, .result-actions a, .history-actions button, .history-actions a {
  min-height: 32px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 12px;
}

.preview-card pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #07111f;
  border: 1px solid #22314a;
  border-radius: 14px;
  padding: 14px;
  max-height: 62vh;
  overflow: auto;
  line-height: 1.55;
  color: #e7efff;
  font-size: 14px;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.auth-card {
  width: min(420px, 100%);
  background: rgba(10, 18, 34, .96);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}
.auth-card h1 { font-size: 28px; }
.auth-error { min-height: 18px; color: #fca5a5; }
.contact-link {
  text-align: center;
  color: #cbd8ff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

.status.ok { color: #a7f3d0; }
.status.err { color: #fca5a5; }

@media (max-width: 980px) {
  .uploader-grid, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 16px, 1200px); }
  .result-row, .history-row, .topbar { align-items: stretch; flex-direction: column; }
  .result-actions, .history-actions, .topbar-actions { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
  .toolbar-row { align-items: stretch; }
  .toolbar-group { flex-wrap: wrap; }
}


.calculator-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, .96), rgba(17, 24, 39, .96));
}
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.calc-item {
  border: 1px solid #2a3a56;
  border-radius: 14px;
  background: #07111f;
  padding: 12px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.calc-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.calc-item strong {
  font-size: 18px;
  line-height: 1;
}
.calc-item.price {
  border-color: rgba(34, 197, 94, .55);
  background: rgba(6, 78, 59, .32);
}
.calc-item.price strong {
  color: #a7f3d0;
  font-size: 22px;
}

.lang-flag { font-size: 16px; line-height: 1; }

.lang-flag-img {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .16);
  flex: 0 0 auto;
}
.template-select {
  width: auto;
  min-width: 180px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid #31425f;
  background: #07111f;
  color: var(--text);
  font-weight: 700;
}

.voice-toggle { display: flex; align-items: center; gap: 8px; min-height: 42px; border: 1px solid #31425f; border-radius: 12px; padding: 10px 12px; background: #07111f; font-weight: 700; font-size: 13px; }
.voice-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

.result-row.audio-error {
  border-color: rgba(255, 176, 32, 0.75);
}
.error-text {
  display: block;
  margin-top: 6px;
  color: #ffcf7a;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}
