/* Lexiscope — Premium UI Layer */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Inter', 'Helvetica Neue', sans-serif;
  color: #ffffff;
}

#cosmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#label-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.word-label {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-shadow:
    0 0 8px rgba(94, 129, 172, 0.45),
    0 0 24px rgba(94, 129, 172, 0.20);
  pointer-events: none;
  user-select: none;
}

.word-label.is-hovered {
  color: #ffffff;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.95),
    0 0 24px rgba(94, 129, 172, 0.50),
    0 0 50px rgba(94, 129, 172, 0.25);
}

.word-label.is-forced {
  opacity: 0;
  animation: forcedFadeIn 0.55s ease forwards;
}

.word-label.is-epicenter {
  font-size: 20px !important;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: #ffffff;
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.95),
    0 0 30px rgba(94, 129, 172, 0.65),
    0 0 55px rgba(94, 129, 172, 0.35);
}

@keyframes forcedFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#menu-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 10000;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(10, 10, 15, 0.60);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition:
    transform 0.35s cubic-bezier(0.25, 1, 0.5, 1),
    background 0.3s ease,
    border-color 0.3s ease;
}

#menu-btn:hover,
#menu-btn.is-open {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.60);
}

#menu-btn span {
  width: 16px;
  height: 1px;
  background: #ffffff;
  transform-origin: center;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
}

#menu-btn.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
#menu-btn.is-open span:nth-child(2) { opacity: 0; }
#menu-btn.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

#sidebar {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 300;
  width: min(340px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 72px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(10, 10, 15, 0.60);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateX(calc(-100% - 30px));
  opacity: 0;
  transition:
    transform 0.55s cubic-bezier(0.25, 1, 0.5, 1),
    opacity 0.55s cubic-bezier(0.25, 1, 0.5, 1);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#sidebar::-webkit-scrollbar {
  display: none;
}

#sidebar.is-open {
  transform: translateX(0);
  opacity: 1;
}

.sb-section {
  margin-bottom: 30px;
}

.sb-divider {
  display: none;
}

.sb-title {
  margin-bottom: 14px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #a0aab5;
}

.sb-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sb-toggle-label {
  font-size: 12px;
  color: #ffffff;
  letter-spacing: 0.08em;
}

.sb-toggle-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sb-toggle-track {
  position: relative;
  width: 34px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.30);
  background: rgba(255, 255, 255, 0.08);
  transition: all 0.25s ease;
}

.sb-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  transition: transform 0.25s ease;
}

#tissage-toggle:checked + .sb-toggle-track {
  border-color: rgba(94, 129, 172, 0.95);
  background: rgba(94, 129, 172, 0.35);
}

#tissage-toggle:checked + .sb-toggle-track .sb-toggle-thumb {
  transform: translateX(18px);
}

.sb-slider-row {
  display: block;
}

.sb-slider-label {
  display: block;
  margin-bottom: 10px;
  font-size: 11px;
  color: #a0aab5;
  letter-spacing: 0.1em;
}

.sb-slider-label em {
  font-style: normal;
  color: #ffffff;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.24);
  border: none;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: #ffffff;
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: #ffffff;
}

#sidebar-search,
.const-input {
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(160, 170, 181, 0.45);
  outline: none;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 0.05em;
  transition: border-color 0.3s ease;
}

#sidebar-search::placeholder,
.const-input::placeholder {
  color: #a0aab5;
}

#sidebar-search:focus,
.const-input:focus {
  border-bottom-color: #ffffff;
}

#sidebar-search.not-found {
  border-bottom-color: rgba(255, 120, 120, 0.85);
}

.sb-hint {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #a0aab5;
}

.sb-feedback {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 11px;
  color: rgba(255, 125, 125, 0.9);
}

.constellation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 24px;
}

.const-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.const-tag em {
  font-style: normal;
  font-size: 12px;
  line-height: 1;
  color: #a0aab5;
}

.const-tag:hover {
  background: rgba(255, 255, 255, 0.11);
}

.constellation-input-wrap {
  margin-top: 2px;
}

button,
.const-reveal-btn,
#derive-btn {
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 10px;
  background: transparent;
  color: #ffffff;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.const-reveal-btn,
#derive-btn {
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.const-reveal-btn:hover,
#derive-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.45);
}

.const-reveal-btn.is-disabled,
.const-reveal-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.const-reveal-btn.is-disabled:hover,
.const-reveal-btn:disabled:hover {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.20);
}

#sensitivity-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 280;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(10, 10, 15, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#manifesto-trigger {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 260;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  font-family: 'Helvetica Neue', 'Inter', sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: color 0.28s ease;
}

#manifesto-trigger:hover {
  color: rgba(255, 255, 255, 1);
}

#manifesto-trigger:focus-visible,
#manifesto-close:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

#modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
}

#manifesto-modal {
  width: min(650px, 100%);
  max-height: min(78vh, 860px);
  padding: 30px 30px 32px;
  position: relative;
  background: rgba(15, 15, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.36s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.36s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0) transparent;
}

#modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

#modal-backdrop.is-open #manifesto-modal {
  transform: translateY(0);
  opacity: 1;
}

#manifesto-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Helvetica Neue', 'Inter', sans-serif;
  font-size: 24px;
  font-weight: 200;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

#manifesto-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.manifesto-content {
  padding-right: 4px;
}

.manifesto-content h2,
.manifesto-content h3 {
  color: #ffffff;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.manifesto-content h2 {
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 500;
}

.manifesto-content h3 {
  margin-top: 22px;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
}

.manifesto-content p {
  color: #c4cdd5;
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}

#manifesto-modal::-webkit-scrollbar {
  width: 4px;
}

#manifesto-modal::-webkit-scrollbar-track {
  background: transparent;
}

#manifesto-modal::-webkit-scrollbar-thumb {
  background: rgba(8, 10, 14, 0);
  border-radius: 999px;
}

#manifesto-modal:hover {
  scrollbar-color: rgba(8, 10, 14, 0.75) transparent;
}

#manifesto-modal:hover::-webkit-scrollbar-thumb,
#manifesto-modal:focus-within::-webkit-scrollbar-thumb {
  background: rgba(8, 10, 14, 0.75);
}

.sens-row {
  display: grid;
  grid-template-columns: auto 88px;
  align-items: center;
  gap: 8px;
}

.sens-label,
.sens-val {
  font-family: 'Fira Code', Consolas, monospace;
  font-size: 9px;
  color: #a0aab5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sens-val {
  color: #ffffff;
  min-width: 80px;
  text-align: right;
}

#loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #ffffff;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: opacity 2s ease;
}

#loader-text {
  margin-bottom: 18px;
  color: #a0aab5;
}

#loader-bar-wrap {
  width: 220px;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 auto 16px;
}

#loader-bar {
  height: 1px;
  width: 0%;
  background: rgba(255, 255, 255, 0.9);
  transition: width 0.15s ease;
}

#loader-hint {
  font-size: 10px;
  line-height: 1.7;
  letter-spacing: 0.08em;
  color: #a0aab5;
}

#loader-hint code {
  font-family: 'Fira Code', Consolas, monospace;
  color: #ffffff;
}

#sidebar-search.shake {
  animation: shake 0.40s ease;
}

@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-5px); }
  40%  { transform: translateX(5px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

@media (max-width: 768px) {
  #sidebar {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  #sensitivity-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
  }

  .sens-row {
    grid-template-columns: auto 72px;
  }

  #manifesto-trigger {
    font-size: 11px;
  }

  #modal-backdrop {
    padding: 16px;
  }

  #manifesto-modal {
    max-height: 82vh;
    padding: 22px 20px 24px;
  }
}
