@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap");

:root {
  --bg-1: #f7f4f8;
  --bg-2: #f7f4f8;
  --bg-3: #f7f4f8;
  --ink: #3b3a36;
  --muted: #7b6f7c;
  --accent: #ff8fb2;
  --accent-2: #7fd1c8;
  --accent-3: #ffd37a;
  --panel: #fffdf8;
  --panel-border: #f0e2ee;
  --bead-empty: rgba(240, 234, 223, 0.35);
  --shadow: 0 16px 36px rgba(120, 110, 130, 0.18);
  --bead-grid-real-width: 520mm;
  --bead-grid-real-height: 520mm;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--ink);
  background: var(--bg-1);
  min-height: 100vh;
  overflow-x: hidden;
}

.site-header {
  position: relative;
  z-index: 1;
  padding: 48px 7vw 24px;
}

.header-inner {
  max-width: 980px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

h1 {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  font-size: clamp(32px, 4.2vw, 56px);
  margin: 0 0 16px;
  line-height: 1.05;
}

.sub {
  max-width: 620px;
  color: var(--muted);
  margin: 0;
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(320px, 1.1fr);
  gap: 32px;
  padding: 0 7vw 64px;
  align-items: start;
}

.tray {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 30px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.8s ease-out;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-user-drag: none;
}

.tray-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tray-title {
  font-weight: 600;
  font-size: 18px;
}

.tray-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.tray-hint {
  font-size: 12px;
  color: #ff7aa8;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.tray-wrap {
  background: linear-gradient(145deg, #fff7fb, #f1f6ff);
  border-radius: 22px;
  padding: 18px;
  border: 1px solid #edd9ef;
  overflow: hidden;
}

.tray-counts {
  margin-top: 20px;
  box-shadow: 0 10px 24px rgba(31, 30, 27, 0.06);
}

.bead-grid {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  cursor: crosshair;
  overflow: hidden;
}

.bg-layer {
  pointer-events: none;
}


.bg-overlay {
  display: none;
}

.bead-grid.bg-edit {
  cursor: grab;
}

.bead-grid.bg-edit.bg-dragging {
  cursor: grabbing;
}

.bead-grid.bg-edit .bead {
  pointer-events: none;
}

.bead-grid.bg-edit .bg-overlay {
  display: block;
}

.bg-frame {
  fill: none;
  stroke: rgba(255, 143, 178, 0.9);
  stroke-width: 2;
  stroke-dasharray: 7 6;
  pointer-events: none;
}

.bg-handle {
  fill: #fff;
  stroke: rgba(255, 143, 178, 0.95);
  stroke-width: 2;
  cursor: nwse-resize;
}

.bg-handle[data-handle="ne"],
.bg-handle[data-handle="sw"] {
  cursor: nesw-resize;
}

:root[data-tray-scale="real"] .tray-wrap {
  overflow: auto;
}

:root[data-tray-scale="real"] .bead-grid {
  width: var(--bead-grid-real-width);
  height: var(--bead-grid-real-height);
}

.bead {
  stroke: #d6c6d1;
  stroke-width: 1;
  filter: drop-shadow(0 2px 3px rgba(90, 80, 110, 0.1));
  transition: transform 0.15s ease, fill 0.2s ease, filter 0.2s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.bead:hover {
  transform: translateY(-1px) scale(1.03);
  filter: drop-shadow(0 4px 6px rgba(90, 80, 110, 0.16));
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 10px 24px rgba(31, 30, 27, 0.06);
}

.tab-btn {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(90, 80, 110, 0.12);
}

.tab-btn.is-active {
  color: var(--ink);
  border-color: #ff7aa8;
  background: linear-gradient(135deg, #ffebf2, #fff7fd);
}

.panel-tab {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.panel-tab.is-active {
  display: flex;
}

.panel-block {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(31, 30, 27, 0.08);
  animation: rise 0.8s ease-out;
}

.palette-block {
  max-height: 430px;
  overflow: auto;
  padding-right: 12px;
}

.palette-block::-webkit-scrollbar {
  width: 8px;
}

.palette-block::-webkit-scrollbar-thumb {
  background: rgba(255, 143, 178, 0.4);
  border-radius: 999px;
}

.panel-block h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.size-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid rgba(59, 58, 54, 0.25);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(90, 80, 110, 0.12);
}

.chip.active {
  border-color: #ff7aa8;
  background: linear-gradient(135deg, #ffebf2, #fff7fd);
  font-weight: 600;
}

.palette {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.palette-group {
  display: grid;
  gap: 10px;
}

.palette-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 12px;
}

.swatch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(59, 58, 54, 0.12);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.swatch-item:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 58, 54, 0.24);
  box-shadow: 0 6px 14px rgba(90, 80, 110, 0.12);
}

.swatch-item.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(255, 143, 178, 0.3);
}

.swatch-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(59, 58, 54, 0.2);
  background-color: var(--swatch-color, #fff);
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
}

.swatch-dot.eraser {
  border-color: rgba(59, 58, 54, 0.3);
}

.swatch-dot.eraser::after {
  content: "";
  position: absolute;
  width: 130%;
  height: 5px;
  left: -15%;
  top: 50%;
  transform: translateY(-50%) rotate(-18deg);
  background: rgba(125, 110, 110, 0.45);
  border-radius: 999px;
}

.swatch-dot.big {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border-width: 1px;
}

.swatch-dot.big.eraser::after {
  height: 6px;
}

.swatch-label {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 600;
}

.swatch-dot.glitter {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.75) 0 1.5px, transparent 3px),
    radial-gradient(circle at 40% 75%, rgba(255, 255, 255, 0.7) 0 1.5px, transparent 3px),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.6) 0 1px, transparent 3px),
    linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0));
  background-blend-mode: screen;
}

.selected-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-direction: column;
}

.selected-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.selected-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.recent-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px dashed rgba(59, 58, 54, 0.18);
  background: rgba(255, 255, 255, 0.55);
  width: 100%;
}

.recent-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-top: 6px;
}

.recent-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.recent-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.recent-swatch {
  border: 1px solid rgba(59, 58, 54, 0.18);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.recent-swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 58, 54, 0.35);
  box-shadow: 0 6px 12px rgba(90, 80, 110, 0.12);
}

.recent-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border-width: 1px;
}

.recent-badge {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(4px);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(59, 58, 54, 0.18);
  box-shadow: 0 8px 18px rgba(90, 80, 110, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.recent-swatch:hover .recent-badge,
.recent-swatch.is-peek .recent-badge {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.recent-empty {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.counts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.counts-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.counts-title h2 {
  margin: 0;
}

.counts-toggle {
  border: 1px solid rgba(59, 58, 54, 0.2);
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.counts-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 58, 54, 0.32);
  box-shadow: 0 6px 14px rgba(90, 80, 110, 0.12);
}

.counts-toggle-icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.tray-counts.is-collapsed .counts-toggle-icon {
  transform: rotate(-135deg);
}

.count-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  overflow: hidden;
  max-height: 48px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
}

.count-total {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
}

.count-note {
  font-size: 11px;
}

.count-empty {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.count-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.counts-body {
  margin-top: 10px;
  overflow: hidden;
  max-height: 700px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 0.28s ease, opacity 0.2s ease, transform 0.2s ease;
}

.tray-counts.is-collapsed .counts-body {
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.tray-counts.is-collapsed .count-summary {
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0;
  pointer-events: none;
}

.count-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(59, 58, 54, 0.12);
  background: rgba(255, 255, 255, 0.75);
}

.count-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.swatch-dot.tiny {
  width: 20px;
  height: 20px;
  border-radius: 8px;
  border-width: 1px;
}

.count-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.count-num {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.opacity-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.opacity-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), #ffb3cc);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(255, 143, 178, 0.32);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px dashed rgba(59, 58, 54, 0.28);
  box-shadow: none;
}

.status {
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

.tips ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .tray-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .palette-block {
    max-height: none;
    overflow: visible;
    padding-right: 18px;
  }
}

@media (max-width: 600px) {
  .site-header {
    padding: 36px 6vw 20px;
  }

  .workspace {
    padding: 0 6vw 48px;
  }

  .palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .swatch-dot {
    width: 24px;
    height: 24px;
  }

  .recent-wrap {
    justify-content: flex-start;
  }
}
