/* ================================================
   DESIGN SYSTEM
   ================================================ */
:root {
  --primary: #4e4eff;
  --secondary: #dfef44;
  --accent: #ff457a;
  --black: #0a0a0f;
  --white: #fafafe;
  --border: #4e4eff;
  --bg: #eaf5ff;

  --large: 20px;
  --medium: 10px;
  --small: 5px;

  --font: "Kode Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ================================================
   UTILITY CLASSES
   ================================================ */

.label {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.button {
  padding: var(--small) var(--medium);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ================================================
   BASE
   ================================================ */
body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--white);
  color: var(--black);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--large) 0;
  -webkit-font-smoothing: antialiased;
}

/* ================================================
   SCREEN SIZE WARNING
   ================================================ */
#sizeWarningBanner {
  display: none;
  width: 100%;
  background: var(--accent);
  color: var(--white);
  padding: 8px 16px;
  text-align: center;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  z-index: 9999;
  border-radius: var(--small);
  margin-bottom: var(--medium);
}

/* ================================================
   TOP HEADER BAR (full width)
   ================================================ */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 var(--large) var(--large) var(--large);
  width: 100%;
}

.top-header-left {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.top-header-left .breadcrumb-sep {
  margin: 0 8px;
  color: var(--black);
}

.top-header-left .breadcrumb-app {
  color: var(--primary);
}

.top-header-right {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--black);
}

/* ================================================
   MAIN CONTAINER (border around everything below header)
   ================================================ */
.container {
  padding: 0 var(--large) 0 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ================================================
   APP LAYOUT — 4-column grid
   ================================================ */
.app-layout {
  display: grid;
  grid-template-columns: 80px 220px 1fr 300px;
  grid-template-rows: 1fr auto;
  flex: 1;
  min-height: 0;
}

/* ================================================
   COLUMN 1 — TOOLBAR (purple bg)
   ================================================ */
.toolbar {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  padding: var(--large) var(--small);
  border-radius: 0 var(--large) var(--large) 0;
}

.toolbar-top,
.toolbar-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--large);
  align-items: center;
}

.toolbar-btn {
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: var(--white);
  border-radius: 50%;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  flex: 0 0 48px;
}

.toolbar-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--white);
}

.toolbar-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.toolbar-btn-label {
  font-family: var(--font);
  font-size: 9px;
  font-weight: 600;
  color: var(--white);
  text-transform: uppercase;
  text-align: center;
  margin-top: 4px;
}

.toolbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ================================================
   COLUMN 2 — OPTIONS PANEL
   ================================================ */
.options-panel {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  padding: var(--large);
  padding-bottom: 0;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}

.options-panel::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(to bottom, transparent, var(--white));
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.options-header {
  margin-bottom: var(--medium);
}

.options-group {
  display: flex;
  flex-direction: column;
  gap: var(--medium);
  margin-bottom: var(--large);
}

/* Toggle checkboxes */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  color: var(--black);
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Speed control */
.speed-label {
  margin-bottom: var(--small);
}

.speed-buttons {
  display: flex;
  gap: 0;
  border: 2px solid var(--primary);
  border-radius: var(--small);
  overflow: hidden;
}

.speed-btn {
  flex: 1;
  padding: var(--small) var(--medium);
  font-size: 11px;
  font-weight: 700;
  /* text-transform: uppercase; */
  background: var(--white);
  border: none;
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  border-right: 1px solid var(--primary);
}

.speed-btn:last-child {
  border-right: none;
}

.speed-btn.active {
  background: var(--primary);
  color: var(--white);
}

.speed-btn:hover:not(.active) {
  background: var(--border);
  color: var(--white);
}

/* Bottom buttons in options */
.options-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--small);
}

.accent-outline-btn {
  padding: var(--small) var(--medium);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--accent);
  border-radius: var(--small);
  background: var(--white);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: center;
}

.accent-outline-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--white);
}

.accent-outline-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Frame counter (hidden in this layout — info shown in frame strip) */
.frame-counter {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--black);
  opacity: 0.5;
  text-align: center;
  padding: var(--small);
  display: none;
}

/* Update frame btn (shown when a frame is selected) */
.update-frame-btn {
  display: none;
  padding: var(--small) var(--medium);
  font-size: 11px;
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--small);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
  text-transform: uppercase;
}

.update-frame-btn.visible {
  display: block;
}

.update-frame-btn:hover {
  background: var(--primary);
  color: var(--white);
}

/* ================================================
   COLUMN 3 — CANVAS AREA
   The canvas area contains the SVG stage on the left
   and the action buttons (Add Frame, Play, Stop) on the right
   ================================================ */
.canvas-area {
  grid-row: 1;
  display: flex;
  align-items: stretch;
  padding-right: var(--large);
  min-height: 0;
  min-width: 0;
}

.stage-wrapper {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--large);
  overflow: hidden;
  /* background: var(--bg); */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--medium);
}

#stage {
  display: block;
  /* width fills the wrapper on large screens;
     aspect-ratio derives height from width;
     max-height:100% clamps height to wrapper height on short/wide viewports,
     at which point width auto-shrinks to maintain the ratio. */
  /* width: 100%; */
  height: auto;
  max-height: 100%;
  aspect-ratio: 450 / 400;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  border-radius: var(--medium);
  background: var(--bg);
  /* border: 1px dashed var(--primary); */
}

.joint-handle {
  cursor: grab;
  transition: r 0.15s;
}
.joint-handle:hover {
  r: 8;
}
.joint-handle.dragging {
  cursor: grabbing;
  r: 6;
}
.hip-handle {
  cursor: grab;
  transition: r 0.15s;
}
.hip-handle:hover {
  r: 10;
}
.hip-handle.dragging {
  cursor: grabbing;
  r: 10;
}

.stage-wrapper.playing .joint-handle,
.stage-wrapper.playing .hip-handle,
.stage-wrapper.playing #figure-bbox {
  opacity: 0;
  pointer-events: none;
}

/* Action buttons column (right side of canvas) */
.action-buttons {
  display: flex;
  flex-direction: column;
  width: 80px;
  height: calc(100% - var(--large) * 2);
  margin-top: var(--large);
  flex-shrink: 0;
  background: var(--white);
  border-radius: 0 var(--large) var(--large) 0;
  overflow: hidden;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  padding: var(--medium);
  min-height: 80px;
}

.action-btn:disabled {
  /* opacity: 0.3; */
  cursor: not-allowed;
}

.action-btn-icon {
  font-size: 22px;
  line-height: 1;
  aspect-ratio: 1;
  /* background-color: var(--white); */
  color: var(--white);
  /* border-radius: 50%; */
  /* padding: var(--medium); */
}

.action-btn-record {
  background: var(--secondary);
  color: var(--primary);
}

.action-btn-record span {
  color: var(--primary);
}

.action-btn-record:hover:not(:disabled) {
  background: #d4e43a;
}

.action-btn-play {
  background: var(--primary);
  color: var(--white);
}

.action-btn-play:hover:not(:disabled) {
  background: #3a3aee;
}

.action-btn-stop {
  background: var(--accent);
  color: var(--white);
}

.action-btn-stop:hover:not(:disabled) {
  background: #3a3aee;
}

/* ================================================
   COLUMN 4 — BLOCKS PANEL
   ================================================ */
.blocks-panel {
  grid-row: 1 / 2;
  display: flex;
  gap: var(--medium);
  flex-direction: column;
  overflow: hidden;
  background: var(--white);
}

.blocks-section {
  border: 2px solid var(--border);
  border-radius: var(--large);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.blocks-header {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  background: var(--primary);
  padding: var(--medium) var(--large);
}

.community-button {
  background: var(--white);
  color: var(--primary);
  border-radius: var(--small);
  border: unset;
}

.community-button:hover {
  background: var(--secondary);
}

.blocks-list {
  display: flex;
  flex-direction: column;
  gap: var(--small);
  padding: var(--medium);
  overflow-y: auto;
  flex: 1;
}

.blocks-empty {
  font-size: 11px;
  color: var(--black);
  opacity: 0.35;
  text-align: center;
  padding: var(--large) var(--medium);
  line-height: 1.5;
}

.block-card {
  display: flex;
  align-items: center;
  gap: var(--small);
  padding: var(--small) var(--medium);
  background: var(--bg);
  border-radius: var(--small);
  cursor: pointer;
  transition: all 0.15s;
}

.block-card.editing {
  background: var(--primary);
}

.block-card.editing span {
  color: var(--white);
}

.block-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 78, 255, 0.1);
}

.block-card-name {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-card-count {
  font-size: 9px;
  color: var(--black);
  opacity: 0.5;
  white-space: nowrap;
}

.block-card-delete {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--black);
  opacity: 0.2;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 20px;
}

.block-card:hover .block-card-delete {
  opacity: 0.6;
}

.block-card-delete:hover {
  background: var(--accent);
  color: var(--white);
  opacity: 1 !important;
}

.block-card-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.block-card-share {
  flex-shrink: 0;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--small);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  cursor: pointer;
  transition: background 0.15s;
}

.block-card-share:hover {
  background: var(--white);
  color: var(--primary);
}

.block-card-share.shared {
  background: #aaa;
  cursor: pointer;
}

.block-card-share.shared:hover {
  background: var(--accent);
  color: var(--white);
}

.block-card-downloaded {
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--black);
  opacity: 0.35;
  padding: 3px 6px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  cursor: default;
}

/* ================================================
   FRAME STRIP (full width bottom)
   ================================================ */
.frame-strip-wrapper {
  grid-column: 2 / 5;
  grid-row: 2;
  padding: 0 0 0 var(--large);
}

.frame-strip-scroll-container {
  border: 2px solid var(--border);
  /* border-top: none; */
  border-radius: 0 var(--large) var(--large) var(--large);
  overflow: hidden; /* clips scrollbar within rounded corners */
  height: 93px;
}

.frame-strip {
  display: flex;
  gap: var(--medium);
  overflow-x: auto;
  padding: var(--medium) var(--medium) var(--small) var(--medium);
  align-items: center;
}

.frame-strip::-webkit-scrollbar {
  height: 4px;
  /* position: absolute; */
  /* top: -4px; */
}
.frame-strip::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

.frame-strip-empty {
  width: 100%;
  text-align: center;
  color: var(--black);
  opacity: 0.3;
  font-size: 11px;
  padding: var(--large);
}

.frame-card {
  flex: 0 0 auto;
  width: 70px;
  height: 70px;
  border: 2px solid var(--border);
  border-radius: var(--medium);
  background: var(--white);
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.frame-card:hover {
  /* border-color: var(--secondary); */
  box-shadow: 0 2px 8px rgba(78, 78, 255, 0.12);
  transform: translateY(-1px);
}

.frame-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  cursor: grabbing;
  transition: none;
  pointer-events: none;
}

.frame-strip-drop-indicator {
  flex: 0 0 auto;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
  align-self: stretch;
  margin: 4px -1px; /* overlap the gap so it sits between cards */
  pointer-events: none;
}

.frame-card.selected {
  border-color: var(--accent);
  /* box-shadow: 0 0 0 2px rgba(78, 78, 255, 0.25); */
}

.frame-card.playing {
  border-color: var(--secondary);
  /* animation: pulse-border 0.6s ease-in-out infinite; */
}

@keyframes pulse-border {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(223, 239, 68, 0.3);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(223, 239, 68, 0.5);
  }
}

.frame-card-thumbnail {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.frame-card-thumbnail svg {
  width: 80%;
}

.frame-card-label {
  font-size: 9px;
  text-align: center;
  padding: 2px;
  color: var(--white);
  background: var(--primary);
  font-family: var(--font);
  font-weight: 700;
  border-top: 1px solid var(--border);
}

.frame-card-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  gap: 2px;
}

.frame-card:hover .frame-card-actions {
  display: flex;
}

.frame-action-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 16px;
  line-height: 1;
}

.frame-action-btn.delete-btn {
  background: var(--accent);
  color: var(--white);
}
.frame-action-btn.duplicate-btn {
  background: var(--primary);
  color: var(--white);
}

/* Frame strip header (select mode) */
.frame-strip-header {
  display: flex;
  gap: var(--small);
  padding: 0 0 var(--small);
}

.frame-strip-btn {
  padding: var(--small) var(--medium);
  font-size: 10px;
  font-family: var(--font);
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--small);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
}

.frame-strip-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.frame-strip-btn.primary-btn {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.frame-strip-btn.primary-btn:hover:not(:disabled) {
  background: #3a3aee;
}

.frame-card.selectable {
  cursor: pointer;
}

.frame-card.frame-selected {
  border-color: var(--primary);
  background: rgba(78, 78, 255, 0.08);
  box-shadow: 0 0 0 2px var(--primary);
}

/* ================================================
   TIMELINE BLOCK CARDS
   ================================================ */
.timeline-block-card {
  flex: 0 0 auto;
  width: 100px;
  /* max-width: 140px; */
  height: 70px;
  padding: var(--small) var(--medium);
  background: var(--primary);
  color: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--medium);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
}

.timeline-block-card:hover {
  background: #3a3aee;
  border-color: #3a3aee;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 78, 255, 0.25);
}

.timeline-block-card.selected {
  box-shadow:
    0 0 0 2px var(--white),
    0 0 0 4px var(--primary);
}

.timeline-block-card.playing {
  animation: pulse-border-block 0.5s infinite alternate;
}

@keyframes pulse-border-block {
  0% {
    box-shadow: 0 0 0 2px rgba(223, 239, 68, 0.3);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(223, 239, 68, 0.5);
    border-color: var(--secondary);
  }
}

.timeline-block-name {
  font-weight: 700;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}
.timeline-block-count {
  font-size: 9px;
  opacity: 0.7;
}

.timeline-block-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-top: 2px;
}
.timeline-block-card:hover .timeline-block-actions {
  opacity: 1;
}

.timeline-block-action-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  transition: background 0.15s;
}

.timeline-block-action-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}
.timeline-block-action-btn.edit-btn {
  font-size: 11px;
}
.timeline-block-action-btn.delete-btn {
  background: rgba(255, 69, 122, 0.5);
}

.timeline-block-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

.block-loop-control {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  opacity: 0.9;
}

.block-loop-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.15s;
  font-family: var(--font);
}

.block-loop-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--white);
}
.block-loop-value {
  min-width: 14px;
  text-align: center;
  font-weight: 700;
  font-family: var(--font);
  font-size: 10px;
}

.block-reverse-btn {
  height: 16px;
  padding: 0 6px;
  border-radius: var(--small);
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: var(--white);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.15s;
  font-family: var(--font);
}

.block-reverse-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--white);
}
.block-reverse-btn.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--white);
}

.timeline-block-card.selectable {
  cursor: pointer;
}
.timeline-block-card.block-selected {
  border-color: var(--white);
  box-shadow: 0 0 0 3px var(--primary);
  background: #3a3aee;
}

/* ================================================
   EDITING BANNER
   ================================================ */
/* Timeline and Editing Banners share base styles */
.timeline-banner,
.editing-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--medium) 0 0;
  /* background: var(--primary); */
  /* color: var(--white); */
  font-family: var(--font);
  font-size: 11px;
  /* border-radius: var(--large) var(--large) 0 0;
  border: 2px solid var(--border);
  border-bottom: none; */
  margin-top: var(--medium);

  .label {
    position: relative;
    border: 2px solid var(--primary);
    border-bottom: 0;
    padding: var(--medium) var(--large);
    border-radius: var(--large) var(--large) 0 0;
    transform: translateY(2px);
    background: var(--white);

    /* Inverted corner at bottom-right: a pseudo-element filled with the page
       background, with a box-shadow in the border color that carves out the curve */
    &::before {
      content: "";
      position: absolute;
      bottom: 0;
      right: -20px;
      width: var(--large);
      height: var(--large);
      z-index: 1;
      background: var(--white);
    }
    &::after {
      content: "";
      position: absolute;
      bottom: 0;
      right: -22px;
      width: var(--large);
      height: var(--large);
      z-index: 2;
      background: var(--white);
      border-radius: 0 0 0 100%;
      border: 2px solid var(--border);
      border-top: 0;
      border-right: 0;
      /* border-top-left-radius: var(--large); */
      /* box-shadow: -2px -2px 0 0 var(--primary); */
      pointer-events: none;
    }
  }
}

.timeline-banner.visible,
.editing-banner.visible {
  display: flex;
}

.editing-banner-name {
  font-weight: 700;
}

.editing-banner-buttons {
  display: flex;
  gap: var(--small);
  align-items: center;
}

.editing-banner-btn {
  /* padding: 3px var(--medium); */
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--small);
  /* font-family: var(--font); */
  /* font-size: 10px; */
  /* font-weight: 700; */
  cursor: pointer;
  transition: all 0.15s;
}

.editing-banner-btn:hover {
  background: var(--primary);
  color: var(--white);
  border: 2px solid var(--primary);
}

.editing-banner-btn.primary-btn {
  background: var(--secondary);
  color: var(--primary);
  border: 2px solid var(--secondary);
}

.editing-banner-btn.primary-btn:hover {
  background: var(--primary);
  color: var(--white);
  border: 2px solid var(--primary);
}

.editing-banner-btn.accent-btn {
  background: var(--white);
  color: var(--accent);
  border: 2px solid var(--accent);
}

.editing-banner-btn.accent-btn:hover {
  background: var(--accent);
  color: var(--white);
  border: 2px solid var(--accent);
}

.editing-done-btn {
  /* padding: 3px var(--medium); */
  background: var(--primary);
  border: 2px solid var(--primary);
  color: var(--white);
  border-radius: var(--small);
  /* font-family: var(--font); */
  /* font-size: 10px; */
  /* font-weight: 700; */
  cursor: pointer;
  transition: background 0.15s;
}

.editing-done-btn:hover {
  background: var(--secondary);
  border: 2px solid var(--secondary);
  color: var(--primary);
}

/* ================================================
   MODALS
   ================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--large);
  padding: 28px 32px;
  box-shadow: 0 8px 30px rgba(10, 10, 15, 0.15);
  text-align: center;
  max-width: 380px;
  width: 90%;
  border: 2px solid var(--border);
}

.modal h3 {
  color: var(--black);
  margin: 0 0 var(--small);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
}
.modal p {
  color: var(--black);
  opacity: 0.6;
  margin: 0 0 var(--large);
  font-size: 12px;
  line-height: 1.5;
}
.modal-buttons {
  display: flex;
  gap: var(--small);
  justify-content: center;
}

.modal-btn {
  padding: var(--small) var(--large);
  font-family: var(--font);
  font-weight: 700;
  font-size: 12px;
  border: 2px solid var(--border);
  border-radius: var(--small);
  cursor: pointer;
  transition: all 0.15s;
}

.modal-btn-cancel {
  background: var(--white);
  color: var(--accent);
  border: 2px solid var(--accent);
}
.modal-btn-cancel:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.modal-btn-confirm {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.modal-btn-confirm:hover {
  background: #e63565;
  border-color: #e63565;
}

.block-name-input {
  width: 100%;
  padding: var(--medium);
  font-family: var(--font);
  font-size: 13px;
  border: 2px solid var(--border);
  border-radius: var(--small);
  margin: var(--small) 0;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
  color: var(--black);
}

.block-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 78, 255, 0.15);
}
.block-frame-count {
  font-size: 11px;
  color: var(--black);
  opacity: 0.4;
  margin-top: var(--small);
}

/* ================================================
   HELP PANEL
   ================================================ */
.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: var(--white);
  box-shadow: -4px 0 20px rgba(10, 10, 15, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 101;
  overflow-y: auto;
  border-left: 3px solid var(--primary);
}

.help-panel.open {
  transform: translateX(0);
}

.help-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--large);
  position: sticky;
  top: 0;
  background: var(--white);
  border-bottom: 2px solid var(--border);
}

.help-panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--primary);
}

.help-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--black);
  opacity: 0.4;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex: 0;
  font-family: var(--font);
  font-weight: 700;
}

.help-close-btn:hover {
  opacity: 1;
  color: var(--accent);
}

.help-panel-content {
  padding: var(--large);
}
.help-step {
  margin-bottom: var(--large);
}
.help-step strong {
  font-family: var(--font);
  color: var(--primary);
  font-size: 12px;
}
.help-step p {
  font-size: 11px;
  color: var(--black);
  opacity: 0.6;
  margin-top: var(--small);
  line-height: 1.6;
}

.help-section-title {
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  opacity: 0.5;
  margin: var(--large) 0 var(--medium);
}

.help-section-title:first-child {
  margin-top: 0;
}

.help-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 1px;
}

.help-dot.pink {
  background: #ff6eb4;
}
.help-dot.purple {
  background: var(--primary);
}

.help-tip {
  font-size: 11px;
  color: var(--black);
  opacity: 0.6;
  margin-top: var(--medium);
  margin-bottom: var(--medium);
  padding: var(--medium);
  background: var(--border);
  border-radius: var(--medium);
  border-left: 3px solid var(--secondary);
  line-height: 1.5;
}

/* ================================================
   GENERAL BUTTON RESET (prevent flex:1 on all btns)
   ================================================ */
button {
  font-family: var(--font);
  cursor: pointer;
}

/* ================================================
   CODE WINDOW (FLOATING)
   ================================================ */
.code-window {
  position: fixed;
  width: 380px;
  min-height: 500px;
  max-height: 90vh;
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--large);
  box-shadow: 0 8px 30px rgba(10, 10, 15, 0.2);
  z-index: 150;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.code-window.visible {
  display: flex;
}

.code-window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--medium) var(--large);
  background: var(--primary);
  color: var(--white);
  cursor: move;
  user-select: none;
}

.code-window-title {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.code-window-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}

.code-window-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.code-window-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* padding: var(--medium); */
  gap: var(--medium);
}

.code-commands-list {
  display: flex;
  flex-direction: column;
  gap: var(--small);
  padding: var(--medium);
  /* background: var(--bg); */
  overflow-y: auto;
  flex: 1;
}

.code-empty-state {
  color: var(--black);
  opacity: 0.3;
  text-align: center;
  font-size: 11px;
  margin: auto;
}

.code-command-line {
  display: flex;
  align-items: center;
  gap: var(--small);
  padding: var(--small);
  background: var(--bg);
  border-radius: var(--small);
  transition: all 0.15s;
}

.code-command-line:hover {
  border-color: var(--primary);
}

.code-command-label {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--main);
  text-transform: uppercase;
}

.code-block-select {
  flex: 1;
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--small);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
}

.code-loop-input {
  width: 50px;
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--small);
  text-align: center;
}

.code-loop-label {
  font-size: 11px;
  color: var(--black);
  font-weight: 700;
}

.code-delete-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: var(--white);
  color: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.code-delete-btn:hover {
  background: var(--accent);
  color: var(--white);
}

.code-command-header .code-delete-btn {
  margin-left: auto;
}

.code-add-section {
  /* padding: var(--medium); */
  /* background: var(--bg); */
}

.code-add-dropdown {
  width: 100%;
  padding: var(--small) var(--medium);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  border: 1px dashed var(--border);
  border-radius: var(--small);
  background: var(--white);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.code-add-dropdown:focus {
  outline: none;
  border-style: solid;
}

.code-window-footer {
  display: flex;
  flex-direction: column;
  gap: var(--small);
  padding: var(--medium);
}

.code-error-panel {
  display: none;
  align-items: center;
  gap: var(--small);
  padding: var(--small) var(--medium);
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: var(--small);
  font-family: var(--font);
  font-size: 11px;
  margin-bottom: var(--small);
  text-align: left;
  cursor: default;
}

.code-error-panel.visible {
  display: flex;
}

.code-error-icon {
  font-size: 14px;
}

.code-action-buttons {
  display: flex;
  gap: var(--small);
}

.code-clear-btn {
  flex: 1;
  padding: var(--small) var(--medium);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--accent);
  border-radius: var(--small);
  background: var(--white);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}

.code-clear-btn:hover {
  background: var(--accent);
  color: var(--white);
}

.code-run-btn {
  flex: 2;
  padding: var(--small) var(--large);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--secondary);
  border-radius: var(--small);
  background: var(--secondary);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
}

.code-run-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.code-run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Button in blocks header */
.blocks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-your-animation-btn {
  padding: var(--medium) var(--medium);
  font-size: 14px;
  background: var(--secondary);
  color: var(--primary);
  border: 1px solid var(--secondary);
  border-radius: var(--medium);
  cursor: pointer;
  transition: all 0.15s;
}

.code-your-animation-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Container blocks (loop/reverse) */
.code-command-container {
  border-radius: var(--small);
  background: var(--bg);
  padding: var(--small);
  /* margin-bottom: var(--small); */
}

.code-command-header {
  display: flex;
  align-items: center;
  gap: var(--small);
  /* padding: var(--small); */
  /* background: var(--white); */
  border-radius: var(--small);
}

.code-command-footer {
  /* padding: var(--small); */
  text-align: left;
}

.code-bracket {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: var(--black);
  /* margin: 0 var(--small); */
}

.code-children {
  padding-left: var(--large);
  /* border-left: 2px solid var(--border); */
  margin-left: var(--medium);
  margin-top: var(--small);
  margin-bottom: var(--small);
  display: flex;
  flex-direction: column;
  gap: var(--small);
}

.code-children .code-command-container {
  padding: 0;
}

.code-children .code-command-line {
  padding: 0;
  background: unset;
}

.code-empty-container {
  color: var(--black);
  opacity: 0.3;
  font-size: 10px;
  padding: var(--small);
  text-align: center;
}

.code-add-nested {
  /* padding: 0 0 var(--small) var(--large); */
}

.code-add-dropdown-nested {
  width: 100%;
  padding: var(--small) var(--medium);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  border: 1px dashed var(--border);
  border-radius: var(--small);
  /* background: var(--white); */
  background: unset;
  color: var(--primary);
  cursor: pointer;
  /* text-transform: uppercase; */
}

.code-add-dropdown-nested:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: rgba(78, 78, 255, 0.08);
}

/* ============================================================
   PROPS PALETTE
   ============================================================ */

.props-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
  text-align: center;
  flex-wrap: wrap;
  gap: var(--medium);
}

.prop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: var(--small);
  border: 2px solid transparent;
  border-radius: var(--small);
  transition:
    border-color 0.15s,
    background 0.15s;
  user-select: none;
}

.prop-icon:hover {
  border-color: var(--primary);
  background: rgba(77, 76, 217, 0.08);
}

.prop-icon svg {
  width: 40px;
  height: 40px;
  display: block;
}

.prop-icon span {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

/* Props on the SVG canvas */
.draggable-prop {
  cursor: grab;
}

.draggable-prop:active {
  cursor: grabbing;
}

.prop-scale-handle {
  cursor: nwse-resize;
}

.prop-rotate-handle {
  cursor: crosshair;
}

.stage-wrapper.playing .draggable-prop,
.stage-wrapper.playing .prop-scale-handle,
.stage-wrapper.playing .prop-rotate-handle {
  pointer-events: none;
}

/* ================================================
   AUTH — HEADER USER AREA
   ================================================ */

.header-user {
  display: flex;
  align-items: center;
  gap: var(--medium);
}

.class-code-widget {
  display: flex;
  align-items: center;
  gap: 4px;
}

.class-code-input {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--small) var(--medium);
  border: 2px solid var(--border);
  border-radius: var(--small);
  background: var(--white);
  color: var(--black);
  width: 90px;
  outline: none;
  transition: border-color 0.15s;
}

.class-code-input:focus {
  border-color: var(--primary);
}

.class-code-input::placeholder {
  color: var(--black);
  opacity: 0.35;
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
}

/* Badge shown when a class code is active */
.class-code-badge {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: var(--white);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--small) var(--medium);
  border: 2px solid var(--border);
  border-radius: var(--small);
}

.leave-class-btn {
  background: none;
  border: none;
  color: var(--white);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.leave-class-btn:hover {
  opacity: 1;
}

/* Active state: hide input+join, show badge */
.class-code-widget.active .class-code-input {
  display: none;
}

.class-code-widget.active .class-code-badge {
  display: flex;
}

.signout-btn {
  background: none;
  border: 2px solid var(--black);
  color: var(--black);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  cursor: pointer;
  border-radius: var(--small);
  opacity: 0.6;
  transition: opacity 0.15s;
}

.signout-btn:hover {
  opacity: 1;
}

/* ================================================
   AUTH — LOGIN MODAL INPUTS
   ================================================ */

#loginModal input {
  width: 100%;
  padding: var(--medium);
  margin-top: var(--medium);
  font-family: var(--font);
  font-size: 13px;
  border: 2px solid #ccc;
  border-radius: 4px;
  outline: none;
  background: var(--white);
}

#loginModal input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 78, 255, 0.15);
}

/* ================================================
   COMMUNITY / CLASS BLOCKS
   ================================================ */

.community-block-card {
  border-left: 3px solid #a0a0ff;
  cursor: default;
}

.community-block-card:hover {
  border-left-color: var(--primary);
  transform: translateY(-1px);
}

.community-block-card.featured {
  border-left: 3px solid #f5c400;
  background: #fffde7;
}

.block-card-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 1px;
}

.block-card-author {
  font-size: 9px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.use-block-btn {
  flex-shrink: 0;
  background: var(--primary);
  color: var(--white);
  border: none;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.use-block-btn:hover {
  background: var(--white);
  color: var(--primary);
}

.use-block-btn:disabled {
  background: #aaa;
  cursor: default;
}

/* ================================================
   SHARE / AVAILABLE BLOCKS WINDOW ROWS
   ================================================ */

.share-block-row {
  display: flex;
  align-items: center;
  gap: var(--small);
  padding: var(--small) var(--medium);
  background: var(--bg);
  border-radius: var(--small);
  cursor: pointer;
  transition: all 0.15s;
}

.share-block-row:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 78, 255, 0.1);
}

.share-block-row.featured {
  background: rgba(245, 196, 0, 0.15);
}

.share-block-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
