/* Приложение «Уроки» (семейный бот). Вариант А: графит и пыльная роза на тёплом тёмно-сером.
   Лаванда = был, пыльно-розовый = не был, песочный = перенос. Своя палитра, тема Telegram выбирает только светлую или тёмную. */
:root {
  --bg: #2a2627; --bg2: #312c2e; --card: #383234; --card2: #423b3d; --line: #4d4547;
  --text: #f2eae8; --muted: #b5aaa8; --faint: #8a7f7e;
  --rose: #c9959c; --rose-strong: #d7a3aa; --rose-ink: #2a2023;
  --lav: #b9acd8; --lav-ink: #231f33;
  --pink: #dba5b2; --pink-ink: #3a2128;
  --sand: #d8c3a0; --sand-ink: #352b1b;
  --weekend: #3a3033;
  --shadow: 0 6px 24px rgba(0, 0, 0, .28);
  --r: 16px;
}
html[data-theme="light"] {
  --bg: #f4eeec; --bg2: #ece4e2; --card: #fffaf8; --card2: #f6eeec; --line: #e2d6d4;
  --text: #2f292b; --muted: #75696a; --faint: #a3999a;
  --rose: #b87b84; --rose-strong: #a96c75; --rose-ink: #ffffff;
  --lav: #a596cc; --lav-ink: #ffffff;
  --pink: #d08e9e; --pink-ink: #ffffff;
  --sand: #c8ab7c; --sand-ink: #ffffff;
  --weekend: #f3e4e4;
  --shadow: 0 6px 20px rgba(80, 50, 55, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 76px; }
#app.no-tabs { padding-bottom: 12px; }
.top { padding: 12px 12px 4px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--bg2); border-radius: 14px; border: 1px solid var(--line); }
.seg button { flex: 1; padding: 9px 4px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 15px; }
.seg button.on { background: var(--rose); color: var(--rose-ink); }
.sync { font-size: 12px; color: var(--muted); text-align: right; padding: 6px 4px 0; min-height: 22px; }
.soon { text-align: center; padding: 36px 18px; }
.soon h2 { font-size: 19px; margin: 0 0 10px; color: var(--text); }
.soon p { color: var(--muted); margin: 0; }
.sync.warn { color: var(--sand); }
main { padding: 4px 12px 12px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line); max-width: 520px; margin: 0 auto; z-index: 5; }
.tabs button { flex: 1; padding: 10px 4px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button.on { background: var(--card2); color: var(--text); box-shadow: inset 0 -2px 0 var(--rose); }

.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ближайший урок */
.hero { background: linear-gradient(140deg, var(--card2), var(--card)); border: 1px solid var(--line); cursor: pointer; }
.hero .label { font-size: 13px; color: var(--rose-strong); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.hero .when { font-size: 26px; font-weight: 750; line-height: 1.15; margin: 6px 0 2px; }
.hero .time { font-size: 20px; font-weight: 600; }
.hero .left { color: var(--muted); margin-top: 4px; }
.hero.empty .when { font-size: 20px; }

/* календарь */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head .m { font-size: 17px; font-weight: 700; }
.nav { width: 40px; height: 40px; border-radius: 12px; background: var(--card2); font-size: 20px; line-height: 40px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.wd { text-align: center; font-size: 12px; color: var(--faint); padding: 2px 0 4px; }
.wd.we { color: var(--rose); }
.day { position: relative; padding: 0; min-width: 0; aspect-ratio: 1 / 1; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.day.we { background: var(--weekend); }
.day.out { visibility: hidden; }
.day.past { color: var(--faint); }
.day.today::after { content: ""; position: absolute; bottom: 5px; width: 16px; height: 3px; border-radius: 2px; background: var(--rose); }
.day .n { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.day.planned .n { box-shadow: inset 0 0 0 2px var(--rose); color: var(--text); font-weight: 700; }
.day.done .n { background: var(--lav); color: var(--lav-ink); font-weight: 700; }
.day.skipped .n { background: var(--pink); color: var(--pink-ink); font-weight: 700; }
.day.moved .n { background: var(--sand); color: var(--sand-ink); font-weight: 700; }
.day.pending .n { box-shadow: inset 0 0 0 2px var(--text); background: transparent; color: var(--text); outline: 2px dashed var(--rose); outline-offset: 2px; }
.day.paid::before { content: ""; position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--lav); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot.planned { box-shadow: inset 0 0 0 2px var(--rose); }
.dot.done { background: var(--lav); }
.dot.skipped { background: var(--pink); }
.dot.moved { background: var(--sand); }
.dot.pending { outline: 2px dashed var(--rose); outline-offset: -1px; }
.dot.paid { width: 7px; height: 7px; background: var(--lav); }

/* список уроков */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); text-align: left; width: 100%; }
.item:first-child { border-top: 0; }
.item .d { flex: 1; min-width: 0; }
.item .d b { display: block; font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill.planned { box-shadow: inset 0 0 0 1.5px var(--rose); color: var(--rose-strong); }
.pill.done { background: var(--lav); color: var(--lav-ink); }
.pill.skipped { background: var(--pink); color: var(--pink-ink); }
.pill.moved { background: var(--sand); color: var(--sand-ink); }
.pill.pending { box-shadow: inset 0 0 0 1.5px var(--muted); color: var(--muted); }
.pill.paid { background: var(--lav); color: var(--lav-ink); }
.pill.unpaid { background: var(--pink); color: var(--pink-ink); }

/* кнопки */
.btn { display: block; width: 100%; padding: 13px 14px; border-radius: 14px; font-weight: 700; font-size: 15px; text-align: center; background: var(--card2); color: var(--text); }
.btn + .btn { margin-top: 8px; }
.btn.main { background: var(--rose); color: var(--rose-ink); }
.btn.lav { background: var(--lav); color: var(--lav-ink); }
.btn.pink { background: var(--pink); color: var(--pink-ink); }
.btn.sand { background: var(--sand); color: var(--sand-ink); }
.btn.line { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }
.btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.btns2 .btn + .btn { margin-top: 0; }
.link { color: var(--rose-strong); font-weight: 600; font-size: 14px; padding: 6px 0; }

/* блоки и деньги */
.big { font-size: 32px; font-weight: 750; letter-spacing: -.3px; }
.facts { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.facts .warn { color: var(--pink); }
.block .t { font-size: 17px; font-weight: 700; }
.block .dots { display: flex; gap: 8px; margin: 12px 0 8px; }
.block .dots i { width: 22px; height: 22px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 2px var(--line); }
.block .dots i.done { background: var(--lav); box-shadow: none; }
.block .dots i.planned { box-shadow: inset 0 0 0 2px var(--rose); }
.block .dots i.moved { box-shadow: inset 0 0 0 2px var(--sand); }
.block .count { font-size: 15px; margin-bottom: 12px; }
.block.closed { opacity: .82; }
.money { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.money:first-of-type { border-top: 0; }
.money .r { font-weight: 700; white-space: nowrap; }
.money .r.minus { color: var(--pink); }
.money .r.plus { color: var(--lav); }

/* настройки */
.stepper { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; background: var(--card2); font-size: 22px; font-weight: 700; }
.stepper .v { min-width: 40px; text-align: center; font-size: 24px; font-weight: 750; }
.field { display: block; margin: 8px 0 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: 16px; }
.field input:focus { outline: 2px solid var(--rose); outline-offset: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* выбор даты: ближайшие дни, суббота и воскресенье выделены */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.chip { flex: none; min-width: 74px; padding: 8px 6px; border-radius: 12px; background: var(--card2); text-align: center; }
.chip small { display: block; font-size: 11px; color: var(--muted); }
.chip b { display: block; font-size: 16px; }
.chip.we { background: var(--weekend); box-shadow: inset 0 0 0 1.5px var(--rose); }
.chip.we small { color: var(--rose-strong); }
.chip.on { background: var(--rose); color: var(--rose-ink); box-shadow: none; }
.chip.on small { color: var(--rose-ink); }
.chip:disabled { opacity: .35; }

/* нижний лист и подтверждение */
#layer .shade { position: fixed; inset: 0; background: rgba(20, 14, 16, .55); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); z-index: 11; max-height: 88vh; overflow-y: auto; box-shadow: 0 -8px 30px rgba(0,0,0,.3); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.sheet .sub { color: var(--muted); margin-bottom: 14px; font-size: 14px; }
.sheet .hint { font-size: 13px; color: var(--muted); margin: -2px 0 10px; }
.confirm { position: fixed; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); max-width: 420px; margin: 0 auto; background: var(--card);
  border-radius: 20px; padding: 18px 16px 14px; z-index: 12; box-shadow: var(--shadow); }
.confirm h3 { margin: 0 0 8px; font-size: 18px; }
.confirm p { margin: 0 0 16px; color: var(--muted); }

.toast { position: fixed; left: 16px; right: 16px; bottom: 84px; max-width: 480px; margin: 0 auto; padding: 12px 14px; border-radius: 14px;
  background: var(--card2); color: var(--text); box-shadow: var(--shadow); z-index: 20; font-size: 14px; opacity: 0; transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease; pointer-events: none; border-left: 4px solid var(--lav); }
.toast.bad { border-left-color: var(--pink); }
.toast.show { opacity: 1; transform: none; }

.notice { text-align: center; padding: 40px 18px; }
.notice h2 { font-size: 20px; margin: 0 0 10px; color: var(--text); }
.notice p { color: var(--muted); }
.pending-bar { font-size: 13px; color: var(--muted); background: var(--bg2); border-radius: 12px; padding: 9px 12px; margin-bottom: 12px; border: 1px dashed var(--line); }
