:root {
  /* testy_v2 tokens (src/theme/design-tokens.scss) — the app's own values. */
  --brand-500: #3970f1;
  --brand-600: #2e5ac1;
  --success-700: #15683a;
  --danger-700: #a3261f;
  --color-success-tint: rgba(35, 227, 115, 0.10);
  --color-danger-tint: rgba(255, 0, 68, 0.10);
  --color-brand-focus: rgba(57, 112, 241, 0.15);

  --text-primary: #1c1c1e;
  --text-muted: rgba(60, 60, 67, 0.65);

  --app-bg-page: #f2f2f7;
  --app-bg-card: #ffffff;
  --app-field-border-color: #e0e0e0;
  --app-field-placeholder-color: #6b6b6b;
  --neutral-100: #e8e8e9;
  --neutral-200: #cecdd0;

  --app-card-radius: 24px;
  --app-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --app-field-height: 48px;
  --app-btn-height: 50px;
  --app-field-radius: 15px;
  --app-radius-pill: 999px;
  --app-btn-radius: 1rem;
  --app-card-radius-md: 12px;
  /* Ionic defaults, which app-dropzone builds on. */
  --ion-color-medium: #92949c;
  --ion-color-medium-shade: #808289;
  --ion-color-light: #f4f5f8;
  --ion-color-primary-tint: #ecf1fe;
  --ion-color-danger: #ff0044;

  --app-spacing-xs: 4px;
  --app-spacing-sm: 8px;
  --app-spacing-lg: 12px;
  --app-spacing-xl: 16px;
  --app-spacing-2xl: 24px;

  /* testy_v2 uses system-ui for Hebrew — see the "Hebrew / RTL" block in its tokens. */
  --app-font: system-ui, -apple-system, sans-serif;
  --app-font-size-caption: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--app-font);
  background: var(--app-bg-page);
  color: var(--text-primary);
  display: grid;
  place-items: start center;
  min-height: 100vh;
  padding: var(--app-spacing-2xl);
}

.card {
  background: var(--app-bg-card);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--app-field-border-color);
  border-radius: var(--app-card-radius);
  box-shadow: var(--app-card-shadow);
  padding: 28px;
  animation: dash-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dash-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head { margin-bottom: var(--app-spacing-2xl); }
.card-head h1 { margin: 0 0 var(--app-spacing-xs); font-size: 22px; font-weight: 700; }
.card-head .sub { margin: 0; color: var(--text-muted); font-size: var(--app-font-size-caption); }

.row { display: flex; gap: var(--app-spacing-lg); }
.row .field { flex: 1; min-width: 0; }

.field {
  display: block;
  margin-bottom: var(--app-spacing-xl);
  font-size: var(--app-font-size-caption);
  font-weight: 600;
}

input:not([type="checkbox"]), select {
  width: 100%;
  height: var(--app-field-height);
  margin-top: var(--app-spacing-sm);
  padding: 0 var(--app-spacing-lg);
  border: 1px solid var(--app-field-border-color);
  border-radius: var(--app-field-radius);
  font: inherit;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--app-bg-card);
}
input::placeholder { color: var(--app-field-placeholder-color); }
input[type="file"].dropzone__input { display: none; }
input[readonly] { background: var(--app-bg-page); color: var(--text-muted); }

input:not([type="checkbox"]):focus, select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--color-brand-focus);
}

input.invalid, select.invalid {
  border-color: var(--danger-700);
  box-shadow: 0 0 0 3px var(--color-danger-tint);
}

/* Filled by the on-device scan — amber until the student touches the field. */
input.autofilled, select.autofilled {
  background: #fff8e1;
  border-color: #e8d9a0;
}

.hint {
  display: block;
  margin-top: var(--app-spacing-sm);
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}
.hint.tips { margin-top: var(--app-spacing-xs); font-size: 12px; opacity: 0.75; }
.hint.checked { color: var(--success-700); }
.hint.autofill { color: #8a6d1f; }

.consent {
  display: flex;
  gap: var(--app-spacing-sm);
  align-items: flex-start;
  font-weight: 400;
  font-size: var(--app-font-size-caption);
  margin-bottom: var(--app-spacing-xl);
  line-height: 1.35;
}
.consent input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--brand-500);
}

button {
  width: 100%;
  height: var(--app-btn-height);
  border: 0;
  border-radius: var(--app-radius-pill);
  background: var(--brand-500);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--brand-600); }

.result {
  margin-top: var(--app-spacing-xl);
  padding: var(--app-spacing-lg) var(--app-spacing-xl);
  border-radius: var(--app-field-radius);
  font-size: var(--app-font-size-caption);
}
.result.ok { background: var(--color-success-tint); color: var(--success-700); }
.result.error { background: var(--color-danger-tint); color: var(--danger-700); }

/* Upload zone — mirrors testy_v2's app-dropzone component. */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--app-spacing-sm);
  width: 100%;
  min-height: 120px;
  margin-top: var(--app-spacing-sm);
  padding: 20px;
  border: 2px dashed var(--ion-color-medium);
  border-radius: var(--app-btn-radius);
  background: var(--ion-color-light);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone:focus-visible {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--color-brand-focus);
}
.dropzone--dragging {
  border-color: var(--brand-500);
  background: var(--ion-color-primary-tint);
}
.dropzone--has-preview { cursor: default; }

.dropzone__icon, .dropzone__prompt { color: var(--ion-color-medium-shade); }
/* Driven by the zone's state, not per-element: `.hidden = true` is an HTMLElement
   property and does nothing at all on an <svg>. */
.dropzone--has-preview .dropzone__icon,
.dropzone--has-preview .dropzone__prompt { display: none; }
.dropzone__prompt { font-size: 13px; font-weight: 400; }

.dropzone__thumb {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--app-card-radius-md);
  object-fit: contain;
}

.dropzone__remove {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: var(--app-btn-radius);
  /* Milky-glass material, as the component uses over a preview. */
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  color: var(--ion-color-danger);
  cursor: pointer;
}
.dropzone__remove:hover { background: rgba(255, 255, 255, 0.92); }

/* Loading skeleton — mirrors testy_v2's loading-skeleton component. */
.skeleton-form { display: flex; flex-direction: column; gap: var(--app-spacing-xl); }
/* A class with `display` beats the UA's [hidden] rule, so say it explicitly or the
   skeleton stays on screen above the loaded form. */
.skeleton-form[hidden] { display: none; }
.skeleton {
  position: relative;
  overflow: hidden;
  display: block;
  background: var(--neutral-100);
  border-radius: var(--app-radius-pill);
  animation: skeleton-breathe 2.4s ease-in-out infinite;
  will-change: opacity;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 0%, rgba(206, 205, 208, 0.5) 50%, transparent 100%);
  animation: skeleton-flow 2.4s ease-in-out infinite;
}
.skeleton.line { height: 0.875rem; }
.skeleton.line.title { height: 1rem; width: 60%; }
.skeleton.field { height: var(--app-field-height); border-radius: var(--app-field-radius); }

@keyframes skeleton-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes skeleton-flow { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }

/* Submitting — testy_v2's AppLoadingOverlayComponent chrome. */
.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.app-loading-overlay[hidden] { display: none; }
.app-loading-overlay__art { width: 60px; height: 60px; }

.bubbles {
  width: 60px;
  height: 60px;
  border-radius: var(--app-radius-pill);
  background: var(--brand-500);
  position: relative;
  overflow: hidden;
}
.bubbles i {
  position: absolute;
  bottom: -10px;
  border-radius: var(--app-radius-pill);
  background: rgba(255, 255, 255, 0.75);
  width: 9px;
  height: 9px;
  animation: bubble-rise 2.2s ease-in-out infinite;
}
.bubbles i:nth-child(1) { inset-inline-start: 12px; }
.bubbles i:nth-child(2) { inset-inline-start: 26px; width: 12px; height: 12px; animation-delay: 0.6s; }
.bubbles i:nth-child(3) { inset-inline-start: 40px; width: 7px; height: 7px; animation-delay: 1.2s; }

@keyframes bubble-rise {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-64px); opacity: 0; }
}

.form-busy { opacity: 0.55; pointer-events: none; transition: opacity 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  .card, .skeleton::after, .bubbles i { animation: none; }
}
