/* Хаб учителя — общий стиль. Палитра от логотипа: красный + золото. */

:root {
  --accent: #d91e36;
  --accent-dark: #b31628;
  --gold: #ffb81c;
  --bg: #faf7f5;
  --surface: #ffffff;
  --text: #000000;
  --text-muted: #000000;
  --border: #d8d0cb;
  --shadow: 0 1px 2px rgba(35, 39, 46, 0.05), 0 8px 24px rgba(35, 39, 46, 0.06);
  --shadow-hover: 0 4px 8px rgba(35, 39, 46, 0.06), 0 16px 40px rgba(217, 30, 54, 0.12);
  --radius: 16px;
}

/* Тёмная тема применяется атрибутом data-theme="dark" на <html>.
   Атрибут выставляет inline-скрипт: выбор пользователя (localStorage)
   или системная настройка. Весь текст — максимальный контраст:
   чисто белый в тёмной теме, чисто чёрный в светлой. */
:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1e2126;
  --text: #ffffff;
  --text-muted: #ffffff;
  --border: #34383f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(217, 30, 54, 0.25);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand img { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }

.brand .brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
  min-width: 0;
}

.header-user img { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }

.header-user .user-name {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Контент ---------- */

.page { max-width: 1080px; margin: 0 auto; padding: clamp(24px, 5vw, 48px) clamp(16px, 4vw, 32px); }

.page-title { font-size: clamp(22px, 3vw, 28px); font-weight: 700; letter-spacing: -0.02em; }

.page-subtitle { margin-top: 6px; color: var(--text-muted); font-size: 15px; }

/* ---------- Плитки модулей ---------- */

.tiles {
  margin-top: 28px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tile:not(.tile-soon):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.tile:not(.tile-soon):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile:not(.tile-soon):active { transform: translateY(-1px); }

.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  font-size: 26px;
  border-radius: 14px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 12%, var(--surface)),
    color-mix(in srgb, var(--gold) 18%, var(--surface)));
}

.tile-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }

.tile-desc { font-size: 14px; line-height: 1.45; color: var(--text-muted); }

.tile-soon { opacity: 0.85; cursor: default; }

.tile-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 22%, var(--surface));
  color: color-mix(in srgb, var(--gold) 55%, var(--text));
}

/* ---------- Страница входа ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60vw 60vh at 15% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
    radial-gradient(50vw 50vh at 100% 100%, color-mix(in srgb, var(--gold) 10%, transparent), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: clamp(32px, 6vw, 48px);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.auth-card .logo { width: 88px; height: 88px; border-radius: 50%; }

.auth-card h1 { margin-top: 18px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

.auth-card .lead { margin-top: 8px; color: var(--text-muted); font-size: 15px; line-height: 1.5; }

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: 28px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

.btn-google:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

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

.btn-google svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn-google.disabled { opacity: 0.5; pointer-events: none; }

.auth-error { margin-top: 16px; color: var(--accent); font-size: 14px; }

.auth-card .link { color: var(--accent); }

/* ---------- Узкие экраны ---------- */

@media (max-width: 480px) {
  .brand .brand-name { font-size: 16px; }
  .header-user .user-name { display: none; }
  .tiles { gap: 12px; }
  .tile { padding: 18px; min-height: 44px; }
}

/* ---------- Переключатель темы ---------- */

:root[data-theme="dark"] { color-scheme: dark; }
:root:not([data-theme="dark"]) { color-scheme: light; }

html.theme-anim, html.theme-anim * { transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease !important; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(15deg); }

.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle svg { width: 19px; height: 19px; }

/* Показываем солнце в тёмной теме, луну в светлой */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
