/* =========================================================
   Hlasový přepis — styly (mobile-first, světlý + tmavý režim)
   ========================================================= */

:root {
  --bg: #eef1f8;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7385;
  --accent: #4f46e5;
  --accent2: #7c3aed;
  --danger: #e11d48;
  --rec: #ef4444;
  --border: #e3e7f0;
  --shadow: 0 8px 30px rgba(23, 29, 54, .08);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --card: #181c2e;
    --text: #eceff8;
    --muted: #98a0b6;
    --border: #272c44;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  background:
    radial-gradient(1100px 560px at 15% -10%, rgba(99, 102, 241, .16) 0%, transparent 55%),
    radial-gradient(900px 480px at 110% 5%, rgba(139, 92, 246, .14) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Kostra ---------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) clamp(12px, 3.5vw, 24px) 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ---------- Hlavička ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 0;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-ic { font-size: 30px; line-height: 1; }
.brand h1 { font-size: 1.22rem; letter-spacing: -.01em; }
.brand .sub { font-size: .8rem; color: var(--muted); margin-top: 1px; }

.lang select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 32px 9px 14px;
  font: inherit;
  font-size: .88rem;
  min-height: 42px;
  box-shadow: var(--shadow);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7385' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

/* ---------- Záložky ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px;
  margin: 14px 0 16px;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 10px;
  font-weight: 600;
  color: var(--muted);
  min-height: 46px;
  transition: background .2s ease, color .2s ease;
}

.tab[aria-selected="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .35);
}

.badge {
  display: inline-block;
  min-width: 21px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .76rem;
  margin-left: 3px;
  background: var(--border);
  color: var(--muted);
}
.tab[aria-selected="true"] .badge { background: rgba(255, 255, 255, .25); color: #fff; }

/* ---------- Karty ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

body.listening .transcript-card {
  border-color: rgba(239, 68, 68, .45);
  box-shadow: 0 8px 30px rgba(239, 68, 68, .12);
}

/* ---------- Přepis ---------- */
#editor {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.7;
  min-height: 170px;
  resize: none;
}
#editor::placeholder { color: var(--muted); opacity: .8; }

.live {
  font-size: 1.05rem;
  line-height: 1.7;
  min-height: 170px;
  max-height: 48vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overscroll-behavior: contain;
}
.live::-webkit-scrollbar { width: 8px; }
.live::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.interim { color: var(--muted); }
.live-placeholder { color: var(--muted); font-style: italic; }

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .82rem;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}
.meta-row .grow { flex: 1; }
.meta-row .dot { opacity: .6; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--rec);
}
.timer::before { content: '● '; animation: blink 1.2s ease-in-out infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- Ovládání ---------- */
.controls {
  position: sticky;
  bottom: 0;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  text-align: center;
}

.status {
  color: var(--muted);
  font-size: .92rem;
  min-height: 1.5em;
  margin-bottom: 10px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.control-row .side-btn:first-child { justify-self: end; }
.control-row .side-btn:last-child { justify-self: start; }

.fab {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(79, 70, 229, .42);
  transition: transform .12s ease, background .25s ease, box-shadow .25s ease;
}
.fab svg { width: 36px; height: 36px; }
.fab:active { transform: scale(.94); }

body.listening .fab {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 10px 26px rgba(239, 68, 68, .45);
}

body.listening .fab::before,
body.listening .fab::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--rec);
  animation: ring 1.6s ease-out infinite;
  pointer-events: none;
}
body.listening .fab::after { animation-delay: .8s; }

@keyframes ring {
  0%   { transform: scale(1);    opacity: .65; }
  100% { transform: scale(1.55); opacity: 0; }
}

.side-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 76px;
  min-height: 60px;
  padding: 9px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.15rem;
  transition: transform .12s ease;
}
.side-btn span { font-size: .72rem; font-weight: 600; color: var(--muted); }
.side-btn:active { transform: scale(.96); }

.side-btn.primary {
  border-color: rgba(79, 70, 229, .35);
  background: rgba(79, 70, 229, .1);
}
.side-btn.primary span { color: var(--accent); }

.minor-row { margin-top: 10px; min-height: 30px; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 10px;
}
.link-btn:hover { color: var(--accent); }

/* ---------- Hlasové příkazy ---------- */
.cmds {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 4px 16px;
  font-size: .9rem;
}

.cmds summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  list-style: none;
  min-height: 30px;
}
.cmds summary::-webkit-details-marker { display: none; }
.cmds summary::after { content: ' ▾'; color: var(--muted); font-size: .8em; }
.cmds[open] summary::after { content: ' ▴'; }

.cmds-state {
  font-size: .74rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(79, 70, 229, .1);
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 4px;
  vertical-align: 1px;
}

.cmd-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0 12px;
  cursor: pointer;
  font-weight: 600;
}
.cmd-toggle input {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
  cursor: pointer;
}

.cmd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 7px;
  padding-bottom: 12px;
}

.cmd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: .82rem;
  color: var(--muted);
}
.cmd-row code {
  font-weight: 700;
  color: var(--accent);
  font-size: .88rem;
  white-space: nowrap;
}

.cmd-note {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.55;
  padding-bottom: 12px;
}

/* ---------- Upozornění ---------- */
.warn {
  background: #fff7e6;
  border: 1px solid #ffdf9e;
  color: #7a5b12;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 12px;
  font-size: .93rem;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  .warn { background: #33290f; border-color: #6b5619; color: #ffd166; }
}

/* ---------- Nahrávky (přepis souborů) ---------- */
.drop {
  text-align: center;
  padding: 34px 20px;
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .12s ease;
  user-select: none;
}
.drop:hover { border-color: var(--accent); }
.drop.drag {
  border-color: var(--accent);
  background: rgba(79, 70, 229, .07);
  transform: scale(1.01);
}
.drop.disabled { opacity: .55; pointer-events: none; }

.drop-ic { font-size: 44px; display: block; margin-bottom: 10px; }
.drop h3 { font-size: 1.08rem; margin-bottom: 4px; }
.drop-sub { color: var(--muted); font-size: .92rem; }
.drop-note {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.55;
  margin-top: 12px;
}

.drop-save {
  color: var(--muted);
  font-size: .76rem;
  margin-top: 8px;
  word-break: break-all;
}

.queue-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 10px;
}
.queue-summary { color: var(--muted); font-size: .88rem; font-weight: 600; }
.queue-tools .btn { min-height: 40px; padding: 8px 13px; font-size: .85rem; }

.q-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 13px 16px;
  margin-bottom: 10px;
}
.q-run   { border-left-color: var(--accent); }
.q-done  { border-left-color: #059669; }
.q-error { border-left-color: var(--danger); }

.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.q-name {
  font-weight: 600;
  font-size: .93rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.q-chip {
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.q-run .q-chip { color: var(--accent); animation: qpulse 1.2s ease-in-out infinite; }
.q-done .q-chip { color: #059669; }
.q-error .q-chip { color: var(--danger); }

@keyframes qpulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.q-meta { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.q-text {
  margin-top: 9px;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.q-error {
  overflow-wrap: anywhere;
}
p.q-error {
  margin-top: 8px;
  font-size: .85rem;
  color: var(--danger);
}
.q-item .hist-actions { margin-top: 10px; }

.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: transparent;
  color: var(--text);
  margin-bottom: 18px;
}

/* ---------- Historie ---------- */
.hist-tools { display: flex; gap: 10px; margin-bottom: 14px; }
.hist-tools .btn { flex: 1; }

.btn {
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  min-height: 46px;
}
.btn.ghost { background: var(--card); border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }
.btn.ghost.danger { color: var(--danger); border-color: rgba(225, 29, 72, .3); }
.btn.solid { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn.solid.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }

.hist-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.hist-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  margin-bottom: 10px;
}

.hist-edit {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  line-height: 1.6;
  background: transparent;
  color: var(--text);
  margin-bottom: 10px;
  resize: vertical;
}

.hist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: .8rem;
  margin-bottom: 10px;
}

.chip {
  background: var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .74rem;
}

.hist-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.mini {
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  min-height: 38px;
}
.mini:hover { background: var(--border); }
.mini.danger { color: var(--danger); }

.empty {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted);
}
.empty .big { font-size: 44px; display: block; margin-bottom: 12px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 1.05rem; }

/* ---------- Patička ---------- */
footer {
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
  padding: 18px 8px calc(14px + env(safe-area-inset-bottom));
}

/* ---------- Přehrávač čtení nahlas ---------- */
.player {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .25);
  padding: 10px 14px;
  z-index: 65;
}

.pl-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.pl-btn:active { transform: scale(.94); }

.pl-mid { flex: 1; min-width: 0; }

.pl-text {
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.pl-controls { display: flex; gap: 8px; }

.pl-controls select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 6px 10px;
  font: inherit;
  font-size: .8rem;
  min-height: 34px;
  max-width: 100%;
}
#voiceSelect { flex: 1; min-width: 0; }
#rateSelect { flex-shrink: 0; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  background: rgba(17, 24, 39, .94);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  z-index: 80;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 18, 32, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 70;
  padding: 20px;
}

.dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.dialog h2 { font-size: 1.12rem; margin-bottom: 8px; }
.dialog p { color: var(--muted); line-height: 1.55; margin-bottom: 18px; font-size: .95rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Větší displeje ---------- */
@media (min-width: 700px) {
  .fab { width: 92px; height: 92px; }
  .brand h1 { font-size: 1.35rem; }
}

/* ---------- Omezený pohyb ---------- */
@media (prefers-reduced-motion: reduce) {
  body.listening .fab::before,
  body.listening .fab::after { animation: none; opacity: .4; }
  .timer::before { animation: none; }
  * { transition: none !important; }
}
