:root {
  color-scheme: light;
  --ink: #183c38;
  --accent: #245d52;
  --muted: #596965;
  --line: #d6dfd6;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f7f6f0; color: var(--ink); font-family: Tahoma, Arial, sans-serif; font-size: 18px; line-height: 1.8; }
.library-wrap { width: 100%; max-width: 1180px; margin: auto; padding: 24px; }
.library-hero { background: #153d35; color: #fff; padding: 20px 0 24px; }
.library-hero h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.5; margin: 8px 0 16px; }
.library-hero p { max-width: 720px; color: #e2ebe6; margin: 8px 0; }
.library-picker { padding: 12px 0 28px; }
.library-picker-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; }
.library-picker-heading h2 { margin: 0; font-size: 24px; }
.library-picker-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.library-sections {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(108px, 1fr);
  gap: 12px;
  margin: 0;
  direction: rtl;
}
.library-section-link {
  position: relative;
  grid-column: span 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 2px 5px #183c3805;
}
.library-section-link:last-child { grid-column: 2 / span 2; }
.library-section-link:hover { background: #edf3ed; border-color: #80a294; }
.library-section-link[aria-current="page"] { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: inset 0 0 0 1px #ffffff35; }
.library-section-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #edf3ed; color: var(--accent); }
.library-section-icon svg { width: 25px; height: 25px; }
.library-section-label { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.library-section-link[aria-current="page"] .library-section-icon { color: #f1d498; background: #ffffff12; }
.library-section-check { position: absolute; top: 10px; inset-inline-end: 10px; opacity: 0; width: 17px; height: 17px; }
.library-section-link[aria-current="page"] .library-section-check { opacity: 1; }
.library-content-heading { border-top: 1px solid var(--line); padding: 24px 0 20px; margin: 0; }
.library-content-heading h2 { margin: 4px 0; font-size: 28px; line-height: 1.5; }
.library-content-heading > p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.library-action, .library-search button { display: inline-block; padding: 13px 22px; min-height: 50px; border-radius: 14px; text-decoration: none; font: inherit; background: var(--accent); color: #fff; border: 1px solid var(--accent); cursor: pointer; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #b38126; outline-offset: 3px; }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.library-card { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 26px; margin-bottom: 18px; overflow-wrap: anywhere; }
.library-card h2 { font-size: 24px; line-height: 1.7; margin: 5px 0 12px; }
.library-kicker { color: var(--accent); font-size: 15px; font-weight: bold; letter-spacing: .02em; margin: 0; }
.library-state { background: #f0f3ea; border-radius: 12px; padding: 10px 14px; color: #375246; font-size: 16px; }
.library-search { display: flex; align-items: end; gap: 14px; margin: 28px 0; }
.library-search label { flex: 1; min-width: 0; }
input, select { font: inherit; border: 1px solid #afc3b8; border-radius: 10px; min-height: 50px; padding: 10px; width: 100%; max-width: 100%; background: white; color: var(--ink); }
label { display: block; margin: 12px 0; }
summary { cursor: pointer; padding: 12px 0; color: var(--accent); font-weight: bold; }
audio { width: 100%; max-width: 100%; }
.library-text { white-space: pre-line; font-size: 22px; line-height: 2.1; }
.quran-card { background: #fffef8; }
.quran-text { font-size: 28px; line-height: 2.3; max-height: 560px; overflow: auto; padding: 18px; border-top: 1px solid var(--line); }
.quran-text p { margin: 0 0 12px; }
@media (min-width: 680px) {
  .library-sections { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(118px, 1fr); gap: 16px; }
  .library-section-link:last-child { grid-column: 3 / span 2; }
  .library-section-label { font-size: 18px; }
}
@media (min-width: 1000px) {
  .library-sections { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .library-section-link:nth-child(5) { grid-column: 2 / span 2; }
  .library-section-link:nth-child(6) { grid-column: 4 / span 2; }
  .library-section-link:nth-child(7) { grid-column: 6 / span 2; }
}
@media (max-width: 679px) {
  .library-wrap { padding: 18px; }
  .library-hero { padding: 8px 0 12px; }
  .library-hero > .library-wrap { padding-block: 18px; }
  .library-hero p { font-size: 16px; }
  .library-picker { padding-top: 6px; }
  .library-grid { grid-template-columns: 1fr; }
  .library-card { padding: 20px; }
  .library-search { flex-direction: column; align-items: stretch; }
  .library-content-heading h2 { font-size: 25px; }
}
