
.sm-app {
  --sm-bg: #071426;
  --sm-panel: #0d213a;
  --sm-card: #132d4d;
  --sm-text: #f7fbff;
  --sm-muted: #a9bfd5;
  --sm-accent: #ffcf4d;
  --sm-accent-2: #56d4ff;
  --sm-green: #37d67a;
  --sm-border: rgba(255,255,255,.12);
  box-sizing: border-box;
  max-width: 1280px;
  margin: 24px auto;
  padding: 24px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(86,212,255,.14), transparent 34%),
    radial-gradient(circle at 90% 10%, rgba(255,207,77,.12), transparent 30%),
    var(--sm-bg);
  color: var(--sm-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
}
.sm-app * { box-sizing: border-box; }
.sm-header { text-align: center; margin-bottom: 20px; }
.sm-kicker {
  margin: 0 0 6px;
  color: var(--sm-accent);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .78rem;
}
.sm-header h2 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1; }
.sm-intro { max-width: 760px; margin: 12px auto 0; color: var(--sm-muted); }
.sm-layout { display: grid; grid-template-columns: minmax(230px, 300px) 1fr; gap: 18px; align-items: start; }
.sm-patterns {
  background: rgba(255,255,255,.045);
  border: 1px solid var(--sm-border);
  border-radius: 18px;
  padding: 12px;
  max-height: 820px;
  overflow: auto;
}
.sm-patterns-title { display: grid; gap: 3px; margin: 2px 4px 12px; }
.sm-patterns-title span { color: var(--sm-muted); font-size: .82rem; }
.sm-pattern-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.sm-pattern-card {
  width: 100%;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 8px;
  background: var(--sm-card);
  color: var(--sm-text);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.sm-pattern-card:hover { transform: translateY(-1px); border-color: rgba(86,212,255,.5); }
.sm-pattern-card.is-active { border-color: var(--sm-accent); background: #19385d; }
.sm-pattern-card svg { width: 100%; height: 52px; overflow: visible; }
.sm-pattern-card polyline { fill: none; stroke: var(--sm-accent-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sm-pattern-card circle { fill: var(--sm-accent); stroke: #071426; stroke-width: 1.5; }
.sm-pattern-meta { display: grid; line-height: 1.15; }
.sm-pattern-meta strong { font-size: .95rem; }
.sm-pattern-meta small { color: var(--sm-accent-2); margin-top: 2px; }
.sm-pattern-meta em { color: var(--sm-muted); font-size: .72rem; font-style: normal; margin-top: 5px; }
.sm-main { min-width: 0; }
.sm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.sm-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 15px;
  font-weight: 800;
  cursor: pointer;
}
.sm-btn:disabled { opacity: .45; cursor: not-allowed; }
.sm-btn-light { background: rgba(255,255,255,.09); color: var(--sm-text); border: 1px solid var(--sm-border); }
.sm-btn-primary { background: var(--sm-accent); color: #172033; }
.sm-btn-secondary { background: var(--sm-accent-2); color: #071426; }
.sm-board-wrap {
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  border: 1px solid var(--sm-border);
}
.sm-board {
  position: relative;
  width: 100%;
  aspect-ratio: 15 / 6;
  overflow: hidden;
  border-radius: 13px;
  background: #f8f1df;
  touch-action: none;
}
.sm-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(6, 1fr);
}
.sm-cell {
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(17,45,77,.18);
  border-bottom: 1px solid rgba(17,45,77,.18);
  color: #d86a88;
  font-weight: 800;
  font-size: clamp(.52rem, 1.3vw, .92rem);
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.sm-cell:nth-child(15n) { border-right: 0; }
.sm-cell.is-hit {
  background: rgba(55,214,122,.28);
  color: #0c5130;
  box-shadow: inset 0 0 0 3px var(--sm-green);
}
.sm-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sm-overlay polyline { stroke: #0e3d67; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.sm-star-point { fill: var(--sm-accent); stroke: #071426; stroke-width: 5; }
.sm-snap-point { fill: rgba(55,214,122,.12); stroke: var(--sm-green); stroke-width: 4; }
.sm-snap-line { stroke: rgba(7,20,38,.35); stroke-width: 3; stroke-dasharray: 8 8; }
.sm-drag-layer {
  position: absolute;
  display: none;
  cursor: grab;
  z-index: 4;
  touch-action: none;
}
.sm-drag-layer.is-dragging { cursor: grabbing; }
.sm-result {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--sm-border);
}
.sm-result > div > span,
.sm-result > div:first-child span {
  display: block;
  color: var(--sm-muted);
  font-size: .78rem;
  margin-bottom: 5px;
}
.sm-balls { display: flex; flex-wrap: wrap; gap: 8px; }
.sm-ball {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sm-accent);
  color: #172033;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.08);
}
.sm-empty { color: var(--sm-muted); }
.sm-status { margin: 0; color: var(--sm-muted); }
.sm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sm-disclaimer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--sm-border);
  color: var(--sm-muted);
  font-size: .78rem;
  text-align: center;
}
@media (max-width: 900px) {
  .sm-layout { grid-template-columns: 1fr; }
  .sm-patterns { max-height: none; }
  .sm-pattern-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .sm-app { padding: 14px; border-radius: 16px; }
  .sm-pattern-list { display: flex; overflow-x: auto; padding-bottom: 6px; }
  .sm-pattern-card { min-width: 230px; }
  .sm-board-wrap { overflow-x: auto; }
  .sm-board { min-width: 760px; }
}


.sm-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--sm-border);
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  color: var(--sm-text);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}
.sm-edit-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--sm-accent);
}
.sm-node-handle {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #071426;
  background: var(--sm-accent);
  box-shadow: 0 0 0 5px rgba(86,212,255,.35);
  cursor: grab;
  z-index: 8;
  padding: 0;
}
.sm-node-handle:active,
.sm-drag-layer.is-dragging-node .sm-node-handle {
  cursor: grabbing;
}
.sm-app.is-node-editing .sm-drag-layer {
  cursor: default;
}
