* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  color-scheme: dark;
  /* ふんわりうさぎシリーズ共通の設計文法（MASK ONはダーク版）: フラット・大きな丸み・アクセント1色 */
  --bg: #0d1117;
  --card: #161b22;
  --ink: #f0f6fc;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #e94560;
  --accent-deep: #d63851;
  --soft: #1a1020;
  --soft-active: #2d1525;
  --line: #30363d;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
body {
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.7;
}

/* Header */
.header {
  background: var(--bg);
  padding: 28px 0 8px; text-align: center;
}
.eyebrow {
  color: var(--accent); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; font-size: 13px; margin-bottom: 6px;
}
.header-logo {
  width: 100px; height: 100px; margin-bottom: 10px; border-radius: 50%;
  filter: drop-shadow(0 2px 8px rgba(85, 232, 208, 0.3));
}
.header h1 {
  font-size: 36px; font-weight: 800; color: #fff;
  letter-spacing: 6px; text-transform: uppercase;
}
.header h1 span { color: #e94560; }
.header p { color: #a0aec0; font-size: 14px; margin-top: 6px; }

/* Container */
.container { max-width: 960px; margin: 0 auto; padding: 30px 20px; }

/* Card */
.card {
  background: var(--card); border-radius: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 28px; margin-bottom: 26px;
  position: relative;
}
.card[data-step]::before {
  content: attr(data-step);
  position: absolute; top: -16px; left: 24px;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 800; font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3); z-index: 2;
}
.card h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; color: #f0f6fc; }

/* Upload */
.upload-area {
  border: 3px dashed #5a2a35; border-radius: 26px;
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #0d1117; position: relative;
}
.upload-area:hover, .upload-area.dragover { border-color: #e94560; background: #1a1020; }
.upload-area .icon { font-size: 40px; margin-bottom: 10px; }
.upload-area p { color: #8b949e; font-size: 14px; }
.upload-area .link { color: #e94560; cursor: pointer; text-decoration: underline; }
.upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-count { font-size: 16px; font-weight: 600; color: #f0f6fc; margin-bottom: 4px; }
.clear-btn {
  color: #e94560; cursor: pointer; font-size: 13px;
  border: none; background: none; text-decoration: underline; margin-left: 8px;
  position: relative; z-index: 10;
}

/* Settings */
.setting-group { margin-bottom: 20px; }
.setting-group > label {
  display: block; font-size: 14px; font-weight: 600; color: #c9d1d9; margin-bottom: 8px;
}

/* Radio Cards */
.radio-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
}
.radio-card {
  border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 10px; text-align: center;
  cursor: pointer; transition: all 0.2s; font-size: 13px;
  background: #0d1117; color: #c9d1d9;
}
.radio-card:hover { border-color: var(--accent); background: var(--soft); }
.radio-card.active { border-color: var(--accent); background: var(--soft-active); }
.radio-card .emoji { font-size: 24px; margin-bottom: 4px; display: block; }

/* Slider */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 6px; }
.slider-value { min-width: 45px; text-align: right; font-weight: 600; font-size: 14px; color: #f0f6fc; }

/* Stamp Grid */
.stamp-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stamp-option {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; border: 2px solid var(--line); border-radius: 12px;
  cursor: pointer; transition: all 0.2s; background: #0d1117;
}
.stamp-option:hover { border-color: #e94560; }
.stamp-option.active { border-color: var(--accent); background: var(--soft-active); }

/* Preview */
.preview-area {
  border: 1px dashed var(--line); border-radius: 18px;
  padding: 16px; min-height: 200px; background: #0d1117;
}
.preview-label { text-align: center; color: #8b949e; font-size: 13px; margin-bottom: 10px; }
.preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
}
.preview-item {
  position: relative; border-radius: 14px; overflow: hidden;
  background: #161b22; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  border: 1px solid #30363d;
  cursor: pointer; transition: all 0.2s;
}
.preview-item:hover { box-shadow: 0 2px 12px rgba(233,69,96,0.3); border-color: #e94560; }
.preview-item canvas { width: 100%; display: block; }
.preview-item .status-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  color: #fff; font-weight: 600;
}
.preview-item .edit-hint {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6); color: #fff; text-align: center;
  font-size: 12px; padding: 4px; opacity: 0; transition: opacity 0.2s;
}
.preview-item:hover .edit-hint { opacity: 1; }
.badge-detecting { background: #f59e0b; }
.badge-done { background: #10b981; }
.badge-noface { background: #6b7280; }
.badge-error { background: #dc2626; }

/* Buttons */
.btn-primary {
  display: block; width: 100%; max-width: 360px;
  margin: 0 auto; padding: 14px 28px;
  font-size: 16px; font-weight: 700; color: #fff;
  background: var(--accent); border: none; border-radius: 999px;
  cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .2s;
}
.btn-primary:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(233,69,96,0.24); }
.btn-primary:disabled { background: #30363d; color: #8b949e; cursor: not-allowed; box-shadow: none; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; font-size: 14px; font-weight: 700;
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: #161b22; border-color: #8b949e; }
.save-row { display: flex; gap: 10px; margin-bottom: 20px; }

/* Model Status */
.model-status {
  text-align: center; padding: 12px; font-size: 14px;
  color: #d4a72c; background: #2d2206; border: 1px solid #4a3a0a;
  border-radius: 14px; margin-bottom: 16px;
}
.model-status.ready { background: #0d2818; color: #3fb950; border-color: #1a4028; }
.model-status.error { background: #2d0b0b; color: #f85149; border-color: #4a1212; }

/* Progress */
.progress-bar {
  width: 100%; height: 6px; background: #e5e7eb;
  border-radius: 3px; overflow: hidden; margin: 12px 0; display: none;
}
.progress-bar { background: #30363d; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; width: 0; }

/* ====== Editor Overlay ====== */
.editor-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: #0d1117; overflow: auto;
}
.editor-overlay.active { display: flex; flex-direction: column; }
.editor-toolbar {
  background: #1a1a2e; padding: 10px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.editor-toolbar .title { color: #fff; font-weight: 600; font-size: 15px; margin-right: auto; }
.editor-toolbar button {
  padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1); color: #fff; font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.editor-toolbar button:hover { background: rgba(255,255,255,0.2); }
.editor-toolbar button.active { background: #e94560; border-color: #e94560; }
.editor-toolbar .sep { width: 1px; height: 24px; background: rgba(255,255,255,0.2); }
.editor-toolbar label { color: #ccc; font-size: 12px; }
.editor-toolbar input[type="range"] { width: 80px; accent-color: var(--accent); }
.editor-toolbar .val { color: #fff; font-size: 12px; min-width: 30px; }
.editor-stamp-panel {
  background: #16213e; padding: 8px 20px;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.ed-stamp-opt {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 2px solid transparent; border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
}
.ed-stamp-opt:hover { border-color: rgba(233,69,96,0.5); background: rgba(255,255,255,0.05); }
.ed-stamp-opt.active { border-color: #e94560; background: rgba(233,69,96,0.15); }
.editor-canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow: auto;
}
.editor-canvas-wrap canvas {
  max-width: 100%; max-height: calc(100vh - 80px);
  border-radius: 4px; cursor: crosshair;
}

/* Features */
.features {
  background: #161b22; border-top: 1px solid #30363d;
  padding: 50px 20px; margin-top: 40px;
}
.features-inner { max-width: 800px; margin: 0 auto; }
.features h2 { font-size: 22px; font-weight: 700; margin-bottom: 16px; color: #f0f6fc; }
.features h3 {
  font-size: 17px; font-weight: 600; margin: 24px 0 10px;
  color: #f0f6fc; border-bottom: 1px solid #30363d; padding-bottom: 8px;
}
.features p, .features li { font-size: 14px; color: #8b949e; }
.features ul { padding-left: 20px; margin: 8px 0; }
.features li { margin-bottom: 6px; }
.features strong { color: #c9d1d9; }

/* Footer */
.footer {
  text-align: center; padding: 30px 20px; color: #8b949e;
  font-size: 13px; border-top: 1px solid var(--line);
  background: var(--card);
}
.footer .series-link { color: var(--accent); }
.footer .brand { font-weight: 700; color: #fff; letter-spacing: 3px; font-size: 16px; }
.footer .brand span { color: #e94560; }

@media (max-width: 600px) {
  .header h1 { font-size: 26px; letter-spacing: 4px; }
  .card { padding: 20px 16px; }
  .radio-cards { grid-template-columns: repeat(2, 1fr); }
  .preview-grid { grid-template-columns: 1fr; }
  .editor-toolbar { gap: 8px; }
}
.hidden { display: none !important; }

/* 編集ツールバーのモード表示ラベル（旧ブラシボタン。監査F-05でボタン→表示専用に） */
.ed-mode-label { color: #fff; font-size: 13px; opacity: .85; }

/* フォルダ選択リンク（全面input overlayより手前に） */
.upload-area .link { position: relative; z-index: 6; cursor: pointer; }
