/* v29 — не показываем дефолтную площадь до восстановления URL-маршрута. */
body.route-booting .app-shell,
body.route-booting .mobile-dock {
  visibility: hidden !important;
  opacity: 0 !important;
}

.route-boot[hidden] { display: none !important; }
.route-boot {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: #f7f8fa;
  color: #18212b;
}
.route-boot-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #5e7cda, #728ee7);
  box-shadow: 0 8px 22px rgba(95,126,216,.24);
  font-weight: 900;
  font-size: 20px;
}
.route-boot-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.route-boot-copy b { font-size: 14px; }
.route-boot-copy span { color: #7f8995; font-size: 11px; }
.route-boot-spinner {
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 2px solid #d9dee6;
  border-top-color: #647fd8;
  border-radius: 50%;
  animation: route-boot-spin .7s linear infinite;
}
@keyframes route-boot-spin { to { transform: rotate(360deg); } }

.app-shell { height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); overflow: hidden; }
.sidebar { min-width: 0; height: 100dvh; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: relative; z-index: 20; }
.sidebar-brand { height: 72px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; font-weight: 900; color: #fff; background: linear-gradient(145deg, #5e7cda, #728ee7); box-shadow: 0 7px 16px rgba(95,126,216,.26); }
.brand b { display: block; letter-spacing: .6px; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; font-weight: 500; }
.sidebar-close { display: none; background: transparent; font-size: 26px; color: var(--muted); }

.profile-card { padding: 18px 22px 16px; border-bottom: 1px solid var(--line); }
.profile-person { display: flex; align-items: center; gap: 12px; min-height: 52px; font-size: 14px; font-weight: 700; }
.profile-person .character-portrait { width: 52px; height: 52px; border: 3px solid #fff; box-shadow: 0 2px 9px rgba(22,35,52,.12); }
.profile-placeholder { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #e8ebef; color: #9ca4ad; }
.profile-mood { padding: 0 0 0 64px; margin-top: -16px; display: block; background: none; font-size: 12px; color: var(--muted); }
.profile-mood:hover { color: var(--blue); }
.profile-balance { display: flex; align-items: center; gap: 6px; margin: 22px 0 0 64px; color: var(--orange); font-size: 13px; }
.profile-balance span { width: 17px; height: 17px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-size: 8px; }

.sidebar-nav { padding: 9px 0 12px; display: flex; flex-direction: column; overflow-y: auto; }
.nav-item { height: 48px; width: 100%; padding: 0 22px; display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 2px; text-align: left; background: transparent; font-weight: 650; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--surface-hover); }
.nav-item.active { color: #17202a; background: #fff; border-left-color: var(--blue); }
.nav-icon { width: 28px; text-align: center; font-size: 20px; color: var(--blue); }
.nav-item:nth-child(3) .nav-icon { color: #52c663; }
.nav-item:nth-child(5) .nav-icon { color: #f34f58; }
.nav-item:nth-child(7) .nav-icon { color: var(--pink); }
.nav-item:nth-child(9) .nav-icon { color: #657cf0; }
.nav-item.season .nav-icon { color: #ef7f20; }
.nav-item em { font-style: normal; color: #fff; background: #ef6069; padding: 3px 7px; border-radius: 12px; font-size: 9px; }
.nav-item strong { color: #fff; background: var(--green); border-radius: 10px; padding: 2px 6px; font-size: 10px; }
.sidebar-footer { margin-top: auto; min-height: 56px; padding: 10px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#connection { color: var(--muted); font-size: 11px; }
#logout { padding: 7px 10px; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: #69717a; font-size: 11px; }
#logout:hover { color: var(--danger); border-color: #ffd2d5; }

.workspace { position: relative; height: 100dvh; min-width: 0; display: grid; grid-template-rows: minmax(250px, var(--chat-size)) minmax(190px, 1fr); overflow: hidden; background: #fff; }

/* Мир всегда помещается в рабочую область без собственного скролла. */
body[data-view-mode="split"] .world-pane,
body[data-view-mode="world"] .world-pane {
  overflow: hidden;
}
.chat-pane, .world-pane { min-height: 0; min-width: 0; overflow: hidden; }

/* Меню мира открывается поверх чата и мира, поэтому chat-pane не должен его обрезать. */
.chat-pane {
  overflow: visible;
  position: relative;
  z-index: 30;
}
.world-pane {
  position: relative;
  z-index: 1;
}
.chat-pane { display: flex; flex-direction: column; background: var(--surface); }
.world-pane { display: flex; flex-direction: column; background: #e9edf1; }
.split-resizer { position: relative; cursor: row-resize; background: #f2f4f6; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); z-index: 5; }
.split-resizer:hover { background: #e9edf2; }
.split-resizer span { position: absolute; left: 50%; top: 50%; width: 48px; height: 3px; border-radius: 5px; transform: translate(-50%,-50%); background: #c9cfd6; }

body[data-view-mode="chat"] .workspace { grid-template-rows: minmax(0,1fr); }
body[data-view-mode="chat"] .world-pane,
body[data-view-mode="chat"] .split-resizer { display: none; }
body[data-view-mode="world"] .workspace { grid-template-rows: minmax(0,1fr); }
body[data-view-mode="world"] .chat-pane,
body[data-view-mode="world"] .split-resizer { display: none; }
.mobile-dock { display: none; }
.mobile-menu { display: none; }


/* v12: разделитель между чатом и миром отключён */
.split-resizer { display: none !important; }


/* v21 — отдельные разделы каталога миров */
.world-browser[hidden] {
  display: none !important;
}

.world-browser {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f4f6f8;
  overflow: hidden;
}

.world-browser-header {
  flex: 0 0 auto;
  min-height: 78px;
  padding: 13px 24px 13px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid var(--line);
}

.world-browser-back {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f2f4f7;
  color: #3e4855;
  font-size: 30px;
  line-height: 1;
}

.world-browser-back:hover {
  background: #e9edf3;
}

.world-browser-title-wrap {
  min-width: 0;
}

.world-browser-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.1px;
}

.world-browser-title-wrap h2 {
  margin: 0;
  color: #18212b;
  font-size: 22px;
  line-height: 1.1;
}

.world-browser-title-wrap p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.world-browser-search {
  flex: 0 0 auto;
  margin: 18px 22px 0;
  height: 48px;
  border: 1px solid #dfe4ea;
  border-radius: 15px;
  background: #fff;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  align-items: center;
  box-shadow: 0 4px 16px rgba(35,48,65,.04);
}

.world-browser-search span {
  text-align: center;
  color: #8993a0;
  font-size: 21px;
}

.world-browser-search input {
  height: 100%;
  min-width: 0;
  padding: 0 15px 0 0;
  border: 0;
  background: transparent;
  font-size: 14px;
  color: var(--text);
}

.world-browser-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 28px;
}

.world-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.world-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e1e5ea;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(35,48,65,.055);
}

.world-card.current {
  border-color: #bed0ff;
  box-shadow: 0 6px 22px rgba(95,126,216,.12);
}

.world-card-cover {
  position: relative;
  aspect-ratio: 16 / 7;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.world-card-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(17,25,34,.02), rgba(17,25,34,.22));
}

.world-card-status {
  position: absolute;
  left: 10px;
  bottom: 9px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(28,38,50,.72);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.world-card-favorite {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255,255,255,.90);
  color: #6e7885;
  font-size: 20px;
  box-shadow: 0 3px 10px rgba(0,0,0,.10);
}

.world-card-favorite.active {
  color: #e4b300;
}

.world-card-body {
  padding: 13px;
}

.world-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.world-card-icon {
  color: var(--blue);
}

.world-card-title-row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2934;
  font-size: 14px;
}

.world-card-body p {
  min-height: 34px;
  margin: 7px 0 13px;
  color: #7d8794;
  font-size: 11px;
  line-height: 1.45;
}

.world-card-enter {
  width: 100%;
  height: 36px;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
}

.world-card-enter:disabled {
  background: #eef1f5;
  color: #8c96a3;
}

.world-browser-empty {
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #89939f;
  text-align: center;
}

.world-browser-empty > span {
  font-size: 38px;
  color: #bdc5cf;
}

.world-browser-empty b {
  margin-top: 8px;
  color: #5f6975;
  font-size: 15px;
}

.world-browser-empty p {
  margin: 5px 0 0;
  font-size: 11px;
}


/* v22 — Мои миры / создание мира */
.world-create-button {
  margin-left: auto;
  height: 38px;
  padding: 0 14px;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 750;
  box-shadow: 0 5px 14px rgba(95,126,216,.20);
}

.world-create-button span { font-size: 18px; line-height: 1; }
.world-create-button:hover { filter: brightness(.98); }

.world-browser-loading {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  color: #87919d;
  font-size: 12px;
}
.world-browser-loading.error { color: #c5575e; }

.my-world-owner-badge {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #586474;
  font-size: 9px;
  font-weight: 800;
}

.world-card-status.public { background: rgba(58,153,83,.82); }
.world-card-status.private { background: rgba(45,55,68,.76); }

.my-world-meta {
  margin: -4px 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: #9aa3ae;
  font-size: 9px;
}

.my-world-meta span + span::before {
  content: '•';
  margin-right: 10px;
  color: #c5cbd2;
}

.my-world-actions {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.my-world-key {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a0a8b2;
  font-size: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.my-world-manage {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: #eef3ff;
  color: var(--blue);
  font-size: 10px;
  font-weight: 750;
}

.world-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.world-create-main,
.world-create-side-card {
  border: 1px solid #e1e5ea;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(35,48,65,.055);
}

.world-create-main {
  padding: 22px;
}

.world-create-section-head {
  margin-bottom: 18px;
}

.world-create-section-head > span,
.world-create-side-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 1.1px;
}

.world-create-section-head h3,
.world-create-side-card h3 {
  margin: 0;
  color: #202a35;
  font-size: 18px;
  line-height: 1.2;
}

.world-create-section-head p,
.world-create-help {
  margin: 6px 0 0;
  color: #8b95a1;
  font-size: 11px;
  line-height: 1.5;
}

.world-create-side {
  display: grid;
  gap: 12px;
}

.world-create-side-card {
  padding: 18px;
}

.world-create-actions-card {
  position: sticky;
  top: 0;
}

.world-create-field { display: block; margin-top: 14px; }
.world-create-field > span,
.world-template-field legend {
  display: block;
  margin-bottom: 7px;
  color: #626d79;
  font-size: 10px;
  font-weight: 750;
}
.world-create-field input,
.world-create-field textarea,
.world-create-field select {
  width: 100%;
  border: 1px solid #dfe4ea;
  border-radius: 12px;
  background: #fafbfc;
  color: #202a35;
  font: inherit;
  outline: 0;
}
.world-create-field input,
.world-create-field select { height: 46px; padding: 0 12px; }
.world-create-field textarea { resize: vertical; min-height: 104px; padding: 11px 12px; line-height: 1.45; }
.world-create-field input:focus,
.world-create-field textarea:focus,
.world-create-field select:focus { border-color: #9fb5f0; box-shadow: 0 0 0 3px rgba(95,126,216,.10); }

.world-create-visibility {
  margin-top: 14px;
}

.world-template-field { margin: 20px 0 0; padding: 0; border: 0; }
.world-template-group + .world-template-group { margin-top: 18px; }
.world-template-group-head { margin-bottom: 10px; }
.world-template-group-head strong { display: block; color: #202a35; font-size: 13px; font-weight: 800; }
.world-template-group-head p { margin: 4px 0 0; color: #8b95a1; font-size: 10px; line-height: 1.45; }
.world-template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.world-template-grid label { display: block; cursor: pointer; }
.world-template-grid input { position: absolute; opacity: 0; pointer-events: none; }
.world-template-grid label > span {
  position: relative;
  height: 116px;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 14px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background-color: #b8bdc2;
  background-size: cover;
  background-position: center;
}
.world-template-grid label > span { justify-content: flex-end; flex-direction: column; gap: 3px; }
.world-template-grid label > span b { color: #fff; font-size: 11px; text-shadow: 0 1px 4px rgba(0,0,0,.35); }
.world-template-grid label > span small { color: rgba(255,255,255,.84); font-size: 9px; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.world-template-grid input:checked + span { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(95,126,216,.12); }

.world-create-error { min-height: 18px; margin: 0 0 8px; color: #c9535b; font-size: 10px; }
.world-create-submit,
.world-create-cancel {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
}
.world-create-submit { background: var(--blue); color: #fff; }
.world-create-submit:disabled { opacity: .6; }
.world-create-cancel { margin-top: 8px; background: #f1f3f6; color: #687381; }
.world-create-cancel:hover { background: #e9edf2; }

/* v23 — вход в пользовательские миры */
.my-world-action-buttons {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.my-world-enter {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 13px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 780;
  box-shadow: 0 4px 12px rgba(95,126,216,.16);
}

.my-world-enter:disabled {
  background: #eef1f5;
  color: #8c96a3;
  box-shadow: none;
}

/* v31 — каждый раздел миров монтируется как отдельный view */
.world-browser-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.world-section-view {
  width: 100%;
  min-width: 0;
}

.world-section-search .world-browser-search {
  margin: 0 0 18px;
}

.world-search-results {
  min-width: 0;
}

.world-section-create {
  width: min(1040px, 100%);
  margin: 0 auto;
}
.ui-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.ui-icon {
  width: 1em;
  height: 1em;
  display: block;
  fill: currentColor;
  flex: 0 0 auto;
}

.brand-logo {
  width: 150px;
  height: auto;
  display: block;
}

.profile-settings {
  display: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 18px;
  background: #eef2f6;
}

.chat-pane,
.world-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.world-pane {
  order: 1;
  flex: 1 1 auto;
  background: transparent;
  position: relative;
  z-index: 1;
}

.chat-pane {
  order: 2;
  flex: 0 0 var(--chat-size);
  background: #fff;
  border: 1px solid #dfe6ee;
  border-top: 0;
  border-radius: 0 0 26px 26px;
  box-shadow: 0 18px 44px rgba(29, 44, 66, .09);
  position: relative;
  z-index: 4;
  overflow: hidden;
}

body[data-view-mode="split"] .world-pane {
  display: flex;
}

body[data-view-mode="split"] .chat-pane {
  display: flex;
}

body[data-view-mode="chat"] .workspace,
body[data-view-mode="world"] .workspace {
  padding: 18px;
}

body[data-view-mode="chat"] .chat-pane,
body[data-view-mode="world"] .world-pane {
  border-radius: 26px;
  border-top: 1px solid #dfe6ee;
}

body[data-view-mode="chat"] .chat-pane {
  flex: 1 1 auto;
}

body[data-view-mode="world"] .world-pane {
  flex: 1 1 auto;
}

.split-resizer,
.chat-actions,
.presence-strip,
.world-header,
.world-tools,
.world-kicker,
.scene-status,
.hint {
  display: none !important;
}
