/* Lingua — shared theme for the web and mobile PWAs.
 *
 * Mirrors the desktop app's tkinter palette (ui/theme.py):
 *   dark  : bg #0b0e14, card #151a21, edge #1b2530, text #f3f7fb, muted #8ba0b6,
 *           accent #7dd3fc (sky)
 *   light : bg #f8fafc, card #ffffff, edge #e2e8f0, text #1e293b, muted #64748b,
 *           accent #0284c7 (sky)
 *
 * The transcript-forward overlay is the visual hero; the rest is supporting
 * chrome. Segoe UI / Consolas on Windows, sensible fallbacks everywhere else.
 */

:root {
  /* Dark theme (default). */
  --bg: #0b0e14;
  --card: #151a21;
  --card-2: #1b2530;
  --edge: #1f2937;
  --line: #243043;
  --text: #f3f7fb;
  --muted: #8ba0b6;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --accent-ink: #06243a;
  --warn: #fbbf24;
  --err: #f87171;
  --ok: #7dd3fc;
  --track: #38506b;
  --overlay-tint: rgba(21, 26, 33, 0.94);
  --overlay-border: rgba(125, 211, 252, 0.25);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;

  --font-sans: "Segoe UI", "SF Pro Text", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: Consolas, "JetBrains Mono", "SFMono-Regular", "Menlo", monospace;
}

:root.theme-light {
  --bg: #f8fafc;
  --card: #ffffff;
  --card-2: #f1f5f9;
  --edge: #e2e8f0;
  --line: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-ink: #ffffff;
  --warn: #d97706;
  --err: #dc2626;
  --ok: #0284c7;
  --track: #94a3b8;
  --overlay-tint: rgba(255, 255, 255, 0.94);
  --overlay-border: rgba(2, 132, 199, 0.30);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

button {
  font: 600 0.85rem var(--font-sans);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--edge); border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
button.ghost { background: transparent; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: 0.9rem var(--font-sans);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
textarea { font-family: var(--font-sans); resize: vertical; min-height: 80px; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="file"] { font-size: 0.85rem; }

label.field {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

hr.rule { border: none; height: 1px; background: var(--line); margin: 16px 0; }

/* Page header strip. */
.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.nav .brand {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.nav .spacer { flex: 1; }
.nav a { padding: 4px 8px; border-radius: 4px; }
.nav a.active, .nav a:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); text-decoration: none; }

main.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}

/* Landing page styles. */
.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
  align-items: start;
  padding: 8px 0 26px;
}
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
h1 { font-size: 2.4rem; line-height: 1.1; letter-spacing: -0.01em; }
.tagline { color: var(--muted); font-size: 1.05rem; margin-top: 6px; }

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0;
}
.pipeline .step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  font-size: 0.85rem;
  color: var(--text);
  position: relative;
}
.pipeline .step .n {
  font: 700 0.7rem var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.12em;
  display: block;
  margin-bottom: 4px;
}
@media (max-width: 700px) { .pipeline { grid-template-columns: 1fr 1fr; } }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { font-size: 1rem; margin-bottom: 4px; }
.card p { font-size: 0.85rem; color: var(--muted); }
.card .icon {
  display: inline-block;
  width: 26px; height: 26px;
  margin-bottom: 8px;
  color: var(--accent);
}

.privacy {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--muted);
}
.privacy strong { color: var(--text); }

/* Desktop capture layout. */
.capture-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) 360px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 980px) { .capture-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.video-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
}
.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.video-stage .placeholder {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 20px;
}
.video-stage .crop {
  position: absolute;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}
.video-stage.dragging, .video-stage.dragging .crop { cursor: crosshair; }
.video-stage.dragging video { pointer-events: none; }
.video-stage.dragging .crop { pointer-events: auto; }

.controls-panel .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.controls-panel .row.full { grid-template-columns: 1fr; }
.controls-panel .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.status-line {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--card-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 28px;
  display: flex;
  align-items: center;
}
.status-line.ok    { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.status-line.warn  { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.status-line.err   { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }

/* The floating overlay panel — the visual hero. */
.transcript-overlay {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, 92vw);
  max-height: 60vh;
  background: var(--overlay-tint);
  border: 1px solid var(--overlay-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-sans);
}
.transcript-overlay.hidden { display: none; }
.transcript-overlay .header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.transcript-overlay .header .title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.transcript-overlay .header .badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.transcript-overlay .header .spacer { flex: 1; }
.transcript-overlay .header button {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.transcript-overlay .header button:hover { color: var(--accent); border-color: transparent; background: transparent; }
.transcript-overlay .body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 14px;
  font-size: 1rem;
  line-height: 1.45;
}
.transcript-overlay .row.speaker {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-top: 8px;
}
.transcript-overlay .row.text {
  color: var(--text);
  font-size: 1.02rem;
}
.transcript-overlay .row.live .text::after {
  content: "▍";
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.transcript-overlay .empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 14px 8px;
}

/* Settings panel. */
.settings {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 16px;
}
.settings h2 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings h2 .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.settings .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
@media (max-width: 700px) { .settings .grid { grid-template-columns: 1fr; } }
.settings .hint {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}
.settings .hint code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

/* Mobile-specific. */
.mobile-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px 80px;
}
.mobile-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.mobile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.transcript-mobile {
  background: var(--overlay-tint);
  border: 1px solid var(--overlay-border);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 180px;
  font-size: 1rem;
  line-height: 1.45;
  margin-bottom: 12px;
}
.transcript-mobile .row.speaker {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-top: 8px;
}
.transcript-mobile .empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 8px;
}

.tab-bar {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.tab-bar button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 12px 8px;
  color: var(--muted);
  font-weight: 600;
}
.tab-bar button.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

footer.meta {
  margin-top: 30px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

/* Visually hidden but still announced. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* PWA install callout banner. */
.install-callout {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 12px 20px 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.install-callout .callout-text {
  flex: 1;
  color: var(--text);
}
.install-callout button {
  padding: 6px 10px;
  font-size: 0.8rem;
}
.install-callout #callout-dismiss-btn {
  padding: 4px 8px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}
.install-callout #callout-dismiss-btn:hover {
  color: var(--text);
  background: transparent;
  border-color: transparent;
}

/* ---------------------------------------------------------- Read picture */
.picture-inputs { grid-template-columns: repeat(3, 1fr); }
.btn-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 600 0.85rem var(--font-sans);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.btn-like:hover { background: var(--edge); border-color: var(--accent); }
.btn-like.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.picture-preview {
  margin-top: 10px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}
.picture-preview img { max-width: 100%; max-height: 320px; object-fit: contain; display: block; }
.mobile-card.dragging { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.picture-option { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 0.9rem; }
.picture-result { min-height: 160px; font-size: 1rem; line-height: 1.45; resize: vertical; }
.picture-stats { margin-top: 6px; font: 0.8rem ui-monospace, Consolas, monospace; color: var(--muted); }
@media (max-width: 420px) {
  .picture-inputs { grid-template-columns: 1fr 1fr; }
}

.picture-preview img[hidden] { display: none; }

/* ---------------------------------------------------------- narrow phones */
@media (max-width: 600px) {
  .nav { flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; }
  .nav .spacer { flex-basis: 100%; height: 0; }
  .install-callout { margin: 10px 12px 0; }
  .mobile-actions > * { min-width: 0; }
  .tab-bar button { min-width: 0; white-space: normal; }
  input[type="file"] { max-width: 100%; }
}
