:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --ink: #17212b;
  --muted: #5f6d7a;
  --line: #d8dee6;
  --line-strong: #c4ccd6;
  --accent: #1a73e8;
  --accent-strong: #185abc;
  --accent-soft: #e8f0fe;
  --accent-warm: #fbbc04;
  --warn: #a3421d;
  --good: #207348;
  --bad: #b3261e;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

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

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px 40px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

h2 {
  font-size: 22px;
  line-height: 1.3;
}

h3 {
  font-size: 17px;
  margin-bottom: 10px;
}

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

.top-actions,
.button-row,
.question-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.cloud-sync-panel {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 6px;
}

.cloud-sync-status {
  display: grid;
  min-width: 150px;
  gap: 2px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.cloud-sync-status strong {
  color: var(--ink);
  font-size: 13px;
}

.cloud-sync-status span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.auth-gate {
  display: grid;
  min-height: calc(100vh - 110px);
  place-items: center;
  padding: 28px 18px;
}

.auth-card {
  display: grid;
  width: min(100%, 460px);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(23, 33, 43, 0.08);
  padding: 28px;
  text-align: right;
}

.auth-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 14px;
}

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

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
  outline: none;
}

.auth-error {
  border: 1px solid #f4b7b2;
  border-radius: 8px;
  background: #fff4f2;
  color: #9f1c13;
  font-size: 13px;
  padding: 10px 12px;
}

.auth-card .primary-button {
  width: 100%;
}

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  min-height: calc(100vh - 98px);
}

.sidebar {
  padding: 22px 16px;
  border-left: 1px solid var(--line);
  background: #eef2f6;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: right;
  cursor: pointer;
  padding: 0 14px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.workspace {
  padding: 28px 40px 40px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

select {
  min-width: 240px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
}

input[type="search"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.control-stack {
  display: grid;
  gap: 10px;
  min-width: min(430px, 100%);
}

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

.inline-search input {
  min-width: 0;
  flex: 1;
}

.grow {
  flex: 1;
}

.exam-builder {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.builder-row,
.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-item {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.toggle-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.selected-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.selected-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 0 8px;
}

.chip-remove {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #e9eef1;
  color: var(--ink);
  cursor: pointer;
}

.question-panel,
.import-help,
.import-box,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.04);
}

.question-panel {
  width: min(100%, 1080px);
  min-height: 390px;
  margin-inline: auto;
  padding: 28px;
}

.question-panel-exam {
  padding-top: 20px;
}

.exam-question-block {
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 22px 0;
}

.question-text,
.choice,
.question-reference {
  direction: ltr;
  text-align: left;
}

.question-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.34fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.question-heading {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.question-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.question-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.15;
}

.question-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.question-tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.case-study-tag {
  border-color: #f3d480;
  background: #fff8df;
  color: #6b4b00;
}

.question-reference {
  display: grid;
  justify-items: end;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.question-reference strong {
  color: var(--ink);
  font-size: 15px;
}

.question-reference span {
  white-space: nowrap;
}

.case-study-panel {
  margin-bottom: 20px;
  border: 1px solid #cbd6e2;
  border-radius: 8px;
  background: #f8fafc;
}

.case-study-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.case-study-summary-title {
  direction: ltr;
  text-align: left;
}

.case-study-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.case-study-content {
  display: grid;
  gap: 12px;
  border-top: 1px solid #dce4ec;
  padding: 16px;
  color: #26323d;
  line-height: 1.55;
}

.case-study-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  direction: rtl;
}

.case-study-toolbar-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.case-study-size-group {
  display: inline-flex;
  gap: 4px;
  border: 1px solid #ccd6e0;
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
}

.case-study-size-button {
  min-width: 58px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.case-study-size-button.active {
  background: var(--accent);
  color: #ffffff;
}

.case-study-scroll {
  min-height: 180px;
  overflow: auto;
  resize: vertical;
  border: 1px solid #d5dee8;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
}

.case-study-compact .case-study-scroll {
  max-height: 260px;
}

.case-study-medium .case-study-scroll {
  max-height: 440px;
}

.case-study-full .case-study-scroll {
  max-height: none;
  resize: none;
}

.case-study-document {
  display: grid;
  gap: 18px;
  color: #202b35;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.58;
}

.case-study-document-head {
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
}

.case-study-document-head p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.case-study-document-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.case-study-facts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  direction: rtl;
}

.case-study-facts span,
.case-study-numbers {
  border: 1px solid #dce4ec;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}

.case-study-section {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.case-study-section h4 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.3;
}

.case-study-content p {
  margin: 0;
}

.case-study-document ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
}

.case-study-document li {
  padding-left: 2px;
}

.case-study-empty {
  color: var(--muted);
}

.case-study-source-note {
  border: 1px solid #c8dcfb;
  border-radius: 8px;
  background: #edf4ff;
  color: #244b85;
  padding: 10px 12px;
  line-height: 1.45;
}

.case-study-frame {
  width: 100%;
  height: min(70vh, 640px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.case-study-link {
  justify-self: start;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.case-study-link:hover {
  text-decoration: underline;
}

.case-study-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.case-study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.case-study-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24, 33, 42, 0.04);
  padding: 18px;
}

.case-study-card h3 {
  margin-bottom: 6px;
}

.case-study-card p {
  color: var(--muted);
}

.case-study-numbers {
  max-height: 74px;
  overflow: auto;
  line-height: 1.5;
}

.question-text {
  font-size: 20px;
  line-height: 1.58;
  max-width: 920px;
}

.question-images {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

.question-images img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.answer-hint {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  direction: ltr;
  text-align: left;
}

.choices {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.choice {
  display: grid;
  grid-template-columns: 18px 34px minmax(0, 1fr);
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 14px 16px;
  cursor: pointer;
}

.option-marker {
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border: 2px solid #8794a3;
  border-radius: 50%;
  background: #ffffff;
}

.choice-text {
  flex: 1;
  line-height: 1.5;
}

.choice:hover {
  border-color: var(--accent);
  background: #f9fbff;
}

.static-choice {
  cursor: default;
}

.static-choice:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.choice.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.choice.selected .option-marker,
.choice.correct .option-marker {
  border-color: var(--accent);
  background:
    radial-gradient(circle at center, var(--accent) 0 38%, transparent 42%),
    #ffffff;
}

.choice.correct {
  background: #edf7f1;
  border-color: var(--good);
  box-shadow: inset 4px 0 0 var(--good);
}

.choice.correct .option-marker {
  border-color: var(--good);
  background:
    radial-gradient(circle at center, var(--good) 0 38%, transparent 42%),
    #ffffff;
}

.choice.wrong {
  background: #fdebea;
  border-color: var(--bad);
  box-shadow: inset 4px 0 0 var(--bad);
}

.letter {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-alt);
  color: #3b4652;
  font-weight: 800;
}

.choice.selected .letter,
.choice.correct .letter {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}

.choice.correct .letter {
  background: var(--good);
}

.question-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.primary-button,
.ghost-button,
.link-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--accent);
  color: white;
}

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

.ghost-button,
.link-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.feedback {
  display: none;
  margin: 12px 0 18px;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
}

.feedback span {
  display: block;
  margin-top: 6px;
}

.feedback.show {
  display: block;
}

.feedback.good {
  background: #e6f4ec;
  color: #135f37;
}

.feedback.bad {
  background: #fdebea;
  color: #8c1d18;
}

.exam-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}

.exam-status-item {
  display: grid;
  gap: 4px;
  direction: ltr;
  text-align: left;
}

.exam-status-item:last-child {
  justify-items: end;
}

.status-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.exam-status strong {
  color: var(--ink);
}

.timer {
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  direction: ltr;
}

.exam-summary {
  display: grid;
  gap: 14px;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
  line-height: 1.45;
}

.summary-title {
  margin-bottom: 6px;
  font-weight: 800;
}

.summary-answer {
  margin-top: 8px;
  color: var(--bad);
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.import-grid,
.stats-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
}

.import-help,
.import-box,
.stat-card {
  padding: 20px;
}

pre {
  overflow: auto;
  direction: ltr;
  text-align: left;
  background: #f0f4f6;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.4;
  margin: 0 0 12px;
}

.import-help p {
  color: var(--muted);
  line-height: 1.5;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  direction: ltr;
  text-align: left;
  margin-bottom: 12px;
}

.file-input {
  width: 100%;
  min-height: 42px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 8px;
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.stat-number {
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 6px;
}

.stat-label {
  color: var(--muted);
}

.wide-card {
  grid-column: span 2;
}

.missing-list {
  margin-top: 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

@media (max-width: 820px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .import-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 116px;
    margin: 0;
    text-align: center;
    white-space: nowrap;
  }

  .workspace,
  .topbar {
    padding-inline: 18px;
  }

  .topbar {
    gap: 14px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: 14px;
  }

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

  .cloud-sync-panel {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .cloud-sync-status {
    min-width: 0;
  }

  .workspace {
    padding-top: 18px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }

  select {
    width: 100%;
    min-width: 0;
  }

  .control-stack,
  .inline-search,
  .builder-row {
    width: 100%;
  }

  .inline-search {
    align-items: stretch;
    flex-direction: column;
  }

  .wide-card {
    grid-column: auto;
  }

  .case-study-toolbar,
  .case-study-panel summary {
    align-items: stretch;
    flex-direction: column;
  }

  .case-study-size-group {
    width: 100%;
  }

  .case-study-size-button {
    flex: 1;
  }

  .case-study-scroll {
    min-height: 160px;
    padding: 14px;
  }

  .case-study-compact .case-study-scroll {
    max-height: 220px;
  }

  .case-study-medium .case-study-scroll {
    max-height: 360px;
  }

  .question-panel {
    padding: 16px;
  }

  .question-meta,
  .exam-status {
    grid-template-columns: 1fr;
  }

  .question-heading h3 {
    font-size: 24px;
  }

  .question-reference,
  .exam-status-item:last-child {
    justify-items: start;
  }

  .question-tag {
    min-height: 30px;
  }

  .question-text {
    font-size: 18px;
  }

  .choice {
    grid-template-columns: 18px 30px minmax(0, 1fr);
    gap: 10px;
    padding: 13px 12px;
  }

  .question-actions {
    justify-content: stretch;
  }

  .question-actions button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 20px;
  }

  .top-actions,
  .button-row {
    grid-template-columns: 1fr;
  }

  .cloud-sync-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .cloud-sync-panel .ghost-button {
    padding-inline: 10px;
  }

  .question-panel {
    padding: 14px;
  }

  .exam-status {
    padding: 10px 12px;
  }

  .timer {
    font-size: 22px;
  }

  .question-heading h3 {
    font-size: 22px;
  }

  .exam-question-block {
    padding: 18px 0;
  }

  .question-text {
    font-size: 17px;
  }

  .choices {
    gap: 8px;
  }

  .choice {
    min-height: 54px;
  }
}
