/* 配色メーカー */
#crs-app, #crs-app * {
  font-family: "Yu Gothic Medium", "YuGothic", "Yu Gothic", "Hiragino Kaku Gothic ProN", "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
  box-sizing: border-box;
  color: #334155;
  line-height: 1.4;
}
#crs-app {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 2rem auto;
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
}
#crs-app button { font: inherit; cursor: pointer; border: none; background: none; padding: 0; margin: 0; }
#crs-app input, #crs-app select { font: inherit; margin: 0; }
#crs-app button:focus:not(:focus-visible) { outline: none; }

/* 外枠のカード（画像保存の範囲） */
#crs-capture {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 6px solid #f8fafc;
  border-radius: 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) { #crs-capture { padding: 2.1rem 2.1rem 1.6rem; } }
#crs-capture .crs-blob1, #crs-capture .crs-blob2 {
  position: absolute; border-radius: 9999px; filter: blur(24px); pointer-events: none;
}
#crs-capture .crs-blob1 { top: -4rem; right: -4rem; width: 8rem; height: 8rem; background: #fefce8; opacity: .4; }
#crs-capture .crs-blob2 { bottom: -3rem; left: -3rem; width: 6rem; height: 6rem; background: #f0f9ff; opacity: .5; }
#crs-capture > * { position: relative; }

#crs-app .crs-title {
  margin: 0 0 .25rem; text-align: center; font-weight: 700; color: #1e293b;
  font-size: clamp(18px, 5vw, 26px); white-space: nowrap;
}
/* サブタイトルなしの大きめタイトル（日本語版） */
#crs-app .crs-title-lg { margin-bottom: 1.25rem; font-size: clamp(22px, 6.5vw, 32px); }
#crs-app .crs-sub { margin: 0 0 1.5rem; text-align: center; font-weight: 700; color: #94a3b8; font-size: .8rem; }

#crs-app .crs-chip {
  padding: .25rem .65rem; border-radius: 9999px; border: 1px solid #e2e8f0; background: #fff;
  font-size: .75rem; font-weight: 700; color: #64748b; transition: background .2s, color .2s;
}
#crs-app .crs-chip:hover { background: #f1f5f9; }
#crs-app .crs-chip.active { background: #1e293b; border-color: #1e293b; color: #fff; }

/* 3色の欄 */
#crs-app .crs-cols { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: 1.3rem; }
#crs-app .crs-col { min-width: 0; background: #f8fafc; border-radius: 1rem; padding: .6rem .6rem .65rem; }
#crs-app .crs-strip {
  position: relative; display: block; height: 52px; border-radius: .7rem; margin-bottom: .4rem;
  border: 1px solid rgba(15, 23, 42, .12); overflow: hidden; cursor: pointer;
}
#crs-app .crs-strip { width: 100%; padding: 0; }
#crs-app .crs-strip input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0;
}
/* スマホ・タブレットはページ内の色選びを使うので、標準の色選びは出さない */
@media (max-width: 479px), (hover: none) and (pointer: coarse) { #crs-app .crs-strip input[type="color"] { display: none; } }
/* 色を選ぶ画面を開いている色 */
#crs-app .crs-strip.picking { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1db3d1; }

/* 色を選ぶ画面 */
#crs-app .crs-picker { margin-top: 1.3rem; background: #f8fafc; border-radius: 1rem; padding: .7rem; }
#crs-app .crs-picker[hidden] { display: none; }
#crs-app .crs-picker:not([hidden]) + .crs-cols { margin-top: .7rem; }
#crs-app .crs-pk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .55rem; }
#crs-app .crs-pk-title { font-size: .8rem; font-weight: 700; color: #1e293b; }
#crs-app .crs-pk-done {
  padding: .3rem .9rem; border-radius: 9999px; background: #1e293b; font-size: .75rem; font-weight: 700; color: #fff;
}
#crs-app .crs-pk-body { display: flex; gap: .6rem; }
#crs-app .crs-pk-sv {
  position: relative; flex: 1; min-width: 0; height: 150px; border-radius: .7rem; cursor: crosshair; touch-action: none;
}
#crs-app .crs-pk-hue {
  position: relative; height: 18px; margin: .7rem 9px 0; border-radius: 9999px; cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
/* つまみ */
#crs-app .crs-pk-knob {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 9999px;
  border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, .3), 0 2px 4px rgba(15, 23, 42, .3); pointer-events: none;
}
#crs-app .crs-pk-hue .crs-pk-knob { top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
#crs-app .crs-pk-foot { display: flex; align-items: center; gap: .5rem; margin-top: .7rem; }
#crs-app .crs-pk-swatch { width: 2rem; height: 2rem; flex-shrink: 0; border-radius: .5rem; border: 1px solid rgba(15, 23, 42, .12); }
#crs-app .crs-pk-hex {
  flex: 1; min-width: 0; height: 2rem; padding: 0 .6rem; border: 1px solid #e2e8f0; border-radius: .5rem; background: #fff; outline: none;
  font-weight: 700; font-size: .85rem; color: #1e293b; -webkit-user-select: text; user-select: text;
}
#crs-app .crs-pk-hex.invalid { color: #ef4444; }
#crs-app .crs-pk-eye {
  display: inline-flex; align-items: center; gap: .3rem; height: 2rem; padding: 0 .7rem; flex-shrink: 0;
  border: 1px solid #e2e8f0; border-radius: .5rem; background: #fff; font-size: .75rem; font-weight: 700; color: #475569;
}
#crs-app .crs-pk-eye[hidden] { display: none; }
#crs-app .crs-pk-eye svg { width: 15px; height: 15px; }
#crs-app .crs-pk-eye:hover, #crs-app .crs-pk-done:hover { filter: brightness(1.1); }
@media (max-width: 479px) {
  #crs-app .crs-pk-sv { height: 130px; }
}
#crs-app .crs-col-head { display: flex; align-items: baseline; gap: .25rem; margin-bottom: .25rem; }
#crs-app .crs-col-name { font-size: .65rem; font-weight: 700; color: #94a3b8; white-space: nowrap; }
#crs-app .crs-col-code {
  display: flex; align-items: center; gap: .2rem; background: #fff; border: 1px solid #e2e8f0; border-radius: .6rem; padding: .15rem .15rem .15rem .4rem;
}
#crs-app .crs-hex {
  flex: 1; min-width: 0; width: 100%; border: none; outline: none; background: transparent; padding: 0;
  font-weight: 700; font-size: .78rem; color: #1e293b;
  -webkit-user-select: text; user-select: text;
}
#crs-app .crs-hex.invalid { color: #ef4444; }
#crs-app .crs-hex-text { display: block; line-height: 1.35rem; white-space: nowrap; overflow: hidden; }
#crs-app .crs-lock {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.35rem; height: 1.35rem; border-radius: .4rem; color: #94a3b8; transition: background .2s;
}
#crs-app .crs-lock:hover, #crs-app .crs-copy:hover { background: #e2e8f0; }
#crs-app .crs-copy {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.35rem; height: 1.35rem; border-radius: .4rem; color: #94a3b8; transition: background .2s;
}
#crs-app .crs-copy svg { width: 13px; height: 13px; }
#crs-app .crs-lock svg { width: 13px; height: 13px; }
#crs-app .crs-lock.locked { background: #1e293b; color: #fff; }
#crs-app .crs-lock.locked:hover { background: #334155; }
/* #crs-app * の文字色がアイコンにもかかるので、ロック中のアイコンは白を直接指定する */
#crs-app .crs-lock.locked svg, #crs-app .crs-lock.locked svg * { color: #fff; }
#crs-app .crs-swap {
  position: absolute; top: 36px; width: 1.4rem; height: 1.4rem; margin: -.7rem 0 0 -.7rem; z-index: 2;
  display: flex; align-items: center; justify-content: center; border-radius: 9999px;
  background: #fff; border: 1px solid #e2e8f0; font-size: .7rem; font-weight: 700; color: #94a3b8;
}
#crs-app .crs-swap:hover { background: #f1f5f9; }

/* スロット */
#crs-app .crs-slot { display: flex; flex-direction: row; align-items: stretch; gap: .6rem; margin-top: 1.1rem; }
#crs-app .crs-selects { display: flex; gap: .5rem; flex: 1; min-width: 0; }
#crs-app .crs-select {
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center;
  background: #f8fafc; border-radius: .9rem; padding: .3rem .6rem;
}
#crs-app .crs-select span { font-size: .65rem; font-weight: 700; color: #94a3b8; }
#crs-app .crs-select select {
  width: 100%; border: none; background: transparent; font-weight: 700; font-size: .85rem; color: #1e293b; cursor: pointer; outline: none;
}
#crs-app .crs-roll {
  flex: 1; min-height: 3rem; padding: .6rem 1rem; border-radius: .9rem; font-weight: 700; font-size: 1.05rem;
  background: #1db3d1; box-shadow: 0 4px 10px -2px rgba(29, 179, 209, .45);
  transition: filter .2s, transform .1s; display: flex; align-items: center; justify-content: center;
}
#crs-app .crs-roll span { color: #fff; }
#crs-app .crs-roll:hover { filter: brightness(1.05); }
#crs-app .crs-roll:active { transform: scale(.97); }
#crs-app .crs-history-wrap { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; }
#crs-app .crs-mini-label { font-size: .65rem; font-weight: 700; color: #94a3b8; flex-shrink: 0; }
#crs-app .crs-history { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: .35rem; }
#crs-app .crs-history-item, #crs-app .crs-history-empty { display: flex; height: 1.3rem; border-radius: .35rem; overflow: hidden; }
#crs-app .crs-history-item { box-shadow: 0 0 0 1px rgba(15, 23, 42, .1); }
#crs-app .crs-history-empty { border: 1px dashed #e2e8f0; }
#crs-app .crs-history-item i { height: 100%; }

/* プレビュー */
#crs-app .crs-preview { margin-top: 0; }
#crs-app .crs-tabs { display: flex; gap: .3rem; background: #f1f5f9; border-radius: .9rem; padding: .25rem; margin: .9rem 0 0; }
#crs-app .crs-tab {
  flex: 1; padding: .4rem .5rem; border-radius: .7rem; font-weight: 700; font-size: .85rem; color: #94a3b8; text-align: center; white-space: nowrap;
  transition: background .2s, color .2s;
}
#crs-app .crs-tab.active { background: #fff; color: #0ea5e9; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
#crs-app .crs-panel { display: none; }
#crs-app .crs-panel.active { display: block; }
/* プレビューの高さは固定（タブを切り替えても画面がガタつかないように） */
#crs-app .crs-stage {
  border-radius: 1.25rem; background: #f8fafc; border: 1px solid #f1f5f9; padding: .75rem;
  display: flex; justify-content: center; align-items: center;
  height: 340px; overflow: hidden;
}
@media (max-width: 479px) { #crs-app .crs-stage { height: 260px; } }
@media (min-width: 680px) { #crs-app .crs-stage { height: 380px; } }
#crs-app .crs-stage > svg { max-width: 100%; max-height: 100%; }
#crs-char-canvas { display: block; width: auto; height: 100%; max-width: 100%; aspect-ratio: 1 / 1; }

/* 肌の色（プレビューの右側） */
#crs-app #crs-char-stage { position: relative; }
#crs-app .crs-skin {
  position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: .5rem .35rem; border-radius: 9999px; background: rgba(255, 255, 255, .85);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}
#crs-app .crs-skin-label { font-size: .65rem; font-weight: 700; color: #94a3b8; line-height: 1; }
#crs-app .crs-skin-sw {
  position: relative; display: block; width: 22px; height: 22px; padding: 0; border-radius: 5px; cursor: pointer;
  border: 1px solid rgba(15, 23, 42, .15); overflow: hidden;
}
#crs-app .crs-skin-sw.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #475569; }
/* カスタム：虹色の輪。選んだ色があれば中に表示 */
#crs-app .crs-skin-custom {
  border: 0; background: linear-gradient(135deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f);
}
#crs-app .crs-skin-custom::after {
  content: ""; position: absolute; inset: 4px; border-radius: 3px; background: var(--skin, transparent);
  pointer-events: none;
}
#crs-app .crs-skin-custom:not(.active)::after { background: #fff; inset: 5px; }
#crs-app .crs-skin-custom.picking { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #475569; }
#crs-app .crs-skin-custom input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0;
}
/* 左右切り替えボタン（スマホのみ） */
#crs-app .crs-skin-side {
  display: none; width: 22px; height: 18px; padding: 0; margin-top: .1rem; border: 0; background: none;
  font-size: 14px; line-height: 1; color: #64748b; cursor: pointer;
}
@media (max-width: 479px), (hover: none) and (pointer: coarse) { #crs-app .crs-skin-custom input[type="color"] { display: none; } }
@media (max-width: 479px) {
  #crs-app .crs-skin-side { display: block; }
  #crs-app #crs-char-stage.skin-left .crs-skin { right: auto; left: .75rem; }
  /* 肌の欄のぶんだけキャラを反対側へずらして、見た目の真ん中に */
  #crs-char-canvas { transform: translateX(-12px); }
  #crs-char-stage.skin-left #crs-char-canvas { transform: translateX(12px); }
  #crs-app .crs-skin { right: .75rem; gap: .32rem; padding: .4rem .28rem; }
  #crs-app .crs-skin-sw { width: 19px; height: 19px; }
}

/* UIサンプル */
#crs-ui { display: block; width: 100%; height: auto; }

#crs-app .crs-footer {
  margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid #f1f5f9; text-align: center;
  font-size: 10px; letter-spacing: .2em; font-weight: 700; color: #94a3b8;
}

/* 保存・コピー */
#crs-app .crs-btns { display: flex; gap: .75rem; margin-top: 1.2rem; }
#crs-app .crs-dark-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.2rem 1rem;
  background: #1e293b; border-radius: .9rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1); transition: background .2s, transform .1s;
}
#crs-app .crs-dark-btn span { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1; white-space: nowrap; }
#crs-app .crs-dark-btn:hover { background: #111827; }
#crs-app .crs-dark-btn:active { transform: scale(.98); }
#crs-status {
  position: fixed; bottom: 3rem; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff !important; padding: 1rem 2rem; border-radius: 1.25rem; font-weight: 700;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .4); z-index: 2147483647; white-space: nowrap; display: none; pointer-events: none;
}

/* スマホ幅：3色の欄を少し詰める */
@media (max-width: 479px) {
  #crs-capture { padding: 1.25rem 1rem 1rem; border-radius: 2rem; }
  #crs-app .crs-cols { gap: .4rem; }
  #crs-app .crs-roll { font-size: .95rem; padding: .5rem .6rem; }
  #crs-app .crs-history { gap: .25rem; }
  #crs-app .crs-swap { top: 32px; }
  #crs-app .crs-col { padding: .4rem .3rem .4rem; }
  #crs-app .crs-col-code { padding: .15rem .1rem .15rem .3rem; }
  #crs-app .crs-hex { font-size: .66rem; letter-spacing: -.03em; }
  #crs-app .crs-lock, #crs-app .crs-copy { width: 1rem; height: 1.1rem; }
  #crs-app .crs-lock svg, #crs-app .crs-copy svg { width: 11px; height: 11px; }
  #crs-app .crs-col-code { gap: 0; }
}
@media (max-width: 359px) {
  #crs-capture { padding-left: .75rem; padding-right: .75rem; }
  #crs-app .crs-hex { font-size: .6rem; }
}
