:root {
  --background: #f5f7fb;
  --foreground: #151922;
  --paper: #ffffff;
  --muted: #586274;
  --border: #d8dee8;
  --navy: #17345f;
  --red: #b42335;
  --green: #1f7a4d;
  --soft-blue: #eef5ff;
  --soft-red: #fff1f2;
  --focus: #f5b942;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family:
    "Noto Sans Ethiopic",
    "Noto Sans",
    Arial,
    Helvetica,
    sans-serif;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  align-items: stretch;
  display: flex;
  justify-content: center;
  min-height: 100svh;
  padding: 14px;
}

.study-surface {
  background: var(--paper);
  border: 2px solid #111827;
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(18, 28, 45, 0.12);
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 920px;
  min-height: calc(100svh - 28px);
  overflow: visible;
  padding: 0 18px 18px;
  width: 100%;
}

.flag-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  height: 12px;
  margin: 0 -18px;
}

.flag-strip span:nth-child(1) {
  background: var(--red);
}

.flag-strip span:nth-child(2) {
  background: var(--paper);
}

.flag-strip span:nth-child(3) {
  background: var(--navy);
}

.topbar {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 -18px;
  padding: 12px 18px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.title-group {
  min-width: 0;
}

.top-actions,
.admin-header-actions,
.settings-actions,
.question-row-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-navigation {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 48px minmax(72px, auto) 48px;
}

.dual-label {
  display: grid;
  gap: 2px;
  line-height: 1.12;
}

.dual-label span[lang="ti"] {
  font-size: 0.92em;
}

button .dual-label,
.secondary-link .dual-label {
  justify-items: center;
}

.choice-row .dual-label,
.timing-row .dual-label {
  flex: 1;
}

.eyebrow,
.language-label,
.block-heading p {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0;
  text-transform: uppercase;
}

h1,
h2 {
  color: var(--foreground);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.06;
  margin: 7px 0 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.55rem;
}

.count-badge {
  align-items: center;
  background: var(--soft-blue);
  border: 1px solid #bed4f0;
  border-radius: 999px;
  color: var(--navy);
  display: inline-flex;
  font-size: 1rem;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  white-space: nowrap;
}

.progress-track {
  background: #e6ebf2;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-track span {
  background: var(--red);
  display: block;
  height: 100%;
  transition: width 180ms ease;
}

.study-block,
.notice-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.answer-block {
  background: #fbfdfb;
  border-color: #bedcc9;
}

.block-heading {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.audio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.audio-button,
.secondary-button,
.primary-button,
.reveal-button,
.settings-button,
.nav-icon-button,
.secondary-link,
.danger-button,
.record-button,
.record-stop-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 850;
  justify-content: center;
  min-height: 50px;
  padding: 0 16px;
  text-decoration: none;
}

.audio-button {
  background: var(--soft-blue);
  border: 1px solid #bfd1ea;
  color: var(--navy);
  gap: 8px;
  min-width: 86px;
}

.sound-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.language-stack {
  display: grid;
  gap: 14px;
}

.language-panel {
  background: #fbfcff;
  border-left: 5px solid var(--navy);
  padding: 2px 0 2px 15px;
}

.language-panel[lang="ti"] {
  background: #fffafa;
  border-left-color: var(--red);
}

.question-copy,
.answer-copy,
.answer-list {
  color: var(--foreground);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.32;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.tigrinya-copy,
.language-panel[lang="ti"] .answer-copy,
.language-panel[lang="ti"] .answer-list {
  font-size: 1.42rem;
  line-height: 1.42;
}

.answer-list {
  display: grid;
  gap: 8px;
  padding-left: 1.25em;
}

.reveal-button {
  background: var(--red);
  color: #ffffff;
  font-size: 1.22rem;
  width: 100%;
}

.secondary-button,
.settings-button,
.secondary-link,
.nav-icon-button {
  background: #f4f6f8;
  border: 1px solid var(--border);
  color: #1f2937;
}

.primary-button {
  background: var(--navy);
  color: #ffffff;
}

.nav-icon-button {
  box-shadow: 0 6px 14px rgba(17, 24, 39, 0.14);
  color: #ffffff;
  font-size: 2rem;
  min-width: 48px;
  padding: 0;
}

.top-navigation .nav-icon-button:first-child {
  background: var(--red);
  border-color: #8f1f2e;
}

.top-navigation .nav-icon-button:last-child {
  background: var(--green);
  border-color: #17613d;
}

.top-navigation .nav-icon-button:active {
  transform: translateY(1px);
}

.stop-button {
  min-width: 76px;
}

.settings-overlay {
  align-items: center;
  background: rgba(17, 24, 39, 0.68);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 50;
}

.settings-card {
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  display: grid;
  gap: 18px;
  max-height: calc(100svh - 32px);
  max-width: 620px;
  overflow: auto;
  padding: 22px;
  width: min(620px, 100%);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
}

legend {
  color: var(--foreground);
  font-weight: 900;
  padding: 0 8px;
}

.choice-row {
  align-items: center;
  display: flex;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 760;
  min-height: 42px;
}

.choice-row input[type="checkbox"],
.choice-row input[type="radio"] {
  height: 24px;
  width: 24px;
}

.timing-row {
  flex-wrap: wrap;
}

.time-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 800;
  min-height: 42px;
  padding: 0 10px;
  width: 88px;
}

.admin-link {
  color: var(--muted);
  font-weight: 850;
}

.admin-body {
  background: #f7f8fb;
}

.admin-shell {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1100px;
  padding: 24px 14px 48px;
}

.admin-header,
.admin-card,
.success-message,
.error-message {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(18, 28, 45, 0.08);
  padding: 18px;
}

.admin-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.admin-card {
  display: grid;
  gap: 16px;
}

.login-card {
  max-width: 440px;
}

.admin-section-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.question-form,
.login-card {
  display: grid;
  gap: 14px;
}

.admin-help {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
}

.question-form label,
.login-card label,
.upload-row {
  color: var(--muted);
  display: grid;
  font-size: 0.92rem;
  font-weight: 850;
  gap: 6px;
}

.question-form input,
.question-form textarea,
.login-card input {
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
  min-height: 46px;
  padding: 10px 12px;
  width: 100%;
}

.question-form textarea {
  line-height: 1.45;
  min-height: 120px;
  resize: vertical;
}

.audio-upload-fieldset {
  background: #fbfcff;
}

.existing-audio,
.recording-tools {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.existing-audio audio,
.recording-preview {
  width: 100%;
}

.recording-buttons {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.record-button {
  background: var(--green);
  color: #ffffff;
  min-height: 46px;
}

.record-stop-button {
  background: var(--soft-red);
  border: 1px solid #f0b5bf;
  color: #8a1525;
  min-height: 46px;
}

.recording-status {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.35;
  margin: 0;
}

.remove-audio {
  align-items: center;
  display: flex !important;
  flex-direction: row;
  font-size: 0.92rem;
  gap: 8px;
}

.success-message {
  background: #eefbf4;
  border-color: #b9dfc9;
  color: #155c37;
  font-weight: 850;
}

.error-message {
  background: var(--soft-red);
  border-color: #f1bac2;
  color: #8a1525;
  font-weight: 850;
}

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

.question-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 14px;
}

.question-row p {
  margin: 6px 0 0;
}

.danger-button {
  background: var(--soft-red);
  border: 1px solid #f0b5bf;
  color: #8a1525;
  min-height: 42px;
}

.question-total {
  color: var(--muted);
  font-weight: 850;
}

[hidden] {
  display: none !important;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 28px;
  }

  .study-surface {
    gap: 22px;
    min-height: calc(100svh - 56px);
    padding: 0 28px 28px;
  }

  .flag-strip,
  .topbar {
    margin-left: -28px;
    margin-right: -28px;
  }

  .topbar {
    padding-left: 28px;
    padding-right: 28px;
  }

  h1 {
    font-size: 2.55rem;
  }

  .study-block,
  .notice-block {
    padding: 22px;
  }

  .language-stack {
    grid-template-columns: 1fr 1fr;
  }

  .question-copy,
  .answer-copy,
  .answer-list {
    font-size: 1.95rem;
  }

  .tigrinya-copy,
  .language-panel[lang="ti"] .answer-copy,
  .language-panel[lang="ti"] .answer-list {
    font-size: 1.78rem;
  }
}

@media (max-width: 720px) {
  .topbar,
  .admin-header,
  .admin-section-heading,
  .question-row {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .top-actions,
  .admin-header-actions,
  .settings-actions,
  .question-row-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .settings-button,
  .stop-button {
    flex: 1 1 120px;
  }

  .top-navigation {
    flex: 1 0 100%;
    grid-template-columns: 56px 1fr 56px;
    width: 100%;
  }

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

@media (max-width: 520px) {
  .app-shell {
    padding: 10px;
  }

  .study-surface {
    gap: 15px;
    min-height: calc(100svh - 20px);
    padding: 0 14px 14px;
  }

  .flag-strip,
  .topbar {
    margin-left: -14px;
    margin-right: -14px;
  }

  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .block-heading {
    flex-direction: column;
  }

  .audio-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .audio-button {
    min-width: 0;
    padding: 0 10px;
  }

  .question-copy,
  .answer-copy,
  .answer-list {
    font-size: 1.44rem;
  }

  .tigrinya-copy,
  .language-panel[lang="ti"] .answer-copy,
  .language-panel[lang="ti"] .answer-list {
    font-size: 1.36rem;
  }

  .settings-card {
    padding: 18px;
  }
}
