* {
  box-sizing: border-box;
}

body {
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  min-height: 100vh;
  background-color: #f5f7fa;
  color: #2d3748;
  line-height: 1.6;
}

.container {
  display: flex;
  width: 100%;
}

/* Sidebar */
.sidebar {
  background: linear-gradient(135deg, #23377e 0%, #1a2a5e 100%);
  color: white;
  padding: 40px 30px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar h1 {
  font-size: 1.5rem;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
}

/* Main content */
.content {
  padding: 40px 50px;
  flex: 1;
  max-width: 900px;
}

.content h2 {
  color: #23377e;
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 3px solid #8c0932;
}

#description {
  background: white;
  padding: 20px 25px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 30px;
}

#description p {
  margin: 0 0 10px;
}

#description p:last-child {
  margin-bottom: 0;
}

/* Image section with info panels */
.image-section {
  display: flex;
  align-items: stretch;
  gap: 25px;
  margin: 30px 0;
}

.image-section img {
  max-width: 400px;
  max-height: 450px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.image-info {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.image-info div {
  background: white;
  padding: 15px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid #8c0932;
}

.image-info strong {
  display: block;
  color: #23377e;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* Quiz form */
#quizForm {
  background: white;
  padding: 25px 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-top: 30px;
}

#quizOptions {
  border: none;
  padding: 0;
  margin: 0;
}

#quizOptions legend {
  font-weight: 600;
  color: #23377e;
  font-size: 1.1rem;
  margin-bottom: 15px;
  padding: 0;
}

#quizOptions label {
  display: block;
  padding: 12px 15px;
  margin: 8px 0;
  background: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

#quizOptions label:hover {
  background: #eef2f7;
  border-color: #23377e;
}

#quizOptions input[type='radio'] {
  margin-right: 12px;
  accent-color: #23377e;
}

#quizOptions br {
  display: none;
}

button {
  padding: 12px 28px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 20px 10px 0 0;
}

#submitBtn {
  background: #23377e;
  color: white;
}

#submitBtn:hover {
  background: #1a2a5e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(35, 55, 126, 0.3);
}

#clearBtn {
  background: white;
  color: #64748b;
  border: 2px solid #e2e8f0;
}

#clearBtn:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

/* Front page */
.front-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.front-content h2 {
  border: none;
  text-align: center;
  margin-bottom: 50px;
}

.icon-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 30px;
}

.icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #2d3748;
  padding: 25px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.icon-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.icon-card img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  margin-bottom: 15px;
}

.icon-card span {
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}

/* Messages */
.message {
  padding: 12px 20px;
  border-radius: 6px;
  margin: 20px 0;
  font-weight: 500;
}

.message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.message.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Navigation */
.navigation {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 3px solid #8c0932;
}

.navigation-top {
  margin-top: 0;
  margin-bottom: 20px;
  padding-top: 0;
  border-top: none;
}

.navigation a {
  color: #23377e;
  text-decoration: none;
  font-weight: 500;
}

.navigation a:hover {
  text-decoration: underline;
}

/* Reference page sticky nav bar */
.ref-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f7fa;
  padding: 10px 0 12px;
  margin: -10px 0 20px;
  border-bottom: 2px solid #e2e8f0;
}

.ref-nav a {
  color: #23377e;
  text-decoration: none;
  font-weight: 500;
}

.ref-nav a:hover {
  text-decoration: underline;
}

.ref-nav-sep {
  color: #cbd5e1;
}

.ref-nav-disabled {
  color: #a0aec0;
  font-weight: 500;
}

.clear-link {
  text-decoration: none;
}

/* User info in sidebar */
.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  text-align: center;
}

.user-score-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 12px 18px;
  border-radius: 8px;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.score-display {
  font-size: 0.85rem;
  opacity: 0.85;
}

.login-link,
.logout-link {
  color: white;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.login-link:hover,
.logout-link:hover {
  opacity: 1;
}

.edit-link {
  color: white;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
  margin-top: 5px;
}

.edit-link:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.6);
}

.login-prompt {
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 15px;
}

.login-prompt a {
  color: #23377e;
  text-decoration: none;
  font-weight: 500;
}

.login-prompt a:hover {
  text-decoration: underline;
}

/* Auth pages */
.auth-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  max-width: 500px;
  margin: 0 auto;
}

.auth-form {
  width: 100%;
  max-width: 400px;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

.form-group label {
  display: block;
  font-weight: 500;
  color: #23377e;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #23377e;
}

.form-group small {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
  margin-top: 4px;
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  background: #23377e;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 10px 0 0;
}

.auth-submit-btn:hover {
  background: #1a2a5e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(35, 55, 126, 0.3);
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  color: #64748b;
}

.auth-link a {
  color: #23377e;
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* OAuth section */
.oauth-divider {
  display: flex;
  align-items: center;
  margin: 25px 0;
  width: 100%;
  max-width: 400px;
}

.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.oauth-divider span {
  padding: 0 15px;
  color: #64748b;
  font-size: 0.9rem;
}

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  color: #2d3748;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.oauth-btn:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.oauth-btn svg {
  flex-shrink: 0;
}

.google-btn:hover {
  border-color: #4285f4;
}

.microsoft-btn:hover {
  border-color: #00a4ef;
}

/* Editor styles */
.edit-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.edit-table th,
.edit-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.edit-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #23377e;
  font-size: 0.9rem;
}

.edit-table tr:last-child td {
  border-bottom: none;
}

.edit-table tr:hover {
  background: #f8fafc;
}

.edit-table code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.edit-thumbnail {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
}

.actions-cell {
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  background: #23377e;
  color: white;
}

.btn:hover {
  background: #1a2a5e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(35, 55, 126, 0.3);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-secondary {
  background: white;
  color: #64748b;
  border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: none;
  transform: none;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.edit-actions {
  margin-top: 20px;
}

.edit-list {
  margin: 20px 0;
}

/* Edit form styles */
.edit-form {
  max-width: 700px;
}

.edit-form fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px 25px;
  margin-bottom: 25px;
  background: white;
}

.edit-form legend {
  font-weight: 600;
  color: #23377e;
  padding: 0 10px;
  font-size: 1rem;
}

.edit-form .form-group {
  margin-bottom: 18px;
}

.edit-form .form-group:last-child {
  margin-bottom: 0;
}

.edit-form label {
  display: block;
  font-weight: 500;
  color: #23377e;
  margin-bottom: 6px;
}

.edit-form input[type='text'],
.edit-form input[type='number'],
.edit-form textarea,
.edit-form select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.edit-form input[type='text']:focus,
.edit-form input[type='number']:focus,
.edit-form textarea:focus,
.edit-form select:focus {
  outline: none;
  border-color: #23377e;
}

.edit-form input[type='file'] {
  padding: 8px 0;
}

.edit-form small {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
  margin-top: 4px;
}

.edit-form .form-row {
  display: flex;
  gap: 20px;
}

.edit-form .form-row .form-group {
  flex: 1;
}

.current-image {
  margin-bottom: 15px;
}

.current-image p {
  margin: 0 0 8px;
  font-weight: 500;
  color: #64748b;
}

.current-image img {
  max-width: 200px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-option input[type='radio'] {
  width: auto;
  margin: 0;
}

.quiz-option label {
  display: inline;
  margin: 0;
  min-width: 25px;
  font-weight: 600;
}

.quiz-option input[type='text'] {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
}

.modal h3 {
  margin: 0 0 15px;
  color: #23377e;
  font-size: 1.25rem;
}

.modal p {
  margin: 0 0 10px;
  color: #2d3748;
}

.modal-warning {
  color: #dc2626;
  font-size: 0.9rem;
  font-style: italic;
}

.modal-actions {
  margin-top: 20px;
}

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

.modal-actions .btn {
  flex: 1;
  text-align: center;
}

/* Mobile styles */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 20px;
  }

  .sidebar h1 {
    font-size: 1.3rem;
  }

  .content {
    padding: 20px;
    max-width: 100%;
  }

  .content h2 {
    font-size: 1.4rem;
  }

  /* Front page mobile */
  .front-content {
    padding: 30px 20px;
  }

  .front-content h2 {
    margin-bottom: 30px;
  }

  .icon-row {
    flex-direction: column;
    gap: 20px;
  }

  .icon-card {
    padding: 20px;
    width: 100%;
    max-width: 280px;
  }

  .icon-card img {
    width: 100px;
    height: 100px;
  }

  /* Quiz page mobile */
  .image-section {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  .image-section img {
    max-width: 100%;
    max-height: 350px;
    width: auto;
    height: auto;
  }

  .image-info {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .image-info div {
    flex: 1 1 calc(50% - 5px);
    min-width: 140px;
    padding: 12px 14px;
  }

  #quizForm {
    padding: 20px;
  }

  #quizOptions legend {
    font-size: 1rem;
  }

  button {
    padding: 14px 24px;
    min-height: 44px;
  }

  #description {
    padding: 15px 20px;
  }

  /* Auth pages mobile */
  .auth-content {
    padding: 30px 20px;
  }

  .auth-form {
    padding: 20px;
  }

  .user-info {
    margin-top: 15px;
  }

  /* Editor mobile */
  .edit-table {
    display: block;
    overflow-x: auto;
  }

  .edit-form .form-row {
    flex-direction: column;
    gap: 0;
  }

  .btn-small {
    padding: 8px 12px;
    margin: 2px 0;
  }

  .actions-cell {
    white-space: normal;
  }

  .quiz-option {
    flex-wrap: wrap;
  }

  .quiz-option input[type='text'] {
    width: 100%;
    margin-top: 5px;
  }
}
