@font-face {
  font-family: Manrope;
  src: url("/fonts/manrope-cyrillic-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Manrope;
  src: url("/fonts/manrope-cyrillic-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Manrope;
  src: url("/fonts/manrope-cyrillic-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
:root {
  --canvas: #f7f8f5;
  --linen: #e9edf0;
  --ink: #202832;
  --muted: #6e7985;
  --blue: #315f82;
  --blue-pale: #dce8ef;
  --thread: #ed2f68;
  --line: #cdd5da;
  --panel: #fff;
  --mono: "IBM Plex Mono", monospace;
  --panel-edge-size: 34px;
}
* {
  box-sizing: border-box;
}
html,
body,
#app {
  min-height: 100%;
  margin: 0;
}
body {
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--linen);
  font-size: 14px;
}
button,
input,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(49, 95, 130, 0.28);
  outline-offset: 2px;
}
.app-shell {
  min-height: 100vh;
}
.brand {
  display: flex;
  gap: 11px;
  align-items: center;
}
.brand svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
}
.brand svg .accent {
  stroke: var(--thread);
}
.brand > div {
  display: flex;
  flex-direction: column;
}
.brand strong {
  font-size: 19px;
  line-height: 1;
}
.brand span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.settings-brand {
  margin: -20px -20px 18px;
  padding: 16px 20px 17px;
  border-bottom: 1px solid var(--line);
}
.settings-brand .brand {
  gap: 10px;
  align-items: flex-start;
}
.settings-brand .brand svg {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}
.settings-brand .brand > div {
  min-width: 0;
}
.settings-brand .brand strong {
  font-size: 17px;
  line-height: 1.15;
}
.settings-brand .brand span {
  font-size: 10px;
}
.panel-local-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.settings .panel-local-header {
  margin: 0 -20px 18px;
  padding: 0 20px;
}
.inspector .panel-local-header {
  padding: 0 18px;
}
.panel-edges {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
.panel-edge {
  position: absolute;
  top: 10px;
  width: var(--panel-edge-size);
  height: var(--panel-edge-size);
  border: 1px solid #9fb2c0;
  background: var(--panel);
  color: var(--thread);
  box-shadow: 0 3px 12px rgba(43, 57, 66, 0.18);
  cursor: pointer;
  font: 22px/1 var(--mono);
  display: grid;
  place-items: center;
  padding: 0;
  text-align: center;
  pointer-events: auto;
}
.panel-edge.left {
  left: 0;
  border-left: 0;
}
.panel-edge.right {
  right: 0;
  border-right: 0;
}
.workspace {
  display: grid;
  grid-template-columns: 292px minmax(420px, 1fr) 320px;
  min-height: 100vh;
}
.workspace.left-hidden {
  grid-template-columns: minmax(420px, 1fr) 320px;
}
.workspace.right-hidden {
  grid-template-columns: 292px minmax(420px, 1fr);
}
.workspace.left-hidden.right-hidden {
  grid-template-columns: minmax(420px, 1fr);
}
.workspace.left-hidden .settings,
.workspace.right-hidden .inspector {
  display: none;
}
.settings,
.inspector {
  background: var(--panel);
  height: 100vh;
  position: sticky;
  top: 0;
}
.settings {
  padding: 20px;
  border-right: 1px solid var(--line);
  overflow: auto;
}
.inspector {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.upload-card {
  height: 154px;
  border: 1px dashed #9aa8b2;
  background: #f6f8f8;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.upload-card.drag-over {
  border-color: var(--thread);
  background: #eef3f4;
}
.upload-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-empty {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--muted);
  gap: 8px;
  padding-bottom: 24px;
}
.upload-empty strong {
  color: var(--ink);
  font-size: 13px;
}
.thread-loop {
  font-size: 31px;
  line-height: 1;
  color: var(--thread);
  font-weight: 400;
}
.upload-action {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 9px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #bcc7ce;
  padding: 7px 10px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  backdrop-filter: blur(5px);
}
.upload-action input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.control-group {
  padding: 18px 0;
  border-bottom: 1px solid #d9e0e4;
}
.control-group h2 {
  font-size: 14px;
  margin: 0 0 12px;
  font-weight: 700;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 11px;
  color: #45515d;
  font-size: 13px;
}
.field > span {
  font-weight: 600;
}
.field small {
  color: var(--muted);
  font-size: 11px;
}
.field input,
.field select {
  width: 100%;
  height: 38px;
  border: 1px solid #bfc9cf;
  background: #fbfcfa;
  padding: 0 10px;
  border-radius: 2px;
  color: var(--ink);
}
.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e9eef0;
  padding: 3px;
}
.segmented button,
.panel-tabs button {
  border: 0;
  background: transparent;
  color: #65727f;
  cursor: pointer;
}
.segmented button {
  padding: 8px 6px;
  font-size: 12px;
}
.segmented .active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(34, 45, 55, 0.12);
  font-weight: 600;
}
.toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 18px;
}
.option-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.toggle {
  display: flex;
  gap: 9px;
  align-items: center;
  cursor: pointer;
  color: #3d4954;
  font-size: 13px;
}
.toggle input {
  position: absolute;
  opacity: 0;
}
.switch {
  width: 29px;
  height: 17px;
  border-radius: 20px;
  background: #bfc9cf;
  position: relative;
  transition: background 0.15s;
}
.switch:after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}
.toggle input:checked + .switch {
  background: var(--blue);
}
.toggle input:checked + .switch:after {
  transform: translateX(12px);
}
.advanced {
  margin-top: 15px;
}
.advanced summary {
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
}
.primary-action,
.secondary-action {
  border: 0;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}
.primary-action {
  width: 100%;
  height: 43px;
  margin-top: 18px;
  background: var(--ink);
  color: white;
  position: sticky;
  bottom: 0;
  box-shadow: 0 -9px 0 var(--panel);
}
.primary-action:hover {
  background: #34404d;
}
.primary-action:disabled,
.secondary-action:disabled {
  opacity: 0.55;
  cursor: wait;
}
.secondary-action {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--blue);
  border: 1px solid #9fb2c0;
  background: #f7fafb;
  font-size: 12px;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error-message {
  font-size: 11px;
  color: #b61f4d;
  background: #fff0f4;
  padding: 8px;
  margin: 9px 0 0;
}
.pattern-stage {
  min-width: 0;
  background: #dfe5e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  position: sticky;
  top: 0;
}
.canvas-toolbar {
  height: 54px;
  padding: 0 calc(16px + var(--panel-edge-size));
  background: #f7f8f5;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.canvas-toolbar > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 9px;
}
.canvas-toolbar strong {
  font-family: var(--mono);
  font-size: 13px;
}
.canvas-toolbar span {
  font-size: 11px;
  color: var(--muted);
}
.toolbar-actions,
.zoom-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zoom-control input {
  width: 92px;
  accent-color: var(--blue);
}
.zoom-control b {
  font: 10px var(--mono);
  width: 34px;
}
.icon-button {
  border: 1px solid #b9c4ca;
  background: white;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: #667581;
}
.icon-button.active {
  background: var(--blue-pale);
  color: var(--blue);
  border-color: #91aabd;
}
.pattern-scroll {
  flex: 1;
  overflow: auto;
  cursor: grab;
  padding: 18px;
  min-height: 420px;
  user-select: none;
}
.pattern-scroll:active {
  cursor: grabbing;
}
.pattern-scroll canvas {
  display: block;
  background: var(--canvas);
  box-shadow: 0 2px 16px rgba(43, 57, 66, 0.12);
  cursor: crosshair;
}
.metric-strip {
  height: 62px;
  background: #f7f8f5;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.metric-strip > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 14px;
  border-right: 1px solid #d7dee2;
}
.metric-strip b {
  font: 600 14px var(--mono);
}
.metric-strip span {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}
.empty-workspace {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  max-width: 620px;
  margin: auto;
}
.mini-grid {
  width: 220px;
  height: 220px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  border-top: 1px solid #aab8c1;
  border-left: 1px solid #aab8c1;
  transform: rotate(-3deg);
  box-shadow: 8px 9px 0 rgba(49, 95, 130, 0.08);
}
.mini-grid i {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid #aab8c1;
  border-bottom: 1px solid #aab8c1;
  background: #f7f8f5;
}
.mini-grid i.marked {
  background: var(--thread);
  position: relative;
}
.mini-grid i.marked:after {
  content: "×";
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 21px;
  line-height: 1;
  font-style: normal;
  transform: translateY(-1px);
}
.empty-workspace p {
  line-height: 1.65;
  color: #5b6874;
  max-width: 540px;
  margin: 29px 0 0;
}
.panel-tabs {
  height: 54px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0 8px;
}
.panel-tabs button {
  font-size: 12px;
  border-bottom: 2px solid transparent;
}
.panel-tabs .active {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--thread);
}
.panel-content {
  padding: 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.route-content .panel-heading {
  margin: 0 0 5px;
}
.route-content .route-method {
  padding: 9px 0;
}
.route-content .route-empty {
  padding: 6px 0;
}
.route-content .step-control {
  margin: 10px 0;
}
.route-content .route-stats div {
  padding: 8px 5px;
}
.route-content .segment-list {
  margin-top: 8px;
}
.route-content .segment-list > div {
  padding: 5px 0;
}
.material-hero {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #dbe1e4;
}
.canvas-swatch {
  width: 50px;
  height: 50px;
  border: 1px solid #b7c1c6;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.25);
  background-image: linear-gradient(
    45deg,
    transparent 48%,
    rgba(90, 90, 90, 0.12) 49%,
    rgba(90, 90, 90, 0.12) 51%,
    transparent 52%
  );
}
.material-hero > div:last-child {
  display: flex;
  flex-direction: column;
}
.material-hero span,
.material-hero small {
  font-size: 11px;
  color: var(--muted);
}
.material-hero strong {
  font-size: 13px;
  margin: 3px 0;
}
.needle-line,
.route-method {
  display: flex;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid #dbe1e4;
  font-size: 12px;
}
.needle-line span,
.route-method span {
  color: var(--muted);
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 9px;
}
.panel-heading h3 {
  margin: 0;
  font-size: 13px;
}
.panel-heading span {
  font-size: 10px;
  color: var(--muted);
}
.thread-list,
.color-list {
  display: flex;
  flex-direction: column;
}
.thread-row {
  height: 36px;
  display: grid;
  grid-template-columns: 14px 1fr auto 46px;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid #edf0f1;
  font-size: 11px;
}
.thread-row i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.thread-row b {
  font-family: var(--mono);
  font-size: 10px;
}
.thread-row em {
  font-style: normal;
  text-align: right;
  color: var(--muted);
}
.color-list {
  padding: 11px;
}
.stitch-legend {
  margin: -2px 0 12px;
  padding: 0 0 10px 4px;
  border-bottom: 1px solid #dbe1e4;
}
.stitch-legend summary {
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  list-style-position: outside;
  padding: 3px 0;
}
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 9px;
}
.legend-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.legend-mark {
  width: 24px;
  height: 24px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #b7c3ca;
  background: #e0e7ea;
  color: var(--ink);
  font: 10px var(--mono);
}
.legend-mark.half-forward {
  background: linear-gradient(135deg, #d4dfe4 0 50%, transparent 50%);
}
.legend-mark.half-backward {
  background: linear-gradient(45deg, #d4dfe4 0 50%, transparent 50%);
}
.legend-mark.blend::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 46%, var(--blue) 47% 53%, transparent 54%);
}
.legend-mark.backstitch {
  background: transparent;
  border-color: transparent;
}
.legend-mark.backstitch::before,
.legend-mark.route::before {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 10px;
  height: 3px;
  transform: rotate(-25deg);
  background: var(--ink);
}
.legend-mark.route {
  background: transparent;
  border-color: transparent;
}
.legend-mark.route::before {
  background: var(--thread);
  height: 4px;
  transform: rotate(18deg);
}
.legend-mark.selection {
  background: rgba(237, 47, 104, 0.12);
  border: 2px solid var(--thread);
}
.legend-divider {
  height: 1px;
  margin: 3px 0 1px;
  background: #edf0f1;
}
.inspector > .color-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.color-row {
  display: grid;
  grid-template-columns: 34px 1fr 32px 20px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid #e5e9eb;
  background: white;
  padding: 7px 5px;
  text-align: left;
  cursor: pointer;
}
.color-row:hover,
.color-row.selected {
  background: #edf3f6;
}
.color-row.hidden {
  opacity: 0.45;
}
.swatch {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  color: white;
  text-shadow: 0 1px 2px #000;
}
.color-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.color-copy strong {
  font: 10px var(--mono);
}
.color-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
}
.count,
.eye {
  font: 10px var(--mono);
  color: var(--muted);
}
.eye {
  font-size: 11px;
  padding: 5px;
}
.route-empty {
  padding: 18px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.route-empty .secondary-action {
  width: 100%;
  margin-top: 12px;
}
.step-control {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 15px 0;
  font-size: 10px;
  color: var(--muted);
}
.step-control input {
  width: 100%;
  accent-color: var(--thread);
}
.route-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #d8dfe2;
}
.route-stats div {
  padding: 10px 5px;
  display: flex;
  flex-direction: column;
  text-align: center;
  border-right: 1px solid #d8dfe2;
}
.route-stats div:last-child {
  border: 0;
}
.route-stats b {
  font: 11px var(--mono);
}
.route-stats span {
  font-size: 8px;
  color: var(--muted);
  margin-top: 3px;
}
.segment-list {
  margin-top: 12px;
}
.segment-list > div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #e4e9eb;
  font-size: 10px;
}
.segment-list span {
  color: var(--muted);
}
.export-actions {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.text-link {
  color: var(--blue);
  text-align: center;
  font-size: 10px;
}
.intro-panel {
  padding: 25px;
}
.intro-panel h2 {
  font-size: 16px;
}
.intro-panel ol {
  padding-left: 22px;
  color: #566471;
  line-height: 2.2;
  font-size: 12px;
}
@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 260px minmax(380px, 1fr);
  }
  .workspace.left-hidden {
    grid-template-columns: minmax(380px, 1fr);
  }
  .workspace.right-hidden {
    grid-template-columns: 260px minmax(380px, 1fr);
  }
  .workspace.left-hidden.right-hidden {
    grid-template-columns: minmax(380px, 1fr);
  }
  .inspector {
    grid-column: 1/-1;
    border-left: 0;
    border-top: 1px solid var(--line);
    min-height: 280px;
  }
  .settings,
  .inspector {
    position: static;
    height: auto;
  }
  .pattern-stage {
    position: relative;
    height: auto;
  }
  .intro-panel {
    display: none;
  }
  .panel-content {
    max-height: 390px;
  }
}
@media (max-width: 720px) {
  .panel-edge {
    top: 0;
  }
  .workspace {
    display: flex;
    flex-direction: column;
  }
  .settings {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .upload-card {
    height: 190px;
  }
  .pattern-stage {
    min-height: 560px;
  }
  .canvas-toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px var(--panel-edge-size);
  }
  .zoom-control > span {
    display: none;
  }
  .metric-strip {
    height: 58px;
  }
  .inspector {
    min-height: 360px;
  }
  .empty-workspace {
    padding: 42px 22px;
  }
  .mini-grid {
    width: min(220px, 62vw);
    height: min(220px, 62vw);
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
