:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1d1d1f;
  --surface-2: #27272a;
  --surface-3: #303034;
  --text: #f5f5f7;
  --muted: #929298;
  --muted-2: #66666d;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #3988ff;
  --accent-soft: rgba(57, 136, 255, 0.16);
  --danger: #ff6b66;
  --radius-card: 25px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 22px calc(116px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 3px 1px 35px;
}

.topbar-copy { min-width: 0; }
.brand-mark {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.brand-mark::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(57, 136, 255, 0.55);
}
.brand-mark span { color: var(--muted); font-weight: 650; }
.greeting {
  margin: 0;
  font-size: clamp(27px, 7vw, 34px);
  line-height: 1.08;
  font-weight: 720;
  letter-spacing: -0.045em;
}
.today-date {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  text-transform: capitalize;
}
.avatar {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  background: linear-gradient(145deg, #2b2b30, #171719);
  color: #fff;
  font-size: 18px;
  font-weight: 650;
}

.calendar-section { margin-bottom: 35px; }
.section-topline, .list-heading, .modal-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: .15em;
}
.calendar-title, .homework-title {
  margin: 0;
  color: var(--text);
  font-size: 25px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.035em;
}
.calendar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}
.month-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
  white-space: nowrap;
}
.today-button {
  display: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.calendar-days {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin-top: 21px;
  touch-action: pan-y;
  user-select: none;
}
.calendar-day {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 78px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 21px;
  padding: 10px 4px 13px;
  background: #09090a;
  color: var(--muted);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
  cursor: pointer;
}
.calendar-day:active { transform: scale(.96); }
.calendar-day .day-name {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}
.calendar-day strong {
  color: #dedee2;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
}
.calendar-day.selected {
  border-color: rgba(57,136,255,.95);
  background: var(--accent);
  box-shadow: 0 7px 24px rgba(57,136,255,.22);
}
.calendar-day.selected .day-name,
.calendar-day.selected strong { color: #fff; }
.calendar-day.today:not(.selected) { border-color: rgba(57,136,255,.55); }
.day-indicator {
  position: absolute;
  bottom: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.day-indicator.overdue { background: var(--danger); }
.calendar-day.selected .day-indicator { background: #fff; }

.homework-section { margin-top: 2px; }
.list-heading { align-items: center; margin-bottom: 17px; }
.homework-title { font-size: 23px; }
.add-top-button {
  display: grid;
  flex: 0 0 43px;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #171719;
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.add-top-button:active { transform: scale(.93); background: #252529; }
.add-top-button svg, .bottom-dock svg, .dock-add-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.homework-list { display: grid; gap: 12px; }

/* Карточки заданий, создаваемые текущим app.js */
.task {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 132px;
  align-items: stretch;
  border: 1px solid rgba(255,255,255,.035);
  border-radius: var(--radius-card);
  padding: 19px 17px 16px 67px;
  background: var(--surface);
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}
.task:active { background: #242427; }
.task .check {
  position: absolute;
  top: 20px;
  left: 17px;
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1.7px solid #5c5c62;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 19px;
  font-weight: 650;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.task .check:active { transform: scale(.9); }
.task.completed .check {
  border-color: var(--accent);
  background: var(--accent);
}
.task .content {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}
.task .subject {
  order: 0;
  max-width: 100%;
  color: var(--accent);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 570;
  overflow-wrap: anywhere;
}
.task .title {
  order: -1;
  margin: 0 0 5px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.25;
  font-weight: 620;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.task .description {
  order: 1;
  margin-top: 9px;
  color: #b0b0b5;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}
.task .deadline {
  order: 2;
  margin-top: 17px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.task .deadline-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.task .actions {
  order: 3;
  display: flex;
  align-self: flex-end;
  gap: 7px;
  margin-top: 12px;
}
.task .actions button {
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 11px;
  background: #29292d;
  color: #c4c4c9;
  font-size: 14px;
  cursor: pointer;
}
.task .actions button:active { background: #39393e; }
.task .actions svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.task .actions .delete-button { color: #a9a9af; }
.task.completed { opacity: .57; }
.task.completed .title { color: #b8b8bd; text-decoration: line-through; text-decoration-thickness: 1px; }
.task.completed .deadline { color: #77777e; }
.task.overdue:not(.completed) { border-color: rgba(255,107,102,.2); }
.task.overdue:not(.completed) .deadline { color: #ff8a84; }

.empty, .loading {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: var(--radius-card);
  padding: 25px 20px;
  background: #141416;
  color: var(--muted);
  text-align: center;
}
.empty-icon { margin-bottom: 12px; font-size: 26px; }
.empty-title { color: var(--text); font-size: 16px; font-weight: 650; }
.empty-text { margin-top: 7px; color: var(--muted); font-size: 13px; }
.loading { min-height: 120px; font-size: 14px; }
#homeworkList button[onclick="retryHomeworkLoad()"] {
  border: 0 !important;
  border-radius: 14px !important;
  padding: 11px 16px !important;
  background: var(--accent) !important;
  color: #fff !important;
}

.bottom-dock {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 16px;
  display: flex;
  width: min(calc(100% - 32px), 520px);
  min-height: 67px;
  align-items: center;
  justify-content: space-around;
  gap: 10px;
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 24px;
  padding: 8px 12px;
  background: rgba(31,31,34,.88);
  box-shadow: 0 12px 38px rgba(0,0,0,.42);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.bottom-dock button {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.dock-today { padding: 8px 13px; }
.dock-today svg { color: var(--accent); }
.dock-divider { width: 1px; height: 29px; background: var(--line); }
.bottom-dock .dock-add { color: #fff; }
.dock-add-icon {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}
.dock-add-icon svg { width: 20px; height: 20px; }

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 12px env(safe-area-inset-bottom);
}
.modal.open { display: flex; }
.modal-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.modal-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(88vh, 780px);
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 28px 28px 23px 23px;
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  background: #1b1b1e;
  box-shadow: 0 -18px 70px rgba(0,0,0,.45);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.sheet-handle {
  width: 38px;
  height: 5px;
  margin: 2px auto 21px;
  border-radius: 99px;
  background: #55555b;
}
.modal-heading { align-items: flex-start; margin-bottom: 21px; }
.modal-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: -.04em;
}
.close-modal {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #29292d;
  color: #eee;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.homework-form { display: flex; flex-direction: column; }
.field-label {
  margin: 13px 0 8px;
  color: #d4d4d9;
  font-size: 13px;
  font-weight: 600;
}
.field-label span { color: var(--muted-2); font-weight: 450; }
.homework-form input, .homework-form textarea {
  width: 100%;
  min-height: 49px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 15px;
  padding: 13px 14px;
  background: #101012;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.homework-form textarea { min-height: 90px; resize: vertical; }
.homework-form input::placeholder, .homework-form textarea::placeholder { color: #66666d; }
.homework-form input:focus, .homework-form textarea:focus { border-color: rgba(57,136,255,.7); }
.homework-form input[type="datetime-local"] { color-scheme: dark; }
.primary-submit {
  min-height: 52px;
  margin-top: 22px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(57,136,255,.2);
}
.primary-submit:active { transform: scale(.985); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (min-width: 600px) {
  .app-shell { padding-right: 30px; padding-left: 30px; }
  .topbar { margin-bottom: 42px; }
  .calendar-day { min-height: 86px; }
  .task { padding-right: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
