:root {
  --teal: #0f766e;
  --teal-dark: #0b5b54;
  --teal-soft: #0f766e11;
  --cream: #faf6ef;
  --cream-dark: #f3ecdf;
  --ink: #24313a;
  --muted: #64748b;
  --line: #e3dacb;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.8;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: var(--teal);
  color: #fff;
  padding: 16px 0 32px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.back-link {
  color: #eaf8f5;
  text-decoration: none;
  font-size: 0.95rem;
}

.back-link:hover {
  color: #fff;
  text-decoration: underline;
}

.ui-lang-toggle {
  display: flex;
  gap: 6px;
}

.ui-lang-btn,
.lang-btn {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: inherit;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.ui-lang-btn {
  color: #eaf8f5;
}

.ui-lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.ui-lang-btn.active {
  background: #fff;
  color: var(--teal);
  border-color: #fff;
  font-weight: 700;
}

.site-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 400;
  font-size: 2rem;
  margin: 20px 0 0;
  line-height: 1.35;
  text-align: center;
}

html[lang="ar"] .site-title {
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", serif;
}

.library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 36px;
}

#library-heading {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
}

.stories-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.choose-label {
  color: var(--muted);
  margin: 8px 0 24px;
}

.story-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.story-card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 10px;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

html[dir="rtl"] .story-card {
  border-left: 1px solid var(--line);
  border-right: 5px solid var(--teal);
}

.story-card:hover {
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.12);
  transform: translateY(-2px);
}

.story-title-ar {
  display: block;
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--teal);
}

.story-title-en,
.story-title-it {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  margin-top: 2px;
}

.story-title-it {
  color: var(--muted);
}

.story-level {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--teal-dark);
  background: var(--teal-soft);
  padding: 4px 12px;
  border-radius: 999px;
}

.reading-view {
  margin-top: 28px;
}

.view-back {
  display: inline-block;
  color: var(--teal);
  text-decoration: none;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.view-back:hover {
  text-decoration: underline;
}

.story-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
}

.story-nav-btn {
  display: inline-block;
  color: var(--teal);
  text-decoration: none;
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 0.9rem;
}

.story-nav-btn:hover {
  background: var(--teal);
  color: #fff;
}

.story-title {
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", serif;
  font-size: 2rem;
  margin: 12px 0 8px;
  color: var(--teal);
}

.story-level-banner {
  color: var(--teal-dark);
  background: var(--teal-soft);
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.story-source {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
}

.story-source-banner {
  display: inline-block;
  color: var(--teal-dark);
  border: 1px dashed var(--teal);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-style: italic;
  margin-bottom: 18px;
  margin-inline-start: 8px;
}

.lang-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.lang-selector .lang-btn {
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.lang-selector .lang-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.lang-selector .lang-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.paragraphs p {
  margin: 0 0 16px;
}

.paragraphs.source {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 26px;
}

html[lang="ar"] .paragraphs.source,
html[lang="ar"] .story-title,
html[lang="ar"] .story-title-ar {
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", serif;
}

.translations-label {
  font-size: 1.15rem;
  font-weight: 400;
  margin: 34px 0 8px;
  color: var(--teal);
}

.translation-block {
  border-left: 3px solid var(--line);
  padding-left: 18px;
  margin-bottom: 28px;
}

html[dir="rtl"] .translation-block {
  border-left: none;
  border-right: 3px solid var(--line);
  padding-left: 0;
  padding-right: 18px;
}

.translation-lang {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.translation-block .paragraphs p {
  color: var(--ink);
}

.site-footer {
  margin-top: 60px;
  padding: 28px 0;
  background: var(--cream-dark);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.footer-meta {
  font-size: 0.8rem;
  margin-top: 4px;
}

@media (min-width: 600px) {
  .story-list {
    grid-template-columns: 1fr 1fr;
  }
}
