/* ===== Class vote — компактный мобильный мокап ===== */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, .12);

  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

  --bg-card: #ffffff;
  --bg-app:  #f7f8fb;
  --bg-input: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;

  --shadow-sheet: 0 -12px 48px rgba(15, 23, 42, .18);
  --shadow-btn: 0 6px 16px rgba(99, 102, 241, .35);
  --shadow-card-hover: 0 4px 14px rgba(15, 23, 42, .07);

  --radius: 16px;
  --radius-sm: 12px;
  --transition: cubic-bezier(.4, 0, .2, 1);

  --color-rose:   linear-gradient(135deg, #fb7185, #e11d48);
  --color-blue:   linear-gradient(135deg, #60a5fa, #2563eb);
  --color-purple: linear-gradient(135deg, #c084fc, #9333ea);
  --color-teal:   linear-gradient(135deg, #5eead4, #0d9488);
  --color-orange: linear-gradient(135deg, #fbbf24, #f97316);

  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: contain;
}
body {
  overflow-x: hidden;
}

button, a, input { touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }

/* ===== App container ===== */
.app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

/* ===== Header — узкая полоса с градиентом ===== */
.header {
  padding: 22px 20px 26px;
  padding-top: calc(22px + env(safe-area-inset-top));
  background: var(--gradient);
  color: #ffffff;
  text-align: center;
  border-radius: 0 0 22px 22px;
  position: relative;
}
.header__emoji {
  font-size: 36px;
  line-height: 1;
  margin: 0 0 8px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .2));
}
.header__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 14px 14px max(16px, env(safe-area-inset-bottom));
}

/* ===== Teachers list ===== */
.teachers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.teacher {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform .14s var(--transition), box-shadow .2s var(--transition), border-color .2s var(--transition);
}
.teacher:hover  { box-shadow: var(--shadow-card-hover); border-color: transparent; }
.teacher:active { transform: scale(.985); }
.teacher.is-voted {
  border-color: var(--primary);
  background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)), var(--bg-card);
}
.teacher.is-disabled { opacity: .5; }
.teacher.is-disabled .teacher__vote { display: none; }

.teacher__avatar {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, .08), 0 3px 8px rgba(0, 0, 0, .08);
}
.teacher[data-color="rose"]   .teacher__avatar { background: var(--color-rose); }
.teacher[data-color="blue"]   .teacher__avatar { background: var(--color-blue); }
.teacher[data-color="purple"] .teacher__avatar { background: var(--color-purple); }
.teacher[data-color="teal"]   .teacher__avatar { background: var(--color-teal); }
.teacher[data-color="orange"] .teacher__avatar { background: var(--color-orange); }

.teacher__info { flex: 1; min-width: 0; }
.teacher__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.teacher__subject {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.teacher__vote {
  padding: 7px 14px;
  border-radius: 100px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color .15s var(--transition), transform .12s var(--transition);
}
.teacher__vote:hover:not(:disabled)  { background: rgba(99, 102, 241, .2); }
.teacher__vote:active:not(:disabled) { transform: scale(.94); }
.teacher.is-voted .teacher__vote {
  background: var(--primary);
  color: #ffffff;
}
.teacher__vote:disabled:not(.is-voted) { cursor: default; opacity: .55; }

/* ===== Bottom sheet ===== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .3s var(--transition);
}
.sheet.is-open .sheet__backdrop { opacity: 1; }

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  background: var(--bg-card);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 8px 0 max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .4s cubic-bezier(.32, .72, 0, 1);
  overflow: hidden;
}
.sheet.is-open .sheet__panel { transform: translateY(0); }

.sheet__err {
  margin: -4px 22px 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}
.sheet__err[hidden] { display: none !important; }

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 6px;
}

/* ===== Step ===== */
.step {
  padding: 12px 22px 6px;
  text-align: center;
  animation: stepIn .35s var(--transition);
}
.step[hidden] { display: none; }
@keyframes stepIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

.step__icon--gradient {
  width: 66px;
  height: 66px;
  margin: 8px auto 14px;
  border-radius: 20px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  font-size: 34px;
  box-shadow: 0 10px 24px rgba(99, 102, 241, .35);
}
.step__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.step__subtitle {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}
.step__subtitle strong { color: var(--text); font-weight: 600; }

/* close / back */
.sheet__close, .sheet__back {
  position: absolute;
  top: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  background: var(--bg-input);
  z-index: 2;
  transition: background-color .15s var(--transition), color .15s var(--transition);
}
.sheet__close { right: 14px; }
.sheet__back  { left:  14px; }
.sheet__close:hover, .sheet__back:hover { background: var(--border); color: var(--text); }

/* ===== Field ===== */
.field {
  position: relative;
  text-align: left;
  margin-bottom: 18px;
}
.field__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding-left: 4px;
}
.field__input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  font-size: 17px;
  transition: border-color .15s var(--transition), background-color .15s var(--transition), box-shadow .15s var(--transition);
}
.field__input:focus {
  outline: 0;
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.field__input--with-icon { padding-right: 48px; }
.field__reveal {
  position: absolute;
  right: 6px;
  bottom: 4px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: 50%;
  transition: color .15s var(--transition), background-color .15s var(--transition);
}
.field__reveal:hover { color: var(--primary); background: var(--primary-soft); }

/* ===== OTP ===== */
.otp {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 20px;
}
.otp__cell {
  width: 48px;
  height: 56px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  transition: border-color .15s var(--transition), background-color .15s var(--transition), transform .15s var(--transition), color .15s var(--transition), box-shadow .15s var(--transition);
}
.otp__cell:focus {
  outline: 0;
  border-color: var(--primary);
  background: var(--bg-card);
  transform: translateY(-2px);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.otp__cell.is-filled {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== Primary button ===== */
.primary-btn {
  position: relative;
  width: 100%;
  height: 50px;
  border-radius: 14px;
  background: var(--primary);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .01em;
  box-shadow: var(--shadow-btn);
  transition: background-color .15s var(--transition), transform .12s var(--transition), opacity .15s var(--transition), box-shadow .2s var(--transition);
}
.primary-btn:hover:not(:disabled)  { background: var(--primary-hover); }
.primary-btn:active:not(:disabled) { transform: scale(.985); }
.primary-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--text-muted);
}
.primary-btn.is-loading { color: transparent; pointer-events: none; }
.primary-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, .3);
  border-top-color: #ffffff;
  border-radius: 50%;
  top: 50%; left: 50%;
  margin: -11px 0 0 -11px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  display: block;
  margin: 12px auto 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ===== Done step ===== */
.step--done { padding-top: 10px; }
.step--done .check-anim {
  width: 88px;
  height: 88px;
  margin: 8px auto 18px;
  color: #10b981;
  filter: drop-shadow(0 8px 16px rgba(16, 185, 129, .35));
}
.step--done .check-anim svg { width: 100%; height: 100%; }
.check-anim__circle {
  stroke-dasharray: 170;
  stroke-dashoffset: 170;
  animation: drawCircle .55s ease-out forwards;
}
.check-anim__path {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: drawCheck .35s ease-out .45s forwards;
}
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck  { to { stroke-dashoffset: 0; } }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ===== Очень узкие телефоны ===== */
@media (max-width: 360px) {
  .header { padding: 18px 16px 22px; }
  .header__emoji { font-size: 32px; }
  .header__title { font-size: 18px; }
  .content { padding: 12px 12px max(14px, env(safe-area-inset-bottom)); }
  .otp__cell { width: 44px; height: 52px; font-size: 20px; }
  .step { padding: 10px 18px 6px; }
}

/* переход на авторизацию */
body.is-leaving {
  animation: cvLeaveOut 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cvLeaveOut {
  to {
    opacity: 0;
    transform: scale(0.985);
  }
}
