:root {
  --ink: #0b3d4a;
  --ink-soft: #1a5563;
  --paper: #f3f7f4;
  --paper-2: #e7f0eb;
  --card: #ffffff;
  --line: #c9d8d2;
  --muted: #5a7370;
  --accent: #0d8a7c;
  --accent-soft: #d4f0eb;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --now: #0b5f6b;
  --now-soft: #e0f4f6;
  --shadow: 0 10px 28px rgba(11, 61, 74, 0.08);
  --radius: 14px;
  --tap: 48px;
  --font: "Manrope", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --content: 440px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 10% -10%, #c8ebe3 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #d7e8f5 0%, transparent 50%),
    linear-gradient(180deg, #eef6f2 0%, var(--paper) 45%, #e8f1ec 100%);
}

.app {
  width: min(var(--content), 100%);
  margin: 0 auto;
  padding: 16px 16px calc(24px + var(--safe-b));
  min-height: 100dvh;
}

.boot,
.msg {
  margin: 48px 0;
  text-align: center;
  color: var(--muted);
  font-weight: 500;
}

.msg.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 16px;
}

.top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.top-bar .brand {
  margin: 0;
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.top-heading {
  min-width: 0;
}

.top-heading .h1 {
  margin: 0;
}

.top-heading .sub,
.top-heading .status-inline {
  margin-top: 6px;
}

/* шапка: не рвать подписи */
.top-actions .btn {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.88rem;
  padding: 0 12px;
  min-height: 44px;
  line-height: 1.2;
}

.home-head {
  margin-bottom: 18px;
}

.home-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
}

.home-title {
  margin: 0;
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  line-height: 1.15;
}

.home-updated {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  flex: 0 1 auto;
  max-width: 100%;
  line-height: 1.3;
}

@media (min-width: 480px) {
  .home-updated {
    text-align: right;
    flex-shrink: 0;
  }
}

.home-school {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.home-section-title {
  margin: 8px 0 12px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.home-block {
  margin-bottom: 20px;
}

.home-block-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  grid-column: 1 / -1;
}

.home-teachers {
  margin-bottom: 12px;
}

.search-field {
  display: block;
  margin: 0 0 14px;
}

.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--line, rgba(11, 61, 74, 0.18));
  border-radius: 12px;
  background: var(--card, #fff);
  color: var(--ink, #0b3d4a);
  font: inherit;
  font-size: 1rem;
}

.search-input:focus {
  outline: 2px solid var(--accent, #0b3d4a);
  outline-offset: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.teacher-list {
  max-height: min(70vh, 560px);
  overflow: auto;
  padding-right: 2px;
}

.entry-canceled .subject {
  text-decoration: line-through;
  opacity: 0.75;
}

.brand {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.h1 {
  margin: 4px 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* параллели на главной: 1–4 в один ряд на узком экране */
.pick-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pick-grid .choice {
  min-height: 56px;
  font-size: 1.05rem;
  padding: 0 4px;
}

.choice {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.choice:active {
  transform: scale(0.98);
}

.choice:hover,
.choice:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice.wide {
  grid-column: 1 / -1;
  font-size: 1rem;
}

/* полный список (учителя, «Прочее»): одна колонка на всю ширину */
.pick-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
  max-width: none;
}

.pick-stack .choice {
  width: 100%;
  min-height: 56px;
  font-size: 1rem;
  padding: 0 12px;
}

.fav-btn.on {
  color: #c27803;
  border-color: #e8c07a;
  background: #fff8eb;
}

.status-inline {
  margin: 6px 0 0;
  color: var(--now);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
}

.fav-section {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.fav-label {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.fav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.fav-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.fav-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.fav-chip-teacher {
  border-style: dashed;
  background: var(--accent-soft);
}

.fav-chip-teacher.active {
  background: var(--ink);
  border-style: solid;
  color: #fff;
}

.consent {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(11, 61, 74, 0.35);
  backdrop-filter: blur(2px);
}

.consent-card {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(11, 61, 74, 0.2);
  margin-bottom: var(--safe-b);
}

.consent-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.consent-text {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.date-block {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.date-block .day-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.date-block .day-date {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin: 0 -2px 8px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-width: 52px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  max-width: 320px;
}

.mode {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.mode.active {
  background: var(--accent-soft);
  border-color: #9ed8cf;
  color: var(--ink);
}

.lessons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lesson {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.lesson.changed {
  border-color: #f0c28a;
  background: linear-gradient(180deg, var(--warn-soft), #fff);
}

.lesson.canceled {
  border-color: #f0b4ae;
  background: var(--danger-soft);
  opacity: 0.92;
}

.lesson.now {
  border-color: var(--now);
  box-shadow: 0 0 0 2px rgba(11, 95, 107, 0.18), var(--shadow);
}

.lesson.now .lesson-num {
  background: var(--now);
  color: #fff;
}

.lesson.now .lesson-num span {
  color: rgba(255, 255, 255, 0.8);
}

.lesson-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--paper-2);
  font-weight: 700;
  min-height: 52px;
}

.lesson-num span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.lesson-body {
  min-width: 0;
}

.lesson-time {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-change {
  background: #ffe4b8;
  color: var(--warn);
}

.badge-cancel {
  background: #ffd4d0;
  color: var(--danger);
}

.entry {
  margin: 0 0 6px;
}

.entry:last-child {
  margin-bottom: 0;
}

.subject {
  margin: 0;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.3;
}

.lesson.canceled .subject {
  text-decoration: line-through;
}

.meta-line {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.week {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.week-day h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
}

.week-day-link {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.week-table-wrap {
  display: none;
}

.footer {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.footer-meta {
  margin-bottom: 4px;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.footer-nav .btn {
  text-decoration: none;
}

.feedback {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.feedback-label {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.feedback-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.feedback-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--accent, #0b3d4a);
  background: var(--card, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.feedback-link:hover,
.feedback-link:focus-visible {
  background: color-mix(in srgb, var(--accent, #0b3d4a) 8%, white);
  border-color: color-mix(in srgb, var(--accent, #0b3d4a) 28%, var(--line));
  outline: none;
}

.feedback-link svg,
.feedback-icon {
  width: 26px;
  height: 26px;
  display: block;
}

.feedback-icon--max {
  width: 28px;
  height: 28px;
}

.alice-badge {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.alice-badge a {
  display: inline-flex;
  line-height: 0;
  opacity: 0.92;
  transition: opacity 0.12s ease;
}

.alice-badge a:hover,
.alice-badge a:focus-visible {
  opacity: 1;
  outline: none;
}

.alice-badge img {
  display: block;
  height: 36px;
  width: auto;
}

.bells {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.bell-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.bell-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.1;
  color: var(--ink);
  background: var(--paper-2);
  border-radius: 10px;
  min-height: 52px;
}

.bell-num span {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: lowercase;
}

.bell-time {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* —— Desktop —— */
@media (min-width: 900px) {
  :root {
    --content: 1080px;
  }

  .app {
    padding: 28px 32px 40px;
  }

  .h1 {
    font-size: 2rem;
  }

  .pick-grid {
    grid-template-columns: repeat(6, 1fr);
    max-width: 720px;
  }

  .pick-stack {
    max-width: none;
    width: 100%;
  }

  .grid-2.pick-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .lessons {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .week-mobile {
    display: none;
  }

  .week-table-wrap {
    display: block;
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow);
  }

  .week-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.88rem;
  }

  .week-table th,
  .week-table td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    vertical-align: top;
  }

  .week-table thead th {
    background: var(--paper-2);
    text-align: center;
    font-weight: 700;
  }

  .wt-corner {
    width: 48px;
  }

  .wt-num {
    text-align: center;
    font-weight: 700;
    background: var(--paper-2);
    width: 48px;
  }

  .wt-day-btn {
    appearance: none;
    border: none;
    background: transparent;
    font: inherit;
    cursor: pointer;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding: 0;
  }

  .wt-day-name {
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.2;
  }

  .wt-day-date {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
  }

  .wt-subj {
    font-weight: 700;
    line-height: 1.25;
  }

  .wt-entry + .wt-entry {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }

  .wt-meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .wt-cancel {
    color: var(--danger);
    font-weight: 700;
    font-size: 0.8rem;
  }

  .wt-cell.changed {
    background: var(--warn-soft);
  }

  .wt-cell.canceled {
    background: var(--danger-soft);
  }

  .wt-empty {
    background: #f7faf8;
  }

  .modes {
    max-width: 280px;
  }

  .consent {
    place-items: center;
  }
}
