/* Цвета мыши (светлая тема по умолчанию; тёмная — ниже) */
:root {
  --mc-mouse-body-1: #bcc3cd;
  --mc-mouse-body-2: #939caa;
  --mc-mouse-belly-1: #f2f5f9;
  --mc-mouse-belly-2: #dde4ec;
  --mc-mouse-tail: #dca7ca;
  --mc-mouse-paw: #a1a9b4;
  --mc-mouse-ear: #aab2bd;
  --mc-mouse-inner-ear: #f3b4cd;
  --mc-mouse-snout: #f1f4f8;
  --mc-mouse-eye: #1f2937;
  --mc-mouse-nose: #f472b6;
  --mc-mouse-stroke: #6b7280;
  --mc-mouse-shadow: rgba(91, 100, 114, 0.22);
  --mc-ground-line: rgba(139, 92, 246, 0.16);
  --mc-ground-glow: rgba(139, 92, 246, 0.12);
  --mc-cheese-glow: rgba(255, 215, 106, 0.34);
  --mc-sky-day-top: #dff3ff;
  --mc-sky-day-bottom: #f5f7d9;
  --mc-sky-night-top: #16233f;
  --mc-sky-night-bottom: #46566f;
  --mc-hill-back: #a9c8a8;
  --mc-hill-front: #789f7d;
  --mc-meadow-near: #8faa88;
  --mc-meadow-mid: #bacbb0;
  --mc-meadow-far: #e0e7d5;
  --mc-tree-far: #6e9878;
  --mc-tree-near: #3f7054;
  --mc-tree-trunk: #775b43;
  --mc-birch-trunk: #edf2e8;
  --mc-birch-mark: #69746d;
  --mc-sun: #ffd267;
  --mc-sun-glow: rgba(255, 210, 103, 0.38);
  --mc-moon: #f5f2d2;
  --mc-moon-mark: #d7d4bd;
  --mouse-maze-card-bg: #ffffff;
  --mouse-maze-card-border: rgba(15, 23, 42, 0.12);
  --mouse-maze-wall: #151b2d;
  --mouse-maze-trail: rgba(126, 91, 239, 0.28);
  --mouse-maze-shadow: 0 18px 46px rgba(15, 23, 42, 0.16);
}

:root[data-theme='midnight'],
:root[data-theme='dark'] {
  --mc-mouse-body-1: #8b93a1;
  --mc-mouse-body-2: #5c6575;
  --mc-mouse-belly-1: #c8d0dc;
  --mc-mouse-belly-2: #9aa6b8;
  --mc-mouse-tail: #b87a9e;
  --mc-mouse-paw: #7a8494;
  --mc-mouse-ear: #8e97a3;
  --mc-mouse-inner-ear: #d48ba8;
  --mc-mouse-snout: #e8edf4;
  --mc-mouse-eye: #0f172a;
  --mc-mouse-nose: #e879a8;
  --mc-mouse-stroke: #4b5563;
  --mc-mouse-shadow: rgba(0, 0, 0, 0.35);
  --mc-ground-line: rgba(167, 139, 250, 0.22);
  --mc-ground-glow: rgba(99, 102, 241, 0.18);
  --mc-cheese-glow: rgba(253, 224, 71, 0.28);
  --mc-sky-day-top: #263c55;
  --mc-sky-day-bottom: #536b74;
  --mc-sky-night-top: #080e1c;
  --mc-sky-night-bottom: #202f4a;
  --mc-hill-back: #38554b;
  --mc-hill-front: #263f36;
  --mc-meadow-near: #233b33;
  --mc-meadow-mid: #1e322b;
  --mc-meadow-far: #18241f;
  --mc-tree-far: #315747;
  --mc-tree-near: #183a2c;
  --mc-tree-trunk: #4d3c31;
  --mc-birch-trunk: #aab6aa;
  --mc-birch-mark: #46534c;
  --mc-sun: #f3c45c;
  --mc-sun-glow: rgba(243, 196, 92, 0.22);
  --mc-moon: #dadbbf;
  --mc-moon-mark: #aeb3a2;
  --mouse-maze-card-bg: #f8fafc;
  --mouse-maze-card-border: rgba(148, 163, 184, 0.28);
  --mouse-maze-wall: #172033;
  --mouse-maze-trail: rgba(126, 91, 239, 0.34);
  --mouse-maze-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-page);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
}

.preloader.show {
  display: flex;
}

.preloader__skeleton {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.preloader__header,
.preloader__table {
  margin: 0 30px;
  border-radius: var(--radius-card);
}

.preloader__header {
  background: var(--color-bg-subtle);
  height: 68px;
  margin-top: 10px;
  margin-bottom: 20px;
  border-top-left-radius: var(--radius-card);
  border-top-right-radius: var(--radius-card);
}

.preloader__table {
  flex: 1;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-soft);
  padding: 16px 0 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Сцена мышь + сыр (глобальный и модальный прелоадер) */
.mouse-cheese-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  align-self: stretch;
}

.mouse-cheese-scene {
  position: relative;
  width: 100%;
  height: min(240px, 40vh);
  min-height: 200px;
  max-height: 320px;
  overflow: hidden;
  flex-shrink: 0;
  isolation: isolate;
}

/* Глобальная сцена заполняет свободную высоту, оставляя место сообщению загрузки. */
.preloader__table > .mouse-cheese-stage {
  flex: 1 1 auto;
  min-height: 360px;
}

.preloader__table > .mouse-cheese-stage .mouse-cheese-scene {
  --mc-ground-baseline: calc(50% - clamp(56px, 5vw, 82px));
  --mc-forest-bottom: calc(var(--mc-ground-baseline) - 48px);
  --mc-meadow-top: calc(var(--mc-ground-baseline) + 8px);
  height: 100%;
  min-height: 360px;
  max-height: none;
}

.mouse-maze-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  align-self: stretch;
  flex: 0 0 auto;
}

.mouse-maze-card {
  position: relative;
  width: min(100%, 430px);
  height: min(58svh, 118vw);
  min-height: 318px;
  max-height: 560px;
  overflow: hidden;
  border: 1px solid var(--mouse-maze-card-border);
  border-radius: 22px;
  background: var(--mouse-maze-card-bg);
  box-shadow: var(--mouse-maze-shadow);
}

.mouse-maze-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mouse-maze-wall {
  fill: none;
  stroke: var(--mouse-maze-wall);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.mouse-maze-trail {
  fill: none;
  stroke: var(--mouse-maze-trail);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.95;
}

.mouse-maze-cheese {
  filter: drop-shadow(0 4px 7px rgba(120, 82, 0, 0.22));
  transform-box: fill-box;
  transform-origin: center;
}

.mouse-maze-mouse {
  filter: drop-shadow(0 5px 9px rgba(15, 23, 42, 0.18));
  transform-box: fill-box;
  transform-origin: center;
}

.mouse-maze-eye {
  transform-origin: center;
}

.mouse-maze-icon-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mouse-cheese-landscape {
  --mc-sky-current-top: var(--mc-sky-day-top);
  --mc-sky-current-bottom: var(--mc-sky-day-bottom);
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--color-bg-subtle) 0%,
    var(--mc-sky-current-top) 12%,
    var(--mc-sky-current-bottom) 72%,
    var(--color-bg-subtle) 100%
  );
}

.mouse-cheese-landscape[data-sky-phase='night'] {
  --mc-sky-current-top: var(--mc-sky-night-top);
  --mc-sky-current-bottom: var(--mc-sky-night-bottom);
}

.mouse-cheese-landscape::after {
  position: absolute;
  inset: 0;
  content: '';
  background-image:
    radial-gradient(circle at 12% 17%, rgba(255, 255, 255, 0.82) 0 1px, transparent 1.5px),
    radial-gradient(circle at 29% 10%, rgba(255, 255, 255, 0.68) 0 1px, transparent 1.4px),
    radial-gradient(circle at 44% 22%, rgba(255, 255, 255, 0.78) 0 1px, transparent 1.5px),
    radial-gradient(circle at 63% 12%, rgba(255, 255, 255, 0.65) 0 1px, transparent 1.4px),
    radial-gradient(circle at 87% 20%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.5px);
  opacity: 0;
}

.mouse-cheese-landscape::before {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--mc-meadow-top, 2px);
  content: '';
  background: linear-gradient(
    180deg,
    var(--mc-hill-front) 0%,
    var(--mc-meadow-near) 18%,
    var(--mc-meadow-mid) 42%,
    var(--mc-meadow-far) 72%,
    var(--color-bg-subtle) 100%
  );
}

.mouse-cheese-landscape[data-sky-phase='night']::after {
  opacity: 0.9;
}

.mouse-cheese-celestial {
  position: absolute;
  z-index: 1;
  top: 13%;
  right: 9%;
  display: block;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-circle);
}

.mouse-cheese-sun {
  background: var(--mc-sun);
  box-shadow: 0 0 0 10px var(--mc-sun-glow), 0 0 30px var(--mc-sun-glow);
}

.mouse-cheese-moon {
  display: none;
  background:
    radial-gradient(circle at 68% 38%, var(--mc-moon-mark) 0 4px, transparent 4.5px),
    radial-gradient(circle at 39% 67%, var(--mc-moon-mark) 0 3px, transparent 3.5px),
    var(--mc-moon);
  box-shadow: 0 0 24px rgba(239, 242, 218, 0.28);
}

.mouse-cheese-landscape[data-sky-phase='night'] .mouse-cheese-sun {
  display: none;
}

.mouse-cheese-landscape[data-sky-phase='night'] .mouse-cheese-moon {
  display: block;
}

.mouse-cheese-forest {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: var(--mc-forest-bottom, calc(22% - 90px));
  left: 0;
  display: block;
  width: 100%;
  height: clamp(190px, 16vw, 280px);
}

.mc-landscape-hill--back {
  fill: var(--mc-hill-back);
}

.mc-landscape-hill--front {
  fill: var(--mc-hill-front);
}

.mc-landscape-tree-line--far {
  opacity: 0.68;
}

.mc-landscape-tree-line--near {
  opacity: 0.92;
}

.mc-landscape-trunk {
  fill: var(--mc-tree-trunk);
}

.mc-landscape-deciduous,
.mc-landscape-birch-leaf {
  fill: var(--mc-tree-far);
}

.mc-landscape-tree-line--near :is(.mc-landscape-deciduous, .mc-landscape-birch-leaf) {
  fill: var(--mc-tree-near);
}

.mc-landscape-pine,
.mc-landscape-fir {
  fill: var(--mc-tree-near);
}

.mc-landscape-tree-line--far :is(.mc-landscape-pine, .mc-landscape-fir) {
  fill: var(--mc-tree-far);
}

.mc-landscape-birch-trunk {
  fill: var(--mc-birch-trunk);
}

.mc-landscape-birch-mark {
  fill: none;
  stroke: var(--mc-birch-mark);
  stroke-width: 2;
  stroke-linecap: round;
}

.mouse-cheese-ground-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18%;
  width: 72%;
  height: 34px;
  border-radius: var(--radius-circle);
  background: var(--mc-ground-glow);
  filter: blur(10px);
}

.mouse-cheese-ground {
  position: absolute;
  z-index: 1;
  left: 8%;
  right: 8%;
  bottom: 22%;
  height: 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    var(--mc-ground-line),
    var(--mc-ground-glow),
    var(--mc-ground-line)
  );
  filter: blur(0.2px);
}

.mouse-cheese-actor-mouse,
.mouse-cheese-actor-cheese {
  position: absolute;
  z-index: 3;
  bottom: 22%;
  left: 0;
  will-change: transform;
}

.preloader__table > .mouse-cheese-stage .mouse-cheese-ground-shadow {
  display: none;
}

.preloader__table > .mouse-cheese-stage .mouse-cheese-ground {
  display: none;
}

.preloader__table > .mouse-cheese-stage .mouse-cheese-actor-mouse {
  bottom: calc(var(--mc-ground-baseline) - 93px);
}

.preloader__table > .mouse-cheese-stage .mouse-cheese-actor-cheese {
  bottom: calc(var(--mc-ground-baseline) - 75px);
}

.mouse-cheese-svg {
  width: min(250px, 42vw);
  height: auto;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 10px 14px var(--mc-mouse-shadow));
}

.mouse-cheese-svg .mc-tail {
  transform-origin: 90px 125px;
  animation: mc-tail-run 0.24s ease-in-out infinite;
}

.mouse-cheese-svg .mc-head {
  transform-origin: 178px 106px;
  animation: mc-head-run 0.38s ease-in-out infinite;
}

.mouse-cheese-svg .mc-eye {
  transform-origin: 172px 101px;
  animation: mc-blink 4s ease-in-out infinite;
}

.mouse-cheese-svg .mc-leg.front,
.mouse-cheese-svg .mc-paw.front {
  animation: mc-leg-front 0.2s ease-in-out infinite;
}

.mouse-cheese-svg .mc-leg.back,
.mouse-cheese-svg .mc-paw.back {
  animation: mc-leg-back 0.2s ease-in-out infinite;
}

.mouse-cheese-svg .mc-run-bob {
  animation: mc-run-bob 0.2s ease-in-out infinite;
  transform-origin: 150px 150px;
}

.mouse-cheese-svg.mouse-cheese-svg--eating .mc-tail,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-head,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-leg.front,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-leg.back,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-paw.front,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-paw.back,
.mouse-cheese-svg.mouse-cheese-svg--eating .mc-run-bob {
  animation-duration: 0.5s;
}

.mouse-cheese-svg.mouse-cheese-svg--eating .mc-head {
  animation-name: mc-nibble-head;
}

.mouse-cheese-svg.mouse-cheese-svg--eating .mc-tail {
  animation-name: mc-nibble-tail;
}

.mouse-cheese-cheese {
  width: min(100px, 18vw);
  height: auto;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 0 10px var(--mc-cheese-glow));
}

.mouse-cheese-cheese .mc-cheese-pulse {
  animation: mc-cheese-pulse 1.2s ease-in-out infinite;
  transform-origin: 50px 36px;
}

.modal_preloader .mouse-cheese-svg {
  width: min(200px, 48%);
}

.modal_preloader .mouse-cheese-cheese {
  width: min(88px, 22%);
}

.modal_preloader .modal_preloader__container {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.modal_preloader .modal_preloader__container .mouse-cheese-stage {
  flex: 0 0 auto;
  align-self: stretch;
}

.modal_preloader .modal_preloader__container .mouse-cheese-scene {
  height: min(220px, 36vh);
  min-height: 180px;
  max-height: 280px;
}

.modal_preloader .modal_preloader__message {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  margin: 0;
  flex-shrink: 0;
}

/* Встроенная сцена (форма входа, карточка выбора workspace) */
.mouse-cheese-embed-host {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-soft);
}

.mouse-cheese-embed-host .mouse-cheese-stage {
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
}

.mouse-cheese-embed-host .mouse-cheese-scene {
  height: min(200px, 48vh);
  min-height: 160px;
  max-height: 220px;
}

.auth-card-mouse-host {
  min-height: 200px;
  margin: var(--space-12, 12px) 0;
}

.auth-form-loading .auth-card-mouse-host {
  display: block;
}

.auth-card__form:not(.auth-form-loading) .auth-card-mouse-host {
  display: none;
}

.workspace-selector-mouse-host {
  min-height: 240px;
  margin-top: var(--space-8, 8px);
}

.workspace-selector-mouse-host .mouse-cheese-svg,
.auth-card-mouse-host .mouse-cheese-svg {
  width: min(200px, 72vw);
}

.workspace-selector-mouse-host .mouse-cheese-cheese,
.auth-card-mouse-host .mouse-cheese-cheese {
  width: min(88px, 28vw);
}

.preloader__message {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(560px, calc(100% - 72px));
  width: auto;
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--table-title, var(--color-text-tertiary));
  font-size: 1.5rem;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  z-index: 2;
  flex-shrink: 0;
}

.preloader__message-text {
  display: block;
}

.preloader__message-text:empty {
  display: none;
}

@media (min-width: 641px) {
  .preloader__table > .preloader__message {
    transform: translateY(-34px);
  }
}

@media (max-width: 640px) {
  .preloader__header,
  .preloader__table {
    margin-left: 10px;
    margin-right: 10px;
  }

  .preloader__header {
    height: 56px;
    margin-bottom: 12px;
  }

  .preloader__table {
    min-height: 360px;
    margin-bottom: 12px;
    padding: 12px 8px 16px;
  }

  .preloader__table .mouse-maze-card {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .preloader__message {
    max-width: calc(100% - 28px);
    margin-top: 10px;
    font-size: 1rem;
    line-height: 1.35;
  }
}

@keyframes skeleton-loading {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes mc-tail-run {
  0% {
    transform: rotate(-9deg);
  }
  50% {
    transform: rotate(10deg);
  }
  100% {
    transform: rotate(-9deg);
  }
}

@keyframes mc-head-run {
  0% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(1.5deg);
  }
  100% {
    transform: rotate(-2deg);
  }
}

@keyframes mc-leg-front {
  0% {
    transform: rotate(16deg) translateY(0);
  }
  50% {
    transform: rotate(-10deg) translateY(4px);
  }
  100% {
    transform: rotate(16deg) translateY(0);
  }
}

@keyframes mc-leg-back {
  0% {
    transform: rotate(-14deg) translateY(3px);
  }
  50% {
    transform: rotate(12deg) translateY(-1px);
  }
  100% {
    transform: rotate(-14deg) translateY(3px);
  }
}

@keyframes mc-run-bob {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes mc-cheese-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes mc-blink {
  0%,
  47%,
  51%,
  100% {
    transform: scaleY(1);
  }
  49% {
    transform: scaleY(0.15);
  }
}

@keyframes mc-nibble-head {
  0%,
  100% {
    transform: rotate(-2deg) translateX(0);
  }
  50% {
    transform: rotate(2deg) translateX(4px);
  }
}

@keyframes mc-nibble-tail {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(3deg);
  }
}
