:root {
  color-scheme: dark;
  --surface-card: #121316;
  --surface-input: #090a0d;
  --surface-elevated: #1a1c22;
  --border-subtle: #27272a;
  --border-hover: #3f3f46;
  --border-focus: #fffc00;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #fffc00;
  --accent-fg: #000000;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fullscreen Stream Viewport */
.stream-container {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  position: relative;
  overflow: hidden;
}

.canvas-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

#screencastCanvas {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000000;
  outline: none;
  cursor: default;
  display: block;
}

/* Loading Overlay */
.stream-overlay {
  position: absolute;
  inset: 0;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  color: var(--text-primary);
  transition: opacity 0.25s ease;
}

.stream-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #27272a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal Scrim (Zero Glassmorphic Mud, 100% Solid Dark Scrim) */
.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
  transition: opacity 0.2s ease;
}

.auth-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Solid Opaque Surface Card (Anti-Slop Zero-Translucency) */
.auth-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  padding: 30px 24px;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--border-subtle);
  color: var(--text-primary);
  text-align: left;
}

.auth-header {
  text-align: center;
  margin-bottom: 20px;
}

.auth-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 6px;
  text-wrap: balance;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Segmented Mode Selector */
.auth-tabs {
  display: flex;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 18px;
}

.auth-tab-btn {
  flex: 1;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.auth-tab-btn:hover {
  color: var(--text-primary);
}

.auth-tab-btn.active {
  background: var(--border-subtle);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Solid Alert Strips (No muddy translucent glass) */
.auth-alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-alert svg {
  flex-shrink: 0;
}

.auth-alert-error {
  background: #1c1112;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
}

.auth-alert-success {
  background: #0f1c13;
  border: 1px solid #14532d;
  color: #86efac;
}

/* Form Controls */
.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.35;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-field input {
  width: 100%;
  min-height: 44px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 40px 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.auth-field input::placeholder {
  color: #52525b;
}

/* Password Toggle Visibility Button */
.input-toggle-btn {
  position: absolute;
  right: 8px;
  height: 28px;
  width: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.input-toggle-btn:hover {
  color: var(--text-primary);
}

/* Primary Action Button */
.auth-btn {
  width: 100%;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.15s ease, transform 0.15s ease;
  font-family: inherit;
}

.auth-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Footer Link */
.auth-footer {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-toggle-link {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

.auth-toggle-link:hover {
  opacity: 0.85;
}

/* Override Browser Autofill Color Hijacking */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
input:autofill,
input:autofill:hover,
input:autofill:focus,
input:autofill:active {
  -webkit-text-fill-color: var(--text-primary) !important;
  -webkit-box-shadow: 0 0 0px 1000px var(--surface-input) inset !important;
  box-shadow: 0 0 0px 1000px var(--surface-input) inset !important;
  caret-color: var(--text-primary) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Mobile Ergonomics: >=16px font to prevent iOS Safari auto-zoom */
@media (max-width: 767px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}
