/* Mobile-first: расписание Академии Наяновой */

*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root{
  color-scheme:dark;
  --bg:#0c1222;
  --surface:#161f33;
  --surface2:#1c2640;
  --border:#253354;
  --text:#e2e8f0;
  --text2:#94a3b8;
  --text3:#64748b;
  --accent:#3b82f6;
  --accent2:#2563eb;
  --ok:#22c55e;
  --err:#ef4444;
  --radius:.75rem;
}

[data-theme="light"]{
  color-scheme:light;
  --bg:#f1f5f9;
  --surface:#ffffff;
  --surface2:#f8fafc;
  --border:#e2e8f0;
  --text:#1e293b;
  --text2:#475569;
  --text3:#94a3b8;
  --accent:#2563eb;
  --accent2:#1d4ed8;
  --ok:#16a34a;
  --err:#dc2626;
}

/* Светлая тема: подсветка текущего урока (в тёмной — зелёный на тёмном) */
[data-theme="light"] .schedule-table .row-now td{
  background:rgba(22,163,74,.1);
}
[data-theme="light"] .lesson-now{
  background:rgba(22,163,74,.12);
}

body{
  min-height:100dvh;
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
}

/* ── Header ── */
.header{
  position:sticky;top:0;z-index:10;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:.75rem 1rem;
  display:flex;align-items:center;justify-content:space-between;
  gap:.5rem;
}
.header h1{font-size:1rem;font-weight:700;white-space:nowrap}

.header-right{display:flex;align-items:center;gap:.5rem}

.theme-btn{
  display:flex;align-items:center;justify-content:center;
  width:2rem;height:2rem;
  border:1px solid var(--border);border-radius:.5rem;
  background:var(--surface2);color:var(--text2);
  font-size:1rem;cursor:pointer;
  transition:all .15s;flex-shrink:0;
}
.theme-btn:hover{color:var(--text);border-color:var(--text3)}
.theme-btn .icon-sun,.theme-btn .icon-moon{display:none}
[data-theme="dark"] .theme-btn .icon-sun{display:inline}
[data-theme="light"] .theme-btn .icon-moon{display:inline}
html:not([data-theme]) .theme-btn .icon-sun{display:inline}

.nav{display:flex;gap:.35rem}
.nav a{
  padding:.35rem .75rem;border-radius:2rem;
  text-decoration:none;font-size:.78rem;font-weight:500;
  color:var(--text2);background:transparent;
  transition:all .15s;white-space:nowrap;
}
.nav a:hover{color:var(--text);background:var(--surface2)}
.nav a.active{color:#fff;background:var(--accent)}

/* ── Android-приложение: иконка в шапке ── */
.android-btn{
  display:flex;align-items:center;justify-content:center;
  width:2rem;height:2rem;
  border:1px solid var(--border);border-radius:.5rem;
  background:var(--surface2);color:var(--text2);
  cursor:pointer;text-decoration:none;
  transition:all .15s;flex-shrink:0;
}
.android-btn:hover{color:var(--text);border-color:var(--text3)}
.android-btn img{width:1.05rem;height:1.05rem;object-fit:contain;display:block}
.android-btn.active{border-color:var(--accent);background:var(--surface)}

/* ── Controls ── */
.controls{
  padding:.75rem 1rem;
  display:flex;flex-direction:column;gap:.65rem;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}

.select-wrap{position:relative}
.select-wrap::after{
  content:'';position:absolute;right:.85rem;top:50%;
  transform:translateY(-50%);
  width:0;height:0;
  border-left:5px solid transparent;border-right:5px solid transparent;
  border-top:5px solid var(--text3);
  pointer-events:none;
}
.select-wrap select{
  width:100%;appearance:none;
  padding:.65rem 2.25rem .65rem .85rem;
  border:1px solid var(--border);border-radius:var(--radius);
  background:var(--bg);color:var(--text);
  font-size:.9rem;
}
.select-wrap select:focus{outline:none;border-color:var(--accent)}

/* Date/time inputs (страница «Аудитории») — стилистика как у select */
.input-wrap input{
  width:100%;appearance:none;
  padding:.65rem .85rem;
  border:1px solid var(--border);border-radius:var(--radius);
  background:var(--bg);color:var(--text);
  font-size:.9rem;font-family:inherit;
}
.input-wrap input:focus{outline:none;border-color:var(--accent)}

/* Week selector — dropdown (на телефоне — на всю ширину) */
.week-select-wrap select{
  width:100%;
}

/* Day tabs — horizontal scroll */
.day-tabs{
  display:flex;gap:.35rem;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
  padding-bottom:.15rem;
}
.day-tabs::-webkit-scrollbar{display:none}

.day-tab{
  flex:0 0 auto;
  padding:.4rem .75rem;
  border:1px solid var(--border);border-radius:2rem;
  background:transparent;color:var(--text2);
  font-size:.78rem;font-weight:500;
  cursor:pointer;transition:all .15s;
  white-space:nowrap;
  min-height:34px;
}
.day-tab:hover{color:var(--text);border-color:var(--text3)}
.day-tab.active{color:#fff;background:var(--accent);border-color:var(--accent)}

/* ── Content ── */
.content{padding:1rem}

.empty-state{
  text-align:center;padding:2.5rem 1.5rem;
  color:var(--text3);font-size:.9rem;
}

/* ── Date header ── */
.date-header{
  font-size:.85rem;font-weight:600;
  color:var(--text2);margin-bottom:.65rem;
}

/* ── Table: hidden by default ── */
.schedule-table{display:none}

/* ── Lesson cards (mobile) ── */
.lessons{display:flex;flex-direction:column;gap:.5rem}

.lesson{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:.7rem .85rem;
  display:grid;
  grid-template-columns:auto 1fr auto auto;
  grid-template-rows:auto auto;
  gap:0 .65rem;
  align-items:start;
  transition:border-color .2s,box-shadow .2s;
}

.lesson-now{
  border-color:var(--ok);
  box-shadow:0 0 0 1px var(--ok),0 2px 12px rgba(34,197,94,.15);
}
.lesson-now .lesson-num{
  background:var(--ok);border-color:var(--ok);color:#fff;
}

.break-now{
  text-align:center;
  font-size:.75rem;font-weight:600;
  color:var(--ok);
  padding:.2rem 0;
  opacity:.8;
}

.day-done{
  text-align:center;
  font-size:.78rem;font-weight:600;
  color:var(--text3);
  padding:.5rem 0;
  opacity:.7;
}

/* ── История изменений ── */
.history-btn{
  margin:0 auto 1rem;
  display:block;
  cursor:pointer;
}
.history-version{
  margin-bottom:1rem;
  padding:.75rem 1rem;
  border-radius:var(--radius);
  background:var(--surface);
  border:1px solid var(--border);
}
.history-head{
  font-weight:600;
  margin-bottom:.5rem;
}
.history-row{
  font-size:.85rem;
  padding:.2rem 0;
  color:var(--text2);
}

/* Таблица изменений */
.history-scroll{overflow-x:auto}
.history-table{
  width:100%;
  border-collapse:collapse;
  font-size:.8rem;
  border:1px solid var(--border);
  background:var(--surface);
}
.history-table th{
  padding:.5rem .6rem;text-align:left;
  font-size:.68rem;font-weight:600;
  color:var(--text3);text-transform:uppercase;letter-spacing:.04em;
  border-bottom:1px solid var(--border);
  white-space:nowrap;
}
.history-table td{
  padding:.45rem .6rem;
  border-bottom:1px solid var(--border);
  color:var(--text2);
}
.history-table tr:last-child td{border-bottom:none}
.history-table .ht-time{white-space:nowrap}
.history-table .ht-change{text-align:center;min-width:3.4rem}
.history-table .ht-room{white-space:nowrap}
.history-table .ht-first{color:var(--text);font-weight:500}
.ht-when{
  display:block;
  margin-top:.15rem;
  color:var(--text3);
  font-size:.68rem;
  white-space:nowrap;
}
.ch-add{color:var(--ok);font-weight:700;font-size:1rem}
.ch-del{color:var(--err);font-weight:700;font-size:1rem}
.ch-room{color:var(--accent);font-weight:700;font-size:1rem}


.lesson-num{
  grid-row:1/3;
  display:flex;align-items:center;justify-content:center;
  width:2rem;height:2rem;
  border-radius:.5rem;
  background:var(--bg);border:1px solid var(--border);
  font-size:.75rem;font-weight:700;color:var(--text3);
  align-self:center;
}

.lesson-subject{
  font-size:.9rem;font-weight:600;
  line-height:1.3;
  grid-column:2;
}
.lesson-subject .group{
  font-weight:400;font-size:.78rem;
  color:var(--accent);
}

.lesson-meta{
  grid-column:2;
  display:flex;flex-wrap:wrap;gap:.35rem .75rem;
  font-size:.78rem;color:var(--text2);
  margin-top:.15rem;
}

.lesson-room{
  grid-column:3;grid-row:1/3;
  align-self:center;
  display:flex;align-items:center;justify-content:center;
  min-width:2.6rem;min-height:2.6rem;
  max-width:7rem;
  padding:.25rem .5rem;
  border-radius:.5rem;
  background:rgba(59,130,246,.1);
  border:1px solid rgba(59,130,246,.25);
  font-size:.9rem;font-weight:700;
  line-height:1.15;
  color:var(--accent);
  white-space:normal;
  overflow-wrap:anywhere;
  text-align:center;
}
.lesson-room.room-long{
  font-size:.72rem;font-weight:600;
}
/* Аудитория изменена администратором (корректировка поверх импорта) */
.lesson-room.room-corrected{
  background:rgba(245,158,11,.12);
  border-color:rgba(245,158,11,.35);
  color:var(--warn,#f59e0b);
}

.lesson-time{
  grid-column:4;grid-row:1/3;
  align-self:center;
  font-size:.75rem;font-weight:500;
  color:var(--text3);
  white-space:nowrap;
  text-align:right;
}

/* ── Desktop: wider cards ── */
@media(min-width:640px){
  .header{padding:.85rem 1.5rem}
  .header h1{font-size:1.15rem}
  .controls{padding:.85rem 1.5rem;flex-direction:row;align-items:center;gap:1rem}
  .select-wrap{min-width:200px;flex:0 0 auto}
  .time-select-wrap{min-width:8.5rem}
  .input-wrap{min-width:9.5rem;flex:0 0 auto}
  .week-select-wrap select{width:auto;min-width:11rem}
  .content{padding:1rem 1.5rem}

  .lesson{
    grid-template-columns:2.5rem 1fr auto auto;
    padding:.75rem 1rem;
  }
  .lesson-num{width:2.25rem;height:2.25rem;font-size:.8rem}
  .lesson-subject{font-size:.95rem}
  .lesson-room{min-width:3rem;min-height:3rem;max-width:8rem;font-size:1rem}
  .lesson-room.room-long{font-size:.8rem}
}

/* ── Desktop: table layout ── */
@media(min-width:900px){
  .lessons{display:none}

  .schedule-table{
    display:table;
    width:100%;border-collapse:collapse;
    background:var(--surface);
    border-radius:var(--radius);
    overflow:hidden;
    box-shadow:0 2px 12px rgba(0,0,0,.15);
  }
  .schedule-table th{
    padding:.65rem 1rem;text-align:left;
    font-size:.7rem;font-weight:600;
    color:var(--text3);text-transform:uppercase;letter-spacing:.04em;
    background:var(--surface);border-bottom:1px solid var(--border);
  }
  .schedule-table td{
    padding:.6rem 1rem;font-size:.85rem;
    border-bottom:1px solid var(--border);
    background:var(--surface);
  }
  .schedule-table tr:last-child td{border-bottom:none}
  .schedule-table tr:hover td{background:var(--surface2)}

  .schedule-table .row-now td{
    background:rgba(34,197,94,.08);
    border-left:3px solid var(--ok);
  }
  .schedule-table .row-break td{
    background:transparent;border:none;padding:0;
  }
  .schedule-table .row-done td{
    background:transparent;border:none;padding:0;
  }

  .schedule-table .col-num{color:var(--text3);width:40px;text-align:center}
  .schedule-table .col-time{color:var(--text2);white-space:nowrap;width:110px}
  .schedule-table .col-subject{font-weight:500}
  .schedule-table .col-extra{color:var(--text2)}
  .schedule-table .col-room{color:var(--text3);width:80px}
  .col-room.room-corrected{color:var(--warn,#f59e0b);font-weight:700}
  .schedule-table .group{color:var(--accent);font-size:.78rem}
}

/* ── Свободные аудитории: сетка плиток ── */
.free-summary{
  font-size:.85rem;
  color:var(--text2);
  margin-bottom:.65rem;
}
.free-summary b{color:var(--ok)}

.free-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(5.5rem,1fr));
  gap:.5rem;
}

.room-tile{
  display:flex;align-items:center;justify-content:center;
  min-height:3.4rem;
  padding:.4rem .3rem;
  border-radius:.6rem;
  border:1px solid var(--border);
  background:var(--surface);
  font-size:.85rem;font-weight:600;
  line-height:1.15;text-align:center;
  overflow-wrap:anywhere;
  cursor:default;
}
.room-tile.room-long{font-size:.7rem;font-weight:500}

.room-free{
  color:var(--ok);
  border-color:rgba(34,197,94,.45);
  background:rgba(34,197,94,.08);
}
.room-busy{
  color:var(--text3);
  background:var(--surface2);
  opacity:.85;
  flex-direction:column;
  justify-content:center;
  gap:.15rem;
  cursor:pointer;
}
.room-busy:hover{border-color:var(--accent)}
.room-tile[data-idx]{cursor:pointer}

.rt-name{
  font-weight:700;
  font-size:.85rem;
  color:var(--text2);
}
.rt-subject{
  font-size:.66rem;font-weight:500;
  color:var(--text2);
  line-height:1.2;
}
.rt-teacher{
  font-size:.66rem;
  color:var(--text3);
}
.rt-class{
  font-size:.66rem;font-weight:600;
  color:var(--accent);
}

/* ── Модальное окно с деталями урока ── */
.modal-overlay{
  position:fixed;inset:0;z-index:20;
  background:rgba(4,8,18,.55);
  display:flex;align-items:center;justify-content:center;
  padding:1rem;
}
.modal-overlay[hidden]{display:none}

.modal{
  position:relative;
  width:100%;max-width:20rem;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:1rem 1.1rem;
  box-shadow:0 8px 30px rgba(0,0,0,.35);
}
.modal-close{
  position:absolute;top:.4rem;right:.4rem;
  width:1.8rem;height:1.8rem;
  border:1px solid var(--border);border-radius:.5rem;
  background:var(--surface2);color:var(--text2);
  font-size:1rem;line-height:1;
  cursor:pointer;transition:all .15s;
}
.modal-close:hover{color:var(--text);border-color:var(--text3)}

.modal-title{
  font-weight:700;font-size:1rem;
  margin-bottom:.15rem;
}
.modal-sub{
  font-size:.75rem;color:var(--text2);
  margin-bottom:.6rem;
}
.modal-list{display:grid}
.m-row{
  display:flex;justify-content:space-between;gap:.6rem;
  padding:.3rem 0;
  border-bottom:1px dashed var(--border);
  font-size:.85rem;
}
.m-row:last-child{border-bottom:none}
.m-k{color:var(--text3);white-space:nowrap}
.m-v{
  color:var(--text);font-weight:500;
  text-align:right;overflow-wrap:anywhere;
}

/* ── Last import indicator ── */
.last-import{
  text-align:center;
  padding:.5rem 1rem;
  color:var(--text3);
  font-size:.8rem;
}

/* -- Footer -- */
.page-footer{padding:1.25rem 1rem;text-align:center;font-size:.78rem;color:var(--text3);border-top:1px solid var(--border)}
.page-footer a{
  color:var(--accent);
  text-decoration:none;
  border-bottom:1px solid transparent;
  transition:color .15s,border-color .15s;
}
.page-footer a:hover{color:var(--accent2);border-bottom-color:var(--accent2)}
.page-footer a:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}

/* ── Лендинг Android-приложения (android.html) ── */
.app-page{max-width:52rem;margin:0 auto;padding:1rem 1rem 0}

.app-hero{text-align:center;padding:1.5rem .5rem .25rem}
.app-icon{
  width:5.5rem;height:5.5rem;
  border-radius:1.25rem;
  box-shadow:0 6px 20px rgba(0,0,0,.3);
}
.app-hero h2{font-size:1.35rem;font-weight:700;margin:.75rem 0 .4rem}
.app-tagline{color:var(--text2);font-size:.95rem;line-height:1.5;max-width:34rem;margin:0 auto .9rem}
.app-meta{display:flex;flex-wrap:wrap;justify-content:center;gap:.4rem;list-style:none;padding:0}
.app-meta li{
  background:var(--surface2);border:1px solid var(--border);border-radius:2rem;
  padding:.3rem .7rem;font-size:.75rem;color:var(--text2);white-space:nowrap;
}

.install-grid{display:grid;gap:1rem;padding:1.25rem 0;margin-top:.5rem}
@media(min-width:860px){
  .install-grid{grid-template-columns:1fr 1fr;align-items:stretch}
}
.install-card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.25rem;display:flex;flex-direction:column;gap:.6rem;
}
.install-card h3{font-size:1.05rem;font-weight:700}
.install-card .card-note{color:var(--text3);font-size:.8rem;margin-top:-.3rem}
.install-card .card-hint{color:var(--text3);font-size:.78rem;line-height:1.5;margin-top:auto}
.install-card.primary{border-color:var(--accent);box-shadow:0 4px 18px rgba(59,130,246,.12)}

.btn-download{
  display:inline-flex;align-items:center;justify-content:center;gap:.5rem;
  text-decoration:none;cursor:pointer;
  padding:.75rem 1.1rem;border-radius:2rem;border:1px solid transparent;
  font-size:.92rem;font-weight:600;font-family:inherit;
  transition:all .15s;white-space:nowrap;
}
.btn-download svg{width:1.1rem;height:1.1rem;flex-shrink:0}
.install-card.primary .btn-download{background:var(--accent);color:#fff}
.install-card.primary .btn-download:hover{background:var(--accent2)}

.store-logo{width:3rem;height:3rem;border-radius:.75rem;object-fit:cover}

.install-steps{margin:.25rem 0 0 1.1rem;display:flex;flex-direction:column;gap:.35rem;font-size:.82rem;line-height:1.5;color:var(--text2)}
.install-steps em{font-style:normal;color:var(--text)}

/* ── Узкие экраны: шапка с Android-иконкой ── */
@media(max-width:380px){
  .header{padding:.6rem .6rem;gap:.35rem}
  .header h1{font-size:.92rem}
  .nav{gap:.2rem}
  .nav a{padding:.35rem .5rem;font-size:.72rem}
  .theme-btn,.android-btn{width:1.85rem;height:1.85rem}
}
