:root {
  --bg: #f3efe4;
  --panel: #fffdf6;
  --ink: #221f1a;
  --muted: #6d675f;
  --accent: #0f7a64;
  --warn: #b3261e;
  --line: #d6cec2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #fff9ea 0%, var(--bg) 55%, #ece5d5 100%);
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  min-height: 100vh;
}

.panel {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fffef9, var(--panel));
  padding: 16px;
  overflow: auto;
}

.panel h1 {
  margin: 0 0 14px;
  font-size: 1.5rem;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.panel section {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

input,
select,
button {
  width: 100%;
  margin-top: 4px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  background: #fffcf3;
}

button {
  border: none;
  border-radius: 8px;
  padding: 9px;
  margin-bottom: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

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

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline input {
  width: auto;
  margin: 0;
}

.split-controls,
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row button {
  margin-bottom: 8px;
}

#deleteSheetBtn {
  background: #8c221d;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  padding: 14px;
}

.parts-panel {
  border-left: 1px solid var(--line);
  border-right: none;
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.part-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.part-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(15, 122, 100, 0.25);
}

.part-item.overlap {
  border-color: rgba(179, 38, 30, 0.8);
  background: rgba(179, 38, 30, 0.12);
}

.part-select {
  flex: 1;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}

.part-select:hover {
  text-decoration: underline;
}

.part-trash {
  width: 28px;
  height: 28px;
  min-width: 28px;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #8c221d;
}

.part-trash svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.parts-empty {
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.score-line {
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid rgba(15, 122, 100, 0.25);
  border-radius: 8px;
  background: rgba(15, 122, 100, 0.08);
  color: var(--ink);
  font-size: 0.86rem;
}

#nestCanvas {
  width: 100%;
  height: calc(100vh - 28px);
  border-radius: 12px;
  border: 1px solid #c8c0b4;
  background: repeating-linear-gradient(
      0deg,
      rgba(145, 138, 125, 0.07) 0,
      rgba(145, 138, 125, 0.07) 1px,
      transparent 1px,
      transparent 24px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(145, 138, 125, 0.07) 0,
      rgba(145, 138, 125, 0.07) 1px,
      transparent 1px,
      transparent 24px
    ),
    #fff;
}

.status {
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.import-warnings {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.import-warnings summary {
  cursor: pointer;
  color: var(--ink);
}

.import-warnings ul {
  margin: 8px 0 0;
  padding-left: 18px;
  max-height: 180px;
  overflow: auto;
}

.import-warnings li {
  margin-bottom: 5px;
}

.note {
  margin: 0 0 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .parts-panel {
    border-left: none;
  }

  #nestCanvas {
    height: 60vh;
  }
}
