/* Coordinate system simulator */

.cs-page { max-width: 1440px; padding-top: 28px; }
.cs-title { margin-bottom: 18px; font-size: clamp(24px, 3vw, 32px); font-weight: 800; letter-spacing: -0.02em; }

.cs-app {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  background: #111214;
}

/* ---- Thin tool strip on the left ---- */
.cs-strip {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 6px;
  background: #0a1626;
  border-right: 1px solid var(--border-subtle);
  contain: size;                 /* the board sets the height */
  min-height: 560px;
  overflow-y: auto;
}
.cs-strip button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-body); font: inherit; font-size: 10px; font-weight: 700; line-height: 1.15;
  text-align: center; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cs-strip button:hover { background: #10223a; }
.cs-strip button[data-tool][aria-pressed="true"] { background: #13304f; border-color: #38bdf8; color: #fff; }
.cs-strip .cs-option[aria-pressed="true"] { color: #38bdf8; }
.cs-strip .cs-option[aria-pressed="false"] { color: var(--text-muted); }
#cs-clear:hover { color: #f87171; }
.cs-strip svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.cs-strip svg .stroke { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cs-strip svg .dash { stroke-dasharray: 2.5 2.5; stroke-linecap: butt; }
.cs-strip svg .thin { stroke-width: 1.4; }
.cs-strip svg .bold { stroke-width: 3.4; }
.cs-strip svg .soft { opacity: 0.5; }
.cs-strip hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 4px 6px; }
.cs-strip-gap { flex: 1; }

/* ---- Board ---- */
.cs-board-wrap { position: relative; min-width: 0; }
.cs-hint {
  position: absolute; bottom: 10px; left: 12px; max-width: min(380px, 70%);
  padding: 6px 11px; border-radius: 8px; background: rgba(10, 22, 38, 0.9); border: 1px solid var(--border-subtle);
  font-size: 12.5px; line-height: 1.45; color: var(--text-body); pointer-events: none;
}
.cs-hint:empty { display: none; }
.cs-board { display: block; width: 100%; height: auto; max-height: calc(100vh - var(--header-h) - 32px); user-select: none; -webkit-user-select: none; touch-action: none; }
.cs-board[data-tool="point"], .cs-board[data-tool="segment"] { cursor: crosshair; }
.cs-board[data-tool="delete"] { cursor: not-allowed; }
.cs-board[data-tool="move"].over-point { cursor: grab; }
.cs-board.dragging { cursor: grabbing !important; }
.cs-board[data-tool="delete"].over-point, .cs-board[data-tool="delete"].over-seg,
.cs-board[data-tool="askx"].over-point, .cs-board[data-tool="asky"].over-point,
.cs-board[data-tool="projx"].over-seg, .cs-board[data-tool="ratio"].over-seg, .cs-board[data-tool="projy"].over-seg { cursor: pointer; }

.cs-board text { font-family: inherit; }
.cs-grid-minor { stroke: #1b1e23; stroke-width: 1; }
.cs-grid-major { stroke: #262a31; stroke-width: 1; }
.cs-axis { stroke: #f08a7e; stroke-width: 2; }
.cs-axis-name { fill: #f08a7e; font-size: 17px; font-style: italic; font-weight: 700; }
.cs-tick { fill: #6b7280; font-size: 11px; }

.cs-seg { stroke-width: 3; stroke-linecap: round; }
.cs-seg.hot { stroke-width: 5; }
.cs-pt { stroke: #111214; stroke-width: 2; }
.cs-pt-ring { fill: none; stroke-width: 2; }
.cs-pt-name { font-size: 15px; font-weight: 800; paint-order: stroke; stroke: #111214; stroke-width: 4px; stroke-linejoin: round; }

.cs-part { stroke-width: 4; }
.cs-badge { fill: #111214; stroke-width: 2; }
.cs-badge-text { font-size: 13px; font-weight: 800; }
.cs-div-label { font-size: 13px; }

/* Ratio picker */
.cs-pop {
  position: absolute; z-index: 5; width: 230px; padding: 12px 14px;
  background: #0a1626; border: 1px solid var(--border-hover); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: cs-fade 0.2s ease both;
}
.cs-pop-title { font-size: 13px; color: var(--text-body); margin-bottom: 10px; }
.cs-pop-title b { color: #fff; }
.cs-pop-row { display: flex; align-items: center; gap: 6px; }
.cs-pop-end { font-weight: 800; color: var(--text-muted); }
.cs-pop-colon { font-weight: 800; font-size: 18px; }
.cs-pop input {
  width: 0; flex: 1; padding: 7px 8px; border-radius: 8px; border: 2px solid #38bdf8;
  background: #06101d; color: #fff; font: inherit; font-size: 16px; font-weight: 700; text-align: center;
}
#cs-n { border-color: #f472b6; }
.cs-pop input:focus { outline: none; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25); }
.cs-pop input.bad { border-color: #ef4444; }
.cs-pop-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.cs-pop-btns button {
  padding: 6px 14px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: #1a56db; color: #fff;
}
.cs-pop-btns button.ghost { background: transparent; border-color: var(--border-hover); color: var(--text-body); }
.cs-pop-btns button.ghost:hover { border-color: #f87171; color: #f87171; }

.cs-drop { stroke-width: 1.5; stroke-dasharray: 5 5; }
.cs-shadow { stroke-width: 6; stroke-linecap: round; opacity: 0.85; }
.cs-bar { stroke-width: 2; }
.cs-measure { font-size: 13px; font-weight: 700; paint-order: stroke; stroke: #111214; stroke-width: 4px; stroke-linejoin: round; }

.cs-fade { animation: cs-fade 0.35s ease both; }
@keyframes cs-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) {
  .cs-app { grid-template-columns: 1fr; }
  .cs-strip {
    flex-direction: row; contain: none; min-height: 0; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid var(--border-subtle);
  }
  .cs-strip button { flex: 0 0 62px; }
  .cs-strip hr { border-top: 0; border-left: 1px solid var(--border-subtle); margin: 6px 2px; }
  .cs-strip-gap { display: none; }
  .cs-hint { position: static; max-width: none; border-radius: 0; border-width: 0 0 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-fade { animation: none; }
}
