/* Дневник класса — спокойный минималистичный стиль: светлые поверхности, мягкие серые, приглушённые акценты.
   Раскладка: шапка с приветствием → содержимое вкладки карточками → нижняя панель из трёх вкладок. */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --fill: #eeeeeb;
  --line: #e4e4e0;
  --ink: #2c2c2a;
  --ink-2: #77776f;
  --ink-3: #a8a8a1;
  --primary: #4a4a46;
  --primary-ink: #ffffff;
  --sage: #8aa592;
  --sand: #c9ac78;
  --rose: #c68e88;
  --sand-tint: #f3ede1;
  --sage-tint: #e9f0eb;
  --shadow: 0 1px 2px rgba(40, 40, 30, .04);
  --r-card: 18px;
  --r-ctl: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514; --surface: #1f1f1d; --fill: #2a2a27; --line: #30302d; --ink: #ecece8; --ink-2: #9d9d96;
    --ink-3: #6e6e68; --primary: #e6e6e1; --primary-ink: #1c1c1b; --sage: #93b19c; --sand: #cfb27f; --rose: #cf9690;
    --sand-tint: #2e2a22; --sage-tint: #222a24; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151514; --surface: #1f1f1d; --fill: #2a2a27; --line: #30302d; --ink: #ecece8; --ink-2: #9d9d96;
  --ink-3: #6e6e68; --primary: #e6e6e1; --primary-ink: #1c1c1b; --sage: #93b19c; --sand: #cfb27f; --rose: #cf9690;
  --sand-tint: #2e2a22; --sage-tint: #222a24; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--font); }
body { min-height: 100vh; overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--fill); border: 1px solid transparent;
  border-radius: var(--r-ctl); padding: 12px 14px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink-3); background: var(--surface); }
textarea { resize: vertical; min-height: 96px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink-3); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
svg.i.s { width: 18px; height: 18px; }

#app { max-width: 560px; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.view { padding: 0 16px; display: grid; gap: 10px; }

/* ---------- шапка ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 16px 14px; }
.hello { min-width: 0; text-align: left; display: grid; gap: 2px; }
.hello h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.hello span { color: var(--ink-2); font-size: 14px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 12.5px; padding: 6px 11px; border-radius: 999px; background: var(--surface); color: var(--ink-2); white-space: nowrap; box-shadow: var(--shadow); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.card p { margin: 0; color: var(--ink-2); font-size: 14px; }
.label { font-size: 13px; color: var(--ink-2); margin: 12px 4px 0; }
.muted { color: var(--ink-2); font-size: 13px; }

/* ---------- дни недели ---------- */
.week-head { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.week-head b { font-size: 15px; font-weight: 600; text-transform: capitalize; }
.arrows { display: flex; gap: 6px; }
.round { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--ink-2); box-shadow: var(--shadow); }
.days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.day { display: grid; justify-items: center; gap: 1px; padding: 8px 0 7px; border-radius: var(--r-ctl); background: var(--surface); box-shadow: var(--shadow); }
.day .wd { font-size: 12px; color: var(--ink-3); }
.day .dn { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day .dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; margin-top: 2px; }
.day .dot.has { background: var(--ink-3); }
.day .dot.miss { background: var(--sand); }
.day.today .wd { color: var(--ink); }
.day.sel { background: var(--primary); }
.day.sel .wd, .day.sel .dn { color: var(--primary-ink); }
.day.sel .dot.has, .day.sel .dot.miss { background: var(--primary-ink); }
.day-sum { font-size: 13px; color: var(--ink-2); margin: 4px 4px 0; }

/* ---------- уроки ---------- */
.lesson { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-card); padding: 14px 14px 14px 16px; box-shadow: var(--shadow); }
.lesson .num { color: var(--ink-3); font-size: 14px; font-weight: 600; line-height: 21px; font-variant-numeric: tabular-nums; }
.lesson .subj { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.lesson .hw { color: var(--ink-2); font-size: 14px; margin-top: 2px; white-space: pre-line; word-break: break-word; }
.lesson .hw.none { color: var(--ink-3); }
.lesson .side { color: var(--ink-3); line-height: 0; padding-top: 1px; }
.lesson.done .hw { text-decoration: line-through; color: var(--ink-3); }
.lesson.done .subj svg { color: var(--sage); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 6px 11px; border-radius: 999px; background: var(--fill); color: var(--ink-2); }
.chip.warn { background: var(--sand-tint); color: var(--ink); margin-top: 8px; }
.chip.ok { background: var(--sage-tint); color: var(--ink); }
button.chip:hover { color: var(--ink); }
.add-row { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 13px; border-radius: var(--r-card);
  border: 1.5px dashed var(--line); color: var(--ink-2); font-size: 14px; }

/* ---------- задачи ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { border-radius: var(--r-card); padding: 14px 16px; background: var(--surface); box-shadow: var(--shadow); display: grid; gap: 2px; }
.tile.dark { background: var(--primary); color: var(--primary-ink); }
.tile small { font-size: 13px; opacity: .75; }
.tile b { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 10px 4px 0; }
.group-title i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.task { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-items: start; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-card); padding: 14px 16px; box-shadow: var(--shadow); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--ink-3); display: grid; place-items: center; color: transparent; }
.check svg { width: 14px; height: 14px; }
.task.done .check { background: var(--sage); border-color: var(--sage); color: #fff; }
.task.done .t-text { text-decoration: line-through; color: var(--ink-3); }
.t-head { display: flex; justify-content: space-between; gap: 8px; }
.t-subj { font-weight: 600; }
.t-due { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.t-text { color: var(--ink-2); font-size: 14px; margin-top: 2px; white-space: pre-line; word-break: break-word; }

/* ---------- списки настроек ---------- */
.list { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 15px 16px; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row .t { display: grid; gap: 1px; min-width: 0; }
.row .t small { color: var(--ink-2); font-size: 13px; }
.row .end { color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.row input[type="time"] { width: auto; padding: 8px 10px; }
.plan-btn { padding: 8px 14px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.switch { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: var(--fill); border-radius: 999px; position: relative; padding: 0; border: 0; flex: 0 0 auto; transition: background .2s; }
.switch::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.switch:checked { background: var(--sage); }
.switch:checked::after { left: 21px; }

/* ---------- кнопки и поля ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 16px; border-radius: var(--r-ctl);
  background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.ghost { background: var(--fill); color: var(--ink); }
.btn.text { background: none; color: var(--ink-2); font-weight: 500; padding: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btns { display: grid; gap: 8px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--ink-2); padding-left: 4px; }
.form { display: grid; gap: 12px; }
.notice { display: grid; gap: 10px; background: var(--sand-tint); border-radius: var(--r-ctl); padding: 12px 14px; font-size: 14px; }

/* ---------- расписание ---------- */
.seg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; background: var(--fill); padding: 4px; border-radius: var(--r-ctl); }
.seg button { padding: 8px 0; border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.slot { display: grid; grid-template-columns: 22px minmax(0, 1fr) 84px 30px; gap: 6px; align-items: center; }
.slot .n { color: var(--ink-3); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot select { padding: 12px 6px; font-size: 13px; }
.slot .rm { color: var(--ink-3); display: grid; place-items: center; height: 40px; }

/* ---------- шторка ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 20, 18, .28); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 90vh; overflow-y: auto; max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
#sheetBody { display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.sheet .meta { color: var(--ink-2); font-size: 14px; margin-top: -10px; }
.sheet .task-body { white-space: pre-line; font-size: 16px; word-break: break-word; background: var(--fill); border-radius: var(--r-ctl); padding: 14px; }
.photos { display: flex; gap: 8px; overflow-x: auto; }
.photos img { height: 160px; min-width: 120px; border-radius: 12px; background: var(--fill); object-fit: cover; cursor: zoom-in; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.thumbs img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--fill); }
.thumbs span { font-size: 13px; color: var(--ink-3); }
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(15, 15, 14, .92); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.solution { background: var(--fill); border-radius: var(--r-ctl); padding: 14px; font-size: 15px; word-break: break-word; }
.solution p { margin: 0 0 8px; }
.solution .answer { font-weight: 650; }
.solution .note { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }

/* ---------- нижняя панель ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.tabs button { display: grid; justify-items: center; gap: 2px; padding: 6px 0 2px; font-size: 11px; color: var(--ink-3); }
.tabs button.active { color: var(--ink); }

/* ---------- вход по ключу ---------- */
.lock { min-height: calc(100vh - 40px); display: grid; align-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; }
.lock .mark { width: 64px; height: 64px; border-radius: 20px; background: var(--surface); display: grid; place-items: center; box-shadow: var(--shadow); color: var(--ink-2); }
.lock .mark svg { width: 28px; height: 28px; }
.lock h1 { margin: 6px 0 0; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.lock p { margin: 0; color: var(--ink-2); max-width: 30ch; }
.lock form { width: 100%; max-width: 320px; display: grid; gap: 10px; margin-top: 8px; }
.lock input.name-input { letter-spacing: normal; font-size: 18px; }
.lock input { text-align: center; font-size: 20px; letter-spacing: .25em; padding: 14px; background: var(--surface); box-shadow: var(--shadow); }
.lock .err { color: var(--rose); font-size: 14px; min-height: 20px; }

/* ---------- прочее ---------- */
.empty { text-align: center; padding: 36px 20px; color: var(--ink-2); display: grid; gap: 6px; justify-items: center; }
.empty .mark { width: 56px; height: 56px; border-radius: 18px; background: var(--surface); display: grid; place-items: center; color: var(--ink-3); box-shadow: var(--shadow); margin-bottom: 6px; }
.empty h3 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; }
.empty p { margin: 0; max-width: 34ch; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--primary); color: var(--primary-ink); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw; }
.loader { display: flex; gap: 6px; justify-content: center; padding: 60px 0; }
.loader span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: b 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; } .loader span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
