/**
 * Task 9 — страница решения (как task_2: правая панель сверху)
 * task-solve__right — условие справа, выровнено по верху (как в task/2/)
 */

/* Переопределяем пропорции колонок: 61% слева (+5%), 39% справа (−5%) */
.task-9-page.task-solve-page {
  grid-template-columns: minmax(0, 61%) 1fr;
}

.task-9-page.task-solve-page .header--task {
  grid-column: 1 / -1;
}

.task-9-page .task-solve__right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-self: start;
  grid-row: 2 / 3;
  margin-top: -0.75rem;
}

.task-9-page .task-solve__right--py.task-9-side-placeholder {
  align-self: stretch;
  min-height: min(40vh, 280px);
  justify-content: flex-start;
}

.task-9-side-placeholder__inner {
  padding: 1rem 0.75rem;
  text-align: center;
  background: var(--card-bg, rgba(30, 35, 40, 0.5));
  border: 1px dashed var(--border, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  opacity: 0.85;
}

.task-9-side-placeholder__icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.task-9-side-placeholder__title {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.task-9-side-placeholder__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.5));
}

[data-theme="light"] .task-9-side-placeholder__inner {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.12);
}

.task-9-statement-wrap {
  padding: 1rem 1.25rem;
}

/* Высота таблицы Univer до нижнего края экрана */
.task-9-page .task-solve-main {
  padding-top: 0.15rem;
  padding-bottom: 0.5rem;
  min-height: 0;
}

.task-9-page .task-solve__left {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.task-9-page .calc-widget--univer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.task-9-page .univer-calc-container {
  flex: 1;
  min-height: 0;
}

.task-9-page .univer-calc-container #univer-calc-app {
  flex: 1;
  min-height: 0;
}

/* Legacy-карточка без premium (старые страницы); HF /task9/{slug}/ — task-wysiwyg--premium */
.task-9-statement:not(.task-wysiwyg--premium):not(.task-wysiwyg-solution--premium) {
  background: var(--card-bg, rgba(30, 35, 40, 0.8));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

[data-theme="light"] .task-9-statement:not(.task-wysiwyg--premium):not(.task-wysiwyg-solution--premium) {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
}

.task-9-statement:not(.task-wysiwyg--premium) p {
  margin: 0 0 0.75rem;
}

.task-9-statement:not(.task-wysiwyg--premium) p:last-child {
  margin-bottom: 0;
}

.task-9-statement:not(.task-wysiwyg--premium) table {
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
  max-width: 100%;
}

.task-9-statement:not(.task-wysiwyg--premium) table td,
.task-9-statement:not(.task-wysiwyg--premium) table th {
  border: 1px solid var(--border, rgba(255, 255, 255, 0.2));
  padding: 0.35rem 0.5rem;
  text-align: center;
  min-width: 2rem;
}

[data-theme="light"] .task-9-statement:not(.task-wysiwyg--premium) table td,
[data-theme="light"] .task-9-statement:not(.task-wysiwyg--premium) table th {
  border-color: rgba(0, 0, 0, 0.15);
}

.task-9-statement mjx-container {
  display: inline-block;
  margin: 0 0.05em;
  vertical-align: middle;
}

.task-9-statement .task-statement__header {
  margin-bottom: 1rem;
}

.task-9-statement-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.task-9-page .task-answer-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.task-9-page .task-answer-form__label {
  margin: 0;
}

.task-9-page .task-answer-form__input {
  min-width: 120px;
}

.task-9-download-link {
  color: var(--green);
  text-decoration: none;
  margin-left: auto;
}

.task-9-download-link:hover {
  text-decoration: underline;
}

/* Python-решения: pill-toggle (как task8) */
.task9-python-solutions-switcher-mount:not([hidden]) {
  display: inline-flex;
  align-items: flex-end;
}

.task9-python-solutions-toggle-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  flex-shrink: 0;
  padding: 0.05rem 0;
}

.task9-python-solutions-toggle__legend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.82);
  white-space: nowrap;
  user-select: none;
  cursor: default;
}

.task9-python-solutions-toggle__legend:not(:disabled) {
  cursor: pointer;
  color: rgba(167, 243, 208, 0.92);
}

.task9-python-solutions-toggle__legend:not(:disabled):hover {
  color: rgba(240, 253, 250, 0.98);
}

.task9-python-solutions-toggle__legend:focus-visible {
  outline: 2px solid rgba(5, 184, 125, 0.85);
  outline-offset: 1px;
  border-radius: 0.2rem;
}

[data-theme="light"] .task9-python-solutions-toggle__legend {
  color: rgba(71, 85, 105, 0.78);
}

[data-theme="light"] .task9-python-solutions-toggle__legend:not(:disabled) {
  color: rgba(5, 120, 87, 0.92);
}

[data-theme="light"] .task9-python-solutions-toggle__legend:not(:disabled):hover {
  color: rgba(4, 100, 72, 0.98);
}

.task9-python-solutions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.22rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(
    180deg,
    rgba(40, 46, 58, 0.96) 0%,
    rgba(24, 30, 40, 0.98) 100%
  );
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}

.task9-python-solutions-toggle__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.36rem 0.62rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: rgba(226, 232, 240, 0.78);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

/* Оттенки фона pill: зелёный / синий / янтарный (цикл для 3+) */
.task9-python-solutions-toggle__item--tone-0 {
  border-color: rgba(16, 185, 129, 0.38);
  background: linear-gradient(
    165deg,
    rgba(5, 150, 105, 0.34) 0%,
    rgba(52, 211, 153, 0.18) 100%
  );
  box-shadow: inset 0 1px 0 rgba(167, 243, 208, 0.12);
}

.task9-python-solutions-toggle__item--tone-1 {
  border-color: rgba(59, 130, 246, 0.38);
  background: linear-gradient(
    165deg,
    rgba(37, 99, 235, 0.34) 0%,
    rgba(96, 165, 250, 0.18) 100%
  );
  box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.12);
}

.task9-python-solutions-toggle__item--tone-2 {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(
    165deg,
    rgba(217, 119, 6, 0.34) 0%,
    rgba(251, 191, 36, 0.18) 100%
  );
  box-shadow: inset 0 1px 0 rgba(253, 230, 138, 0.12);
}

.task9-python-solutions-toggle__item[class*="--tone-"] {
  color: rgba(248, 250, 252, 0.92);
}

.task9-python-solutions-toggle__item--tone-0:hover {
  border-color: rgba(16, 185, 129, 0.55);
  background: linear-gradient(
    165deg,
    rgba(5, 150, 105, 0.48) 0%,
    rgba(52, 211, 153, 0.28) 100%
  );
  box-shadow:
    0 2px 8px rgba(5, 150, 105, 0.22),
    inset 0 1px 0 rgba(167, 243, 208, 0.16);
}

.task9-python-solutions-toggle__item--tone-1:hover {
  border-color: rgba(59, 130, 246, 0.55);
  background: linear-gradient(
    165deg,
    rgba(37, 99, 235, 0.48) 0%,
    rgba(96, 165, 250, 0.28) 100%
  );
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.22),
    inset 0 1px 0 rgba(191, 219, 254, 0.16);
}

.task9-python-solutions-toggle__item--tone-2:hover {
  border-color: rgba(245, 158, 11, 0.58);
  background: linear-gradient(
    165deg,
    rgba(217, 119, 6, 0.48) 0%,
    rgba(251, 191, 36, 0.28) 100%
  );
  box-shadow:
    0 2px 8px rgba(217, 119, 6, 0.22),
    inset 0 1px 0 rgba(253, 230, 138, 0.16);
}

.task9-python-solutions-toggle__item[class*="--tone-"]:hover {
  color: rgba(255, 255, 255, 0.98);
  transform: translateY(-1px);
}

.task9-python-solutions-toggle__item--tone-0:focus-visible {
  outline: 2px solid rgba(5, 184, 125, 0.85);
  outline-offset: 1px;
}

.task9-python-solutions-toggle__item--tone-1:focus-visible {
  outline: 2px solid rgba(14, 165, 233, 0.85);
  outline-offset: 1px;
}

.task9-python-solutions-toggle__item--tone-2:focus-visible {
  outline: 2px solid rgba(245, 158, 11, 0.85);
  outline-offset: 1px;
}

.task9-python-solutions-toggle__item--tone-0.task9-python-solutions-toggle__item--active,
.task9-python-solutions-toggle__item--tone-0.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(16, 185, 129, 0.78);
  background: linear-gradient(
    165deg,
    rgba(5, 150, 105, 0.62) 0%,
    rgba(4, 120, 87, 0.48) 100%
  );
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.36),
    0 2px 12px rgba(5, 150, 105, 0.32),
    inset 0 1px 0 rgba(167, 243, 208, 0.2);
}

.task9-python-solutions-toggle__item--tone-1.task9-python-solutions-toggle__item--active,
.task9-python-solutions-toggle__item--tone-1.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(59, 130, 246, 0.78);
  background: linear-gradient(
    165deg,
    rgba(37, 99, 235, 0.62) 0%,
    rgba(29, 78, 216, 0.48) 100%
  );
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.36),
    0 2px 12px rgba(37, 99, 235, 0.32),
    inset 0 1px 0 rgba(191, 219, 254, 0.2);
}

.task9-python-solutions-toggle__item--tone-2.task9-python-solutions-toggle__item--active,
.task9-python-solutions-toggle__item--tone-2.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(245, 158, 11, 0.8);
  background: linear-gradient(
    165deg,
    rgba(217, 119, 6, 0.62) 0%,
    rgba(180, 83, 9, 0.48) 100%
  );
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.38),
    0 2px 12px rgba(217, 119, 6, 0.32),
    inset 0 1px 0 rgba(253, 230, 138, 0.2);
}

.task9-python-solutions-toggle__item[class*="--tone-"].task9-python-solutions-toggle__item--active,
.task9-python-solutions-toggle__item[class*="--tone-"].task9-python-solutions-toggle__item--active:hover {
  color: rgba(255, 255, 255, 0.98);
  cursor: default;
  transform: translateY(-1px);
}

.task9-python-solutions-toggle__item:not([class*="--tone-"]):hover {
  border-color: rgba(5, 184, 125, 0.35);
  background: rgba(5, 184, 125, 0.1);
  color: rgba(240, 253, 250, 0.95);
  transform: translateY(-1px);
}

.task9-python-solutions-toggle__item:not([class*="--tone-"]):focus-visible {
  outline: 2px solid rgba(5, 184, 125, 0.85);
  outline-offset: 1px;
}

.task9-python-solutions-toggle__item:not([class*="--tone-"]).task9-python-solutions-toggle__item--active,
.task9-python-solutions-toggle__item:not([class*="--tone-"]).task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(5, 184, 125, 0.72);
  background: linear-gradient(
    165deg,
    rgba(5, 184, 125, 0.34) 0%,
    rgba(4, 130, 90, 0.26) 100%
  );
  color: #ecfdf5;
  cursor: default;
  box-shadow:
    0 0 0 1px rgba(5, 184, 125, 0.32),
    0 2px 10px rgba(5, 184, 125, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.task9-python-solutions-toggle__item:active {
  transform: translateY(0);
}

[data-theme="light"] .task9-python-solutions-toggle {
  border-color: rgba(15, 23, 42, 0.1);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(241, 245, 249, 0.92) 100%
  );
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

[data-theme="light"] .task9-python-solutions-toggle__item:not([class*="--tone-"]) {
  color: rgba(51, 65, 85, 0.72);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-0 {
  border-color: rgba(5, 150, 105, 0.32);
  background: linear-gradient(
    165deg,
    rgba(16, 185, 129, 0.22) 0%,
    rgba(167, 243, 208, 0.42) 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-1 {
  border-color: rgba(37, 99, 235, 0.32);
  background: linear-gradient(
    165deg,
    rgba(59, 130, 246, 0.2) 0%,
    rgba(191, 219, 254, 0.46) 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-2 {
  border-color: rgba(217, 119, 6, 0.34);
  background: linear-gradient(
    165deg,
    rgba(245, 158, 11, 0.22) 0%,
    rgba(253, 230, 138, 0.48) 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .task9-python-solutions-toggle__item[class*="--tone-"] {
  color: rgba(30, 41, 59, 0.88);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-0:hover {
  border-color: rgba(5, 150, 105, 0.48);
  background: linear-gradient(
    165deg,
    rgba(16, 185, 129, 0.3) 0%,
    rgba(110, 231, 183, 0.38) 100%
  );
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-1:hover {
  border-color: rgba(37, 99, 235, 0.48);
  background: linear-gradient(
    165deg,
    rgba(59, 130, 246, 0.28) 0%,
    rgba(147, 197, 253, 0.42) 100%
  );
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-2:hover {
  border-color: rgba(217, 119, 6, 0.5);
  background: linear-gradient(
    165deg,
    rgba(245, 158, 11, 0.3) 0%,
    rgba(252, 211, 77, 0.44) 100%
  );
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-0.task9-python-solutions-toggle__item--active,
[data-theme="light"] .task9-python-solutions-toggle__item--tone-0.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(5, 150, 105, 0.62);
  background: linear-gradient(
    165deg,
    rgba(16, 185, 129, 0.38) 0%,
    rgba(5, 150, 105, 0.24) 100%
  );
  color: rgba(6, 78, 59, 0.96);
  box-shadow:
    0 0 0 1px rgba(5, 150, 105, 0.24),
    0 2px 8px rgba(5, 150, 105, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-1.task9-python-solutions-toggle__item--active,
[data-theme="light"] .task9-python-solutions-toggle__item--tone-1.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(37, 99, 235, 0.62);
  background: linear-gradient(
    165deg,
    rgba(59, 130, 246, 0.36) 0%,
    rgba(29, 78, 216, 0.22) 100%
  );
  color: rgba(30, 64, 175, 0.96);
  box-shadow:
    0 0 0 1px rgba(37, 99, 235, 0.24),
    0 2px 8px rgba(37, 99, 235, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .task9-python-solutions-toggle__item--tone-2.task9-python-solutions-toggle__item--active,
[data-theme="light"] .task9-python-solutions-toggle__item--tone-2.task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(217, 119, 6, 0.64);
  background: linear-gradient(
    165deg,
    rgba(245, 158, 11, 0.38) 0%,
    rgba(180, 83, 9, 0.22) 100%
  );
  color: rgba(146, 64, 14, 0.96);
  box-shadow:
    0 0 0 1px rgba(217, 119, 6, 0.26),
    0 2px 8px rgba(217, 119, 6, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .task9-python-solutions-toggle__item:not([class*="--tone-"]):hover {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.08);
  color: rgba(6, 78, 59, 0.92);
}

[data-theme="light"] .task9-python-solutions-toggle__item:not([class*="--tone-"]).task9-python-solutions-toggle__item--active,
[data-theme="light"] .task9-python-solutions-toggle__item:not([class*="--tone-"]).task9-python-solutions-toggle__item--active:hover {
  border-color: rgba(5, 150, 105, 0.55);
  background: linear-gradient(
    165deg,
    rgba(5, 150, 105, 0.2) 0%,
    rgba(16, 185, 129, 0.14) 100%
  );
  color: #047857;
  box-shadow:
    0 0 0 1px rgba(5, 150, 105, 0.22),
    0 2px 8px rgba(5, 150, 105, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

@media (prefers-reduced-motion: reduce) {
  .task9-python-solutions-toggle__item {
    transition: none;
  }
}
