/* ---- Theme tokens ---- */
:root {
  --brand: #CD8500;        /* buttons / primary accents */
  --brand-dark: #a56a00;   /* button hover */
  --text: #000000;         /* all text */
  --bg: #FFFFFF;           /* page background */
  --surface: #FFF6E6;      /* cards & other surfaces */
  --border: #ecd9b6;       /* soft border derived from accent */
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(205, 133, 0, 0.10);
}

* { box-sizing: border-box; }

/* ---- Thin custom scrollbar ---- */
html { scrollbar-width: thin; scrollbar-color: var(--surface) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 8px; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Page background image (faded + blurred) ---- */
body::before {
  content: "";
  position: fixed;
  inset: -20px;                 /* overscan so blurred edges stay covered */
  background: url("/static/image.png") center center / cover no-repeat;
  filter: blur(6px);
  opacity: 1;                /* low opacity so text stays readable */
  z-index: -1;
  pointer-events: none;
}

.app { max-width: 860px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---- Icons ---- */
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: 26px; }
.hero h1 { margin: 0; font-size: 2rem; letter-spacing: -0.5px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 0.9rem; font-weight: 700;
}
.hint { margin: 0 0 12px; font-size: 0.88rem; opacity: 0.7; }

/* ---- Buttons ---- */
.btn {
  cursor: pointer; border: none; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; padding: 11px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #d9b877; cursor: not-allowed; }
.btn-large { font-size: 1.05rem; padding: 14px 34px; }
.btn-ghost { background: transparent; color: var(--brand-dark); border: 1px solid var(--border); }
.btn-ghost:hover { background: #fff; }
.btn.recording { background: var(--danger); }
.btn .icon { width: 17px; height: 17px; }

/* ---- Source toggle ---- */
.source-toggle {
  display: inline-flex; gap: 6px; background: #fff; max-width: 100%; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 12px; padding: 5px; margin-bottom: 16px;
}
.toggle-btn {
  border: none; background: transparent; padding: 9px 16px; border-radius: 8px;
  cursor: pointer; font-weight: 600; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
}
.toggle-btn.active { background: var(--brand); color: #fff; }
.toggle-btn .icon { width: 17px; height: 17px; }

/* ---- Record / upload panels ---- */
.source-panel { margin-top: 6px; }
.record-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.record-status { font-size: 0.9rem; opacity: 0.75; }
.record-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-dark); }
.file-label { display: block; font-size: 0.9rem; margin-bottom: 8px; }
input[type="file"] {
  width: 100%; padding: 10px; background: #fff;
  border: 1px dashed var(--border); border-radius: 10px;
}

/* ---- Preview ---- */
.preview {
  margin-top: 16px; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.preview-label { font-weight: 600; font-size: 0.9rem; flex: none; }
.player-slot { flex: 1; min-width: 0; display: flex; }

/* ---- Custom audio player ---- */
.aplayer {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px;
}
.aplayer-toggle {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.05s ease;
}
.aplayer-toggle:hover { background: var(--brand-dark); }
.aplayer-toggle:active { transform: scale(0.95); }
.aplayer-toggle .icon { width: 18px; height: 18px; }
.aplayer-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.aplayer-seek {
  position: relative; height: 6px; background: var(--surface);
  border-radius: 999px; cursor: pointer; touch-action: none;
}
.aplayer-progress {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  background: var(--brand); border-radius: 999px;
}
.aplayer-knob {
  position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 0 3px rgba(205, 133, 0, 0.2);
  opacity: 0; transition: opacity 0.15s ease;
}
.aplayer:hover .aplayer-knob, .aplayer.playing .aplayer-knob { opacity: 1; }
.aplayer-time {
  font-size: 0.75rem; opacity: 0.7; font-variant-numeric: tabular-nums;
  display: flex; gap: 5px;
}
.aplayer-time .sep { opacity: 0.5; }
.aplayer audio { display: none; }

/* ---- Options (radios / checkboxes) ---- */
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; }
.option {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.option:hover { border-color: var(--brand); }
.option input { accent-color: var(--brand); width: 17px; height: 17px; cursor: pointer; }
.option.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(205, 133, 0, 0.15); }
.option .lang-name { font-weight: 600; }
.option .lang-native { display: block; font-size: 0.82rem; opacity: 0.65; }

/* ---- Generate ---- */
.generate-row { text-align: center; margin: 6px 0 4px; }
.generate-row .btn { display: inline-flex; }

/* ---- Errors ---- */
.form-error { color: var(--danger); text-align: center; font-weight: 600; margin-top: 12px; }

/* ---- Loading ---- */
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 22px 0; font-weight: 600; }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Results ---- */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 16px; margin-top: 12px; }
.result-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: relative; }
.result-card.failed { border-color: var(--danger); background: #fff5f5; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.result-lang { font-weight: 700; }
.result-native { font-size: 0.82rem; opacity: 0.65; }
.result-actions { display: flex; gap: 8px; margin-top: 12px; }
.download-link {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; background: var(--brand); color: #fff;
  border-radius: 8px; padding: 8px 10px; font-size: 0.85rem; font-weight: 600;
}
.download-link:hover { background: var(--brand-dark); }
.download-link .icon { width: 16px; height: 16px; }
.result-error { color: var(--danger); font-size: 0.85rem; display: flex; align-items: flex-start; gap: 7px; }
.result-error .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ---- Tooltip (transcript on hover) ---- */
.info-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--brand); color: var(--brand-dark);
  cursor: help; position: relative;
}
.info-badge .icon { width: 14px; height: 14px; }
.info-badge .tooltip {
  visibility: hidden; opacity: 0; position: absolute; bottom: 130%; right: 0; width: min(240px, 74vw);
  background: var(--text); color: #fff; text-align: left; padding: 10px 12px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 400; line-height: 1.4; z-index: 20;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); transition: opacity 0.15s ease; white-space: normal;
}
.info-badge .tooltip::after {
  content: ""; position: absolute; top: 100%; right: 12px;
  border: 6px solid transparent; border-top-color: var(--text);
}
.info-badge:hover .tooltip, .info-badge:focus .tooltip { visibility: visible; opacity: 1; }
.tooltip-label { display: block; font-weight: 700; margin-bottom: 4px; color: var(--surface); }

.source-transcript {
  background: #fff; border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 0.9rem; margin-bottom: 6px;
}
.source-transcript strong { color: var(--brand-dark); }

.hidden { display: none !important; }

/* ---- Prompt textarea (prompt engine) ---- */
.prompt-input {
  width: 100%;
  margin-top: 4px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
  resize: vertical;
  line-height: 1.45;
}
.prompt-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(205, 133, 0, 0.15);
}
.engine-btn { min-width: 160px; justify-content: center; }


/* ============================ RESPONSIVE ============================ */
/* Tablets and small laptops */
@media (max-width: 720px) {
  .app { padding: 24px 16px 52px; }
}

/* Phones */
@media (max-width: 560px) {
  .app { padding: 18px 13px 44px; }
  .hero { margin-bottom: 18px; }
  .hero h1 { font-size: 1.5rem; }
  .card { padding: 16px 14px; margin-bottom: 16px; }
  .card h2 { font-size: 1.05rem; gap: 8px; }
  .hint { font-size: 0.85rem; }

  /* Toggles fill the width and split evenly, never overflow */
  .source-toggle { width: 100%; flex-wrap: nowrap; }
  .toggle-btn { flex: 1 1 0; min-width: 0; justify-content: center; padding: 10px 8px; }
  .engine-btn { min-width: 0; }

  /* Generate button full width for easy tapping */
  .generate-row .btn { width: 100%; }
  .btn-large { padding: 14px 18px; }

  /* Preview stacks vertically */
  .preview { flex-direction: column; align-items: stretch; }
  .preview .btn-ghost { align-self: flex-end; }

  /* Language options: two comfortable columns */
  .options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Small phones */
@media (max-width: 400px) {
  .hero h1 { font-size: 1.3rem; letter-spacing: -0.3px; }
  .card { padding: 14px 12px; }
  .options { grid-template-columns: 1fr; }   /* single column when very narrow */
  .record-timer { margin-left: auto; }
}

/* Landscape / very wide: keep the column centered (already max-width 860) */
