/**
 * X Post Styler — NFT Tools Lab shell (matches Games Lab playground).
 */

.xps-page {
  --lo-blue: #6fd3f2;
  --lo-deep-blue: #17345f;
  --lo-navy: #0d2142;
  --lo-yellow: #ffd84d;
  --lo-text: #16304f;
  --xps-styled-font: "Noto Sans Math", "Cambria Math", "STIX Two Math", "Latin Modern Math", var(--lo-font-display), serif;
  --labs-stage-aspect: unset;
  --labs-game-card-min-h: auto;
}

.xps-page *,
.xps-page *::before,
.xps-page *::after {
  -webkit-tap-highlight-color: transparent;
}

.xps__shell {
  width: min(540px, 100%);
}

.xps-page .labs-game-card {
  min-height: auto;
  gap: 0.75rem;
}

.xps-page .labs-game-head {
  min-height: auto;
  margin-bottom: 0;
  padding-right: 0;
}

.xps__lead {
  max-width: none;
}

.xps-editor {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.xps-editor__slot {
  width: 100%;
}

.xps-page .xps-editor__stage.labs-game-stage {
  aspect-ratio: unset;
  min-height: clamp(220px, 38vh, 360px);
  max-height: min(52vh, 420px);
  padding: 0.45rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.xps-label {
  margin: 0;
  font-family: var(--lo-font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--lo-deep-blue);
}

.xps-hint {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: rgba(22, 48, 79, 0.78);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 52, 95, 0.1);
}

.xps-lines {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.xps-line-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(23, 52, 95, 0.08);
}

.xps-line-row:last-child {
  border-bottom: none;
}

.xps-line-row--selected {
  background: rgba(143, 211, 108, 0.22);
}

.xps-line-row--swipe {
  animation: xps-row-swipe 0.45s ease-out;
}

@keyframes xps-row-swipe {
  from { background: rgba(143, 211, 108, 0.06); }
  50% { background: rgba(143, 211, 108, 0.32); }
  to { background: rgba(143, 211, 108, 0.22); }
}

.xps-line-btn {
  flex-shrink: 0;
  width: 38px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-right: 1px solid rgba(23, 52, 95, 0.12);
  background: linear-gradient(180deg, rgba(111, 211, 242, 0.35) 0%, rgba(111, 211, 242, 0.15) 100%);
  color: var(--lo-deep-blue);
  font-family: var(--lo-font-display);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.xps-line-btn:hover {
  background: linear-gradient(180deg, rgba(255, 216, 77, 0.65) 0%, rgba(255, 216, 77, 0.35) 100%);
}

.xps-line-btn--selected {
  background: var(--lo-green, #8fd36c);
  color: var(--lo-navy);
}

.xps-line-btn:disabled,
.xps-line-btn--empty {
  opacity: 0.35;
  cursor: default;
}

.xps-line-btn:focus-visible {
  outline: 2px solid var(--lo-deep-blue);
  outline-offset: -2px;
  z-index: 1;
}

.xps-line-input {
  flex: 1;
  min-width: 0;
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  background: transparent;
  font-family: var(--xps-styled-font);
  font-size: max(16px, 1.02rem);
  line-height: 1.55;
  color: var(--lo-text);
  resize: none;
  overflow: hidden;
  min-height: calc(1.55 * max(16px, 1.02rem) + 20px);
  touch-action: manipulation;
}

.xps-line-input:focus {
  outline: none;
  background: rgba(111, 211, 242, 0.08);
}

.xps-line-input::placeholder {
  color: rgba(22, 48, 79, 0.45);
}

.xps-toolbar {
  padding: 0.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid rgba(23, 52, 95, 0.12);
  box-shadow: 0 4px 0 rgba(17, 52, 89, 0.08);
}

.xps-toolbar__title {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: rgba(22, 48, 79, 0.78);
}

.xps-toolbar__title strong {
  color: var(--lo-deep-blue);
  font-weight: 700;
}

.xps-style-scroll {
  max-height: min(240px, 36vh);
  overflow-y: auto;
  border-radius: 14px;
  border: 2px solid rgba(23, 52, 95, 0.12);
  background: #fff;
}

.xps-style-cat {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0.55rem 0.75rem 0.35rem;
  font-family: var(--lo-font-display);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lo-deep-blue);
  background: linear-gradient(180deg, rgba(111, 211, 242, 0.35) 88%, transparent);
}

.xps-style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 50px;
  padding: 0.65rem 0.75rem;
  border: none;
  border-bottom: 1px solid rgba(23, 52, 95, 0.08);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  touch-action: manipulation;
}

.xps-style-row:hover {
  background: rgba(111, 211, 242, 0.12);
}

.xps-style-row:focus-visible {
  outline: 2px solid var(--lo-deep-blue);
  outline-offset: -2px;
}

.xps-style-row--normal {
  background: #fafafa;
}

.xps-style-row__label {
  flex-shrink: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--lo-text);
}

.xps-style-row__sample {
  flex: 1;
  min-width: 0;
  font-family: var(--xps-styled-font);
  font-size: 1.05rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xps-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 52, 95, 0.1);
}

.xps-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 38px;
  font-size: 0.86rem;
  font-weight: 600;
  color: rgba(22, 48, 79, 0.85);
  cursor: pointer;
}

.xps-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--lo-deep-blue);
}

.xps-counter-wrap {
  margin: 0;
}

.xps-counter-wrap--main {
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 52, 95, 0.1);
}

.xps-counter-label {
  display: block;
  font-family: var(--lo-font-display);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--lo-deep-blue);
}

.xps-counter {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-family: var(--lo-font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.xps-counter--calm {
  background: linear-gradient(180deg, #ffe57a 0%, var(--lo-yellow) 55%, #f5c83a 100%);
  color: var(--lo-navy);
  border: 2px solid rgba(13, 33, 66, 0.12);
}

.xps-counter--close {
  background: rgba(255, 216, 77, 0.75);
  color: #92400e;
}

.xps-counter--warn {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.xps-counter-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(22, 48, 79, 0.62);
}

.xps-editing-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.xps-char-count-compact {
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
}

.xps__actions {
  margin-top: 0.15rem;
}

.xps__actions .labs-back-to-hub--block {
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(23, 52, 95, 0.1);
}

.xps-btn {
  border: 2.5px solid rgba(13, 33, 66, 0.16);
  font-family: var(--lo-font-display);
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.xps-btn:hover,
.xps-btn:focus-visible {
  transform: translateY(-2px);
  outline: 2px solid var(--lo-deep-blue);
  outline-offset: 3px;
}

.xps-btn--yellow {
  background: linear-gradient(180deg, #ffe57a 0%, var(--lo-yellow) 55%, #f5c83a 100%);
  color: var(--lo-navy);
  box-shadow: 0 5px 0 rgba(196, 140, 20, 0.45);
}

.xps-btn--blue {
  background: linear-gradient(160deg, #7ec8ff 0%, #4aa8e8 55%, #3d92d4 100%);
  color: #fff;
  box-shadow: 0 5px 0 rgba(35, 105, 160, 0.45);
}

.xps-btn--block {
  width: 100%;
  text-align: center;
  justify-content: center;
}

.xps-btn--sm {
  min-height: 38px;
  padding: 0.35rem 0.85rem;
  font-size: 0.88rem;
}

.xps__actions .home-btn {
  width: 100%;
  text-align: center;
  justify-content: center;
  min-height: 48px;
}

.xps-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  z-index: 180;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-family: var(--lo-font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--lo-navy);
  background: linear-gradient(180deg, #ffe57a 0%, var(--lo-yellow) 55%, #f5c83a 100%);
  border: 2px solid rgba(13, 33, 66, 0.14);
  box-shadow: 0 8px 20px rgba(17, 52, 89, 0.2);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: min(92vw, 360px);
  text-align: center;
}

.xps-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.xps-info-card {
  text-align: left;
}

.xps-info-dialog__steps {
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(22, 48, 79, 0.88);
}

.xps-info-dialog__steps li {
  margin-bottom: 0.55rem;
}

.xps-info-dialog__steps li:last-child {
  margin-bottom: 0;
}

.xps-info-dialog__note {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  font-weight: 600;
  color: rgba(22, 48, 79, 0.72);
  border-radius: 12px;
  background: rgba(111, 211, 242, 0.18);
  border: 1px solid rgba(23, 52, 95, 0.1);
}

@media (max-width: 480px) {
  .xps-page .xps-editor__stage.labs-game-stage {
    min-height: 200px;
    max-height: min(42vh, 320px);
  }

  .xps-line-btn {
    width: 32px;
    font-size: 10px;
  }

  .xps-style-scroll {
    max-height: min(180px, 28vh);
  }

  body.xps-editing .xps__head,
  body.xps-editing .xps__actions,
  body.xps-editing .xps-toggles,
  body.xps-editing .xps-counter-wrap--main,
  body.xps-editing .xps-hint,
  body.xps-editing .xps-toolbar {
    display: none;
  }

  body.xps-editing .xps-editing-bar {
    display: flex;
  }

  body.xps-editing .xps__card {
    gap: 0.45rem;
  }
}

body.xps-info-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .xps-line-row--swipe {
    animation: none;
  }

  .xps-btn:hover,
  .xps-btn:focus-visible {
    transform: none;
  }
}
