:root {
  --green: #2ecc71;
  --green-dark: #27ae60;
  --green-light: #e8f8ef;
  --green-soft: #d4f5e2;
  --white: #ffffff;
  --text: #1a2e22;
  --text-muted: #5a6f62;
  --border: #c8ead6;
  --shadow: 0 8px 32px rgba(39, 174, 96, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Heebo", sans-serif;
  background: linear-gradient(160deg, var(--green-light) 0%, var(--white) 45%, #f6fffa 100%);
  color: var(--text);
  direction: rtl;
}

.hidden {
  display: none !important;
}

.exam-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.exam-badge {
  background: var(--green-soft);
  color: var(--green-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

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

.timer-label {
  color: var(--text-muted);
  font-size: 14px;
}

.timer-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: center;
}

.progress-bar {
  height: 4px;
  background: var(--green-light);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
  transition: width 0.4s ease;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.welcome-card {
  text-align: center;
  max-width: 560px;
  margin: 40px auto 0;
}

.logo-circle {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--green-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

h1 {
  margin: 0 0 12px;
  font-size: 28px;
  color: var(--green-dark);
}

h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text-muted);
}

.intro-text {
  text-align: right;
  white-space: pre-line;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-block {
  text-align: right;
  margin-bottom: 20px;
}

.form-block label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.form-block input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-block input:focus {
  outline: none;
  border-color: var(--green);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(39, 174, 96, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.45);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white);
  color: var(--green-dark);
  border: 2px solid var(--green);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-lg {
  width: 100%;
  padding: 16px;
  font-size: 18px;
}

.error-msg {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.screen-top {
  margin-bottom: 20px;
}

.screen-top.compact {
  margin-bottom: 16px;
}

.category-badge {
  display: inline-block;
  background: var(--green-soft);
  color: var(--green-dark);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.hint {
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

.reading-text {
  background: var(--green-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  line-height: 1.8;
  font-size: 17px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.recording-panel {
  background: #fafcfa;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
}

.recording-status {
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-muted);
}

.recording-status.recording {
  color: #e67e22;
}

.recording-status.done {
  color: var(--green-dark);
}

.recording-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

#recordingPlayback {
  width: 100%;
  margin-top: 8px;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.questions-card {
  padding: 20px;
}

.question-counter {
  color: var(--text-muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 360px;
  margin-bottom: 20px;
}

.split-layout.grammar-only {
  grid-template-columns: 1fr;
}

.text-panel,
.question-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-text {
  flex: 1;
  overflow-y: auto;
  line-height: 1.75;
  white-space: pre-wrap;
  font-size: 15px;
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 16px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  width: 100%;
  text-align: right;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn:hover {
  border-color: var(--green);
  background: var(--green-light);
}

.option-btn.selected {
  border-color: var(--green-dark);
  background: var(--green-soft);
  font-weight: 600;
}

.feedback-block {
  margin-bottom: 22px;
}

.feedback-block label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

.choice-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.choice-btn {
  flex: 1;
  min-width: 80px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

.choice-btn.selected {
  border-color: var(--green-dark);
  background: var(--green-soft);
  font-weight: 600;
}

.complete-summary {
  color: var(--text-muted);
  margin-top: 12px;
}

.secure-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  text-align: right;
  line-height: 1.6;
  font-size: 14px;
}

.secure-warning a {
  color: var(--green-dark);
  font-weight: 700;
}

.upload-fallback {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.upload-label {
  display: inline-block;
  cursor: pointer;
  margin-top: 8px;
}

.loading-screen {
  text-align: center;
  padding-top: 120px;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .split-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .text-panel {
    max-height: 200px;
  }

  .nav-row {
    flex-direction: column-reverse;
  }

  .nav-row .btn {
    width: 100%;
  }
}
