:root {
  --welcome-shell-max-width: 1100px;
}

#student-login-shell {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  font-family: Arial, sans-serif;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Hide the editor DOM until the welcome / sign-in gate is dismissed. */
body.entry-gate-active {
  background: #000;
  overflow: hidden;
}

body.entry-gate-active > :not(#student-login-gate):not(#guest-agreement-overlay) {
  display: none !important;
}

.welcome-github-footer {
  color: rgba(255, 255, 255, 0.75);
  margin-top: 18px;
  margin-bottom: 28px;
  font-size: 12px;
  line-height: 1.5;
}

.welcome-legal-links {
  display: block;
  margin-top: 8px;
}

.welcome-legal-links a:hover {
  opacity: 0.9;
}

.welcome-news-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  text-align: left;
}

.welcome-news-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-align: left;
}

.welcome-news-loading,
.welcome-news-empty {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.welcome-news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welcome-news-item {
  margin: 0;
}

.welcome-news-link {
  display: inline-block;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welcome-news-link:hover {
  color: rgba(255, 255, 255, 0.9);
}

.welcome-news-excerpt {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
}

.welcome-news-source {
  margin: 14px 0 0;
  font-size: 12px;
}

.welcome-news-source a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welcome-news-source a:hover {
  color: #fff;
}

.welcome-more-about {
  margin: 22px 0 0;
  font-size: 14px;
}

.welcome-more-about a {
  color: #fff;
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welcome-more-about a:hover {
  color: rgba(255, 255, 255, 0.9);
}

.welcome-system-text {
  text-align: center;
}

.welcome-system-text h2 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
}

.welcome-system-text p {
  color: #f0f0f0;
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.6;
}

.welcome-system-text p:last-child {
  margin-bottom: 28px;
}

#integrated-welcome-inner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px 36px;
  border-radius: 16px;
  color: white;
  width: min(100%, var(--welcome-shell-max-width));
  max-width: var(--welcome-shell-max-width);
  box-sizing: border-box;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  position: relative;
}

.integrated-welcome-layout {
  display: block;
}

.integrated-welcome-auth {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.integrated-welcome-samples {
  display: none;
}

#integrated-welcome-inner.integrated-welcome-with-playground {
  padding: 0;
  text-align: left;
}

/* Sign-in steps injected without the layout wrapper still need side padding. */
#integrated-welcome-inner.integrated-welcome-with-playground:not(:has(.integrated-welcome-layout)) {
  padding: 28px 32px;
}

.student-login-step .student-class-btn,
.student-login-step .student-name-btn {
  width: 100%;
  box-sizing: border-box;
}

#integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.05fr);
}

#integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-auth {
  padding: 28px 32px;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
}

#integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-samples {
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
}

#integrated-welcome-inner.integrated-welcome-with-playground .welcome-playground-section {
  display: flex;
  flex-direction: column;
}

#integrated-welcome-inner.integrated-welcome-with-playground .welcome-playground-grid-wrap {
  padding-right: 4px;
}

.welcome-playground-section {
  margin-top: 0;
  padding-top: 0;
}

.welcome-playground-head {
  text-align: left;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.welcome-playground-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
}

.welcome-playground-subtitle {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.78);
}

.welcome-playground-loading,
.welcome-playground-empty,
.welcome-playground-error {
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

.welcome-playground-error {
  color: #ffcdd2;
}

.welcome-playground-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.welcome-playground-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.welcome-playground-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.45);
}

.welcome-playground-card:disabled {
  opacity: 0.7;
  cursor: wait;
}

.welcome-playground-thumb {
  aspect-ratio: 16 / 10;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.welcome-playground-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.welcome-playground-thumb-fallback {
  font-size: 36px;
}

.welcome-playground-card-body {
  padding: 12px 14px 14px;
}

.welcome-playground-card-title {
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
}

.welcome-playground-card-scope {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 6px;
}

.welcome-playground-card-desc {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.welcome-playground-card-cta {
  display: inline-block;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px 10px;
  border-radius: 999px;
}

@media (max-width: 900px) {
  #integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  #integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-auth {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    padding: 28px 24px;
    flex-shrink: 0;
  }

  #integrated-welcome-inner.integrated-welcome-with-playground .integrated-welcome-samples {
    padding: 24px 20px 28px;
  }
}

@media (max-width: 640px) {
  #integrated-welcome-inner {
    padding: 28px 20px;
  }

  .welcome-playground-grid {
    grid-template-columns: 1fr;
  }
}

body.guest-agreement-open {
  overflow: hidden;
}

.guest-agreement-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: Arial, sans-serif;
}

.guest-agreement-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.guest-agreement-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  max-height: min(82vh, 520px);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
}

.guest-agreement-title {
  margin: 0;
  padding: 18px 20px 10px;
  font-size: 1.125rem;
  line-height: 1.3;
  color: #fff;
  font-weight: bold;
}

.guest-agreement-content {
  padding: 0 20px 16px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.55;
  color: #f0f0f0;
  text-align: left;
}

.guest-agreement-content p,
.guest-agreement-content li {
  color: #f0f0f0;
}

.guest-agreement-content a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.guest-agreement-content a:hover {
  color: rgba(255, 255, 255, 0.9);
}

.guest-agreement-content p:last-child {
  margin-bottom: 0;
}

.guest-agreement-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.12);
}

.guest-agreement-btn {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.guest-agreement-cancel {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.guest-agreement-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.guest-agreement-agree {
  background: #fff;
  color: #667eea;
  border-color: #fff;
}

.guest-agreement-agree:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.92);
}
