:root {
  --ink: #111111;
  --muted: #666666;
  --line: #dddddd;
  --soft: #f7f7f7;
  --paper: #ffffff;
  --accent: #111111;
  --accent-soft: #eeeeee;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "Noto Sans SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 80% 8%, rgba(0, 0, 0, 0.035), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  border-right: 1px solid #e3e3e3;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid #dcdcdc;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.pokemon-buddy span,
.kirby-mark span {
  position: absolute;
  display: block;
}

.panel,
.canvas-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.04);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
  color: #101828;
  font-weight: 800;
}

.panel-title svg,
.canvas-head svg,
.status-pill svg,
button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 172px;
  padding: 22px;
  border: 1px dashed #cfcfcf;
  border-radius: 8px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(45deg, #f6f6f6 0 10px, #fff 10px 20px) border-box;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  transform: translateY(-2px);
  border-color: #111111;
  background: #fcfcfd;
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 50%;
  color: #fff;
  background: #111111;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}

.drop-zone strong {
  font-size: 16px;
}

.drop-zone small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.control {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.control:first-of-type {
  margin-top: 0;
}

.control > span,
.toggle b {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.control strong {
  justify-self: end;
  margin-top: -26px;
  color: #101828;
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: #111111;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  color: var(--ink);
  background: #fcfcfd;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #f8fafc;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  color: #667085;
  background: transparent;
  font-weight: 800;
}

.segment.is-active {
  color: #fff;
  background: #111111;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.toggle input {
  display: none;
}

.toggle span {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #d0d5dd;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 2px 5px rgba(60, 51, 68, 0.2);
}

.toggle input:checked + span {
  background: #111111;
}

.toggle input:checked + span::after {
  transform: translateX(20px);
}

.actions {
  display: grid;
  gap: 10px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #111827, #344054);
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.18);
}

.secondary-action {
  border: 1px solid #d0d5dd;
  color: #344054;
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.75);
  opacity: 0.55;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #555555;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(27px, 4vw, 46px);
  line-height: 1.12;
  letter-spacing: 0;
  color: #172033;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  color: #111111;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.25fr);
  gap: 18px;
}

.canvas-panel {
  min-width: 0;
  overflow: hidden;
}

.canvas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
}

.canvas-head span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.canvas-head strong {
  font-size: 15px;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 16px;
  background: #f7f7f7;
}

.pattern-wrap {
  align-items: start;
  justify-items: start;
  min-height: 620px;
  max-height: 72vh;
  overflow: auto;
}

canvas {
  display: block;
  border-radius: 8px;
}

#sourceCanvas {
  max-width: 100%;
  max-height: 100%;
}

#patternCanvas {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

.overview-block {
  margin: 0 16px 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.overview-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.overview-head strong {
  display: block;
  margin-top: 3px;
  color: #172033;
  font-size: 14px;
}

.overview-canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 560px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

#overviewCanvas {
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
}

.overview-empty {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #d0d5dd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  font-weight: 700;
}

.overview-empty[hidden] {
  display: none;
}

.empty-state {
  position: absolute;
  inset: 16px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  border: 1px dashed #d0d5dd;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.84);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state p {
  margin: 0;
  font-weight: 700;
}

.pixel-heart {
  display: grid;
  grid-template-columns: repeat(3, 18px);
  gap: 4px;
}

.pixel-heart span,
.bead-sample span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111111;
}

.pixel-heart span:nth-child(2),
.pixel-heart span:nth-child(4),
.pixel-heart span:nth-child(5),
.pixel-heart span:nth-child(6),
.pixel-heart span:nth-child(8) {
  background: #111111;
}

.pixel-heart span:nth-child(1),
.pixel-heart span:nth-child(3),
.pixel-heart span:nth-child(7),
.pixel-heart span:nth-child(9) {
  opacity: 0;
}

.bead-sample {
  display: flex;
  gap: 7px;
}

.bead-sample span {
  width: 26px;
  height: 26px;
  background: var(--c);
  border: 1px solid rgba(60, 51, 68, 0.12);
  box-shadow: inset 0 -4px 0 rgba(60, 51, 68, 0.09);
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.65fr) minmax(360px, 1.35fr);
  gap: 18px;
  margin-top: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div {
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfd;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stats strong {
  display: block;
  margin-top: 9px;
  font-size: 22px;
  line-height: 1.1;
}

.color-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow: auto;
  padding-right: 3px;
}

.color-item,
.list-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.color-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.swatch {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(60, 51, 68, 0.12);
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(60, 51, 68, 0.08);
}

.color-name {
  min-width: 0;
}

.color-name strong,
.color-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-name strong {
  font-size: 13px;
}

.color-name span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.color-count {
  color: #101828;
  font-weight: 800;
}

.list-empty {
  grid-column: 1 / -1;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .topbar h2 {
    font-size: 31px;
  }

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

  .canvas-wrap,
  .pattern-wrap {
    min-height: 360px;
  }
}
