.task-stage-section {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

button.task-stage-title {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 100%;
  max-width: none !important;
  margin: 0;
  padding: 10px 18px 10px 28px;
  border: 1px solid rgba(148, 163, 184, 0.28) !important;
  outline: none;
  border-radius: 12px;
  background: transparent !important;
  color: #1e293b;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease;
}

button.task-stage-title:hover {
  background: rgba(148, 163, 184, 0.12) !important;
}

body.dark button.task-stage-title {
  background: rgba(255, 255, 255, 0.035) !important;
  color: inherit;
}

body.dark button.task-stage-title:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #ffffff;
}

button.task-stage-title::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 999px;
  background: #3b82f6;
  opacity: 0.75;
}

.task-stage-section.is-open button.task-stage-title::before {
  background: #22c55e;
}

button.task-stage-title::after {
  content: "›";
  margin-left: auto;
  color: rgba(30, 41, 59, 0.65);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.25s ease;
}

body.dark button.task-stage-title::after {
  color: rgba(255, 255, 255, 0.7);
}

.task-stage-section.is-open button.task-stage-title::after {
  transform: rotate(90deg);
}

.task-stage-content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  scroll-margin-top: 20px;
  transition: max-height 0.32s ease, opacity 0.22s ease;
}

.task-stage-section.is-open .task-stage-content {
  opacity: 1;
}

/* ===== Карточка задания ===== */

.task-card {
  margin-top: 10px;
  margin-bottom: 16px;
  padding: 20px !important;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.98) !important;
  line-height: 1.7 !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

body.dark .task-card {
  background: rgba(255, 255, 255, 0.085) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.task-card-title {
  margin: 8px 0 10px;
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
}

body.dark .task-card-title {
  color: #ffffff;
}

.task-card .task-text {
  max-width: 720px;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

.task-card .task-text,
.task-card .task-paragraph,
.task-card .task-list li {
  font-size: 16px !important;
  line-height: 1.72 !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

body.dark .task-card .task-text {
  color: rgba(255, 255, 255, 0.92);
}

body:not(.dark) .task-card .task-text,
body:not(.dark) .task-card .task-paragraph {
  color: #475569;
}

.task-card .task-paragraph {
  margin: 10px 0 14px !important;
}

.task-card .task-heading {
  margin: 20px 0 10px !important;
  font-size: 17px !important;
  line-height: 1.45 !important;
  font-weight: 850 !important;
}

.task-card .task-list {
  margin: 10px 0 18px !important;
  padding-left: 22px;
}

.task-card .task-list li {
  margin-bottom: 9px !important;
  padding-left: 4px;
}

.task-card strong {
  font-weight: 800;
}

.task-card em {
  opacity: 0.9;
}

/* ===== Файлы задания ===== */

.task-card .files {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 163, 184, 0.35);
}

body.dark .task-card .files {
  border-top-color: rgba(255, 255, 255, 0.14);
}

.task-card .files-title {
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 800;
}

.task-card .download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  margin-right: 8px;
  margin-bottom: 8px;
}

/* ===== Отправка работы ===== */

.task-card .submit-inline {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 163, 184, 0.35);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

body.dark .task-card .submit-inline {
  border-top-color: rgba(255, 255, 255, 0.14);
}

.task-submit-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.task-card .submit {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(236, 255, 242, 0.96);
  line-height: 1.2;
}

.task-card .submit b,
.task-card .submit span,
.submit-method-name {
  color: #111;
  font-weight: 700;
}

.task-card .go-link {
  margin-left: 2px;
  padding: 5px 10px;
  line-height: 1.1;
}

/* ===== Карточки дисциплин ===== */

.card {
  width: 100%;
  min-width: 0;
  border-top: 5px solid var(--card-accent, rgba(148, 163, 184, 0.25)) !important;
  border-radius: 16px !important;
  overflow: hidden !important;
}

body:not(.dark) .card,
body:not(.dark) .top-panel,
body:not(.dark) .modal-content {
  background: rgba(248, 250, 252, 0.94);
  color: #334155;
}

body:not(.dark) .card h3,
body:not(.dark) .modal h2,
body:not(.dark) .task-heading {
  color: #1e293b;
}

.card .teacher-link {
  margin-bottom: 6px !important;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1px !important;
}

.card .exam-badge-row,
.card .meta-row {
  margin-top: 0 !important;
  margin-bottom: 1px !important;
}

.card .task-text {
  margin-top: 0 !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

.card .task-text .task-heading:first-child,
.card .task-text p:first-child {
  margin-top: 0 !important;
}

/* ===== Семестры ===== */

.semester-select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  width: auto;
  min-width: 220px;
  padding: 10px 44px 10px 18px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background-color: #253687 !important;
  color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.semester-select:hover,
.semester-select:focus {
  background-color: #0a0f29 !important;
  color: #ffffff !important;
  outline: none;
  border-color: rgba(59, 130, 246, 0.9);
}

.semester-select option {
  background-color: #0d0533;
  color: #ffffff;
}

.semester-select option:checked {
  background-color: #1d4ed8;
}

body:not(.dark) .semester-select {
  background-color: #4f5184 !important;
  color: #ffffff !important;
  border: none !important;
}

body:not(.dark) .semester-select:hover,
body:not(.dark) .semester-select:focus {
  background-color: #3f4678 !important;
}

.semester-tabs-mobile {
  display: none;
}

/* ===== SVG фон ===== */

.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-icon {
  position: absolute;
  width: 42px;
  height: 42px;
  color: #b620b6;
  opacity: 0.16;
}

.bg-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.dark .bg-icon {
  opacity: 0.045;
  filter: brightness(1.35);
}

/* ===== Основная сетка ===== */

html,
body {
  overflow-x: hidden;
}

.container {
  width: min(100% - 28px, 1180px);
  margin-left: auto;
  margin-right: auto;
}

.top-panel,
.semester-panel,
.subjects {
  width: 100%;
}

.subjects {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 18px;
  align-items: stretch;
}

.semester-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.semester-panel h2 {
  margin: 0;
}

.semester-form-desktop {
  width: auto;
  margin-left: auto;
}

/* ===== Шапка ===== */

.bar-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
}

.bar-btn img {
  flex-shrink: 0;
  display: inline-block;
  object-fit: contain;
}

/* ===== Toast копирования ===== */

#copy-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #22c55e;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 9999;
}

#copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Планшеты ===== */

@media (max-width: 1150px) {
  header,
  .header,
  .site-header {
    width: min(100% - 28px, 720px) !important;
    max-width: 720px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    overflow: hidden !important;
  }

  .container {
    width: min(100% - 28px, 720px) !important;
    max-width: 720px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .subjects {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  nav,
  .nav,
  .header-nav,
  .header-bar-inner {
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar,
  .nav::-webkit-scrollbar,
  .header-nav::-webkit-scrollbar,
  .header-bar-inner::-webkit-scrollbar {
    display: none;
  }

  .theme-toggle {
    left: auto !important;
    right: 18px !important;
    top: 18px !important;
    transform: none !important;
    z-index: 50 !important;
  }
}

/* ===== Телефоны / iPhone ===== */

@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  header,
  .header-shell,
  .header-top,
  .header-bar,
  .header-bar-inner,
  .container,
  .top-panel,
  .semester-panel,
  .subjects,
  .card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  header,
  .header-shell {
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .header-title {
    font-size: 20px !important;
    line-height: 1.2 !important;
    text-align: center;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .header-date {
    font-size: 13px !important;
  }

  .header-bar-inner {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .header-bar-inner::-webkit-scrollbar {
    display: none;
  }

  .bar-btn {
    font-size: 13px !important;
    padding: 8px 10px !important;
  }

  .bar-btn img {
    width: 24px !important;
    height: 24px !important;
  }

  .bg-icon {
    width: 36px;
    height: 36px;
    opacity: 0.28;
  }

  body.dark .bg-icon {
    opacity: 0.06;
  }

  .subjects {
    grid-template-columns: 1fr !important;
  }

  .card {
    padding: 14px !important;
    border-radius: 16px;
    min-height: auto;
  }

  .modal-content {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 22px;
    border-radius: 20px;
  }

  .modal-content h2 {
    font-size: 24px;
    line-height: 1.25;
  }

  .work-badges {
    gap: 8px;
    flex-wrap: wrap;
  }

  .work-badge {
    font-size: 11px;
  }

  .task-card {
    padding: 20px !important;
    border-radius: 16px;
  }

  .task-card .task-text,
  .task-card .task-paragraph,
  .task-card .task-list li {
    font-size: 15.5px !important;
    line-height: 1.72 !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  .task-card .task-heading {
    font-size: 16.5px !important;
  }

  .task-card .task-list {
    list-style: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
    margin-top: 10px !important;
    margin-bottom: 18px !important;
  }

  .task-card .task-list li {
    position: relative;
    padding-left: 16px !important;
    margin-bottom: 9px !important;
  }

  .task-card .task-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    top: 8px;
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
  }

  .task-card .submit-inline {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-card .submit {
    width: 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .submit-method-name {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 15px !important;
    text-decoration: none !important;
  }

  .js-copy-email[data-email]:not([data-email=""]) {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
  }

  .task-card .submit .go-link {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  .download-btn {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  button.task-stage-title {
    width: 100%;
    max-width: 100%;
  }

  .semester-form-desktop {
    display: none !important;
  }

  .semester-panel {
    display: block !important;
  }

  .semester-panel h2 {
    display: block !important;
    margin-bottom: 14px !important;
    white-space: normal !important;
  }

  .semester-tabs-mobile {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .semester-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px !important;
    padding: 8px 4px !important;
    border: none;
    border-radius: 12px;
    background: #6d6fb9;
    color: #ffffff;
    text-decoration: none;
    font-size: 12px !important;
    font-weight: 700;
    line-height: 1.1 !important;
    text-align: center;
    white-space: nowrap !important;
    transition: background 0.2s ease, box-shadow 0.2s ease;
  }

  body:not(.dark) .semester-tab.active {
    background: #4f5184;
    box-shadow: 0 4px 12px rgba(63, 94, 168, 0.35);
  }

  body.dark .semester-tab {
    background: #253687 !important;
    color: #ffffff !important;
    border: none !important;
  }

  body.dark .semester-tab:hover,
  body.dark .semester-tab.active,
  body.dark .semester-tab:active {
    background: #0a0f29 !important;
  }

  .theme-toggle {
    position: fixed !important;
    left: auto !important;
    right: 16px !important;
    top: auto !important;
    bottom: 16px !important;
    transform: none !important;
    width: 74px !important;
    height: 40px !important;
    z-index: 100 !important;
  }

  .theme-toggle__knob {
    width: 34px !important;
    height: 34px !important;
    font-size: 18px !important;
  }

  body.dark .theme-toggle__knob {
    transform: translateX(34px) !important;
  }
}

/* ===== Фикс прозрачности светлой темы ===== */

body:not(.dark) .modal-content,
body:not(.dark) .task-card,
body:not(.dark) .card,
body:not(.dark) .top-panel,
body:not(.dark) .semester-panel {
  background: #f8fafc !important;
}

body:not(.dark) .modal {
  background: rgba(15, 23, 42, 0.58) !important;
}

/* ===== Поддержка проекта ===== */

.support-email {
  font-weight: 800;
  text-decoration: none;
  transition: 0.2s;
}

body.dark .support-email {
  color: #93c5fd;
}

body:not(.dark) .support-email {
  color: #2563eb;
}

.support-email:hover {
  opacity: 0.8;
}

.cat-emoji {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: middle;
  margin-left: 4px;
}
.file-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex: 0 0 22px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.file-icon.pdf {
  background-image: url("/static/main/icons/pdf.png");
}

.file-icon.doc,
.file-icon.docx,
.file-icon.word {
  background-image: url("/static/main/icons/word.png");
}

.file-icon.xls,
.file-icon.xlsx,
.file-icon.excel {
  background-image: url("/static/main/icons/excel.png");
}

.file-icon.ppt,
.file-icon.pptx {
  background-image: url("/static/main/icons/ppt.png");
}

.file-icon.jpg,
.file-icon.jpeg,
.file-icon.png,
.file-icon.image {
  background-image: url("/static/main/icons/image.png");
}

.file-icon.txt {
  background-image: url("/static/main/icons/txt.png");
}

.file-icon.rar,
.file-icon.zip,
.file-icon.7z {
  background-image: url("/static/main/icons/winrar.png");
}

.file-icon.link,
.file-icon.url,
.file-icon.google {
  background-image: url("/static/main/icons/google.png");
}

.file-icon.default {
  background-image: url("/static/main/icons/default.png");
}
.file-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex: 0 0 22px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* PDF */
.file-icon.pdf {
  background-image: url("/static/main/icons/pdf.png");
}

/* WORD */
.file-icon.doc,
.file-icon.docx,
.file-icon.word {
  background-image: url("/static/main/icons/word.png");
}

/* EXCEL */
.file-icon.xls,
.file-icon.xlsx,
.file-icon.excel {
  background-image: url("/static/main/icons/excel.png");
}

/* POWERPOINT */
.file-icon.ppt,
.file-icon.pptx {
  background-image: url("/static/main/icons/ppt.png");
}

/* IMAGES */
.file-icon.jpg,
.file-icon.jpeg,
.file-icon.png,
.file-icon.image {
  background-image: url("/static/main/icons/image.png");
}

/* TEXT */
.file-icon.txt {
  background-image: url("/static/main/icons/txt.png");
}

/* ARCHIVE */
.file-icon.rar,
.file-icon.zip,
.file-icon.7z,
.file-icon.winrar {
  background-image: url("/static/main/icons/winrar.png");
}

/* LINKS */
.file-icon.link,
.file-icon.url,
.file-icon.google {
  background-image: url("/static/main/icons/google.png");
}

/* DEFAULT */
.file-icon.default {
  background-image: url("/static/main/icons/default.png");
}

/* ===== Почта в модальных окнах шапки ===== */
.email-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.email-copy-btn {
  border: none;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 6px 10px;
  border-radius: 10px;

  background: rgba(34, 197, 94, 0.15);   /* как support */
  color: #22c55e;

  font-size: 13px;
  font-weight: 700;
  line-height: 1;

  transition: all 0.2s ease;
}

.email-copy-btn:hover {
  background: #22c55e;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
}

.email-copy-btn span {
  font-size: 12px;
}