@font-face {
  font-family: "Trainer Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./assets/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Trainer Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Trainer Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("./assets/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Trainer JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./assets/fonts/jetbrains-mono-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Trainer JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg-0: #06111d;
  --bg-1: #0a1728;
  --bg-2: #10243c;
  --panel: rgba(8, 16, 29, 0.78);
  --panel-strong: rgba(10, 18, 34, 0.92);
  --panel-soft: rgba(17, 24, 39, 0.68);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.32);
  --text: #e5edf8;
  --muted: #9eb0c8;
  --muted-strong: #bfd0e8;
  --accent: #4cb4ff;
  --accent-strong: #138dff;
  --accent-warm: #ffb454;
  --success: #3ddc97;
  --danger: #ff7a7a;
  --shadow-lg: 0 30px 80px rgba(2, 10, 20, 0.42);
  --shadow-md: 0 14px 32px rgba(2, 10, 20, 0.3);
  --font-sans: "Trainer Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Trainer Space Grotesk", "Trainer Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Trainer JetBrains Mono", ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(76, 180, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 180, 84, 0.12), transparent 24%),
    linear-gradient(180deg, #07101c 0%, #0a1728 45%, #06111d 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.16;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0.7rem;
}

.app-kicker,
.manual-kicker,
.mobile-sheet-kicker,
.panel-label,
.profile-modal-head {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.trainer-btn,
.manual-lang-btn,
.sandbox-btn,
.status-btn,
.algo-delete-btn,
.custom-formula-apply,
.manual-toc-link {
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.trainer-btn {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  background: rgba(15, 26, 44, 0.74);
  padding: 0.48rem 0.76rem;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.trainer-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(24, 40, 66, 0.92);
  border-color: rgba(76, 180, 255, 0.4);
}

.trainer-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.trainer-btn-ghost {
  background: rgba(7, 18, 31, 0.6);
}

.trainer-btn-accent {
  color: #f5fbff;
  background: linear-gradient(135deg, rgba(19, 141, 255, 0.95), rgba(76, 180, 255, 0.88));
  border-color: rgba(76, 180, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(76, 180, 255, 0.12) inset;
}

.trainer-btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(19, 141, 255, 1), rgba(76, 180, 255, 0.94));
}

.app-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(372px, 424px) minmax(0, 1fr);
  gap: 0.7rem;
}

.sidebar,
.details-pane {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background:
    linear-gradient(180deg, rgba(11, 22, 38, 0.92), rgba(8, 15, 28, 0.88)),
    var(--panel);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 0.8rem 0.85rem 0.72rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 33, 54, 0.9), rgba(10, 22, 38, 0.7));
}

.sidebar-brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.72rem;
}

.sidebar-brand {
  min-width: 0;
}

.sidebar-brand-title {
  margin-top: 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.1vw, 1.72rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: #f5fbff;
}

.sidebar-utility-slot,
.mobile-utility-slot {
  min-width: 0;
}

.utility-rail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.utility-btn {
  padding: 0.42rem 0.66rem;
  font-size: 0.62rem;
}

.sidebar-topbar {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0;
}

.sidebar-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-tab {
  color: var(--muted);
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: 0.72rem;
  background: transparent;
  padding: 0.46rem 0.6rem;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  color: var(--accent);
  border-color: rgba(76, 180, 255, 0.72);
  background: rgba(19, 141, 255, 0.14);
  box-shadow: 0 0 0 1px rgba(76, 180, 255, 0.12) inset;
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  user-select: none;
  cursor: pointer;
}

.sort-toggle input {
  width: 0.9rem;
  height: 0.9rem;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.catalog-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  padding: 0.9rem;
}

.subgroup-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.subgroup-title {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 900;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, 160px));
  justify-content: center;
  gap: 0.62rem;
}

.catalog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(15, 25, 43, 0.86), rgba(10, 17, 30, 0.94)),
    rgba(17, 24, 39, 0.46);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 1rem;
  padding: 0.56rem 0.3rem 0.46rem;
  width: min(160px, 100%);
  max-width: 160px;
  justify-self: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.catalog-card:hover {
  transform: translateY(-2px);
  border-color: rgba(76, 180, 255, 0.24);
  box-shadow: 0 14px 24px rgba(2, 10, 20, 0.2);
}

.catalog-card.active {
  border-color: rgba(76, 180, 255, 0.7);
  box-shadow:
    0 0 0 1px rgba(76, 180, 255, 0.12) inset,
    0 20px 30px rgba(2, 10, 20, 0.28);
}

.status-dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  border: 2px solid rgba(4, 11, 20, 0.9);
  padding: 0;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.status-dot:hover:not(:disabled) {
  transform: scale(1.08);
}

.status-dot:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status-dot.NEW {
  background: #73839b;
}

.status-dot.IN_PROGRESS {
  background: #f5b942;
  box-shadow: 0 0 12px rgba(245, 185, 66, 0.45);
}

.status-dot.LEARNED {
  background: var(--success);
  box-shadow: 0 0 12px rgba(61, 220, 151, 0.45);
}

.catalog-preview {
  width: 112px;
  height: 112px;
  border-radius: 0.9rem;
  background: linear-gradient(180deg, rgba(244, 248, 252, 0.94), rgba(214, 224, 235, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.catalog-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.catalog-preview-empty {
  font-size: 0.66rem;
  color: #566579;
}

.tile-title {
  margin-top: 0.46rem;
  width: 100%;
  padding: 0 0.25rem;
  text-align: center;
  line-height: 1.08;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.92rem, 0.5vw + 0.82rem, 1.12rem);
  letter-spacing: -0.03em;
  color: #eff6ff;
}

.details-pane {
  overflow: hidden;
  padding: 0.85rem;
}

.details-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(236px, 272px);
  gap: 0.75rem;
}

.details-main,
.details-side {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.details-main {
  align-items: stretch;
}

.details-side,
.panel,
.panel-algorithms,
.algo-list {
  min-width: 0;
}

.details-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, rgba(10, 21, 35, 0.86), rgba(8, 17, 29, 0.7));
  width: min(100%, 980px);
  margin: 0 auto;
}

.details-heading-copy {
  min-width: 0;
}

.details-heading-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.case-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.48rem, 1.5vw, 2.05rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: #f5fbff;
}

.case-meta {
  margin-top: 0.22rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.video-frame {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #dfe8f1 0%, #cdd8e3 100%);
  overflow: hidden;
  width: min(100%, 980px);
  margin: 0 auto;
}

.sandbox-frame {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: linear-gradient(180deg, #e7edf3 0%, #d5dee7 100%);
}

.sandbox-stage {
  position: relative;
  min-height: 0;
}

.sandbox-preview {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #dfe8f1 0%, #cdd8e3 100%);
  pointer-events: none;
  transition: opacity 180ms ease;
}

.sandbox-preview[data-visible="false"] {
  opacity: 0;
}

.sandbox-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sandbox-preview-label {
  position: absolute;
  left: 0.85rem;
  bottom: 0.85rem;
  padding: 0.34rem 0.58rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  color: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.sandbox-preview[data-status="loading"] .sandbox-preview-label,
.sandbox-preview[data-status="error"] .sandbox-preview-label {
  opacity: 1;
  transform: translateY(0);
}

.sandbox-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 0;
}

.sandbox-overlay {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.sandbox-overlay-top-right {
  top: 0.7rem;
  right: 0.7rem;
  transform: none;
}

.sandbox-top-panel {
  width: 128px;
  height: 128px;
  border-radius: 0.82rem;
  border: 1px solid rgba(51, 65, 85, 0.2);
  background: rgba(248, 250, 252, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.sandbox-top-image {
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}

.sandbox-controls {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.65rem;
  min-height: 4.05rem;
  border-top: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(4, 10, 19, 0.93);
  backdrop-filter: blur(10px);
  padding: 0.62rem 0.75rem;
}

.sandbox-controls-left {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.sandbox-speed-toggle {
  min-width: 4.2rem;
  height: 2.15rem;
  padding: 0 0.9rem;
  border-color: rgba(76, 180, 255, 0.4);
  background: rgba(19, 141, 255, 0.16);
  color: #dff2ff;
}

.sandbox-timeline {
  display: flex;
  align-items: center;
  min-width: 0;
  justify-self: stretch;
}

.sandbox-timeline-slider {
  width: 100%;
  min-width: 0;
}

.sandbox-btn {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(17, 24, 39, 0.72);
  color: #f5fbff;
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.46rem 0.72rem;
  cursor: pointer;
}

.sandbox-btn svg {
  width: 0.98rem;
  height: 0.98rem;
  display: block;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sandbox-btn svg .fill-icon {
  fill: currentColor;
  stroke: none;
}

.sandbox-btn:hover:not(:disabled),
.manual-lang-btn:hover,
.status-btn:hover:not(:disabled),
.algo-delete-btn:hover,
.custom-formula-apply:hover,
.manual-toc-link:hover {
  transform: translateY(-1px);
}

.sandbox-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.sandbox-btn-icon,
.sandbox-btn-step {
  min-width: 2.8rem;
  width: 2.8rem;
  height: 2.15rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  letter-spacing: 0;
}

.sandbox-btn-primary {
  min-width: 3.3rem;
  width: 3.3rem;
  height: 2.15rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  letter-spacing: 0;
  border-color: rgba(19, 141, 255, 0.9);
  background: linear-gradient(135deg, rgba(19, 141, 255, 0.95), rgba(76, 180, 255, 0.88));
}

.sandbox-btn-primary svg {
  width: 1.02rem;
  height: 1.02rem;
}

.active-algo-display,
.panel {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(11, 20, 35, 0.9), rgba(8, 15, 27, 0.74));
  padding: 1rem;
}

.active-algo-display {
  min-height: 6.2rem;
  width: min(100%, 980px);
  margin: 0 auto;
}

.panel-algorithms {
  flex: 1;
  min-height: 260px;
  overflow: auto;
}

.status-group {
  display: flex;
  gap: 0.55rem;
  min-width: 0;
}

.status-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(17, 24, 39, 0.82);
  color: var(--muted-strong);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.status-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-btn.active[data-status="NEW"] {
  background: rgba(115, 131, 155, 0.2);
  border-color: rgba(158, 176, 200, 0.38);
  color: #eef5ff;
}

.status-btn.active[data-status="IN_PROGRESS"] {
  background: rgba(245, 185, 66, 0.16);
  border-color: rgba(245, 185, 66, 0.42);
  color: #ffd38a;
}

.status-btn.active[data-status="LEARNED"] {
  background: rgba(61, 220, 151, 0.16);
  border-color: rgba(61, 220, 151, 0.44);
  color: #9af1c8;
}

.algo-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.algo-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.68rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  min-width: 0;
}

.algo-option-active {
  background: rgba(19, 141, 255, 0.14);
  border-color: rgba(76, 180, 255, 0.38);
}

.algo-option-inactive {
  background: rgba(16, 24, 37, 0.65);
}

.algo-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.algo-main code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted-strong);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.algo-radio {
  accent-color: var(--accent-strong);
}

.algo-delete-btn {
  flex-shrink: 0;
  align-self: flex-start;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 122, 122, 0.34);
  background: rgba(255, 122, 122, 0.1);
  color: #ffc0c0;
  font-size: 0.64rem;
  font-weight: 800;
  cursor: pointer;
}

.custom-algo-form {
  margin-top: 0.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.custom-formula-input,
.profile-textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 0.8rem;
  background: rgba(4, 11, 20, 0.92);
  color: var(--text);
  padding: 0.7rem 0.82rem;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  outline: none;
}

.custom-formula-input:focus,
.profile-textarea:focus {
  border-color: rgba(76, 180, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(76, 180, 255, 0.14);
}

.custom-formula-apply {
  width: 100%;
  border: 1px solid rgba(76, 180, 255, 0.24);
  border-radius: 0.8rem;
  background: rgba(17, 35, 58, 0.78);
  color: #eef6ff;
  padding: 0.64rem;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.algo-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-bottom: 0.38rem;
}

.algo-line:last-child {
  margin-bottom: 0;
}

.move-tile {
  border-radius: 0.66rem;
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.24rem 0.5rem;
  font-family: var(--font-mono);
  font-weight: 900;
  line-height: 1;
  font-size: clamp(1rem, 1.35vw, 1.4rem);
}

button.move-tile {
  cursor: pointer;
  background: transparent;
}

.move-tile.base {
  color: #a4d6ff;
  border-color: rgba(76, 180, 255, 0.32);
  background: rgba(19, 141, 255, 0.12);
}

.move-tile.inverse {
  color: #ffc0c0;
  border-color: rgba(255, 122, 122, 0.34);
  background: rgba(255, 122, 122, 0.12);
}

.move-tile.current {
  box-shadow: 0 0 0 2px rgba(245, 251, 255, 0.45), 0 0 18px rgba(76, 180, 255, 0.26);
  transform: translateY(-1px);
}

.algo-placeholder,
.catalog-empty,
.algo-empty {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(17, 24, 39, 0.35);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 1rem;
}

.mobile-sheet-head {
  display: none;
}

.sheet-backdrop,
.profile-modal,
.manual-modal {
  position: fixed;
  inset: 0;
}

.sheet-backdrop {
  background: rgba(2, 8, 17, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: rgba(10, 18, 33, 0.96);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.72rem 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 120;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
}

.profile-modal,
.manual-modal {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  overflow: auto;
  z-index: 100;
}

.profile-modal::backdrop,
.manual-modal::backdrop {
  background: rgba(2, 8, 17, 0.64);
  backdrop-filter: blur(6px);
}

.profile-modal.hidden,
.manual-modal.hidden {
  display: none;
}

.profile-modal-card,
.manual-card {
  width: min(96vw, 980px);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: linear-gradient(180deg, rgba(9, 18, 31, 0.98), rgba(6, 13, 24, 0.96));
  box-shadow: var(--shadow-lg);
}

.profile-modal-card {
  max-width: 820px;
  padding: 1rem;
}

.profile-actions {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.55rem;
}

.profile-actions .trainer-btn {
  flex: 1;
}

.profile-msg {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  min-height: 1rem;
  color: #fde68a;
}

.profile-msg-error {
  color: #ffb4b4;
}

.manual-card {
  padding: 1rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.9rem;
  max-height: min(92vh, 960px);
}

.manual-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.manual-title {
  margin: 0.22rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  letter-spacing: -0.03em;
}

.manual-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.manual-lang-btn {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.8);
  color: var(--muted-strong);
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.manual-lang-btn.active {
  background: rgba(19, 141, 255, 0.9);
  border-color: rgba(76, 180, 255, 0.5);
  color: #fff;
}

.manual-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 0.9rem;
}

.manual-toc,
.manual-content {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(10, 18, 31, 0.8);
}

.manual-toc {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.manual-toc-link {
  border: 1px solid transparent;
  border-radius: 0.85rem;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  padding: 0.72rem 0.8rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.manual-toc-link.active {
  border-color: rgba(76, 180, 255, 0.28);
  background: rgba(19, 141, 255, 0.12);
  color: #f5fbff;
}

.manual-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.manual-section {
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 1rem;
  background: rgba(14, 24, 41, 0.72);
}

.manual-section.active {
  border-color: rgba(76, 180, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(76, 180, 255, 0.08) inset;
}

.manual-section-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.manual-section-lead {
  margin: 0 0 0.75rem;
  color: var(--muted-strong);
  line-height: 1.6;
}

.manual-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
  line-height: 1.65;
}

.manual-list li + li {
  margin-top: 0.38rem;
}

body[data-layout="tablet"] .app-layout {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(280px, 42vh) minmax(0, 1fr);
}

body[data-layout="tablet"] .catalog-grid {
  grid-template-columns: repeat(3, minmax(136px, 160px));
  justify-content: center;
}

body[data-layout="tablet"] .details-grid {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
}

body[data-layout="mobile"] .app-shell {
  padding: max(0.65rem, env(safe-area-inset-top)) 0.65rem max(0.65rem, env(safe-area-inset-bottom));
  gap: 0.55rem;
}

body[data-layout="mobile"] .trainer-btn {
  min-height: 42px;
  padding: 0.55rem 0.74rem;
}

body[data-layout="mobile"] .app-layout {
  display: block;
}

body[data-layout="mobile"] .sidebar,
body[data-layout="mobile"] .details-pane {
  height: 100%;
}

body[data-layout="mobile"][data-view="details"] .sidebar {
  display: none;
}

body[data-layout="mobile"][data-view="catalog"] .details-pane {
  display: none;
}

body[data-layout="mobile"] .sidebar-header {
  padding: 0.85rem;
}

body[data-layout="mobile"] .sidebar-brand-row {
  flex-direction: column;
  margin-bottom: 0.65rem;
}

body[data-layout="mobile"] .sidebar-utility-slot {
  width: 100%;
}

body[data-layout="mobile"] .utility-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body[data-layout="mobile"] .sidebar-topbar {
  align-items: flex-start;
  flex-direction: column;
}

body[data-layout="mobile"] .catalog-container {
  padding: 0.85rem;
}

body[data-layout="mobile"] .catalog-grid {
  grid-template-columns: repeat(2, minmax(132px, 156px));
  justify-content: center;
  gap: 0.55rem;
}

body[data-layout="mobile"] .catalog-card {
  max-width: 156px;
  width: min(156px, 100%);
  padding: 0.62rem 0.3rem 0.42rem;
}

body[data-layout="mobile"] .catalog-preview {
  width: 100px;
  height: 100px;
}

body[data-layout="mobile"] .tile-title {
  font-size: 1rem;
}

body[data-layout="mobile"] .details-pane {
  padding: 0.75rem;
  position: relative;
  z-index: 60;
}

body[data-layout="mobile"] .details-grid {
  position: relative;
  grid-template-columns: 1fr;
  height: 100%;
}

body[data-layout="mobile"] .details-main {
  gap: 0.7rem;
}

body[data-layout="mobile"] .details-heading {
  padding: 0.78rem 0.82rem;
}

body[data-layout="mobile"] .details-heading-actions {
  display: inline-flex;
}

body[data-layout="mobile"] .case-title {
  font-size: 1.45rem;
}

body[data-layout="mobile"] .case-meta {
  font-size: 0.78rem;
}

body[data-layout="mobile"] .video-frame {
  min-height: clamp(290px, 48dvh, 58dvh);
  aspect-ratio: auto;
}

body[data-layout="mobile"] .sandbox-overlay-top-right {
  display: none;
}

body[data-layout="mobile"] .sandbox-controls {
  grid-template-columns: 1fr;
  row-gap: 0.55rem;
}

body[data-layout="mobile"] .sandbox-controls-left {
  order: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body[data-layout="mobile"] .sandbox-speed-toggle {
  order: 2;
  justify-self: start;
}

body[data-layout="mobile"] .sandbox-timeline {
  order: 3;
  min-width: 0;
  justify-self: stretch;
}

body[data-layout="mobile"] .active-algo-display {
  min-height: 0;
  max-height: 148px;
  overflow: auto;
}

body[data-layout="mobile"] .move-tile {
  font-size: 0.9rem;
}

body[data-layout="mobile"] .sandbox-btn-icon,
body[data-layout="mobile"] .sandbox-btn-step,
body[data-layout="mobile"] .sandbox-btn-primary {
  min-width: 0;
  width: 100%;
}

body[data-layout="mobile"] .details-side {
  position: fixed;
  left: 0.65rem;
  right: 0.65rem;
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  max-height: min(74dvh, 640px);
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem 1.2rem 0.9rem 0.9rem;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.98), rgba(6, 13, 24, 0.96));
  box-shadow: var(--shadow-lg);
  transform: translateY(calc(100% + 1rem));
  transition: transform 0.23s ease;
  z-index: 50;
  overflow: auto;
}

body[data-layout="mobile"] .mobile-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

body[data-layout="mobile"] .mobile-utility-slot {
  width: 100%;
}

body[data-layout="mobile"] .mobile-sheet-title {
  font-family: var(--font-display);
  font-size: 1rem;
}

body[data-layout="mobile"][data-sheet="settings"] .details-side {
  transform: translateY(0);
}

body[data-layout="mobile"][data-sheet="settings"] .sheet-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body[data-layout="mobile"] .panel-algorithms {
  min-height: unset;
}

body[data-layout="mobile"] .manual-card {
  width: min(96vw, 920px);
  max-height: 92dvh;
}

body[data-layout="mobile"] .manual-layout {
  grid-template-columns: 1fr;
}

body[data-layout="mobile"] .manual-toc {
  max-height: 180px;
}

@media (max-width: 720px) {
  .manual-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-actions {
    flex-direction: column;
  }
}
