:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7280;
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --primary-soft: #eef1fe;
  --border: #e3e7f0;
  --danger: #e5484d;
  --ok: #2f9e6e;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(29, 36, 51, .07);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .who { text-align: right; line-height: 1.25; }
.userbox .who .name { font-weight: 600; font-size: 14px; }
.userbox .who .meta { font-size: 12px; color: var(--muted); }

main.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

h1 { font-size: 24px; margin-bottom: 4px; }
h2 { font-size: 18px; }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* --- Формы --- */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 5px; color: var(--text);
}

input[type="text"], input[type="password"], input[type="date"],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn.secondary:hover { background: #dfe6fd; }
.btn.danger { background: #fdecec; color: var(--danger); }
.btn.danger:hover { background: #fbdcdc; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.error-msg {
  background: #fdecec;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

.success-msg {
  background: #e7f6ee;
  color: var(--ok);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

/* --- Вход / регистрация --- */
.auth-wrap { max-width: 440px; margin: 40px auto 0; }
.auth-tabs {
  display: flex;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}
.auth-tabs button {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-tabs button.active { background: var(--primary); color: #fff; }
.auth-hint { font-size: 13px; color: var(--muted); margin-top: 14px; text-align: center; }

.chips-input { display: flex; flex-direction: column; gap: 8px; }
.chips-box {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 42px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.chips-box:has(input:focus) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 8px; padding: 4px 8px; font-size: 13px; font-weight: 600;
}
.chip button {
  border: none; background: none; color: var(--primary);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}
.chips-box input {
  flex: 1; min-width: 120px; border: none; outline: none; padding: 6px; font-size: 14px;
}

/* --- Календарь --- */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.cal-title { font-size: 20px; font-weight: 700; min-width: 190px; text-align: center; }
.cal-nav { display: flex; gap: 8px; align-items: center; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar .dow {
  text-align: center; font-size: 12px; font-weight: 700;
  color: var(--muted); padding: 6px 0; text-transform: uppercase;
}
.cal-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 86px;
  padding: 6px 8px;
  font-size: 13px;
  position: relative;
  cursor: default;
}
.cal-day.other { opacity: .45; background: transparent; }
.cal-day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cal-day.clickable { cursor: pointer; transition: border .15s, transform .1s; }
.cal-day.clickable:hover { border-color: var(--primary); }
.cal-day .dnum { font-weight: 600; }
.cal-lesson {
  margin-top: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* --- Урок --- */
.lesson-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.badge {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}
.topic-line { font-size: 20px; font-weight: 700; margin: 8px 0 4px; }

.block-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 14px;
}
.block-kind-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; border-radius: 8px;
  padding: 3px 10px; margin-bottom: 8px;
}
.kt-text   { background: #e7f6ee; color: #2f9e6e; }
.kt-video  { background: #fdecec; color: #d64545; }
.kt-link   { background: #e8f1fd; color: #2b6cb0; }
.kt-file   { background: #fdf3e0; color: #b7791f; }
.kt-homework { background: #f3e8fd; color: #805ad5; }
.kt-other  { background: #eef1f6; color: #55607a; }

.block-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.block-content { font-size: 14px; white-space: pre-wrap; line-height: 1.55; }
.block-content a { color: var(--primary); word-break: break-all; }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; text-decoration: none; color: var(--text);
}
.file-item:hover { border-color: var(--primary); color: var(--primary); }
.file-item .fsize { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.video-embed { position: relative; padding-top: 56.25%; margin-top: 10px; border-radius: 10px; overflow: hidden; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* --- Редактор блоков --- */
.block-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  background: #fbfcff;
}
.block-editor .be-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.block-editor .be-head select { width: auto; flex: 0 0 auto; }
.block-editor .be-head .spacer { flex: 1; }
.be-order { display: flex; gap: 4px; }
.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  width: 30px; height: 30px; cursor: pointer; font-size: 13px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.del:hover { border-color: var(--danger); color: var(--danger); }

.empty-note {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 28px 12px;
}

.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; margin-top: 8px; background: var(--card);
  text-decoration: none; color: var(--text);
}
.list-item:hover { border-color: var(--primary); }
.list-item .li-main { font-weight: 600; font-size: 14px; }
.list-item .li-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.day-lessons h2 { margin: 18px 0 6px; }

@media (max-width: 640px) {
  .cal-day { min-height: 64px; padding: 4px 5px; }
  .cal-lesson { font-size: 10px; padding: 2px 4px; }
  header.topbar { padding: 0 12px; }
}
