:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --card: #f5f5f5;
  --border: #e5e5e5;
  --accent: #00c853;
}

body.dark {
  --bg: #0f1115;
  --text: #f2f2f2;
  --muted: #aaaaaa;
  --card: #181b22;
  --border: #2a2e38;
  --accent: #00e676;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

.container {
  width: min(1180px, 92%);
  margin: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 18px;
  flex: 1;
  overflow: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0.95;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-actions select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
}

/* Dark mode toggle */
.theme-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 4px;
}

.theme-toggle-wrap .toggle-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #4b5563;
  border-radius: 999px;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s ease, background 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

body.dark .toggle-switch {
  background: #10b981;
}

body.dark .toggle-switch::after {
  transform: translateX(20px);
  background: #1f2937;
}

.theme-toggle-wrap:hover .toggle-switch {
  opacity: 0.85;
}

[dir="rtl"] .toggle-switch::after {
  left: auto;
  right: 2px;
}

[dir="rtl"] body.dark .toggle-switch::after {
  transform: translateX(-20px);
}

.hero {
  padding: 34px 0 20px;
  content-visibility: auto;
  contain-intrinsic-size: 1px 280px;
}

.hero h1 {
  font-size: clamp(42px, 7vw, 82px);
  margin: 0;
  letter-spacing: -3px;
  line-height: 0.95;
}

.hero p {
  font-size: 18px;
  color: var(--muted);
  max-width: 900px;
  line-height: 1.6;
}

.category-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.category-pills a {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 20px;
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.category-pills a:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.grid-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.main-feed {
  width: 100%;
}

.main-feed h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: 1px 420px;
}

.card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #ddd;
}

.card-body {
  padding: 16px;
}

.card h3 {
  font-size: 22px;
  margin: 0 0 10px;
  line-height: 1.2;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.ad-slot {
  border: 1px dashed var(--border);
  color: var(--muted);
  min-height: 90px;
  display: grid;
  place-items: center;
  margin: 18px auto;
  width: min(1180px, 92%);
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  contain-intrinsic-size: 1px 120px;
}

.ad-slot.top-ad {
  max-width: 728px;
  width: 100%;
}

.ad-slot.footer-ad {
  max-width: 728px;
  width: 100%;
}

.article-page {
  max-width: 850px;
  padding-top: 35px;
}

.article-page h1 {
  font-size: clamp(34px, 5vw, 58px);
  letter-spacing: -2px;
  line-height: 1.05;
}

.article-meta {
  color: var(--muted);
  margin-bottom: 15px;
}

.language-links {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  flex-wrap: wrap;
}

.language-links a {
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
}

.article-image {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  margin: 20px 0;
  border-radius: 12px;
}

.article-content {
  font-size: 20px;
  line-height: 1.75;
}

.opinion-box {
  margin-top: 30px;
  padding: 20px;
  border-left: 5px solid var(--accent);
  background: var(--card);
  border-radius: 10px;
}

body[dir="rtl"] .opinion-box {
  border-left: none;
  border-right: 5px solid var(--accent);
}

.comments {
  max-width: 850px;
  margin-top: 40px;
}

.comment {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.comment-form {
  display: grid;
  gap: 12px;
  margin-top: 25px;
}

input,
textarea,
select,
button {
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

button {
  background: var(--accent);
  color: #000;
  font-weight: 900;
  cursor: pointer;
  border: none;
}

.site-footer {
  margin-top: 60px;
  padding: 30px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.site-footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.footer-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.footer-legal-links a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.footer-legal-links a:hover {
  text-decoration: underline;
}

.footer-copyright {
  text-align: center;
  margin: 0;
  font-size: 14px;
  width: 100%;
  display: block;
}

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.admin-login form {
  width: 360px;
  display: grid;
  gap: 12px;
}

.error {
  color: red;
}

.admin-wrap {
  width: min(1200px, 94%);
  margin: 30px auto;
}

.admin-nav {
  display: flex;
  gap: 15px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stats-grid div {
  background: var(--card);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--border);
  padding: 10px;
  vertical-align: top;
}

.comment-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 24px;
}

.comment-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.comment-item h4 {
  margin: 0 0 6px;
}

.comment-item small {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 850px) {
  .nav {
    display: none;
  }

  .grid-layout {
    grid-template-columns: 1fr;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    gap: 6px;
  }

  .theme-toggle-wrap .toggle-label {
    display: none;
  }

  .hero {
    padding-top: 28px;
  }

  .hero p {
    font-size: 16px;
  }

  .site-footer .container {
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .footer-legal-links {
    justify-content: center;
  }

  .footer-copyright {
    text-align: center;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .ad-slot {
    min-height: 60px;
    margin: 12px auto;
  }

  .card h3 {
    font-size: 20px;
  }

  .article-content {
    font-size: 18px;
  }
}