:root {
  color-scheme: light dark;
  --tc-accent: #0069b4;
  --tc-line: color-mix(in srgb, currentColor 20%, transparent);
  --tc-muted: color-mix(in srgb, currentColor 62%, transparent);
  --tc-surface: color-mix(in srgb, currentColor 5%, transparent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: CanvasText;
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

button { font: inherit; }

.tc-page {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 12px clamp(20px, 4vw, 56px) 24px;
}

.tc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}

.tc-visual-wrap {
  position: sticky;
  top: 20px;
}

.tc-visual {
  position: relative;
  isolation: isolate;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--tc-line);
}

.tc-base,
.tc-layer,
.tc-light,
.tc-sticker,
.tc-detail,
.tc-color {
  display: block;
  width: 100%;
}

.tc-base {
  position: relative;
  z-index: 1;
  height: auto;
}

.tc-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.tc-light,
.tc-sticker {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.tc-light {
  z-index: 3;
  opacity: .45;
  mix-blend-mode: overlay;
}
.tc-light[hidden] { display: none; }
.tc-sticker { z-index: 4; }

.tc-color,
.tc-detail {
  position: absolute;
  inset: 0;
  height: 100%;
}

.tc-color,
.tc-light {
  -webkit-mask-image: var(--part-mask);
  mask-image: var(--part-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.tc-color {
  background-color: var(--part-color);
  opacity: 0;
  transition: background-color .18s ease, opacity .18s ease;
}

.tc-layer.is-ready .tc-color { opacity: 1; }

.tc-layer[hidden] { display: none; }

.tc-detail {
  object-fit: fill;
  opacity: .62;
  mix-blend-mode: multiply;
}

.tc-caption {
  margin: 10px 0 0;
  color: var(--tc-muted);
  font-size: 12px;
  line-height: 1.6;
}

.tc-controls {
  display: grid;
  gap: 30px;
}

.tc-section {
  padding-top: 22px;
  border-top: 1px solid var(--tc-line);
}

.tc-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.tc-section-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
}

.tc-active-part {
  margin: 0 0 14px;
  color: var(--tc-muted);
  font-size: 13px;
}

.tc-part-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tc-part-group {
  display: grid;
  gap: 8px;
  align-content: start;
}

#tc-drawer-part-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#tc-drawer-part-grid .tc-part-button {
  min-height: 40px;
  padding: 6px;
  text-align: center;
}

#tc-drawer-part-grid .tc-part-name { white-space: nowrap; }
#tc-drawer-part-grid .tc-part-state { display: none; }

.tc-part-button {
  min-height: 48px;
  appearance: none;
  border: 1px solid var(--tc-line);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 9px 11px;
  text-align: left;
  transition: border-color .18s ease, background-color .18s ease;
}

.tc-part-button:hover { border-color: var(--tc-accent); }

.tc-part-button.is-active {
  border-color: var(--tc-accent);
  background: color-mix(in srgb, var(--tc-accent) 12%, transparent);
}

.tc-part-button:disabled {
  cursor: not-allowed;
  opacity: .46;
}

.tc-part-name,
.tc-part-state { display: block; }

.tc-part-name { font-size: 13px; font-weight: 700; }
.tc-part-state { margin-top: 3px; font-size: 11px; }

.tc-selected-color {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--tc-muted);
  font-size: 13px;
}

.tc-selected-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 50%;
  background: var(--selected-color, #0069b4);
}

.tc-swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.tc-swatch {
  aspect-ratio: 1;
  position: relative;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch-color);
  cursor: pointer;
  padding: 0;
  transition: transform .18s ease, border-color .18s ease;
}

.tc-swatch:hover { transform: scale(1.08); }
.tc-swatch.is-active { border-color: CanvasText; }

.tc-swatch::after {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: inherit;
  content: "";
}

.tc-swatch:focus-visible,
.tc-part-button:focus-visible,
.tc-reset:focus-visible {
  outline: 3px solid var(--tc-accent);
  outline-offset: 3px;
}

.tc-reset {
  width: 100%;
  appearance: none;
  border: 1px solid var(--tc-line);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
}

.tc-note {
  margin: 0;
  color: var(--tc-muted);
  font-size: 12px;
  line-height: 1.7;
}

@media (min-width: 901px) {
  .tc-page { max-width: 1120px; padding: 12px 32px 24px; }
  .tc-layout {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 480px);
    gap: 32px;
  }
  .tc-visual-wrap {
    width: min(100%, 380px, calc((100vh - 360px) * 0.77622));
    justify-self: center;
  }
  .tc-controls { gap: 14px; }
  .tc-section { padding-top: 14px; }
  .tc-section:first-child { padding-top: 0; }
  .tc-section-title { margin-bottom: 8px; }
  .tc-active-part { margin-bottom: 8px; }
  .tc-part-grid { gap: 8px; }
  .tc-part-group { gap: 6px; }
  .tc-part-button { padding: 6px 9px; }
  .tc-selected-color { margin-bottom: 10px; }
  .tc-swatch-grid { grid-template-columns: repeat(8, minmax(0, 44px)); gap: 8px; }
}

@media (max-width: 900px) {
  .tc-layout { grid-template-columns: 1fr; }
  .tc-visual-wrap { position: static; }
  .tc-controls { gap: 22px; }
}

@media (max-width: 520px) {
  .tc-page { padding: 12px 16px 24px; }
  .tc-part-grid { gap: 8px; }
  .tc-part-button { min-height: 56px; padding: 8px; }
  .tc-part-name { font-size: 12px; }
  #tc-drawer-part-grid .tc-part-name { font-size: 11px; }
  .tc-part-state { font-size: 10px; }
  .tc-swatch-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
}
