/* Poormaz Live control panel - dark, mobile-first, one-handed use.
   No decorative UI. Big hit targets, no hover-dependent affordances. */

:root {
  --bg: #0b0b0d;
  --panel: #17171b;
  --text: #f5f5f7;
  --muted: #8a8a92;
  --red: #ff3b30;
  --red-dark: #b8241c;
  --green: #34c759;
  --amber: #ff9f0a;
  --border: #2a2a2f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation; /* disable double-tap-to-zoom */
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 12px);
  padding-bottom: calc(var(--safe-bottom) + 12px);
  padding-left: 16px;
  padding-right: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 20px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.stream-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.unknown { background: var(--amber); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 24px;
}

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.hidden { display: none !important; }

.big-btn {
  width: 100%;
  min-height: 26vh;
  border-radius: 28px;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.05s ease, opacity 0.15s ease;
}

.big-btn:active {
  transform: scale(0.97);
}

.big-btn.start {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  box-shadow: 0 8px 30px rgba(255, 59, 48, 0.35);
}

.big-btn.stop {
  background: repeating-linear-gradient(
    135deg,
    #b8241c,
    #b8241c 18px,
    #8f1a14 18px,
    #8f1a14 36px
  );
  box-shadow: 0 8px 30px rgba(184, 36, 28, 0.5);
  animation: pulse-rec 1.4s ease-in-out infinite;
}

.big-btn.retry {
  background: linear-gradient(180deg, #3a3a40 0%, #232326 100%);
  min-height: 14vh;
}

.big-btn[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

.icon { font-size: 40px; line-height: 1; }
.label { font-size: 22px; }

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 8px 30px rgba(184, 36, 28, 0.5); }
  50% { box-shadow: 0 8px 46px rgba(255, 59, 48, 0.75); }
}

.rec-label {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--red);
}

.timer {
  font-size: 64px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.last-clip {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.processing-label {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.processing-sub {
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 5px solid var(--border);
  border-top-color: var(--amber);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ready-label {
  font-size: 24px;
  font-weight: 800;
  color: var(--green);
}

.ready-duration {
  font-size: 18px;
  color: var(--text);
}

.error-label {
  font-size: 22px;
  font-weight: 800;
  color: var(--red);
}

.error-detail {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  max-width: 320px;
}

/* --- Instagram panel (secondary, isolated control surface) ---
   Deliberately smaller and quieter than the main clip button: the clip
   button is the one action this app must never make you hesitate over
   while walking through a crowd. Instagram is a background concern you
   check occasionally, so it lives in a collapsed <details> by default. */

.ig-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 6px;
}

.ig-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 6px 2px;
}

.ig-summary::-webkit-details-marker { display: none; }

.ig-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.ig-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.ig-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.ig-dot.offline { background: var(--muted); }
.ig-dot.starting { background: var(--amber); animation: pulse-dot 1.2s ease-in-out infinite; }
.ig-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ig-dot.error { background: var(--red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.ig-body {
  padding: 14px 2px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ig-timer-row {
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ig-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
}

.ig-error {
  color: var(--red);
  font-size: 13px;
}

.ig-actions {
  display: flex;
  gap: 10px;
}

.mid-btn {
  flex: 1;
  min-height: 52px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  cursor: pointer;
}

.mid-btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.ig-start { background: #2b6cb0; }
.ig-stop { background: #4a4a52; }
.ig-restart { background: var(--red-dark); width: 100%; }

.ig-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
}

.ig-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.ig-input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  padding: 12px;
  border-radius: 10px;
}

.ig-form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.ig-form-msg {
  font-size: 13px;
  color: var(--muted);
}

.ig-form-msg.ok { color: var(--green); }
.ig-form-msg.bad { color: var(--red); }

.footer {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.conn-indicator { color: var(--green); }
.conn-indicator.bad { color: var(--red); }

.logout-form { margin: 0; }

.logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  text-decoration: underline;
}

/* --- Login screen --- */

.login-screen {
  justify-content: center;
  align-items: center;
}

.login-box {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  text-align: center;
}

.login-sub {
  color: var(--muted);
  margin: 0 0 8px;
}

.login-error {
  background: rgba(255, 59, 48, 0.15);
  color: #ff8a80;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  padding: 16px;
  border-radius: 14px;
  text-align: center;
}

.login-submit {
  min-height: 15vh;
}

/* --- YouTube / Kick fixed relay controls --- */
.relay-panel {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

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

.relay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.relay-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.relay-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.relay-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.relay-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); }
.relay-dot.starting { background: var(--amber); animation: pulse-dot 1.2s ease-in-out infinite; }
.relay-dot.offline, .relay-dot.unknown { background: var(--muted); }
.relay-dot.error { background: var(--red); }

.relay-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.relay-btn {
  border: 0;
  min-height: 46px;
  border-radius: 11px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.relay-btn[disabled] { opacity: .42; pointer-events: none; }
.relay-start { background: #2b6cb0; }
.relay-stop { background: #4a4a52; }
.relay-restart { background: #6b4fa1; }
.relay-error { color: var(--red); font-size: 12px; margin: -2px 0 9px; }
