@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Merriweather:wght@400;700&display=swap');

:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #1e40af;
  --accent-2: #3b82f6;
  --border: #e2e8f0;
  --success: #059669;
  --danger: #dc2626;
  --bg-image: url('https://1maxsusvxtb.uz/images/school-building.jpg');
  --bg-overlay: rgba(255,255,255,0.75);
  --shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

body.theme-dark {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #0b1220;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --accent-2: #38bdf8;
  --border: #1f2937;
  --success: #34d399;
  --danger: #f87171;
  --bg-overlay: rgba(0,0,0,0.55);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: linear-gradient(135deg, var(--bg), var(--panel-2));
  background-color: var(--bg);
  background-image: linear-gradient(0deg, var(--bg-overlay), var(--bg-overlay)), var(--bg-image);
  background-size: cover, cover;
  background-position: center center, center center;
  background-attachment: fixed, fixed;
  color: var(--text);
  line-height: 1.6;
}

@media (max-width: 768px) {
  body { background-attachment: scroll, scroll; background-position: center top, center top; }
}

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Header styling inspired by school website */
.site-header { 
  position: sticky; 
  top: 0; 
  backdrop-filter: blur(12px); 
  background: rgba(255,255,255,0.9); 
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 10; 
}
body.theme-dark .site-header { background: rgba(15,23,42,0.9); }

.header-inner { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 16px;
  padding: 12px 0;
}

.brand { 
  font-weight: 700; 
  letter-spacing: 0.5px; 
  color: var(--accent); 
  text-decoration: none; 
  font-family: Merriweather, Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
}

.main-nav { display: flex; gap: 12px; flex-wrap: wrap; }
.nav-link { 
  color: var(--muted); 
  text-decoration: none; 
  padding: 10px 16px; 
  border-radius: 8px; 
  transition: all 0.3s ease;
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-link:hover, .nav-link.active { 
  color: var(--accent); 
  background: rgba(30, 64, 175, 0.1); 
  border-color: var(--accent);
}
.nav-link:hover { transform: translateY(-2px); }

.site-footer { 
  border-top: 2px solid var(--border); 
  margin-top: 32px; 
  padding: 20px 0 32px; 
  color: var(--muted); 
  backdrop-filter: blur(8px); 
  background: rgba(255,255,255,0.8); 
  text-align: center;
}
body.theme-dark .site-footer { background: rgba(15,23,42,0.8); }

/* Typography */
h1, h2, h3 { 
  margin: 12px 0 16px; 
  font-family: Merriweather, Georgia, 'Times New Roman', serif;
  color: var(--text);
  line-height: 1.3;
}
h1 { font-size: 2rem; color: var(--accent); }
h2 { font-size: 1.75rem; color: var(--accent); }
h3 { font-size: 1.5rem; }

.lead { 
  color: var(--muted); 
  margin-bottom: 20px;
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Grid and Layout */
.grid { 
  display: grid; 
  grid-template-columns: repeat(1, minmax(0, 1fr)); 
  gap: 20px; 
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Cards with school-inspired styling */
.card { 
  background: var(--panel); 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  padding: 20px; 
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  border-left: 4px solid var(--accent);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}
.card a { text-decoration: none; color: inherit; }
.card-title { 
  font-weight: 600; 
  margin-bottom: 8px; 
  color: var(--accent);
  font-size: 1.1rem;
}
.card-desc { 
  color: var(--muted); 
  font-size: 0.95rem;
  line-height: 1.5;
}

.section { 
  background: var(--panel); 
  border: 1px solid var(--border); 
  border-radius: 16px; 
  padding: 24px; 
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

/* Navigation elements */
.breadcrumbs { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  font-size: 0.95rem; 
  margin: 8px 0 20px; 
  color: var(--muted);
  padding: 12px 0;
}
.breadcrumbs a { 
  color: var(--accent); 
  text-decoration: none;
  font-weight: 500;
}
.breadcrumbs a:hover { text-decoration: underline; }

.pill-row { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 12px; 
  margin: 16px 0 8px; 
}
.pill { 
  padding: 10px 16px; 
  border: 1px solid var(--border); 
  border-radius: 25px; 
  color: var(--text); 
  text-decoration: none; 
  background: rgba(255,255,255,0.8);
  transition: all 0.3s ease;
  font-weight: 500;
}
.pill:hover { 
  background: var(--accent); 
  color: white;
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Buttons with school styling */
.button { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px; 
  padding: 10px 16px; 
  border-radius: 8px; 
  border: 1px solid var(--border); 
  background: rgba(255,255,255,0.9);
  color: var(--text); 
  text-decoration: none; 
  cursor: pointer; 
  transition: all 0.3s ease;
  font-weight: 500;
}
body.theme-dark .button { background: rgba(255,255,255,0.1); }
.button.primary { 
  border-color: var(--accent); 
  background: var(--accent);
  color: white;
}
.button.success { 
  border-color: var(--success); 
  background: var(--success);
  color: white;
}
.button:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.button:active { transform: translateY(0); }

/* Lists */
.list { 
  list-style: none; 
  padding: 0; 
  margin: 0; 
}
.list li { 
  padding: 16px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  margin-bottom: 12px; 
  background: var(--panel); 
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}
.list li:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.list li a { color: inherit; text-decoration: none; display: block; }

/* Images and media */
.thumbnail { 
  width: 64px; 
  height: 64px; 
  object-fit: cover; 
  border-radius: 8px; 
  border: 2px solid var(--border); 
}
.item-row { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px; 
}
.item-main { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.img-wrap { margin: 12px 0; }
.img-wrap img { 
  max-width: 100%; 
  height: auto; 
  border-radius: 12px; 
  border: 2px solid var(--border); 
  box-shadow: var(--shadow);
}

/* Quiz and forms */
.quiz { display: grid; gap: 16px; }
.question { 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  padding: 20px; 
  background: var(--panel); 
  box-shadow: var(--shadow);
}
.question h4 { margin: 0 0 12px; color: var(--accent); }
.options { display: grid; gap: 8px; }
.result { margin-top: 16px; font-weight: 600; }
.result.ok { color: var(--success); }
.result.bad { color: var(--danger); }

/* Form elements */
label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Timer */
.timer { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  padding: 10px 16px; 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  background: rgba(255,255,255,0.9);
  font-weight: 600;
}
.timer.urgent { 
  color: #fff; 
  background: rgba(220,38,38,0.8); 
  border-color: rgba(220,38,38,0.9); 
}

/* Answer key */
.answer-key { 
  margin-top: 20px; 
  padding: 16px; 
  border: 2px dashed var(--border); 
  border-radius: 12px; 
  background: var(--panel); 
}
.answer-row { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  margin-bottom: 8px;
}
.answer-row .mark { 
  width: 20px; 
  text-align: center; 
  font-weight: bold;
}

/* Dim overlay */
.dim-overlay { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.5); 
  backdrop-filter: blur(2px); 
  z-index: 9999; 
  display: none; 
  opacity: 0; 
  transition: opacity 0.3s ease; 
}
.dim-overlay.active { display: block; opacity: 1; }

/* Additional school-inspired elements */
.book-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
  line-height: 1.4;
}

/* Responsive design */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .site-header { padding: 8px 0; }
  .brand { font-size: 1.1rem; }
  .nav-link { padding: 8px 12px; }
  .card, .section { padding: 16px; }
  .grid { gap: 16px; }
}

/* Special styling for educational content */
.section h2 {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  margin-bottom: 20px;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .site-header, .site-footer, .button, .nav-link {
    display: none !important;
  }
  .card, .section {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}