:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #60636a;
  --border: #d8d3c7;
  --accent: #2f6f73;
  --accent-light: #dceced;
  --danger: #8b2f2f;
  --success: #276749;
  --warning: #8a621d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 48px;
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
}

h2 { margin-top: 0; }

.subtitle { margin: 4px 0 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin: 16px 0;
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.input-panel label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.input-row, .button-row, .move-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.move-buttons {
  margin-top: 12px;
}

input {
  flex: 1;
  min-width: 240px;
  font-size: 1.2rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button.move-action {
  background: #f2efe7;
  border: 1px solid var(--border);
  color: var(--ink);
}

button.move-action strong {
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.examples {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.examples button {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #c2dddf;
  font-size: 0.9rem;
}

.note, .message {
  color: var(--muted);
  line-height: 1.45;
}

.message.good {
  color: var(--success);
  font-weight: 700;
}

.message.warn {
  color: var(--danger);
  font-weight: 700;
}

.tile-view {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 90px;
}

.side {
  flex: 1 1 300px;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 12px;
}

.side-title {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.boundary {
  flex: 0 0 auto;
  align-self: stretch;
  min-width: 70px;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--accent);
}

.tile {
  border: 2px solid var(--border);
  border-radius: 14px;
  min-width: 96px;
  padding: 10px 12px;
  background: white;
  position: relative;
}

.tile.negative {
  border-color: #d6b3b3;
  background: #fff7f7;
}

.tile.constant { border-color: #d7c89b; }
.tile.variable { border-color: #a8cad0; }
.tile.absolute { border-color: #bca6d6; background: #fbf8ff; }
.tile.fraction { border-color: #d9b56f; background: #fffaf0; }
.tile.composite { border-color: #ccc; background: #fafafa; }

.tile-label {
  font-size: 1.25rem;
  font-weight: 900;
}

.tile-meta {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.25;
}

.charge {
  position: absolute;
  top: -10px;
  left: -8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: var(--accent);
  color: white;
}

.tile.negative .charge { background: var(--danger); }

.fraction-display {
  display: inline-grid;
  grid-template-rows: auto 2px auto;
  align-items: center;
  justify-items: center;
  min-width: 48px;
  line-height: 1.1;
}

.frac-bar {
  width: 100%;
  height: 2px;
  background: var(--ink);
  margin: 3px 0;
}

.frac-part { font-weight: 900; }

.transformations {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.transform {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fbfaf7;
  max-width: 330px;
}

.transform strong { display: block; margin-bottom: 3px; }
.transform.locked { opacity: 0.55; }
.transform.available { border-color: #9ccdb3; background: #f3fbf6; }
.transform.conditional { border-color: #e0c173; background: #fffaf0; }

.history-list { margin-bottom: 0; }

.history-list li {
  margin-bottom: 6px;
  line-height: 1.35;
}

pre {
  margin: 0;
  padding: 14px;
  background: #1f2328;
  color: #d7e2f0;
  border-radius: 14px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.45;
}


.branch-view {
  display: grid;
  gap: 1rem;
}

.branch-card {
  border: 1px solid rgba(47, 123, 125, 0.25);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(47, 123, 125, 0.05);
}

.branch-card h3 {
  margin-top: 0;
}

.branch-tile-view {
  margin: 0.75rem 0;
}


.tile.product {
  border-color: rgba(111, 85, 159, 0.65);
  background: rgba(111, 85, 159, 0.08);
}

.tile.product .charge {
  background: #6f559f;
}


.tile.factoredGroup {
  border-color: rgba(111, 85, 159, 0.55);
  background: rgba(111, 85, 159, 0.06);
}

.tile.factoredGroup .charge {
  background: #6f559f;
}


.tile {
  cursor: pointer;
}

.tile.selected {
  outline: 4px solid #f5b942;
  box-shadow: 0 0 0 6px rgba(245, 185, 66, 0.18);
  transform: translateY(-2px);
}

.selected-action {
  border-color: rgba(245, 185, 66, 0.9);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.16);
}

.secondary-action {
  opacity: 0.85;
}


.tile.factoredNumber {
  border-color: rgba(47, 123, 125, 0.65);
  background: rgba(47, 123, 125, 0.08);
}

.tile.factoredNumber .charge {
  background: #2f7b7d;
}


.add-both-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 0.85rem;
  border: 1px dashed rgba(47, 123, 125, 0.35);
  border-radius: 0.85rem;
  background: rgba(47, 123, 125, 0.04);
}

.add-both-row label {
  font-weight: 700;
  color: #2f7b7d;
}

.add-both-row input {
  max-width: 10rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(47, 123, 125, 0.35);
  border-radius: 0.6rem;
  font-size: 1rem;
}


.tile.squaredBinomial {
  border-color: rgba(111, 85, 159, 0.75);
  background: rgba(111, 85, 159, 0.10);
}

.tile.squaredBinomial .charge {
  background: #6f559f;
}


.power-both-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 0.85rem;
  border: 1px dashed rgba(111, 85, 159, 0.35);
  border-radius: 0.85rem;
  background: rgba(111, 85, 159, 0.05);
}

.power-both-row label {
  font-weight: 700;
  color: #6f559f;
}

.power-both-row input {
  max-width: 10rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(111, 85, 159, 0.35);
  border-radius: 0.6rem;
  font-size: 1rem;
}

.tile.powerShell {
  border-color: rgba(111, 85, 159, 0.75);
  background: rgba(111, 85, 159, 0.09);
}

.tile.powerShell .charge {
  background: #6f559f;
}


.tile.powerProduct {
  border-color: rgba(245, 185, 66, 0.85);
  background: rgba(245, 185, 66, 0.12);
}

.tile.powerProduct .charge {
  background: #b7791f;
}


.tile.plusMinus {
  border-color: rgba(181, 87, 69, 0.8);
  background: rgba(181, 87, 69, 0.08);
}

.tile.plusMinus .charge {
  background: #b55745;
}


.tile.imaginaryRoot {
  border-color: rgba(65, 92, 180, 0.8);
  background: rgba(65, 92, 180, 0.08);
}

.tile.imaginaryRoot .charge {
  background: #415cb4;
}


/* ===== v1.2.0 classroom-friendly skin ===== */

body {
  background:
    radial-gradient(circle at top left, rgba(47, 111, 115, 0.08), transparent 30%),
    radial-gradient(circle at top right, rgba(65, 92, 180, 0.07), transparent 28%),
    var(--bg);
}

.app {
  width: min(1180px, calc(100% - 24px));
  margin: 20px auto 56px;
}

.hero {
  margin-bottom: 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  width: min(420px, 100%);
  height: auto;
  display: block;
}

.site-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
  background: linear-gradient(135deg, #2f6f73, #415cb4);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(47, 111, 115, 0.18);
}

.site-link-button:hover {
  opacity: 0.95;
}

.hero-copy {
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.85));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.05);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 8px;
}

.subtitle {
  max-width: 850px;
  font-size: 1.05rem;
  line-height: 1.55;
}

.welcome-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,252,0.98));
}

.quick-start-list {
  margin-top: 0.5rem;
  padding-left: 1.3rem;
  line-height: 1.65;
}

.small-note {
  color: var(--muted);
  margin-top: 0;
  line-height: 1.45;
}

.examples-wrap {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(47, 111, 115, 0.03);
}

.examples-title {
  margin: 0 0 10px;
  font-weight: 800;
  color: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 18px 0 8px;
}

.tool-card {
  padding: 14px;
  border: 1px dashed rgba(47, 123, 125, 0.35);
  border-radius: 16px;
  background: rgba(47, 123, 125, 0.04);
}

.tool-card label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
  color: #2f7b7d;
}

.tool-card-purple {
  border-color: rgba(111, 85, 159, 0.35);
  background: rgba(111, 85, 159, 0.05);
}

.tool-card-purple label {
  color: #6f559f;
}

.tool-inline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.tool-inline input {
  max-width: 180px;
  padding: 10px 12px;
  font-size: 1rem;
}

.suggested-moves {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.suggested-moves h3 {
  margin-bottom: 10px;
}

.button-row button {
  box-shadow: 0 8px 18px rgba(47, 111, 115, 0.12);
}

.panel {
  border-radius: 20px;
}

.debug-details summary {
  cursor: pointer;
  font-weight: 800;
  margin-bottom: 12px;
}

.app-footer {
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.88);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-logo {
  width: min(250px, 100%);
  height: auto;
  display: block;
}

.footer-copy p {
  margin: 4px 0;
}

.footer-copy a {
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 720px) {
  .site-link-button {
    width: 100%;
  }

  .hero-copy,
  .panel {
    padding: 16px;
  }

  .tool-inline input {
    max-width: 100%;
  }

  input {
    min-width: 0;
  }
}


/* ===== v1.2.1 fixes ===== */
.button-row button#expandBtn {
  background: linear-gradient(135deg, #2f6f73, #3b7d80);
}

.tile .tile-meta div,
.tile-meta {
  word-break: normal;
}

.tile.fraction {
  box-shadow: inset 0 0 0 1px rgba(217, 181, 111, 0.18);
}


/* ===== v1.2.2 right-click tile properties ===== */

.tile {
  transition: transform 160ms ease, box-shadow 160ms ease, min-width 160ms ease;
}

.tile-meta {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0,0,0,0.12);
}

.tile.properties-revealed {
  min-width: 132px;
}

.tile.properties-revealed .tile-meta {
  display: block;
}

.tile.properties-revealed::after {
  content: "properties";
  position: absolute;
  right: 8px;
  bottom: -10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(47, 111, 115, 0.92);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tile:not(.properties-revealed) .tile-label {
  margin: 2px 0;
}

@media (hover: none) {
  .tile::before {
    content: "hold";
    position: absolute;
    right: 7px;
    top: -10px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(96, 99, 106, 0.16);
    color: var(--muted);
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
  }
}


/* ===== v1.2.3 mobile/landscape tile layout ===== */

.mobile-landscape-banner {
  display: none;
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 185, 66, 0.55);
  border-radius: 14px;
  background: rgba(245, 185, 66, 0.13);
  color: #6b4a0f;
  line-height: 1.35;
}

.tile-view {
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

.side {
  min-width: min(520px, 82vw);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-align: start;
}

.tiles {
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 4px 14px;
  scroll-snap-type: x proximity;
}

.tile {
  flex: 0 0 auto;
  min-width: clamp(72px, 10vw, 120px);
  max-width: clamp(110px, 18vw, 180px);
  padding: clamp(7px, 1.2vw, 12px);
  scroll-snap-align: start;
}

.tile-label {
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.fraction-display {
  min-width: clamp(36px, 7vw, 58px);
}

.boundary {
  position: sticky;
  left: 0;
  right: 0;
  min-width: clamp(44px, 7vw, 70px);
  background: linear-gradient(90deg, rgba(247,245,239,0.92), rgba(247,245,239,0.72));
  z-index: 2;
}

.tile-view::-webkit-scrollbar,
.tiles::-webkit-scrollbar,
.side::-webkit-scrollbar {
  height: 8px;
}

.tile-view::-webkit-scrollbar-thumb,
.tiles::-webkit-scrollbar-thumb,
.side::-webkit-scrollbar-thumb {
  background: rgba(47, 111, 115, 0.32);
  border-radius: 999px;
}

.tile-view::-webkit-scrollbar-track,
.tiles::-webkit-scrollbar-track,
.side::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
  border-radius: 999px;
}

@media (max-width: 760px) {
  .mobile-landscape-banner {
    display: block;
  }

  .app {
    width: min(100% - 12px, 1180px);
    margin-top: 8px;
  }

  .hero-copy,
  .panel {
    padding: 12px;
    border-radius: 16px;
  }

  .tile-view {
    gap: 8px;
  }

  .side {
    min-width: 78vw;
    padding: 10px;
  }

  .tile {
    min-width: clamp(64px, 18vw, 92px);
    max-width: clamp(88px, 26vw, 132px);
  }

  .tile.properties-revealed {
    min-width: clamp(118px, 42vw, 180px);
    max-width: clamp(150px, 58vw, 230px);
  }

  .tile-meta {
    font-size: 0.68rem;
  }

  .boundary {
    min-width: 38px;
    font-size: 2rem;
  }

  .button-row,
  .move-buttons,
  .examples,
  .tool-inline {
    gap: 7px;
  }

  button {
    padding: 9px 11px;
    font-size: 0.88rem;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .mobile-landscape-banner {
    display: block;
    position: sticky;
    top: 6px;
    z-index: 8;
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  }

  .mobile-landscape-banner::after {
    content: " Rotate your phone sideways for the best tile view.";
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  .mobile-landscape-banner {
    display: none;
  }

  .side {
    min-width: 44vw;
  }

  .tile {
    min-width: clamp(62px, 9vw, 96px);
    max-width: clamp(88px, 14vw, 140px);
  }
}


/* ===== v1.2.4 transformations allowed near tile field ===== */

.tile-workspace-panel {
  scroll-margin-top: 12px;
}

.transformations-allowed-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(47, 111, 115, 0.22);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(47, 111, 115, 0.055), rgba(47, 111, 115, 0.025));
}

.transformations-allowed-panel h3 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 1.12rem;
}

.transformations-allowed-panel .move-buttons {
  margin-top: 10px;
}

.transformations-allowed-panel:has(.move-action) {
  border-color: rgba(47, 111, 115, 0.34);
}

@media (max-width: 760px) {
  .transformations-allowed-panel {
    margin-top: 12px;
    padding: 12px;
    position: relative;
  }

  .transformations-allowed-panel h3 {
    font-size: 1rem;
  }

  .transformations-allowed-panel .small-note {
    font-size: 0.86rem;
  }

  .transformations-allowed-panel .move-action {
    width: 100%;
    text-align: left;
  }
}


/* ===== v1.2.5 student layout + no tile properties ===== */

.tile-meta,
.tile.properties-revealed .tile-meta {
  display: none !important;
}

.tile.properties-revealed::after,
.tile::before {
  content: none !important;
}

.tile {
  cursor: pointer;
}

.tile-workspace-panel {
  border-color: rgba(47, 111, 115, 0.28);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,252,0.98));
}

.tile-workspace-panel .tile-view {
  margin-top: 12px;
  margin-bottom: 12px;
}

.core-actions-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(47, 111, 115, 0.20);
  border-radius: 16px;
  background: rgba(47, 111, 115, 0.035);
}

.core-actions-panel h3,
.advanced-action-tools h3 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 1.12rem;
}

.core-actions-panel .button-row {
  margin-top: 10px;
}

.advanced-action-tools {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed rgba(96, 99, 106, 0.22);
  border-radius: 16px;
  background: rgba(96, 99, 106, 0.025);
}

.action-panel {
  display: none;
}

.tile-label {
  text-align: center;
}

@media (max-width: 760px) {
  .core-actions-panel,
  .advanced-action-tools,
  .transformations-allowed-panel {
    padding: 10px;
  }

  .core-actions-panel .button-row button,
  .transformations-allowed-panel .move-action {
    width: 100%;
    text-align: left;
  }

  .advanced-action-tools {
    margin-top: 18px;
  }
}


/* ===== v1.3.0 drag + snap manipulative layer ===== */

.drag-instructions {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(65, 92, 180, 0.22);
  border-radius: 14px;
  background: rgba(65, 92, 180, 0.055);
  color: #2b376f;
  line-height: 1.4;
}

.tile {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.tile:active {
  cursor: grabbing;
}

.dragging-tile {
  cursor: grabbing;
}

.tile.dragging-source {
  opacity: 0.38;
  transform: scale(0.96);
}

.drag-ghost {
  opacity: 0.94;
  pointer-events: none;
  transform: rotate(-1deg) scale(1.04);
  box-shadow: 0 18px 38px rgba(0,0,0,0.18);
}

.whole-tile-ghost {
  background: white;
}

.ghost-charge-flipped {
  border-color: rgba(181, 87, 69, 0.88) !important;
}

.ghost-charge-flipped .charge {
  background: #b55745 !important;
}

.side {
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.side.drop-additive {
  border-color: rgba(181, 87, 69, 0.75);
  background: rgba(181, 87, 69, 0.06);
  box-shadow: inset 0 0 0 2px rgba(181, 87, 69, 0.14);
}

.tile.drag-preview-additive {
  border-color: rgba(181, 87, 69, 0.85);
  box-shadow: 0 0 0 5px rgba(181, 87, 69, 0.14);
}

.tile.drag-preview-denominator {
  border-color: rgba(217, 181, 111, 0.95);
  box-shadow: 0 0 0 5px rgba(217, 181, 111, 0.18);
}

.denominator-drop-zone {
  margin-top: 10px;
  min-height: 34px;
  border: 1px dashed rgba(217, 181, 111, 0.58);
  border-radius: 12px;
  background: rgba(217, 181, 111, 0.08);
  display: grid;
  place-items: center;
  color: #7a5516;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.72;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.denominator-drop-zone.active {
  opacity: 1;
  border-color: rgba(217, 181, 111, 0.95);
  background: rgba(217, 181, 111, 0.2);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(217, 181, 111, 0.16);
}

.denominator-drop-zone span {
  pointer-events: none;
}

.factor-handle {
  position: absolute;
  top: -12px;
  right: -10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid rgba(217, 181, 111, 0.88);
  background: #fffaf0;
  color: #7a5516;
  font-size: 0.66rem;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  cursor: grab;
  z-index: 3;
}

.factor-handle span {
  text-transform: uppercase;
  font-weight: 800;
  font-size: 0.55rem;
  letter-spacing: 0.04em;
}

.factor-handle strong {
  font-size: 0.8rem;
}

.factor-handle:active {
  cursor: grabbing;
}

.factor-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  border: 2px solid rgba(217, 181, 111, 0.95);
  background: #fffaf0;
  color: #7a5516;
  font-weight: 900;
}

.factor-ghost span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 760px) {
  .drag-instructions {
    font-size: 0.86rem;
    padding: 9px 10px;
  }

  .denominator-drop-zone {
    min-height: 38px;
    font-size: 0.62rem;
  }

  .factor-handle {
    top: -10px;
    right: -6px;
    padding: 4px 6px;
  }
}


/* ===== v1.3.1 drag-combine like terms ===== */

.tile.drop-combine-target {
  border-color: rgba(39, 103, 73, 0.9);
  background: rgba(39, 103, 73, 0.08);
  box-shadow:
    0 0 0 5px rgba(39, 103, 73, 0.16),
    0 12px 22px rgba(39, 103, 73, 0.12);
  transform: translateY(-2px);
}

.tile.drag-preview-combine {
  border-color: rgba(39, 103, 73, 0.9);
  box-shadow: 0 0 0 5px rgba(39, 103, 73, 0.13);
}

.tile.drop-combine-target::after {
  content: "combine";
  position: absolute;
  right: 8px;
  bottom: -10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(39, 103, 73, 0.94);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .tile.drop-combine-target::after {
    font-size: 0.55rem;
    bottom: -9px;
  }
}


/* ===== v1.3.3 literal equation mode ===== */

.literal-mode-toggle {
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(65, 92, 180, 0.24);
  border-radius: 14px;
  background: rgba(65, 92, 180, 0.055);
  color: #2b376f;
  line-height: 1.35;
}

.literal-mode-toggle input {
  min-width: 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex: 0 0 auto;
}

.literal-factor-handles {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: nowrap;
  margin-top: 8px;
}

.literal-factor-handle {
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid rgba(217, 181, 111, 0.88);
  background: #fffaf0;
  color: #7a5516;
  font-size: 0.78rem;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  cursor: grab;
}

.literal-factor-handle:active {
  cursor: grabbing;
}


/* ===== v1.3.4 distinguished magic workspace stage ===== */

.tile-workspace-panel {
  position: relative;
  width: min(1380px, calc(100vw - 24px));
  margin-left: 50%;
  transform: translateX(-50%);
  padding: clamp(14px, 2vw, 24px);
  border: 2px solid rgba(31, 88, 93, 0.42);
  background:
    radial-gradient(circle at 12% 8%, rgba(66, 142, 148, 0.10), transparent 24%),
    linear-gradient(180deg, rgba(248, 252, 252, 0.99), rgba(237, 245, 245, 0.99));
  box-shadow: 0 28px 70px rgba(26, 67, 71, 0.16);
  overflow: visible;
}

.workspace-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 14px;
}

.workspace-section-heading h2 {
  margin-bottom: 4px;
}

.workspace-focus-hint {
  max-width: 360px;
  margin: 0;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 115, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
}

.workspace-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: clamp(430px, 54vh, 680px);
  border: 3px solid #24565a;
  border-radius: 26px;
  overflow: hidden;
  background: #f9fbf7;
  box-shadow:
    0 22px 54px rgba(22, 61, 64, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  isolation: isolate;
}

.workspace-stage-header {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 16px;
  color: #fff;
  background:
    linear-gradient(90deg, #183f43, #27666b 58%, #397d82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.workspace-stage-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.workspace-stage-kicker {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.workspace-stage-title strong {
  font-size: clamp(1rem, 1.8vw, 1.28rem);
  letter-spacing: -0.01em;
}

.workspace-focus-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 900;
  box-shadow: none;
  backdrop-filter: blur(6px);
}

.workspace-focus-button:hover,
.workspace-focus-button:focus-visible {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.82);
}

.workspace-focus-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.workspace-stage-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(12px, 2vw, 22px);
  background-color: #f8faf6;
  background-image:
    linear-gradient(rgba(47, 111, 115, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 111, 115, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.95), rgba(248,250,246,0.80) 62%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
}

.workspace-stage .drag-instructions {
  flex: 0 0 auto;
  margin: 0 0 14px;
  border-color: rgba(47, 111, 115, 0.30);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 18px rgba(28, 73, 76, 0.07);
}

.workspace-stage .tile-view {
  flex: 1 1 auto;
  min-height: clamp(280px, 38vh, 500px);
  margin: 0;
  padding: clamp(12px, 2vw, 24px) 4px 16px;
  align-items: stretch;
  outline: none;
}

.workspace-stage .side {
  min-height: clamp(230px, 32vh, 430px);
  padding: clamp(13px, 2vw, 22px);
  border: 2px dashed rgba(47, 111, 115, 0.34);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 0 34px rgba(47, 111, 115, 0.035);
}

.workspace-stage .tiles {
  min-height: 120px;
  flex: 1 1 auto;
  align-items: center;
  padding-top: 18px;
  padding-bottom: 22px;
}

.workspace-stage .boundary {
  min-height: clamp(230px, 32vh, 430px);
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(248,250,246,0.78), rgba(255,255,255,0.96), rgba(248,250,246,0.78));
}

.workspace-message {
  flex: 0 0 auto;
  min-height: 46px;
  margin: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(47, 111, 115, 0.18);
  background: rgba(255, 255, 255, 0.96);
}

body.workspace-focus {
  overflow: hidden;
}

body.workspace-focus .tile-workspace-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  transform: none;
  padding: clamp(8px, 1.5vw, 18px);
  border: 0;
  border-radius: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: #eaf2f2;
  box-shadow: none;
  overscroll-behavior: contain;
}

body.workspace-focus .workspace-section-heading {
  margin-bottom: 8px;
  padding-right: 148px;
}

body.workspace-focus .workspace-focus-hint {
  display: none;
}

body.workspace-focus .workspace-stage {
  min-height: min(76dvh, 820px);
  border-radius: 20px;
}

body.workspace-focus .workspace-focus-button {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10020;
  background: #8f3e33;
  border-color: rgba(255,255,255,0.74);
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

body.workspace-focus .workspace-stage .tile-view {
  min-height: 52dvh;
}

body.workspace-focus .workspace-stage .side,
body.workspace-focus .workspace-stage .boundary {
  min-height: 45dvh;
}

@media (max-width: 760px) {
  .tile-workspace-panel {
    width: calc(100vw - 8px);
    padding: 8px;
    border-radius: 18px;
  }

  .workspace-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 4px 4px 0;
  }

  .workspace-focus-hint {
    max-width: none;
    width: 100%;
    border-radius: 12px;
    text-align: left;
  }

  .workspace-stage {
    min-height: max(480px, 66dvh);
    border-width: 2px;
    border-radius: 18px;
  }

  .workspace-stage-header {
    padding: 10px;
    gap: 8px;
  }

  .workspace-stage-kicker {
    font-size: 0.58rem;
  }

  .workspace-stage-title strong {
    font-size: 0.94rem;
  }

  .workspace-focus-button {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .workspace-stage-body {
    padding: 9px;
  }

  .workspace-stage .drag-instructions {
    margin-bottom: 8px;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .workspace-stage .tile-view {
    min-height: 340px;
    padding-top: 8px;
  }

  .workspace-stage .side {
    min-height: 300px;
    min-width: 84vw;
    padding: 12px 9px;
  }

  .workspace-stage .boundary {
    min-height: 300px;
  }

  .workspace-stage .tiles {
    min-height: 160px;
    padding-top: 24px;
    padding-bottom: 26px;
  }

  .workspace-message {
    min-height: 42px;
    padding: 10px;
    font-size: 0.84rem;
  }

  body.workspace-focus .tile-workspace-panel {
    width: 100vw;
    padding: 6px;
  }

  body.workspace-focus .workspace-section-heading {
    padding-right: 116px;
  }

  body.workspace-focus .workspace-section-heading .small-note {
    display: none;
  }

  body.workspace-focus .workspace-stage {
    min-height: 78dvh;
    border-radius: 14px;
  }

  body.workspace-focus .workspace-stage-header {
    min-height: 52px;
    padding-right: 122px;
  }

  body.workspace-focus .workspace-focus-button {
    top: 8px;
    right: 8px;
  }

  body.workspace-focus .workspace-stage .tile-view {
    min-height: 58dvh;
  }

  body.workspace-focus .workspace-stage .side,
  body.workspace-focus .workspace-stage .boundary {
    min-height: 51dvh;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .workspace-stage {
    min-height: 74dvh;
  }

  .workspace-stage .side,
  .workspace-stage .boundary {
    min-height: 46dvh;
  }

  body.workspace-focus .workspace-stage {
    min-height: 92dvh;
  }

  body.workspace-focus .workspace-stage .tile-view {
    min-height: 63dvh;
  }

  body.workspace-focus .workspace-stage .side,
  body.workspace-focus .workspace-stage .boundary {
    min-height: 57dvh;
  }
}


/* ===== v1.3.5 beta feedback + support ===== */

.beta-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.beta-status-line .eyebrow {
  margin-bottom: 0;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f0a623;
  color: #2d2416;
  border: 1px solid rgba(80, 55, 10, 0.18);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
}

.beta-badge-large {
  padding: 9px 12px;
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.beta-feedback-panel {
  border: 1px solid rgba(47, 111, 115, 0.24);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,251,251,0.98));
}

.feedback-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.feedback-lead {
  max-width: 850px;
  line-height: 1.6;
}

.feedback-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(47, 111, 115, 0.14);
}

.feedback-form label {
  display: block;
  font-weight: 800;
  color: var(--text);
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.feedback-form input,
.feedback-form select,
.feedback-form textarea {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}

.feedback-form textarea {
  resize: vertical;
  min-height: 125px;
  margin-bottom: 14px;
}

.feedback-grid + label {
  margin-top: 14px;
}

.optional-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.feedback-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
}

.secondary-link-button,
.venmo-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 800;
}

.secondary-link-button {
  border: 1px solid var(--border);
  background: white;
  color: var(--accent);
}

.feedback-status {
  margin: 12px 0 0;
}

.support-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 320px);
  gap: 24px;
  align-items: center;
  border: 1px solid rgba(217, 181, 111, 0.40);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(255,249,237,0.96));
}

.support-copy p {
  max-width: 760px;
  line-height: 1.6;
}

.venmo-link-button {
  margin-top: 4px;
  background: linear-gradient(135deg, #2f6f73, #415cb4);
  color: white;
  box-shadow: 0 8px 18px rgba(47, 111, 115, 0.14);
}

.support-no-pressure {
  color: var(--muted);
  font-size: 0.94rem;
}

.venmo-qr-card {
  display: block;
  padding: 12px;
  border: 1px solid rgba(47, 111, 115, 0.20);
  border-radius: 18px;
  background: white;
  text-decoration: none;
  color: var(--text);
  text-align: center;
}

.venmo-qr-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.venmo-qr-card span {
  display: block;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent);
}

@media (max-width: 760px) {
  .feedback-heading-row {
    display: block;
  }

  .feedback-heading-row .beta-badge-large {
    margin-top: 4px;
  }

  .feedback-grid {
    grid-template-columns: 1fr;
  }

  .support-panel {
    grid-template-columns: 1fr;
  }

  .venmo-qr-card {
    width: min(320px, 100%);
    margin: 0 auto;
  }

  .feedback-actions > * {
    width: 100%;
  }
}
