:root {
  --bg-primary: #0a0f1d;
  --bg-card: rgba(18, 26, 46, 0.85);
  --bg-card-hover: rgba(28, 39, 68, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-glow: rgba(239, 68, 68, 0.4);
  --accent-blue: #38bdf8;
  --accent-green: #22c55e;
  --accent-purple: #a855f7;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* App View Containers */
.view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.hidden {
  display: none !important;
}

/* =========================================================
   HOME VIEW
   ========================================================= */
#home-view {
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px) 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ef4444, #991b1b);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.settings-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.hero-card {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 22px;
}

/* Hlavní tlačítko "Začít přenos" */
.btn-start {
  width: 100%;
  padding: 18px 24px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.45), 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.btn-start:active {
  transform: scale(0.97);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-start svg {
  width: 24px;
  height: 24px;
}

/* Seznam streamů */
.streams-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-count {
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-secondary);
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
}

.clear-btn:hover {
  color: var(--accent-red);
}

.streams-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: rgba(18, 26, 46, 0.4);
  border: 1px dashed var(--border-subtle);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stream-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stream-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.stream-card:active {
  transform: scale(0.99);
}

.stream-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.play-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.stream-card-info {
  min-width: 0;
  flex: 1;
}

.stream-card-url {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.stream-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
}

.stream-card-codec {
  color: var(--accent-blue);
  font-weight: 500;
}

.stream-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
}

.icon-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* =========================================================
   STREAM VIEW (Full camera window)
   ========================================================= */
#stream-view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: #000;
  z-index: 100;
  overflow: hidden;
}

/* Cele okno aplikace zobrazuje obraz kamery */
#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay vrstva */
.stream-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 24px) 16px;
}

.stream-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

/* Vlevo nahoře: LIVE indikátor */
.live-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
  animation: pulse-live 1.4s infinite;
}

@keyframes pulse-live {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.stream-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-secondary);
}

/* V PRAVÉM HORNÍM ROHU: Jaké kódování používá a pod tím jaké rozlišení */
.stream-info-box {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.badge-codec {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-blue);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.badge-resolution {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* DOLE UPROSTŘED: Tlačítko na sdílení a tlačítko STOP */
.stream-bottom-controls {
  pointer-events: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

/* Tlačítko na sdílení URL streamu */
.btn-share {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
}

.btn-share:active {
  transform: scale(0.97);
  background: rgba(51, 65, 85, 0.9);
}

.btn-share svg {
  width: 20px;
  height: 20px;
}

/* Tlačítko STOP pro ukončení streamu */
.btn-stop {
  width: 100%;
  padding: 16px 24px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.55);
  transition: all 0.15s;
}

.btn-stop:active {
  transform: scale(0.97);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-stop svg {
  width: 22px;
  height: 22px;
}

/* =========================================================
   TOAST NOTIFICATION (Upozornění mizící za 5s)
   ========================================================= */
#toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 90%;
  max-width: 440px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.toast.toast-warning {
  border: 1px solid rgba(245, 158, 11, 0.5);
}

.toast.toast-success {
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.toast.toast-error {
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 1px;
}

.toast-warning .toast-icon { color: #f59e0b; }
.toast-success .toast-icon { color: #22c55e; }
.toast-error .toast-icon { color: #ef4444; }

.toast-body {
  flex: 1;
}

.toast-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Progress bar pro 5 sekundové upozornění */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.15);
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  background: #f59e0b;
  transform-origin: left;
  animation: toast-timer 5s linear forwards;
}

@keyframes toast-timer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@keyframes slide-in {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-fade-out {
  animation: fade-out 0.4s ease forwards;
}

@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateY(-15px);
  }
}

/* =========================================================
   VIDEO MODAL / PŘEHRÁVAČ
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-video-container {
  width: 100%;
  background: #000;
  aspect-ratio: 16 / 9;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-footer {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(18, 26, 46, 0.6);
}

.modal-footer .url-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-open-external {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-open-external:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Settings modal */
.settings-modal-content {
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
