/* Shared touch-friendly layout for the browser and Telegram WebView. */
[hidden] { display: none !important; }
:root { --tg-top: 0px; --tg-bottom: 0px; }
html { scroll-padding-top: 90px; }
.mobile-nav { display: none; }
.kind-lesson .timeline-content { grid-column: 3 / -1; }
.timeline-content, .task-main, .form-grid > *, .summary-card { min-width: 0; overflow-wrap: anywhere; }
.timeline-content, .task-main { word-break: normal; }
.modal { max-height: min(90dvh, calc(var(--visual-height, 100vh) - 24px)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); }
/* Native fieldsets and date/time controls must be allowed to shrink on phones. */
.modal :is(form, fieldset, label, .modal-body, .telegram-settings, .telegram-heading > div) { min-width: 0; min-inline-size: 0; max-width: 100%; }
.modal :is(legend, p, small, strong, h2, .button, .text-button) { overflow-wrap: anywhere; }
.modal legend { max-width: 100%; white-space: normal; }
.modal :is(input, select, textarea) { min-width: 0; max-width: 100%; box-sizing: border-box; }
.modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Avoid an implicit min-content grid track and iOS native control sizing.
   The inputs keep their native date/time pickers and form validation. */
.settings-modal .native-picker-field { display: flex; flex-direction: column; align-items: stretch; width: 100%; }
.settings-modal .native-picker-field input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  inline-size: 100%;
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
  max-inline-size: 100%;
  box-sizing: border-box;
  margin: 0;
  min-height: 46px;
  padding: 12px;
  font-size: 16px;
}
.telegram-heading { grid-template-columns: 38px minmax(0, 1fr); }
.telegram-connected strong { min-width: 0; overflow-wrap: anywhere; }
.modal-head > div { min-width: 0; }
body:has(dialog[open]) { overflow: hidden; }
.task-class-picker input:focus-visible + span, .schedule-mode input:focus-visible + span { outline: 3px solid var(--purple); outline-offset: 2px; }
.modal-close { flex: 0 0 auto; }
.summary-primary .summary-label, .summary-primary small { color: #eeeaff; }
.in-telegram body { padding-top: var(--tg-top); }
.in-telegram .topbar { top: var(--tg-top); }
.native-shell { --tg-top: max(var(--safe-area-inset-top, 0px), env(safe-area-inset-top, 0px)); --tg-bottom: max(var(--safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px)); }
.native-shell body { padding-top: 0; }
.native-shell .topbar { top: 0; height: calc(60px + var(--tg-top)); padding-top: var(--tg-top); box-sizing: border-box; backdrop-filter: none; }
.native-shell .mobile-nav { backdrop-filter: none; }
.native-update { position: fixed; z-index: 10000; left: 16px; right: 16px; max-width: 440px; margin: auto; bottom: calc(104px + var(--tg-bottom)); padding: 20px; border: 1px solid var(--line, #3b332a); border-radius: 24px; background: var(--surface, #191715); color: var(--ink, #fff); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; box-shadow: 0 12px 32px #0003; }
.native-update strong { grid-column: 1 / -1; font-size: 18px; line-height: 1.3; }
.native-update p { grid-column: 1 / -1; margin: 0 0 4px; color: var(--ink-soft, #aaa); font-size: 13px; line-height: 1.5; }
.native-update .native-update-primary { background: #ffad50; color: #211307; border: 0; border-radius: 14px; padding: 12px; font-size: 13px; font-weight: 700; min-height: 44px; }
.native-update .native-update-dismiss { color: var(--ink-soft, #aaa); background: transparent; border: 0; padding: 12px; font-size: 13px; }
.native-update input { grid-column: 1 / -1; width: 100%; min-width: 0; box-sizing: border-box; }
dialog.modal.change-center { position: fixed; inset: 14px; margin: auto; width: min(620px, calc(100vw - 28px)); max-width: calc(100vw - 28px); height: min(760px, calc(100dvh - 28px - max(var(--tg-top, 0px), env(safe-area-inset-top, 0px)) - max(var(--tg-bottom, 0px), env(safe-area-inset-bottom, 0px)))); max-height: none; padding: 0; border-radius: 26px; box-sizing: border-box; }
.native-shell dialog.modal.change-center { inset: max(14px, var(--tg-top, 0px), env(safe-area-inset-top, 0px)) 14px max(14px, var(--tg-bottom, 0px), env(safe-area-inset-bottom, 0px)); }
.miniapp-entry { display: grid; place-items: center; padding: 24px; min-height: 100dvh; }
.entry-card { width: min(100%, 430px); padding: 32px; }
.entry-card .brand-mark { margin-bottom: 30px; }
.entry-card h1 { line-height: 1.12; }
.entry-card p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.6; }
.entry-link { display: block; text-align: center; text-decoration: none; }
.entry-retry { width: 100%; margin-top: 10px; }
.entry-hint { display: block; margin-top: 12px; color: var(--ink-soft); line-height: 1.5; text-align: center; }
.entry-login-code { display:grid;justify-items:center;gap:10px;margin:18px 0;padding:17px 12px;border:1px solid var(--line);border-radius:18px;background:var(--surface);text-align:center; }
.entry-login-code small { color:var(--ink-soft); }
.entry-login-code strong { font-size:clamp(27px,8vw,38px);letter-spacing:.14em;font-variant-numeric:tabular-nums;user-select:all;color:var(--brand); }

@media (max-width: 680px) {
  html { scroll-padding-top: 80px; overflow-x: clip; }
  body { background: var(--paper); overflow-x: clip; }
  .topbar { height: 60px; padding: 0 16px; backdrop-filter: none; background: var(--paper); }
  .topbar-actions > .button { display: none; }
  .topbar-actions>.change-center-button{display:grid;width:40px;height:40px;border-radius:13px}
  .topbar-actions .group-button { display: inline-flex; padding: 8px 11px; min-height: 40px; font-size: 12px; }
  .shell { width: calc(100% - 24px); padding: 22px 0 calc(100px + max(env(safe-area-inset-bottom), var(--tg-bottom))); }
  .day-header { gap: 16px; margin-bottom: 18px; }
  .week-picker { margin-top: 0; padding: 10px; border-radius: 20px; box-shadow: none; }
  .week-picker-head { margin-bottom: 9px; gap:6px; }
  .week-picker-head>strong{font-size:14px}.month-calendar-button{width:40px;height:40px;border-radius:13px}.month-calendar-dialog{padding:16px}.month-calendar-grid{gap:4px}.month-calendar-day{min-height:61px;padding:6px 4px 4px;border-radius:11px}.month-lesson-strips{gap:1.5px}.month-lesson-strips i{height:2.5px}
  .week-days { gap: 4px; }
  .week-days a { min-height: 56px; border-radius: 13px; }
  .week-days a strong { font-size: 16px; }
  .week-days a span { font-size: 9px; }
  .headman-columns { grid-template-columns: minmax(0, 1fr); }
  .member-request { align-items: flex-start; }
  .important-item, .group-material, .headman-lesson { padding: 13px; }
  h1 { font-size: 32px; line-height: 1.08; }
  h2 { font-size: 23px; }
  .day-subtitle { font-size: 13px; line-height: 1.5; }
  .date-nav { align-self: stretch; justify-content: space-between; box-shadow: none; }
  .date-nav a { min-width: 48px; height: 44px; }
  .date-nav .date-today { flex: 1; max-width: 200px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-card { border-radius: 20px; padding: 15px; min-height: 120px; gap: 8px; box-shadow: none; backdrop-filter: none; }
  .summary-primary { grid-column: 1 / -1; min-height: 140px; }
  .summary-card strong { font-size: 25px; }
  .summary-card p { font-size: 12px; }
  .summary-label { font-size: 9px; letter-spacing: .09em; }
  .summary-card small { font-size: 11px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .panel, .panel-actions, .panel-actions form { min-width: 0; }
  .panel { border-radius: 22px; box-shadow: none; backdrop-filter: none; }
  .timeline-panel, .focus-panel, .tasks-panel { padding: 18px 12px; }
  .panel-head { padding: 0 4px; gap: 16px; margin-bottom: 20px; }
  .panel-actions { flex-wrap: wrap; gap: 6px; }
  .button, .text-button, .mini-button, .session-check, .icon-button, .modal-close, .note-delete { min-height: 44px; }
  .icon-button, .modal-close, .note-delete { min-width: 44px; }
  .timeline-item { grid-template-columns: 43px 25px minmax(0, 1fr); gap: 8px; }
  .timeline::before { left: 63px; }
  .timeline-dot { width: 9px; height: 9px; border-width: 2px; }
  .timeline-marker { width:25px;height:25px;border-width:2px;border-radius:7px;font-size:11px;align-self:start;margin-top:16px; }
  .timeline-time { font-size: 11px; align-self: start; padding-top: 22px; }
  .timeline-content { padding: 13px 12px; margin: 5px 0; border-radius: 14px; }
  .timeline-content h3 { font-size: 15px; line-height: 1.3; }
  .timeline-content p { font-size: 12px; line-height: 1.45; }
  .timeline-controls { grid-column: 3; padding-bottom: 7px; }
  .timeline-controls .session-check { width: 100%; }
  .lesson-notes summary { min-height: 44px; width: 100%; font-size: 12px; flex-wrap: wrap; }
  .note-form textarea, .note-options select { font-size: 16px; max-width: 100%; }
  .note-options select { min-width: 0; width: 100%; min-height: 44px; }
  .note-form-actions { flex-wrap: wrap; }
  .attach-control { min-height: 44px; display: grid; align-content: center; }
  .note-labels { flex-wrap: wrap; }
  .note-card { padding: 9px; }
  .focus-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .focus-meta dd { overflow-wrap: anywhere; }
  .task-row { grid-template-columns: 44px 4px minmax(0, 1fr) 44px; gap: 7px; }
  .task-check { width: 44px; height: 44px; }
  .task-due { display: block; grid-column: 3; grid-row: 2; }
  .task-row > form:last-child { grid-column: 4; grid-row: 1; }
  .task-due span { font-size: 10px; }
  .task-due strong { font-size: 12px; }
  .task-main h3 { line-height: 1.35; }
  .modal { inset-inline: 0; width: 100%; max-width: 100%; margin: auto 0 0; max-height: calc(var(--visual-height, 100dvh) - 12px - var(--tg-top)); border-radius: 24px 24px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom), var(--tg-bottom)); touch-action: pan-y pinch-zoom; overscroll-behavior-x: none; }
  .modal::backdrop { backdrop-filter: none; }
  .modal form, .modal-body { padding: 22px 18px; }
  .modal-body > form, .modal-body details form, .telegram-settings form { padding: 0; }
  .modal-head { gap: 12px; margin-bottom: 22px; }
  .modal input, .modal select, .modal textarea { font-size: 16px; min-width: 0; }
  .modal input[type="radio"], .modal input[type="checkbox"] { min-height: auto; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
  .form-grid [data-study-field] { grid-column: 1 / -1; }
  .task-class-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-class-picker span { min-height: 68px; }
  .task-class-picker b { font-size: 11px; }
  .schedule-mode span { min-height: 44px; display: flex; align-items: center; line-height: 1.4; }
  .telegram-settings { margin: 0 12px 12px; padding: 14px; }
  .modal .notification-toggle { min-height: 56px; gap: 12px; }
  .notification-toggle strong { font-size: 13px; line-height: 1.4; }
  .notification-toggle small { font-size: 12px; line-height: 1.5; }
  .modal .notification-master { padding: 12px; }
  .group-input-row { grid-template-columns: minmax(0, 1fr); }
  .toasts { top: 72px; left: 12px; right: 12px; }
  .toast { font-size: 13px; }
  .mobile-nav { position: fixed; z-index: 15; bottom: max(10px,env(safe-area-inset-bottom),var(--tg-bottom)); left: 12px; right: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px; border:1px solid color-mix(in srgb,var(--line) 82%,transparent); border-radius:25px; background:color-mix(in srgb,var(--surface) 94%,transparent); box-shadow:0 12px 38px rgba(28,18,10,.18); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px); }
  .mobile-nav a, .mobile-nav button { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; min-height: 58px; padding: 4px 0; border: 0; border-radius:18px; background: transparent; text-decoration: none; color: var(--ink-soft); font-size: 11px; font-weight: 750; cursor: pointer; }
  .mobile-nav .nav-icon { width:28px; height:28px; display:grid; place-items:center; color:currentColor; }
  .mobile-nav .nav-icon svg { width:26px; height:26px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
  .mobile-nav a[aria-current="page"] { color: var(--brand-strong, #d96b00); background:color-mix(in srgb,var(--brand,#f28c28) 12%,transparent); }
  .mobile-nav .mobile-day { position: relative; font-weight: 800; }
  .mobile-nav .mobile-day .nav-icon { width: 42px; height: 32px; border-radius: 16px; }
  .mobile-nav .mobile-day[aria-current="page"] .nav-icon { background: color-mix(in srgb, var(--brand, #f28c28) 18%, transparent); }
  .day-progress-wide { grid-template-columns: 1fr; gap: 9px; padding: 12px; }
  .day-add-button { padding: 9px 12px; }
  .mobile-add span { width: 36px; height: 30px; display: grid; place-items: center; border-radius: 11px; background: var(--purple); color: white; }
  .keyboard-open .mobile-nav { display: none; }
  .entry-card { padding: 25px; }
}

@media(max-width:560px){.change-center{width:100vw;height:100dvh;margin:0;max-width:none;border:0;border-radius:0}.change-center>header{padding:calc(18px + env(safe-area-inset-top)) 18px 12px}.change-center>nav{padding-inline:18px}.change-center-scroll{padding-inline:18px;padding-bottom:calc(24px + env(safe-area-inset-bottom));height:calc(100% - 134px - env(safe-area-inset-top))}}

@media (max-width: 420px) {
  .settings-modal .form-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-modal input[type="time"], .settings-modal input[type="date"] { min-height: 46px; }
}

[data-tg-theme="dark"] {
  color-scheme: dark;
  --ink: #f0edf8; --ink-soft: #b6b0c7; --paper: #141c28; --surface: #192332;
  --line: #ffffff1c; --purple: #b5a6ff; --shadow: none;
}
[data-tg-theme="dark"] body { background: var(--paper); }
[data-tg-theme="dark"] :is(.topbar, .date-nav, .panel, .modal, .note-card, .kind-task .timeline-content, .session-check, .telegram-connected, .telegram-test-form, .notification-master) { background: var(--surface); border-color: var(--line); }
[data-tg-theme="dark"] :is(.timeline-content, .modal input, .modal textarea, .modal select, .note-form textarea, .note-options select, .task-class-picker span, .schedule-mode span, .telegram-settings, .sync-intro, .sync-status, .notes-empty, .telegram-next, .file-drop) { background: #222e40; border-color: var(--line); }
[data-tg-theme="dark"] .type-lecture .timeline-content { background: #2c2846; }
[data-tg-theme="dark"] .type-practice .timeline-content { background: #382c2b; }
[data-tg-theme="dark"] .type-lab .timeline-content { background: #1b3432; }
[data-tg-theme="dark"] .teacher-line { color: var(--ink-soft); }
[data-tg-theme="dark"] .note-card.is-important { background: #3e3522; border-color: #90783b; }
[data-tg-theme="dark"] .button-dark { background: #7661d9; }
[data-tg-theme="dark"] .task-check { background: var(--surface); border-color: var(--line); }
[data-tg-theme="dark"] .switch-track { background: #526179; border-color: #8794a8; }
[data-tg-theme="dark"] .notification-switch input:checked + .switch-track { background: #8966e0; border-color: #bfa7ff; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
.offline-day-notice{margin:12px 0;padding:10px 13px;border-radius:12px;background:color-mix(in srgb,var(--orange,#ef7f1a) 13%,var(--surface));color:var(--ink-soft);font-size:12px}
