/* Theme approximating teachingfactory-cc.eu: light, corporate; blue primary,
   green accent, Montserrat headings + Open Sans body. */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f2f5f9;
  --text: #2b2f38;
  --muted: #6b7280;
  --border: #dde3ea;
  --accent: #1863dc;          /* TF-CC primary blue */
  --accent-strong: #1252bd;
  --accent-2: #4aa274;        /* readable green (for status/badges) */
  --brand-green: #70c090;     /* TF-CC secondary green (decorative) */
  --danger: #cf2e2e;
  --radius: 14px;
  --font-head: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1000px 520px at 12% -10%, rgba(24, 99, 220, 0.10) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(112, 192, 144, 0.12) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 24px 18px 64px; }

/* Brand header */
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-logo { height: 54px; width: auto; flex: 0 0 auto; }
.topbar .titles { min-width: 0; }
header h1 { margin: 0 0 3px; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.01em; }
header p { margin: 0; color: var(--muted); }

/* Logged-in user + nav links, pushed to the right of the header. */
.userbar {
  margin-left: auto; display: flex; align-items: center; gap: 14px;
  flex: 0 0 auto; font-size: .88rem; flex-wrap: wrap; justify-content: flex-end;
}
.userbar .who { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.userbar a { color: var(--accent); text-decoration: none; font-weight: 600; }
.userbar a:hover { text-decoration: underline; }

.login-card { max-width: 420px; margin-left: auto; margin-right: auto; }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.err-text { color: var(--danger); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px rgba(20, 40, 80, 0.05);
}

.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > * { flex: 1 1 220px; }

label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

select, input, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: .95rem;
  font-family: var(--font-body);
}
select:focus, input:focus, textarea:focus { outline: 2px solid rgba(24, 99, 220, 0.35); border-color: var(--accent); }
textarea { resize: vertical; }

.pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(24, 99, 220, 0.10); color: var(--accent); font-size: .8rem; font-weight: 600;
}

button {
  border: 0; border-radius: 10px; padding: 12px 18px; font-size: 1rem;
  font-weight: 700; cursor: pointer; color: #fff; background: var(--accent);
  font-family: var(--font-head);
  transition: transform .05s ease, background .2s, opacity .2s;
}
button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--panel-2); }
button.danger { background: var(--danger); color: #fff; }
button.danger:hover { background: #b02525; }
button:disabled { opacity: .45; cursor: not-allowed; }

.status { font-size: .85rem; color: var(--muted); }
.status.live { color: var(--accent-2); font-weight: 600; }
.status.err { color: var(--danger); }

.qr-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 8px; border: 1px solid var(--border); }
.linkline { word-break: break-all; }
.linkline a { color: var(--accent); }

.transcript { min-height: 90px; font-size: 1.05rem; line-height: 1.5; }
.transcript .interim { color: var(--muted); }

/* Header row with a title/label on the left and a small action on the right. */
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rowhead label { margin: 0; }
button.small { padding: 7px 12px; font-size: .82rem; }

/* Admin: full running transcript of what attendees are shown. */
.admin-transcript {
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1.5;
}
.admin-transcript .line { padding: 3px 0; }
.admin-transcript .line.partial { color: var(--muted); font-style: italic; }

/* Active-meetings list. */
.meeting {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.meeting:last-child { border-bottom: 0; }
.meeting button { padding: 8px 14px; font-size: .85rem; }
.meeting .meeting-you { color: var(--accent-2); font-weight: 700; }
.pill.live-pill { background: var(--accent-2); color: #fff; }

.captions {
  font-size: clamp(1.4rem, 4.5vw, 2.4rem);
  line-height: 1.35;
  min-height: 60vh;
  max-height: 72vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
/* Pin short content to the bottom without justify-content: flex-end, which
   would make overflowing top lines unreachable by scrolling. */
.captions::before { content: ""; margin-top: auto; }

/* Floating "jump to latest" button — appears when the viewer scrolls up. */
.jump-btn {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 50;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}
.captions .line { padding: 6px 0; opacity: .5; color: var(--text); }
.captions .line.latest { opacity: 1; font-weight: 700; }
/* Replayed on join/reconnect — silent history, visually distinct from live text. */
.captions .line.history {
  opacity: .4;
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--muted);
  padding-left: 10px;
}
/* Still being spoken — tentative until finalized, with a live badge. */
.captions .line.partial { font-style: italic; opacity: .75; }
.captions .line.partial::after {
  content: "live";
  margin-left: 8px;
  padding: 1px 7px;
  font-size: .62em;
  font-style: normal;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
  color: #fff;
  background: var(--accent-2);
  border-radius: 999px;
  animation: livepulse 1.2s ease-in-out infinite;
}
@keyframes livepulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.big-btn { width: 100%; padding: 18px; font-size: 1.15rem; }

/* Join-card language picker: full-width, labeled, matches the existing select styling. */
.lang-picker { margin-bottom: 14px; }
.lang-picker label { margin-bottom: 6px; }

/* Compact live switcher: sits inline in the live-card header next to the voice button. */
.live-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lang-picker-live { margin-bottom: 0; flex: 0 0 auto; }
.lang-picker-live select {
  width: auto;
  padding: 8px 10px;
  font-size: .85rem;
}

.hidden { display: none !important; }
.spacer { height: 8px; }
.mono { font-variant-numeric: tabular-nums; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* Phones: tighten spacing, let the QR/link stack, keep tap targets big. */
@media (max-width: 560px) {
  .wrap { padding: 16px 12px 48px; }
  .brand-logo { height: 42px; }
  header h1 { font-size: 1.25rem; }
  .card { padding: 16px; }
  .qr-box { justify-content: center; text-align: center; }
  .qr-box img { width: min(70vw, 220px); height: auto; aspect-ratio: 1; }
  .row > * { flex-basis: 100%; }        /* stack controls one per row */
  button { padding: 14px 18px; }         /* comfortable touch target */
  .captions { min-height: 66vh; }
}

/* Respect users who prefer no motion. */
@media (prefers-reduced-motion: reduce) {
  .captions .line.partial::after { animation: none; }
}

/* Mic input level meter (speaker live view) */
.meter {
  height: 12px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: var(--accent-2);
  transition: width 80ms linear;
}
.meter-fill.warn { background: #d99e2b; }
.meter-fill.hot { background: var(--danger); }
