:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66736f;
  --line: #d7ddda;
  --paper: #fbfcfb;
  --band: #eef4f1;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --gold: #b7791f;
  --blue: #315f86;
  --danger: #b42318;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.file-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--white);
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  background: var(--accent-strong);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.topbar h1,
.auth-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar nav form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.app-shell,
.admin-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 36px) 40px;
}

.reader-toolbar,
.notice-band,
.admin-form-band,
.word-band,
.admin-options,
.coverage-band {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.reader-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  min-height: 40px;
  border-radius: 6px;
  padding: 8px 10px;
}

.reader-toolbar input {
  width: 92px;
}

.reader-toolbar select {
  width: 220px;
}

.wide-control {
  min-width: 220px;
}

.toolbar-count,
.translation-summary {
  color: var(--muted);
  font-size: 13px;
}

.toolbar-count {
  align-self: center;
  padding: 8px 0;
}

.notice-band {
  display: grid;
  grid-template-columns: auto auto minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.notice-band strong {
  color: var(--ink);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 28px;
  padding: 24px 0;
}

.reader-main,
.lens-panel {
  min-width: 0;
}

.verse-ref {
  color: var(--accent-strong);
  font-weight: 800;
  margin-bottom: 12px;
}

.arabic {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  font-family: "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif;
  font-size: 34px;
  line-height: 2.1;
  text-align: right;
}

.translation-summary {
  margin-top: 14px;
}

.translation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 4px;
}

.translation-item,
.lens-output,
.auth-panel,
.option-row {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.translation-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.translation-meta h3,
.translation-item h3 {
  margin: 0;
  font-size: 15px;
}

.translation-meta span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.translation-item p,
.option-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.lens-output {
  margin-top: 16px;
  border-color: #b9d7d2;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.compact {
  margin-top: 20px;
}

.lens-panel {
  position: sticky;
  top: 12px;
  align-self: start;
  display: grid;
  gap: 12px;
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.file-button {
  display: grid;
  place-items: center;
  text-align: center;
}

.file-button input {
  display: none;
}

.export-box {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 10px;
}

.option-choice {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
}

.option-choice span {
  display: grid;
  gap: 3px;
}

.option-choice em,
.pill,
.gloss-evidence {
  width: fit-content;
  color: var(--accent-strong);
  background: #dff3ef;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-style: normal;
}

.pill.origin {
  color: var(--blue);
  background: #e7f0f8;
}

.pill.default {
  color: #7a4c05;
  background: #fff0c2;
}

.gloss-evidence.ur {
  color: #6d3f00;
  background: #fff4dc;
  direction: rtl;
  font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif;
}

.lens-labels {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.lens-labels span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  padding: 4px 9px;
}

.lens-segments {
  line-height: 2;
  margin: 12px 0;
}

.changed-term {
  background: #fff0c2;
  border-bottom: 2px solid var(--gold);
  border-radius: 4px;
  padding: 2px 4px;
}

.warning-text,
.error-text {
  color: var(--danger);
}

.word-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.word-chip {
  min-height: 154px;
  display: grid;
  align-content: start;
  gap: 7px;
  text-align: left;
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.word-chip:hover {
  background: var(--band);
  color: var(--ink);
}

.word-arabic {
  font-family: "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif;
  font-size: 24px;
  text-align: right;
}

.word-meta,
.word-gloss {
  overflow-wrap: anywhere;
}

.word-meta {
  color: var(--muted);
  font-size: 12px;
}

.word-gloss {
  font-weight: 800;
}

.gloss-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.admin-form,
.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.admin-form h2,
.admin-form-band h2,
.admin-options h2 {
  margin: 0 0 14px;
}

.wide-label {
  grid-column: 1 / -1;
}

.checkbox-label {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: center;
}

.checkbox-label input {
  min-height: auto;
}

.coverage-band {
  display: grid;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

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

.stats-grid strong,
.stats-grid span {
  display: block;
}

.stats-grid strong {
  font-size: 22px;
  line-height: 1.1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.filter-form {
  margin-bottom: 14px;
}

.option-table {
  display: grid;
  gap: 10px;
}

.option-row {
  display: grid;
  gap: 10px;
}

.option-row > div:first-child {
  display: grid;
  gap: 4px;
}

.pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

@media (max-width: 960px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .lens-panel {
    position: static;
  }

  .notice-band {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1,
  .auth-panel h1 {
    font-size: 25px;
  }

  .reader-toolbar,
  .reader-toolbar label,
  .reader-toolbar input,
  .reader-toolbar select,
  .reader-toolbar button,
  .wide-control {
    width: 100%;
  }

  .reader-toolbar button {
    min-width: 0;
  }

  .arabic {
    font-size: 28px;
    padding: 16px;
  }

  .translation-grid {
    grid-template-columns: 1fr;
    max-height: none;
  }
}
