:root {
  --bg: #0a0a0f;
  --bg-card: #14141c;
  --border: #23232f;
  --text: #e8e8ee;
  --text-dim: #9a9aab;
  --accent: #e63946;
  --accent-hover: #ff4d5a;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.nav { display: flex; gap: 20px; align-items: center; }
.nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}
.nav a:hover { color: var(--text); }

.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

.hero { text-align: center; padding: 60px 0 40px; }
.hero h1 { font-size: 3rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 12px; }
.subtitle { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 32px; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.2s;
}
.btn-secondary:hover { border-color: var(--text-dim); }

.projects { margin-top: 40px; }
.projects h2 { font-size: 1.5rem; margin-bottom: 24px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.card-icon { font-size: 2.2rem; margin-bottom: 12px; }
.card h3 { font-size: 1.1rem; margin-bottom: 6px; }
.card p { color: var(--text-dim); font-size: 0.9rem; }

.auth {
  max-width: 440px;
  margin: 40px auto;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.auth h1 { margin-bottom: 24px; font-size: 1.8rem; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--text-dim); }
.form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form input:focus { outline: none; border-color: var(--accent); }
.form small { color: var(--text-dim); font-size: 0.8rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.errors {
  background: rgba(230, 57, 70, 0.1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  color: var(--accent-hover);
  font-size: 0.9rem;
}

.auth-alt { margin-top: 20px; text-align: center; color: var(--text-dim); font-size: 0.9rem; }
.auth-alt a { color: var(--accent); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

.dashboard h1 { margin-bottom: 8px; }

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-info-main h2 { font-size: 1.4rem; margin-bottom: 4px; }
.profile-username { color: var(--text-dim); }
.profile-email { color: var(--text-dim); font-size: 0.9rem; margin: 4px 0 12px; }
.profile-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-role { color: var(--accent); border-color: var(--accent); }
.badge-success { color: #4ade80; border-color: #4ade80; }

.twofa-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.twofa-section h3 { font-size: 1rem; margin-bottom: 4px; }
.twofa-section p { color: var(--text-dim); font-size: 0.85rem; margin: 0; }

.section-title { margin: 32px 0 16px; font-size: 1.2rem; }

.avatar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.avatar-link:hover { transform: scale(1.05); box-shadow: 0 0 0 2px var(--accent-hover); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-weight: 700;
}

.alert { padding: 14px 18px; border-radius: var(--radius); margin: 16px 0; border: 1px solid; font-size: .95rem; }
.alert-success { background: rgba(74,222,128,.08); border-color: rgba(74,222,128,.4); color: #86efac; }
.alert-info { background: rgba(96,165,250,.08); border-color: rgba(96,165,250,.4); color: #93c5fd; }
.alert-warning { background: rgba(230,57,70,.08); border-color: rgba(230,57,70,.4); color: var(--text); }

.verify-page { max-width: 480px; }
.verify-header { text-align: center; margin-bottom: 28px; }
.verify-icon-big { font-size: 3.5rem; margin-bottom: 12px; }
.code-input {
  font-family: 'Courier New', monospace !important;
  font-size: 1.8rem !important;
  text-align: center;
  letter-spacing: 12px;
  padding: 14px 12px !important;
  font-weight: 700;
}
.resend-form { text-align: center; margin: 12px 0; }

.verify-result { text-align: center; max-width: 480px; margin: 60px auto; }
.verify-icon { font-size: 4rem; margin-bottom: 20px; }
.verify-icon-success { color: #4ade80; }
.verify-icon-error { color: var(--accent); }
.verify-actions { display: flex; gap: 12px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }

.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 3rem; margin-bottom: 12px; }
.error-page p { color: var(--text-dim); margin-bottom: 24px; }

@media (max-width: 600px) {
  .header { padding: 12px 16px; }
  .main { padding: 20px 14px; }
  .hero h1 { font-size: 2rem; }
  .form-row { grid-template-columns: 1fr; }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-meta { justify-content: center; }
  .dashboard-topbar { flex-direction: column; gap: 12px; align-items: stretch; }
}

/* ============ Страница аватарки (чистая) ============ */
.avatar-page { max-width: 720px; margin: 0 auto; padding: 20px; }
.avatar-page-header { text-align: center; margin-bottom: 24px; }
.avatar-page-header h1 { font-size: 2rem; margin: 12px 0 4px; }
.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

.file-picker {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 16px; margin: 0 auto 24px; width: fit-content;
  background: var(--bg-card); border: 2px dashed var(--border);
  border-radius: var(--radius); cursor: pointer; font-weight: 600; color: var(--text);
  transition: all .2s;
}
.file-picker:hover { border-color: var(--accent); background: rgba(230,57,70,0.05); }

.crop-area { display: flex; flex-direction: column; gap: 20px; }
.crop-layout { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
@media (max-width: 720px) { .crop-layout { grid-template-columns: 1fr; } }

.crop-main {
  background: #000; border-radius: var(--radius); padding: 20px;
  display: flex; justify-content: center; align-items: center;
  min-height: 460px; /* Даем место для рендера */
}

.crop-frame {
  width: 420px; height: 420px; /* Фиксируем размеры */
  max-width: 100%; max-height: 100%;
  background: #111; border-radius: 8px; overflow: hidden;
}

.crop-frame img { display: block; max-width: 100%; }

.crop-side {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
}
.crop-side h3 { font-size: .8rem; color: var(--text-dim); text-transform: uppercase; margin: 0; letter-spacing: 1px; }

.crop-preview {
  width: 180px; height: 180px; border-radius: 50%;
  overflow: hidden; background: #111; border: 3px solid var(--accent);
  display: flex; justify-content: center; align-items: center;
}
.crop-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.crop-zoom { display: flex; flex-direction: column; gap: 6px; width: 100%; font-size: .85rem; color: var(--text-dim); }
.crop-zoom input[type="range"] { width: 100%; accent-color: var(--accent); }
.crop-buttons { display: flex; gap: 10px; width: 100%; margin-top: 10px; }
.crop-buttons button { flex: 1; padding: 10px; font-size: 0.9rem; }

/* === Стили Cropper.js === */
.cropper-container {
  direction: ltr !important;
  touch-action: none !important; 
  user-select: none !important;
}

/* Убираем линии и точки */
.cropper-line, .cropper-point, .cropper-dashed { display: none !important; }

/* Круглая маска */
.cropper-view-box {
  border-radius: 50% !important;
  outline: 2px solid rgba(255, 255, 255, 0.9) !important;
  outline-color: rgba(255, 255, 255, 0.9) !important;
}
.cropper-face {
  border-radius: 50% !important;
  background-color: transparent !important;
}

/* Затемнение за кругом */
.cropper-modal {
  background-color: #000 !important;
  opacity: 0.5 !important;
}
