/* ========== FONTS ========== */
:root{
  --font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* ========== THEME TOKENS ========== */
:root{
  --bg: #0b1020;
  --bg2: #0a0f1c;
  --card: rgba(255,255,255,.06);
  --card2: rgba(255,255,255,.08);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --border: rgba(255,255,255,.10);
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --accent: #7aa2ff;
  --accent2: #7df0d6;
  --danger: #ff6b6b;

  --radius: 18px;
  --radius2: 24px;

  --container: 1120px;
}

:root[data-theme="light"]{
  --bg: #f6f7fb;
  --bg2: #ffffff;
  --card: rgba(20,30,50,.04);
  --card2: rgba(20,30,50,.06);
  --text: rgba(10,16,30,.92);
  --muted: rgba(10,16,30,.62);
  --border: rgba(20,30,50,.12);
  --shadow: 0 16px 45px rgba(10,20,40,.10);
  --accent: #2f63ff;
  --accent2: #13b9a2;
}

/* ========== BASE ========== */
*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 10% -10%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    radial-gradient(1000px 700px at 105% 0%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}

a{ color: inherit; }
h2{
  margin:0;
  font-size: 15px;
  letter-spacing: .2px;
}
.muted{ color: var(--muted); font-size: 12px; }

.container{
  max-width: var(--container);
  margin: 0 auto;
  padding: 18px;
}

.grid{
  display:grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* ========== TOPBAR ========== */
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(12px);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.brand .title{
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2px;
}
.brand .subtitle{
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.right{
  display:flex;
  align-items:center;
  gap: 12px;
}

.clock{
  text-align:right;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.clock .time{
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
}
.clock .date{
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* ========== CARDS ========== */
.card{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card2) 60%, transparent));
  border-radius: var(--radius2);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.info-message{
  white-space: pre-wrap;
  line-height: 1.45;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px dashed color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--card2) 70%, transparent);
}

/* ========== LIST / ROWS ========== */
.list{ display:flex; flex-direction:column; gap:10px; }

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card2) 70%, transparent);
}

.row .name{
  font-weight: 800;
  letter-spacing: .15px;
}

.actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

/* ========== BUTTONS ========== */
.btn{
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card2) 70%, transparent);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .15px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap: 8px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover{
  background: color-mix(in srgb, var(--card2) 95%, transparent);
}
.btn:active{
  transform: translateY(1px);
}

.btn-primary{
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 20%, transparent), transparent),
    color-mix(in srgb, var(--card2) 85%, transparent);
}

.btn-ghost{
  width: 44px;
  height: 40px;
  justify-content:center;
  padding: 0;
}

/* ========== SCHEDULE ========== */
.schedule{ display:flex; flex-direction:column; gap: 12px; }

.day{
  padding: 12px;
  border-radius: var(--radius2);
  border: none;
  background: color-mix(in srgb, var(--card2) 70%, transparent);
}

.day-title{
  font-weight: 900;
  letter-spacing: .25px;
  margin-bottom: 10px;
}

.lesson{
  display:grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.lesson:first-of-type{ border-top:none; }

.lesson .t{
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson .s{
  font-weight: 800;
}
.lesson .meta{
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.skeleton{ color: var(--muted); padding: 12px; }

.footer{ margin-top: 16px; }

.nav{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
}

.nav-link{
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card2) 55%, transparent);
  padding: 8px 10px;
  border-radius: 14px;
  text-decoration:none;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  transition: background .15s ease, transform .08s ease;
}

.nav-link:hover{ background: color-mix(in srgb, var(--card2) 90%, transparent); }
.nav-link:active{ transform: translateY(1px); }

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 50;
}

.modal{
  width: min(560px, 100%);
  border-radius: var(--radius2);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card2) 70%, transparent));
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-head{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  align-items:flex-start;
  margin-bottom: 10px;
}

.modal-title{
  font-weight: 900;
  letter-spacing: .2px;
}

.modal-body{
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--card2) 60%, transparent);
  border-radius: var(--radius);
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.modal {
  width: min(560px, 100%);
  border-radius: var(--radius2);
  border: 1px solid var(--border);
  background: var(--bg2);   /* ← полностью непрозрачный фон */
  box-shadow: var(--shadow);
  padding: 14px;
}
.modal-overlay[hidden] { display: none !important; }


html, body {
  height: 100%;
  min-height: 100dvh;
  overscroll-behavior: none;
}

html {
  background: linear-gradient(0deg, var(--bg), var(--bg2));
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.today-highlight {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}

.today-highlight{
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 4px;
}

#modalCopy {
  display: none !important;
}

/* ===== Mobile nav (burger) ===== */
.nav-toggle{
  display:none;               /* на ПК скрыто */
  font-size: 18px;
}

.nav-menu{
  display:flex;               /* на ПК как было */
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
}

/* На мобильных: бургер видно, меню — выпадающее */
@media (max-width: 980px){
  .nav-toggle{ display:inline-flex; }

  .nav-menu{
    position: absolute;
    top: 64px;                /* ниже topbar */
    left: 18px;
    right: 18px;

    display: grid;
    gap: 10px;
    padding: 12px;

    border: 1px solid var(--border);
    border-radius: var(--radius2);
    background: color-mix(in srgb, var(--bg2) 92%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);

    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
  }

  .nav-menu.is-open{
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-link{
    width: 100%;
    justify-content: center;
    padding: 12px;
    border-radius: 16px;
  }
}

/* ===== Fix burger position ===== */

/* ===== Header: spaced + no overlaps (desktop & mobile) ===== */

/* ПК: заголовок слева, навигация по центру, время справа */
@media (min-width: 981px){
  .topbar{
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 16px;
  }
  .brand{ justify-self: start; }
  .nav{ justify-self: center; }
  .right{ justify-self: end; }
  .nav-toggle{ display: none; }
}

/* Мобилка: 1 строка (☰ + время), 2 строка (заголовок). Меню выпадает и не двигает контент */
@media (max-width: 980px){
  .topbar{
    position: sticky;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    row-gap: 8px;
    column-gap: 10px;
  }

  .nav-toggle{
    display: inline-flex;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .right{
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .brand{
    grid-column: 1 / 4;
    grid-row: 2;
    text-align: center;
  }

  .nav-menu{
    position: absolute;
    left: 18px;
    right: 18px;
    top: calc(100% + 8px);
    z-index: 30;
  }
}

/* ===== Mobile schedule scaling ===== */

@media (max-width: 480px){

  .lesson{
    grid-template-columns: 80px 1fr; /* уже колонка времени */
    gap: 8px;
  }

  .lesson .t{
    font-size: 11px;
  }

  .lesson .s{
    font-size: 13px;
  }

  .lesson .meta{
    font-size: 11px;
  }

  .day{
    padding: 10px;
  }

}

/* ===== Compact schedule columns ===== */

/* ПК */
.lesson{
  grid-template-columns: minmax(90px, 120px) minmax(0, 1fr);
}

.lesson > *{
  min-width: 0; /* критически важно для grid */
}

/* Телефоны */
@media (max-width: 480px){
  .lesson{
    grid-template-columns: 75px minmax(0, 1fr);
    gap: 8px;
  }

  .lesson .t{
    font-size: 11px;
  }

  .lesson .s{
    font-size: 13px;
  }

  .lesson .meta{
    font-size: 11px;
  }
}

/* ===== Slightly smaller mobile schedule ===== */

@media (max-width: 480px){

  .lesson{
    grid-template-columns: 70px minmax(0, 1fr); /* уже время */
    gap: 6px;
    padding: 8px 0;
  }

  .lesson .t{
    font-size: 10.5px;
  }

  .lesson .s{
    font-size: 12.5px;
  }

  .lesson .meta{
    font-size: 10.5px;
  }

  .day{
    padding: 9px;
  }

}

@media (max-width: 480px){
  .schedule{
    font-size: 0.95rem;
  }
}

/* ===== Stop horizontal overflow in schedule ===== */

/* 1) на всякий случай запрещаем горизонтальный скролл страницы */
html, body { overflow-x: hidden; }

/* 2) разрешаем grid-элементам реально сжиматься */
.lesson > * { min-width: 0; }

/* 3) ключ: вторая колонка должна иметь min-width:0, иначе раздувает */
.lesson{
  grid-template-columns: 70px minmax(0, 1fr);
}

/* 4) переносим любые длинные строки (даже без пробелов) */
.lesson .s,
.lesson .meta,
.lesson .t{
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 5) если вдруг где-то вставляется длинная строка — обрезаем вместо расширения */
.lesson .meta{
  overflow: hidden;
}

@media (max-width: 980px){
  .nav-menu{
    max-width: calc(100vw - 36px);
  }
}

/* ===== Move schedule to bottom on mobile ===== */

@media (max-width: 980px){

  .grid{
    display: flex;
    flex-direction: column;
  }

  .grid > section:first-child{
    order: 1; /* Предметы */
  }

  .grid > section:last-child{
    order: 2; /* Расписание */
  }

}
