/* =====================================================
   Image Crop Studio — components.css
   カード / ボタン / チップ / フォーム部品 / モーダル
   ===================================================== */

/* ---- ガラスカード ---- */
.card {
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  outline: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-title {
  font-family: var(--font-latin);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title .card-note {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 10px;
  color: var(--text-faint);
  margin-left: auto;
}

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: var(--radius-ui);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-bg-hover); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.45; cursor: default; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: #7C4EE8; border-color: #7C4EE8; }

.btn-lg { padding: 12px 22px; font-size: 14px; border-radius: 11px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--accent-bg-hover); border-color: transparent; }

/* ---- 選択チップ(比率・プリセット・背景色) ---- */
.chip-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-grid.cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-muted);
  border-radius: var(--radius-ui);
  padding: 7px 12px;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.is-active {
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.chip .chip-sub {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faint);
  margin-top: 1px;
}
.chip.is-active .chip-sub { color: var(--accent-soft); }

/* ---- 入力欄 ---- */
.field {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: var(--radius-ui);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
.field:focus { border-color: var(--accent-soft); }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-label {
  font-size: 11px;
  color: var(--text-muted);
  flex: none;
}
.field-suffix { font-size: 12px; color: var(--text-faint); flex: none; }

/* ---- スライダー ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #E6DFF8, var(--accent-soft));
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
  border: 2px solid #fff;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
  border: 2px solid #fff;
}
input[type="range"]:disabled { opacity: 0.4; }
input[type="range"]:disabled::-webkit-slider-thumb { cursor: default; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* ---- トグルスイッチ ---- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #DDD6F0;
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(63, 58, 86, 0.25);
  transition: transform 0.15s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-knob { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.toggle-label { font-size: 12px; color: var(--text-muted); }

/* ---- 背景色スウォッチ ---- */
.swatch {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-ui);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
  flex: none;
}
.swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.swatch-transparent {
  background:
    conic-gradient(#E5E1F2 0 25%, #fff 0 50%, #E5E1F2 0 75%, #fff 0) 0 0 / 12px 12px;
}
.swatch input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ---- セグメント(保存形式) ---- */
.segment {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  overflow: hidden;
  background: var(--surface-solid);
}
.segment button {
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-latin);
  font-weight: 500;
}
.segment button + button { border-left: 1px solid var(--border); }
.segment button.is-active { background: var(--accent-bg); color: var(--accent); }

/* ---- モーダル ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(63, 58, 86, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: 0 20px 60px rgba(63, 58, 86, 0.3);
  width: min(560px, 100%);
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-latin);
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-ui);
  border: none;
  background: var(--accent-bg-hover);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { background: var(--accent-bg); color: var(--accent); }
.modal-body { padding: 0 18px 6px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
