:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.app {
  width: min(1480px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0;
}

.panel {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  padding: 20px;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(20, 32, 54, 0.08);
}

.eyebrow {
  margin: 0 0 8px;
  color: #5272ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.hint,
.settings p,
.status {
  color: #6b7488;
}

.hint {
  max-width: 560px;
  margin-bottom: 0;
}

.controls,
.quick-split {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.quick-split {
  align-items: center;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
}

.quick-split label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #f2f4f8;
}

.quick-split input {
  width: 58px;
  border: 1px solid #d8deea;
  border-radius: 10px;
  padding: 5px 7px;
}

button,
.file-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: #e9edff;
  color: #263b91;
  font-weight: 700;
  cursor: pointer;
}

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

.file-button {
  background: #5272ff;
  color: #ffffff;
}

.file-button input {
  display: none;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #f2f4f8;
  font-weight: 700;
}

.settings {
  width: 100%;
  max-width: 360px;
  font-size: 14px;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.settings input[type="range"] {
  flex: 1;
}

.settings p {
  margin: 8px 0 0;
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  margin-top: 16px;
  height: calc(100vh - 190px);
  min-height: 520px;
}

.canvas-wrap,
.output {
  min-height: 0;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(20, 32, 54, 0.08);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 20px;
  border: 2px dashed transparent;
}

.canvas-wrap.dragging {
  border-color: #5272ff;
  background: #f7f9ff;
}

canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 960px);
  max-height: calc(100vh - 250px);
  border-radius: 12px;
  cursor: crosshair;
  object-fit: contain;
}

.empty-state {
  position: absolute;
  color: #8992a6;
  font-weight: 700;
  pointer-events: none;
}

.output {
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.status {
  margin-bottom: 16px;
  line-height: 1.5;
}

.pieces {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.piece {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e6e9f2;
  border-radius: 16px;
  background-image:
    linear-gradient(45deg, #edf0f5 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f5 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f5 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.piece img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 10px;
}

.piece a {
  color: #263b91;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 900px) {
  .panel,
  .workspace {
    display: block;
  }

  .controls,
  .quick-split {
    justify-content: flex-start;
    margin-top: 20px;
  }

  .settings {
    margin-top: 16px;
  }

  .output {
    margin-top: 24px;
    max-height: 520px;
  }
}
