/* World Sketch — list surface plus a full-page editor
   (conversation left, sketch right). */

/* ── List ── */

.ws-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
}

.ws-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b7bccb;
}

.ws-toolbar-right select {
  background: #0e1017;
  border: 1px solid #2c2f3a;
  border-radius: 4px;
  color: #e6e8ef;
  padding: 6px 8px;
  font-family: inherit;
}

.ws-world-delete {
  background: #7a2620;
  color: #fff;
}

.ws-thumb {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #2c2f3a;
  border-radius: 4px;
  overflow: hidden;
}

.ws-thumb svg {
  max-width: 100%;
  max-height: 100%;
}

.ws-thumb-empty {
  background: #14161f;
  color: #565d6d;
  font-size: 11px;
}

.ws-row-summary {
  font-size: 12px;
  color: #8890a0;
  margin-top: 3px;
  max-width: 460px;
}

/* ── Editor page ── */

.ws-editor-sub {
  display: flex;
  gap: 18px;
  margin: -6px 0 12px;
  font-size: 12px;
  color: #8890a0;
}

.ws-sub-item b {
  color: #c3c8d6;
}

.ws-editor-body {
  display: grid;
  grid-template-columns: minmax(320px, 38%) 1fr;
  gap: 14px;
  /* Fill the viewport so the sketch pane can size itself in % — the drawing
     scales to whatever space is left rather than a guessed pixel height. */
  height: calc(100vh - 230px);
  min-height: 520px;
}

.ws-pane {
  border: 1px solid #2c2f3a;
  border-radius: 6px;
  background: #12141c;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ws-pane-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #2c2f3a;
  background: #171a24;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8890a0;
}

.ws-pane-spacer {
  flex: 1;
}

.ws-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 10px;
  min-height: 160px;
}

.ws-canvas .ws-svg {
  max-width: 100%;
  max-height: 100%;
}

/* ── Layer toggles ── */

.ws-layers {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #2c2f3a;
}

.ws-layers-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #6b7280;
  margin-right: 4px;
}

.ws-layer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1b1f2b;
  color: #6b7280;
  border: 1px solid #2c3142;
  border-radius: 12px;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: inherit;
}

.ws-layer.on {
  background: #26314a;
  color: #dde1ea;
  border-color: #3a4767;
}

/* Palette swatch. Shared by the sketch view's chips, the region editor's chips
   and the shape list — the colour itself always comes from styleFor(), never
   from CSS, so there is exactly one place a hue is decided. */
.ws-swatch {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 2px;
}

.ws-layer .ws-swatch {
  opacity: 0.5;
}

.ws-layer.on .ws-swatch {
  opacity: 1;
}

/* ── Shape list ── */

.ws-shapes-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid #2c2f3a;
  background: #171a24;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8890a0;
}

.ws-shapes-count {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #6b7280;
}

.ws-shapes {
  max-height: 190px;
  overflow-y: auto;
  padding: 4px 0;
}

.ws-shape-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  font-size: 12px;
  color: #c3c8d6;
}

.ws-shape-row:hover {
  background: #1d2230;
}

/* Colour arrives inline from styleFor() — the border is declared transparent
   here only so the inline border-color has something to override. */
.ws-shape-glyph {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  background: #7e879a;
  border: 1px solid transparent;
  box-sizing: border-box;
}

.ws-glyph-rect {
  border-radius: 1px;
}

.ws-glyph-point {
  border-radius: 50%;
}

.ws-glyph-path {
  height: 3px;
  border-radius: 2px;
}

.ws-glyph-label {
  background: none;
}

.ws-shape-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-shape-type {
  font-size: 11px;
  color: #6b7280;
}

.ws-shape-geom {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  color: #7e879a;
  min-width: 108px;
  text-align: right;
}

/* ── Chapter plan ── */

.ws-world-map {
  /* The map is the primary view of a world, so it takes the larger share and
     the region list scrolls beneath it. */
  flex: 1 1 58%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 10px;
}

.ws-world-map .ws-world-svg {
  max-width: 100%;
  max-height: 100%;
  /* Stop the browser treating a drag as a text selection or a pan gesture. */
  touch-action: none;
  user-select: none;
  /* The canvas is exactly the grid, so the drop hint for a cell PAST the last
     column or row falls outside the viewBox. Painting outside is what lets the
     grid stay tight without losing the drag-to-grow gesture — the hit-testing
     already works out there, because the drag listens on the container. */
  overflow: visible;
}

.ws-world-map .wm-region {
  cursor: grab;
}

.ws-world-map .wm-region:hover rect:first-of-type {
  stroke: #6f86c4;
  stroke-width: 2;
}

.ws-world-map .wm-region.wm-dragging {
  cursor: grabbing;
  opacity: 0.75;
}

.ws-plan-regions {
  flex: 1 1 42%;
  min-height: 120px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-plan-region {
  border: 1px solid #2c2f3a;
  border-radius: 5px;
  padding: 8px 10px;
  background: #171a24;
}

.ws-plan-region.is-drawing {
  border-color: #3a6b52;
}

.ws-plan-region-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ws-plan-name {
  font-weight: 700;
  color: #e6e8ef;
  font-size: 13px;
}

.ws-plan-size {
  font-size: 11px;
  color: #7e879a;
}

.ws-plan-state {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}

.ws-plan-state.done {
  background: #1e3327;
  color: #7fc4a0;
}

.ws-plan-state.todo {
  background: #2b2b1e;
  color: #c9bd7f;
}

.ws-plan-state.drawing {
  background: #26314a;
  color: #9fb6e8;
}

.ws-plan-open {
  padding: 3px 10px;
  font-size: 11px;
}

.ws-plan-brief {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #a9b0c0;
}

.ws-plan-brief-empty {
  color: #6b7280;
  font-style: italic;
}

/* ── Conversation ── */

.ws-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ws-turn {
  border-radius: 6px;
  padding: 8px 10px;
  max-width: 88%;
}

.ws-turn-user {
  align-self: flex-end;
  background: #26314a;
}

.ws-turn-assistant {
  align-self: flex-start;
  background: #1b1f2b;
}

.ws-turn-pending {
  opacity: 0.65;
}

.ws-turn-who {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #8890a0;
  margin-bottom: 3px;
}

.ws-turn-body {
  color: #dde1ea;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.ws-turn-receipt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: #7fc4a0;
  border-top: 1px solid #2c3a33;
  padding-top: 5px;
}

/* Only on receipts whose revision is actually kept — see chatTurnHTML. */
.ws-turn-restore {
  margin-left: auto;
  padding: 2px 8px;
  background: #1b2b24;
  border: 1px solid #2c4a3c;
  border-radius: 10px;
  color: #7fc4a0;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.ws-turn-restore:hover {
  background: #243d32;
  color: #a8e6c4;
}

.ws-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #2c2f3a;
}

.ws-chat-form textarea {
  flex: 1;
  resize: none;
  background: #0e1017;
  border: 1px solid #2c2f3a;
  border-radius: 4px;
  color: #e6e8ef;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
}

.ws-chat-form textarea:disabled {
  opacity: 0.5;
}

/* ── Shared ── */

.ws-empty {
  color: #6b7280;
  font-size: 12px;
  padding: 16px;
  text-align: center;
  margin: 0;
}

.ws-hint {
  font-size: 12px;
  color: #8890a0;
  margin: 0 0 8px;
}

.ws-svg .ws-label {
  font-family: inherit;
  font-size: 11px;
  fill: #52514e;
}

.ws-svg .ws-ruler {
  font-family: inherit;
  font-size: 10px;
  fill: #6b7280;
}

#wsJsonText {
  width: 100%;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  background: #0e1017;
  border: 1px solid #2c2f3a;
  border-radius: 4px;
  color: #e6e8ef;
  padding: 8px;
}
