:root {
  color-scheme: light;
  --bg: #f5f3ed;
  --surface: #fffdfa;
  --surface-2: #ece7de;
  --text: #1d2523;
  --muted: #66706c;
  --line: #ded7cc;
  --accent: #17786a;
  --accent-strong: #0f5c50;
  --accent-soft: #d8ece7;
  --warn: #a85e21;
  --shadow: 0 18px 50px rgba(38, 43, 40, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111816;
  --surface: #17211f;
  --surface-2: #23302d;
  --text: #eef4f0;
  --muted: #a8b8b2;
  --line: #34433f;
  --accent: #73d2bd;
  --accent-strong: #a0eadb;
  --accent-soft: #183c35;
  --warn: #e6aa6e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Amiri", "Traditional Arabic", "Scheherazade New", serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
}

label,
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field label {
  margin-bottom: 0;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.search-select {
  position: relative;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-results.open {
  display: grid;
}

.search-result {
  min-height: 38px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.search-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 10px 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--accent);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.status-block {
  display: grid;
  gap: 4px;
}

.status-block p {
  color: var(--muted);
  font-size: 13px;
}

.status-block strong {
  font-size: 18px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.primary-button,
.reader-tools button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  box-shadow: none;
}

.icon-button {
  width: 42px;
  font-size: 18px;
}

.primary-button {
  padding: 0 24px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.reader {
  padding: 24px 26px 30px;
  overflow: auto;
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.reader-tools button {
  padding: 0 14px;
}

.verses {
  display: grid;
  gap: 14px;
}

.verse {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.verse.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.verse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.repeat-count {
  color: var(--accent-strong);
}

.arabic {
  direction: rtl;
  text-align: right;
  font-family: "Amiri", "Traditional Arabic", "Scheherazade New", serif;
  font-size: var(--arabic-size, 42px);
  line-height: 2.05;
}

.translation {
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.hidden-text .arabic {
  filter: blur(10px);
  user-select: none;
}

.hidden-text .translation {
  display: none;
}

.credits {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding: 16px 26px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.credits strong {
  color: var(--text);
}

.credits a {
  color: var(--accent-strong);
  font-weight: 800;
}

.error {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--warn);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .transport {
    width: 100%;
  }

  .primary-button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .sidebar,
  .reader,
  .topbar,
  .credits {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .arabic {
    line-height: 1.9;
  }
}
