/* Material 3 (dark baseline) + Nunito */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('fonts/nunito-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('fonts/nunito-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #141218;
  --surface: #141218;
  --s1: #1d1b20;
  --s2: #211f26;
  --s3: #2b2930;
  --s4: #36343b;
  --on-surface: #e6e0e9;
  --on-surface-var: #cac4d0;
  --outline: #938f99;
  --outline-var: #49454f;
  --primary: #d0bcff;
  --on-primary: #381e72;
  --primary-container: #4f378b;
  --on-primary-container: #eaddff;
  --secondary: #ccc2dc;
  --secondary-container: #4a4458;
  --on-secondary-container: #e8def8;
  --tertiary: #efb8c8;
  --tertiary-container: #633b48;
  --on-tertiary-container: #ffd8e4;
  --error: #f2b8b5;
  --state: rgba(230, 224, 233, .08);
  --state-2: rgba(230, 224, 233, .12);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--on-surface);
  font-family: Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: .1px;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px 8px;
}

/* ---------- top app bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-height: 64px;
  padding-bottom: 8px;
}

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

.logo {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--on-primary-container);
  background: var(--primary-container);
}

.titles { min-width: 0; }

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .4px;
  color: var(--on-surface-var);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.actions { order: 2; display: flex; gap: 2px; align-items: center; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-var);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--state); color: var(--on-surface); }
.icon-btn:active { background: var(--state-2); }
.icon-btn svg { display: block; }
#btn-refresh.spin svg { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- segmented buttons ---------- */
.segbar {
  order: 3;
  flex: 1 1 100%;
  display: flex;
  width: fit-content;
  max-width: 100%;
  border-radius: 20px;
  border: 1px solid var(--outline);
  overflow: hidden;
}

.seg {
  border: 0;
  border-right: 1px solid var(--outline);
  background: transparent;
  color: var(--on-surface);
  font: 600 14px/20px Nunito, inherit;
  letter-spacing: .1px;
  padding: 9px 18px;
  flex: 0 0 auto;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
.seg:last-child { border-right: 0; }
.seg:hover { background: var(--state); }
.seg[aria-selected="true"] {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

/* ---------- notice ---------- */
.notice {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 18px;
  background: var(--s3);
  color: var(--on-surface-var);
  border-left: 3px solid var(--tertiary);
}
.notice.err { border-left-color: var(--error); color: var(--error); }

/* ---------- hero: filled tonal card ---------- */
.hero {
  margin: 16px 0 0;
  border-radius: 24px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  padding: 20px 20px 18px;
  animation: rise .35s cubic-bezier(.2, .7, .3, 1) both;
}
.hero .kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: rgba(234, 221, 255, .82);
}
.hero .kicker .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s infinite;
}
.hero.is-next .kicker .dot { background: rgba(234, 221, 255, .6); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(208, 188, 255, .5); }
  70% { box-shadow: 0 0 0 8px rgba(208, 188, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(208, 188, 255, 0); }
}

.hero h2 {
  margin: 8px 0 0;
  font-size: clamp(20px, 3.2vw, 26px);
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--on-primary-container);
}
.hero .hmeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.hero .chip {
  background: rgba(234, 221, 255, .12);
  border-color: rgba(234, 221, 255, .26);
  color: var(--on-primary-container);
}
.hero .chip.link:hover { background: rgba(234, 221, 255, .22); border-color: rgba(234, 221, 255, .4); color: #fff; }

.hero .hrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .4px;
  color: rgba(234, 221, 255, .78);
}
.hero .left { font-variant-numeric: tabular-nums; }
.hero .bar {
  margin-top: 10px;
  height: 4px;
  border-radius: 2px;
  background: rgba(234, 221, 255, .22);
  overflow: hidden;
}
.hero .bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .6s ease;
}

/* ---------- day cards ---------- */
.days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.day {
  background: var(--s2);
  border-radius: 16px;
  padding: 8px 8px 4px;
  animation: rise .4s cubic-bezier(.2, .7, .3, 1) both;
}
.day.today {
  outline: 1px solid var(--primary);
  outline-offset: 0;
  background: var(--s2);
}
.day.past { opacity: .5; }
.day.past:hover { opacity: .85; }
.day.free { opacity: .78; }

.day > header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--outline-var);
  margin-bottom: 4px;
}
.day > header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
  letter-spacing: .1px;
  text-transform: capitalize;
}
.day > header .date {
  color: var(--on-surface-var);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .1px;
  font-variant-numeric: tabular-nums;
}
.day > header .count {
  margin-left: auto;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .4px;
  color: var(--on-surface-var);
  font-variant-numeric: tabular-nums;
}
.day > header .today-tag {
  font-size: 10px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--on-primary);
  background: var(--primary);
  border-radius: 8px;
  padding: 0 8px;
}

.lessons { list-style: none; margin: 0; padding: 0; }

.lesson {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: start;
  padding: 10px 8px;
  border-radius: 12px;
  transition: background .2s;
}
.lesson + .lesson { margin-top: 2px; }
.lesson:hover { background: var(--state); }

.lesson .num {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 1px;
}
.lesson .num b {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--s4);
  color: var(--on-surface);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  letter-spacing: 0;
}
.lesson .num small {
  font-size: 9px;
  line-height: 12px;
  letter-spacing: .2px;
  color: var(--on-surface-var);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.lesson .subject {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: .1px;
  overflow-wrap: anywhere;
  padding-top: 6px;
}
.lesson .meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .1px;
  color: var(--on-surface-var);
}
.lesson .time {
  grid-column: 3;
  grid-row: 1;
  font-size: 11px;
  line-height: 16px;
  letter-spacing: .2px;
  color: var(--on-surface-var);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--outline-var);
  background: transparent;
  color: var(--on-surface-var);
  font-family: inherit;
  font-size: 11.5px;
  line-height: 16px;
  letter-spacing: 0;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: background .2s, border-color .2s, color .2s;
}
.chip.link { cursor: pointer; }
.chip.link:hover { background: var(--state); border-color: var(--outline); color: var(--on-surface); }
.chip.alt {
  background: var(--tertiary-container);
  border-color: transparent;
  color: var(--on-tertiary-container);
}

/* current pair */
.lesson.now {
  background: var(--secondary-container);
}
.lesson.now .subject,
.lesson.now .meta,
.lesson.now .time,
.lesson.now .num small { color: var(--on-secondary-container); }
.lesson.now .num b { background: var(--secondary); color: var(--on-secondary-container); }
.lesson.now .chip {
  border-color: rgba(232, 222, 248, .28);
  color: var(--on-secondary-container);
}
.lesson.now .subject::after {
  content: "сейчас";
  margin-left: 8px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--secondary);
  vertical-align: middle;
}

/* shift change divider */
.shift-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
}
.shift-row .rule {
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--outline-var) 0 6px, transparent 6px 12px);
}
.shift-row .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.empty-day {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 18px;
  padding: 16px 10px 18px;
}

/* ---------- footer ---------- */
.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 18px 26px;
  color: var(--on-surface-var);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: .4px;
  opacity: .8;
}
.foot a { color: inherit; }

/* ---------- skeleton ---------- */
.skeleton {
  height: 190px;
  background:
    linear-gradient(100deg, transparent 20%, rgba(230, 224, 233, .06) 40%, transparent 60%) var(--s2);
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -220% 0; } }

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

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; }
.sheet[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  position: relative;
  margin: auto;
  width: min(1000px, 92vw);
  max-height: min(86dvh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--s1);
  border-radius: 28px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .9);
  animation: pop .24s cubic-bezier(.2, .8, .3, 1) both;
  overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.sheet-handle {
  width: 32px; height: 4px;
  border-radius: 2px;
  background: var(--outline-var);
  margin: 10px auto 0;
  flex: none;
}

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 8px 24px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: 0;
  flex: 1;
}

.picker-tabs {
  flex: 0 0 auto;
  display: flex;
  align-self: flex-start;
  margin: 0 20px 10px;
  border: 1px solid var(--outline);
  border-radius: 20px;
  overflow: hidden;
}
.picker-tabs .seg { border-right: 1px solid var(--outline); }
.picker-tabs .seg:last-child { border-right: 0; }

.search {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 20px 10px;
  padding: 0 18px;
  height: 56px;
  border-radius: 28px;
  background: var(--s4);
  color: var(--on-surface-var);
}
.search:focus-within { background: var(--s4); outline: 1px solid var(--outline); }
.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--on-surface);
  font: 400 16px/24px Nunito, inherit;
  letter-spacing: .2px;
  min-width: 0;
}
.search input::-webkit-search-cancel-button { filter: invert(.65); }

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px 8px 16px;
  overscroll-behavior: contain;
}

.hint {
  flex: 0 0 auto;
  margin: 0 24px 8px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: .3px;
}

.opt {
  display: flex;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--on-surface);
  font: 400 15px/22px Nunito, inherit;
  letter-spacing: .1px;
  text-align: left;
  padding: 11px 10px 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}
.opt:hover { background: var(--state); }
.opt[aria-selected="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.opt .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .star {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  color: var(--on-surface-var);
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  transition: color .2s, background .2s;
}
.opt .star:hover { background: var(--state); color: var(--on-surface); }
.opt .star.on { color: var(--primary); }

.sheet-group {
  padding: 14px 16px 6px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--on-surface-var);
}

.bells { margin: 0 8px 6px; }

.bell-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--outline-var);
}
.bell-row:last-child { border-bottom: 0; }
.bell-row .n { color: var(--on-surface-var); font-size: 12px; line-height: 16px; letter-spacing: .4px; }
.bell-row .t { font-size: 15px; line-height: 22px; font-variant-numeric: tabular-nums; }

.btn {
  border: 0;
  font: 600 14px/20px Nunito, inherit;
  letter-spacing: .1px;
  height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  cursor: pointer;
  transition: filter .2s, background .2s;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--outline); }

@media (min-width: 900px) {
  .segbar { order: 2; flex: 0 0 auto; }
  .actions { order: 3; }
  .topbar-in { flex-wrap: nowrap; }
}

/* wide picker: two columns, like Google's list dialogs */
#sheet-settings .sheet-panel { width: min(640px, 92vw); }

@media (min-width: 820px) {
  #picker-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    align-content: start;
  }
  #picker-list .sheet-group,
  #picker-list .empty-day { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .seg { flex: 1 1 auto; }
  .chip { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 9px; }
  .chip.link { touch-action: manipulation; }
  .sheet-panel {
    margin: auto 0 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: 28px 28px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet { align-items: flex-end; }
  main { padding: 10px 12px 4px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .day { border-radius: 16px; }
  .lesson { padding: 10px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
