:root {
  --bg: #050816;
  --panel: #0d1428;
  --panel-2: #121b34;
  --text: #f5f7ff;
  --muted: #9fb0d5;
  --accent: #7aa2ff;
  --accent-2: #ffce45;
  --ok: #38d39f;
  --warn: #ffce45;
  --bad: #ff5c7c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #050816 0%, #0a1328 100%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.app-shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.panel {
  background: rgba(13, 20, 40, 0.94);
  border: 1px solid rgba(122, 162, 255, 0.15);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

#login-card {
  width: min(420px, 100%);
  margin: 10vh auto 0;
  padding: 28px;
}

.eyebrow {
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  text-align: center;
}

h1, .title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

#login-card h1 {
  text-align: center;
  margin-bottom: 24px;
}

.muted {
  color: var(--muted);
}

.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;
}

label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
}

input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(122, 162, 255, 0.22);
  background: var(--panel-2);
  color: var(--text);
  padding: 14px 16px;
  font-size: 1rem;
}

input:focus,
button:focus {
  outline: 2px solid rgba(122, 162, 255, 0.9);
  outline-offset: 2px;
}

button,
input,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pin-boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.pin-digit {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  border-radius: 14px;
}

button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #091120;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

#pin-form button {
  margin-top: 18px;
  width: 100%;
  padding: 14px 16px;
}

.hidden { display: none !important; }
.error {
  color: #ff9bb0;
  margin-top: 12px;
  text-align: center;
}

#viewer-panel {
  min-height: calc(100vh - 48px);
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.status-dot.live { background: var(--ok); }
.status-dot.idle { background: var(--warn); }
.status-dot.offline { background: var(--bad); }

.captions {
  opacity: 0.72;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.caption-item {
  font-size: var(--caption-size, clamp(1.4rem, 2.6vw, 2.5rem));
  line-height: 1.45;
}

.partial-caption {
  min-height: 2.2em;
  margin-top: 18px;
  color: var(--accent-2);
  font-weight: 800;
  font-size: calc(var(--caption-size, clamp(1.4rem, 2.6vw, 2.5rem)) * 1.12);
  line-height: 1.4;
}

.footer-controls {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 10px;
}

.footer-controls button {
  width: 58px;
  height: 58px;
  font-size: 1rem;
}

#btn-clear {
  background: rgba(255, 92, 124, 0.92);
  color: #fff;
}

@media (max-width: 768px) {
  .app-shell { padding: 16px; }
  #viewer-panel { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  #login-card { margin-top: 8vh; padding: 22px; }
  .pin-boxes { gap: 8px; }
}
