* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
  --bg: #090c15;
  --bg-gradient: radial-gradient(circle at 10% 15%, rgba(243, 128, 32, 0.12) 0%, transparent 45%),
                 radial-gradient(circle at 90% 85%, rgba(59, 130, 246, 0.1) 0%, transparent 45%);
  --card: rgba(22, 28, 44, 0.7);
  --card-solid: #161c2c;
  --card-hover: rgba(30, 39, 62, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(243, 128, 32, 0.4);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #f38020;
  --accent-gradient: linear-gradient(135deg, #f38020 0%, #e05e00 100%);
  --accent-glow: rgba(243, 128, 32, 0.25);
  --success: #22c55e;
  --r: 20px;
  --r-sm: 14px;
}

html, body {
  min-height: 100%;
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.ic { width: 22px; height: 22px; display: block; }

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 130px;
}

/* ===== ШАПКА ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 18px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.topbar-actions { display: flex; gap: 6px; }

.demo-badge {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  background: rgba(243, 128, 32, 0.15);
  color: #fb923c;
  border: 1px solid rgba(243, 128, 32, 0.3);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn:active {
  transform: scale(0.92);
  background: var(--card-hover);
}

/* ===== БАННЕР С АВАТАРОМ ===== */
.banner {
  background: linear-gradient(135deg, rgba(30, 41, 67, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px 20px;
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 12, 21, 0.2) 0%, rgba(9, 12, 21, 0.8) 100%);
  z-index: 1;
}

.banner-top, .banner-bottom {
  position: relative;
  z-index: 2;
}

.banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.banner-greeting {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(243, 128, 32, 0.8);
  background: #1e293b;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  padding: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-letter {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.banner-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.banner-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}
.banner-value small {
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
}

.plus {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 24px;
  font-weight: 400;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(243, 128, 32, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.plus:active {
  transform: scale(0.92);
}

/* ===== СЕТКА КАРТОЧЕК ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.card:active {
  transform: translateY(2px) scale(0.98);
  border-color: var(--border-focus);
}

.card-ico {
  font-size: 28px;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== ЭКРАНЫ (VIEWS) ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease-out; }

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

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.view-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.view-text {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== ПАНЕЛИ И СПИСКИ ===== */
.panel {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.profile-row:last-child { border-bottom: none; }
.profile-row span:first-child { color: var(--muted); font-weight: 500; }
.profile-row span:last-child { color: var(--text); font-weight: 600; }

.badge-role {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-role.admin { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-role.ai { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-role.user { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }

.admin-panel {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(180deg, rgba(30, 15, 20, 0.7) 0%, rgba(22, 28, 44, 0.7) 100%);
}
.admin-title {
  font-size: 15px;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 12px;
}

.help-list div {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}
.help-list div:last-child { border-bottom: none; }
.help-list b { color: var(--text); font-weight: 600; }

/* ===== ФОРМЫ И КНОПКИ ===== */
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.input {
  width: 100%;
  background: rgba(10, 14, 25, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.2s ease;
}
.input:focus {
  border-color: var(--accent);
}

.textarea {
  min-height: 90px;
  resize: vertical;
  font-family: inherit;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}
.btn.primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn.primary:active {
  transform: translateY(1px);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:active {
  background: rgba(255, 255, 255, 0.12);
}

/* ===== СПИСОК ПРЕДМЕТОВ ДЗ ===== */
.hw-item {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.hw-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.hw-subject {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.hw-date {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.hw-task {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
}

/* ===== СЕГМЕНТИРОВАННЫЙ КОНТРОЛ ===== */
.seg {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 16px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.seg-btn.active {
  background: var(--card-solid);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== НИЖНЯЯ НАВИГАЦИЯ ===== */
.bottom-nav {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 400px;
  background: rgba(18, 24, 38, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 9999px;
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  z-index: 100;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.nav-btn.active {
  color: var(--accent);
  background: rgba(243, 128, 32, 0.12);
}
.nav-btn:active {
  transform: scale(0.92);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(85px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.handle {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}
