/* ==========================================================================
   RPP PWA — базовые стили
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body.modal-open { overflow: hidden; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--accent-soft); }

.app {
  width: min(100%, 820px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* ------------------------------- Header --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 12px;
  margin: 0 -16px;
  padding-left: 18px;
  padding-right: 18px;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2));
  color: #fff;
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--hero-1) 60%, transparent);
}

.brand-mark svg { width: 24px; height: 24px; display: block; }

.brand-text { min-width: 0; }

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}

.status-pill[data-state="online"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.status-pill[data-state="online"] .status-dot { background: var(--ok); }
.status-pill[data-state="offline"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.status-pill[data-state="offline"] .status-dot { background: var(--warn); }
.status-pill[data-state="syncing"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.status-pill[data-state="syncing"] .status-dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.status-pill[data-state="error"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.status-pill[data-state="error"] .status-dot { background: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 0.35; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.25); } }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------- Main ---------------------------------- */

.main {
  flex: 1;
  padding-top: 18px;
  min-width: 0;
}

.view { animation: viewIn 0.25s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 12px;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.date-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 2px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ------------------------------ Segmented ------------------------------- */

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented button {
  flex: 1 0 auto;
  min-width: max-content;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented button:hover { color: var(--text); }

.segmented button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}

/* --------------------------------- Cards -------------------------------- */

.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  background-image: var(--card-deco);
  background-size: var(--card-deco-size);
  background-repeat: var(--card-deco-repeat);
  box-shadow: var(--shadow);
  padding: 18px;
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.card-note { font-size: 0.72rem; color: var(--faint); }

/* ------------------------------- Hero card ------------------------------ */

.hero-card {
  position: relative;
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  background:
    radial-gradient(120% 160% at 100% 0%, rgba(255, 255, 255, 0.22) 0%, transparent 55%),
    linear-gradient(135deg, var(--hero-1), var(--hero-2));
  box-shadow: 0 22px 50px -26px color-mix(in srgb, var(--hero-1) 75%, transparent);
  overflow: hidden;
  margin-bottom: 14px;
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.9;
}

.hero-label .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dffb2;
  box-shadow: 0 0 0 0 rgba(125, 255, 178, 0.65);
  animation: live 1.8s ease-out infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(125, 255, 178, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(125, 255, 178, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 255, 178, 0); }
}

.hero-badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.hero-timer {
  font-family: var(--font-mono);
  font-size: clamp(1.9rem, 8vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 2px 0 4px;
}

.hero-sub {
  font-size: 0.86rem;
  line-height: 1.4;
  opacity: 0.92;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-progress {
  margin-top: 14px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.hero-progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #fff;
  transition: width 0.6s ease;
}

.hero-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.82;
}

/* ------------------------------- Lessons -------------------------------- */

.lesson-list {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lesson-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.2s ease;
}

.lesson-item:last-child { border-bottom: 0; }

.lesson-item.is-current {
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%);
}

.lesson-item.is-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.lesson-item.is-past { opacity: 0.58; }
.lesson-item.is-empty { opacity: 0.45; }

.lesson-num {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.lesson-item.is-current .lesson-num {
  background: var(--accent);
  color: var(--accent-contrast);
}

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

.lesson-name {
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--muted);
}

.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-chip svg { width: 11px; height: 11px; flex: 0 0 auto; }

.lesson-time {
  flex: 0 0 auto;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.45;
}

.lesson-time .lesson-end { color: var(--faint); font-weight: 600; }

.lesson-item.is-current .lesson-time { color: var(--accent); }

/* -------------------------------- Chips --------------------------------- */

.day-chips {
  display: flex;
  gap: 7px;
  margin: 0 0 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.day-chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  transition: all 0.16s ease;
}

.chip:hover { border-color: var(--line-strong); color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-contrast);
  box-shadow: 0 8px 16px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}

.chip svg { width: 13px; height: 13px; flex: 0 0 auto; }

.chip .chip-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  opacity: 0.7;
}

/* --------------------------------- Bells -------------------------------- */

.bells-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bells-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.bells-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
}

.bells-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.bells-row:last-child { border-bottom: 0; }
.bells-row.is-current { background: var(--accent-soft); }
.bells-row.is-past { opacity: 0.5; }

.bells-row.is-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.bells-num {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.bells-row.is-current .bells-num { background: var(--accent); color: var(--accent-contrast); }

.bells-time {
  flex: 1;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.bells-tag {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.bells-grid { display: grid; gap: 12px; }

@media (min-width: 680px) {
  .bells-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* ------------------------------- Teachers ------------------------------- */

.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box svg {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder { color: var(--faint); }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input.plain { padding-left: 14px; }

.teacher-count {
  margin: 0 2px 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.teacher-list {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.teacher-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: background 0.15s ease;
}

.teacher-row:last-child { border-bottom: 0; }
.teacher-row:hover { background: var(--surface-2); }

.teacher-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.82rem;
}

.teacher-row-main { flex: 1; min-width: 0; }

.teacher-row-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
}

.teacher-row-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.teacher-row .chevron { color: var(--faint); flex: 0 0 auto; }

.teacher-card { padding: 18px; }

.teacher-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.teacher-hero .avatar {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2));
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.teacher-hero h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.3;
}

.teacher-hero p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.field {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.field-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.field-value { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }

@media (max-width: 430px) {
  .field { grid-template-columns: 1fr; gap: 3px; }
}

/* ------------------------------- Settings ------------------------------- */

.settings-group { margin-bottom: 14px; }

.settings-title {
  margin: 0 4px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.settings-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 15px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.setting-row:last-child { border-bottom: 0; }
button.setting-row:hover { background: var(--surface-2); }

.setting-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.setting-icon svg { width: 18px; height: 18px; }

.setting-text { flex: 1; min-width: 0; }

.setting-name { display: block; font-size: 0.88rem; font-weight: 700; line-height: 1.3; }

.setting-desc {
  display: block;
  margin-top: 2px;
  font-size: 0.73rem;
  color: var(--muted);
  line-height: 1.35;
}

.setting-value {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  max-width: 45%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* toggle */

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.2s ease;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* theme grid */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 9px;
  padding: 14px;
}

.theme-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.theme-tile:hover { border-color: var(--line-strong); }
.theme-tile:active { transform: scale(0.97); }

.theme-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.theme-swatch {
  height: 46px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 6px;
  overflow: hidden;
}

.theme-swatch i {
  display: block;
  height: 10px;
  border-radius: 3px;
  flex: 1;
}

.theme-name {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
}

.theme-tile.active .theme-name { color: var(--accent); }

.theme-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 10px;
}

/* sync info */

.sync-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.sync-cell {
  background: var(--surface);
  padding: 13px 15px;
}

.sync-cell .k {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.sync-cell .v {
  margin-top: 4px;
  font-size: 0.84rem;
  font-weight: 700;
}

.code-row {
  display: flex;
  gap: 8px;
  padding: 13px 15px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.code-row:last-child { border-bottom: 0; }
.code-row .input { box-shadow: none; padding: 10px 12px; font-size: 0.82rem; font-family: var(--font-mono); }

.code-row .btn { flex: 0 0 auto; }

.footer-note {
  margin: 22px 4px 0;
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--faint);
  text-align: center;
}

.footer-note a { color: var(--muted); }

/* -------------------------------- Buttons ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  transition: transform 0.13s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--hero-1) 75%, transparent);
}

.btn-ghost { background: transparent; }
.btn-sm { padding: 8px 12px; font-size: 0.76rem; }

.btn svg { width: 16px; height: 16px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

/* --------------------------------- Empty -------------------------------- */

.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

.empty svg { width: 42px; height: 42px; color: var(--faint); opacity: 0.7; }
.empty strong { font-size: 0.92rem; color: var(--text); }
.empty span { font-size: 0.78rem; max-width: 300px; line-height: 1.5; }

/* ------------------------------- Skeleton ------------------------------- */

.skeleton {
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px;
  overflow: hidden;
}

.sk-line {
  height: 13px;
  border-radius: 6px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-line.w85 { width: 85%; }
.sk-line.big { height: 34px; width: 55%; margin: 14px 0; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* -------------------------------- Tabbar -------------------------------- */

.tabbar {
  position: fixed;
  z-index: 45;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 780px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 22px;
  border: 1px solid var(--tabbar-line);
  background: var(--tabbar-bg);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 18px 40px -18px rgba(20, 40, 80, 0.45);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--faint);
  transition: color 0.16s ease, background 0.16s ease;
}

.tab svg { width: 21px; height: 21px; }

.tab-label { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.01em; }

.tab:hover { color: var(--muted); }

.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* -------------------------------- Toasts -------------------------------- */

.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(calc(100% - 32px), 420px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 16px 34px -16px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.24s ease both;
}

.toast.out { animation: toastOut 0.24s ease both; }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* -------------------------------- Offline ------------------------------- */

:root { --offline-h: calc(27px + env(safe-area-inset-top)); }

.offline-banner {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  background: var(--warn);
  color: #1b1300;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateY(-110%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease, visibility 0.2s;
}

.offline-banner.show {
  transform: none;
  opacity: 1;
  visibility: visible;
}

body.is-offline .topbar { top: var(--offline-h); }
body.is-offline .app { padding-top: var(--offline-h); }

/* -------------------------------- Modal --------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 16, 30, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(100%, 640px);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.5);
  animation: sheetIn 0.28s cubic-bezier(0.2, 0.9, 0.25, 1) both;
  padding-bottom: env(safe-area-inset-bottom);
}

@keyframes sheetIn { from { transform: translateY(28px); opacity: 0.6; } to { transform: none; opacity: 1; } }

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 24px; border-bottom: 1px solid var(--line); max-height: 82dvh; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
}

.modal-body {
  overflow-y: auto;
  padding: 4px 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.modal-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1rem;
}

/* ----------------------------- Onboarding ------------------------------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow-y: auto;
  background-color: var(--bg);
  background-image: var(--bg-image);
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

.onboarding-inner {
  width: min(100%, 640px);
  align-self: center;
  animation: viewIn 0.35s ease both;
}

.onboarding-hero {
  text-align: center;
  margin-bottom: 22px;
}

.onboarding-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2));
  color: #fff;
  box-shadow: 0 22px 40px -18px color-mix(in srgb, var(--hero-1) 70%, transparent);
}

.onboarding-logo svg { width: 40px; height: 40px; }

.onboarding h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.onboarding p {
  margin: 7px auto 0;
  max-width: 420px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted);
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

@media (max-width: 400px) { .class-grid { grid-template-columns: repeat(3, 1fr); } }

.class-btn {
  padding: 13px 6px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: all 0.15s ease;
}

.class-btn:hover { border-color: var(--accent); color: var(--accent); }
.class-btn:active { transform: scale(0.95); }
.class-btn.active { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }

.shift-label {
  margin: 14px 2px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.onboarding-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--faint);
  margin-top: 14px;
  text-align: center;
}

.onboarding-hint svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* ------------------------------ Install --------------------------------- */

.install-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: var(--accent-soft);
  margin-bottom: 14px;
}

.install-banner .icon { color: var(--accent); flex: 0 0 auto; }
.install-banner .text { flex: 1; font-size: 0.78rem; line-height: 1.4; }
.install-banner .text b { display: block; font-size: 0.83rem; }

/* ------------------------------ Utilities ------------------------------- */

.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }

@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .topbar { margin-left: -12px; margin-right: -12px; padding-left: 14px; padding-right: 14px; }
  .brand-sub { display: none; }
  .hero-card { padding: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
