/* Character window: paper doll, name plate, what they are watching, actions. */

.cw {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483200;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(16, 20, 34, .98), rgba(8, 11, 20, .98));
  border: 1px solid rgba(125, 211, 252, .38);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .66), 0 0 46px rgba(56, 189, 248, .18);
  color: #eef2ff;
  font: 600 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  animation: cw-in 160ms ease-out;
}
.cw[hidden] { display: none; }
@keyframes cw-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Once dragged, left/top are authoritative: the JS drops the centring transform,
   and the open animation must not fight it back to the middle of the screen. */
.cw.is-placed { animation: none; }
.cw-head {
  display: flex;
  cursor: grab;
  touch-action: none;
  user-select: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(56, 189, 248, .12);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.cw-name {
  font-size: 16px;
  font-weight: 900;
  color: #7dd3fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-head:active { cursor: grabbing; }
.cw-close {
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  padding: 2px 9px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: 700 14px/1 system-ui, sans-serif;
  cursor: pointer;
}

.cw-body { display: flex; gap: 10px; padding: 12px; }

/* The paper doll. Sized generously — it is the thing the window is FOR. The art
   is measured and scaled to fit by character-fit.js, because the renderer's two
   paths draw at different internal scales. */
.cw-doll {
  position: relative;
  flex: 0 0 128px;
  height: 190px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 82%, rgba(56, 189, 248, .20), rgba(255, 255, 255, .03) 70%),
    rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
}
.exp-char-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 280px;
  height: 430px;
  transform-origin: 0 0;
  pointer-events: none;
}

.cw-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cw-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.cw-lv, .cw-job {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.cw-lv { background: linear-gradient(180deg, #fbbf24, #d97706); color: #1a1200; }
.cw-job { background: rgba(255, 255, 255, .10); color: #cbd5e1; }

.cw-bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .10);
  overflow: hidden;
}
.cw-bar i { position: absolute; inset: 0 auto 0 0; display: block; transition: width 180ms linear; }
.cw-bar span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 9px;
  font-weight: 800;
  line-height: 16px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
}
.cw-bar--hp i { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.cw-bar--mp i { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }

.cw-section {
  margin-top: 4px;
  color: #9fb6c9;
  font-size: 10px;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.cw-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.cw-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}
.cw-slot img { width: 26px; height: 26px; object-fit: contain; }
/* An empty slot keeps its box so the row never reflows into a ragged line. */
.cw-slot.is-empty { opacity: .35; }
.cw-slot.is-empty::before { content: ""; width: 26px; height: 26px; }
.cw-slot span { color: #9fb6c9; font-size: 8px; font-weight: 700; }

/* What they came for. A world here is a channel, so this is the most interesting
   thing about a stranger. */
.cw-watching { padding: 0 12px 10px; }
.cw-watch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border-radius: 11px;
  background: rgba(56, 189, 248, .10);
  border: 1px solid rgba(125, 211, 252, .22);
}
.cw-watch-thumb {
  width: 62px;
  height: 35px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  background: #05070d;
}
.cw-watch-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cw-watch-title,
.cw-watch-creator {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-watch-title { font-size: 11px; font-weight: 800; }
.cw-watch-creator { color: #9fb6c9; font-size: 10px; font-style: normal; font-weight: 600; }
.cw-watch-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #fff;
  font: 800 10px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cw-watch-btn:hover { filter: brightness(1.14); }

.cw-actions {
  display: flex;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.cw-actions button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 9px 6px;
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font: 800 11px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cw-actions button:hover { background: rgba(255, 255, 255, .2); }
.cw-actions button[data-cw="party"] { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.cw-actions button[data-cw="friend"] { background: linear-gradient(180deg, #f59e0b, #d97706); }
.cw-actions button[data-cw="chat"] { background: linear-gradient(180deg, #d946ef, #a21caf); }
.cw-actions button[data-cw="trade"] { background: linear-gradient(180deg, #f59e0b, #b45309); }
.cw-selfnote { flex: 1; text-align: center; color: #9fb6c9; font-size: 11px; font-weight: 600; }

@media (max-width: 480px) {
  .cw { width: calc(100vw - 24px); }
  .cw-doll { flex-basis: 104px; height: 156px; }
}
