:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17181c;
  --muted: #77808c;
  --accent: #f7bd3f;
  --accent-strong: #d99a1a;
  --border: #e6e9ee;
  --danger: #d24a3a;
  --tuddy-blue: #4b8dff;
}
:root[data-scheme="dark"], :root[data-scheme="space_gray"], :root[data-scheme="vkcom_dark"] {
  --bg: #17181c;
  --card: #232427;
  --text: #f0f2f5;
  --muted: #8b939c;
  --border: #2c2d31;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#app { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }

/* Шапка */
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.header .back {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.header h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.header .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Экран выбора класса */
.hero { text-align: center; padding: 20px 0 24px; }
.hero img { width: 96px; height: 96px; border-radius: 24px; }
.hero h1 { margin: 12px 0 4px; font-size: 24px; font-weight: 700; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.class-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px;
}
.class-btn {
  aspect-ratio: 1; border-radius: 18px; border: 2px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 28px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, border-color 0.15s;
}
.class-btn:hover, .class-btn:active {
  border-color: var(--accent); transform: scale(0.98);
}
.class-btn small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; letter-spacing: 0.02em; }

/* Табы */
.tabs {
  display: flex; background: var(--card); border-radius: 12px; padding: 4px;
  margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.tab {
  flex: 1; padding: 10px 12px; border: none; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 8px; transition: 0.15s;
}
.tab.active { background: var(--accent); color: #1a1300; }

/* Карточка ДЗ */
.hw-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}
.hw-card .subject {
  font-size: 12px; font-weight: 700; color: var(--accent-strong);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.hw-card .due {
  float: right; font-size: 12px; color: var(--muted); font-weight: 600;
}
.hw-card .due.overdue { color: var(--danger); }
.hw-card .due.today { color: var(--accent-strong); }
.hw-card .text {
  margin-top: 6px; font-size: 15px; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.hw-card .text.clamp {
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hw-card .more {
  display: inline-block; color: var(--tuddy-blue); font-size: 13px;
  margin-top: 6px; cursor: pointer; font-weight: 500;
}
.hw-card .attachments {
  margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px;
}
.hw-card .att {
  padding: 4px 10px; border-radius: 8px; background: var(--bg);
  font-size: 12px; color: var(--muted); text-decoration: none;
  border: 1px solid var(--border);
}
.hw-card .att:hover { color: var(--tuddy-blue); border-color: var(--tuddy-blue); }
.hw-card.no-homework .text { color: var(--muted); font-style: italic; }

/* Баннер Tuddy */
.tuddy-banner {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding: 8px 12px; border-radius: 10px;
  background: linear-gradient(135deg, #fff7e0 0%, #ffe9b3 100%);
  color: #6a4a00; font-size: 12px; font-weight: 500;
  text-decoration: none; border: 1px solid #f0d78f;
}
:root[data-scheme="dark"] .tuddy-banner,
:root[data-scheme="space_gray"] .tuddy-banner,
:root[data-scheme="vkcom_dark"] .tuddy-banner {
  background: linear-gradient(135deg, #3d3a26 0%, #4a4020 100%);
  color: #ffdc8a; border-color: #5a4a20;
}
.tuddy-banner img { width: 24px; height: 24px; border-radius: 6px; }
.tuddy-banner .arrow { margin-left: auto; opacity: 0.6; font-size: 16px; }

/* Пусто */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty img { width: 120px; height: 120px; opacity: 0.85; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }

/* Спиннер */
.spinner {
  display: block; margin: 60px auto; width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Ошибка */
.error {
  padding: 14px 16px; background: #ffe6e2; color: #a02a1a;
  border-radius: 10px; margin: 20px 0;
}
:root[data-scheme="dark"] .error,
:root[data-scheme="space_gray"] .error,
:root[data-scheme="vkcom_dark"] .error {
  background: #3a1e18; color: #ff9080;
}

/* Модалка ДЗ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.15s;
}
.modal {
  background: var(--card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto;
  padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: slideUp 0.2s;
}
.modal .close {
  float: right; border: none; background: transparent; color: var(--muted);
  font-size: 26px; cursor: pointer; line-height: 1; padding: 0;
}
.modal .subject {
  font-size: 12px; font-weight: 700; color: var(--accent-strong);
  text-transform: uppercase;
}
.modal h2 { margin: 4px 0 12px; font-size: 20px; }
.modal .due { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.modal .text { white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.5; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Реклама Tuddy на пустом экране */
.tuddy-promo-big {
  background: linear-gradient(135deg, #fff7e0 0%, #ffe9b3 100%);
  border-radius: 16px; padding: 20px; text-align: center;
  margin-top: 20px; border: 1px solid #f0d78f;
}
:root[data-scheme="dark"] .tuddy-promo-big,
:root[data-scheme="space_gray"] .tuddy-promo-big,
:root[data-scheme="vkcom_dark"] .tuddy-promo-big {
  background: linear-gradient(135deg, #3d3a26 0%, #4a4020 100%);
  border-color: #5a4a20;
}
.tuddy-promo-big img { width: 64px; height: 64px; border-radius: 14px; margin-bottom: 8px; }
.tuddy-promo-big h3 { margin: 6px 0 4px; color: var(--text); font-size: 17px; }
.tuddy-promo-big p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.tuddy-promo-big a {
  display: inline-block; background: var(--accent); color: #1a1300;
  padding: 10px 20px; border-radius: 10px; font-weight: 700;
  font-size: 14px; text-decoration: none;
}
