/* ── Light Theme (default) ── */
:root {
  --bg: #f5f5f5;
  --bg2: #ffffff;
  --bg3: #ececec;
  --border: #e0e0e0;
  --cyan: #0ea5e9;
  --cyan-dim: #0284c7;
  --green: #10b981;
  --red: #ef4444;
  --text: #1a1a1a;
  --text-dim: #999999;
  --text-mid: #666666;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --mask-color: rgba(239, 68, 68, 0.45);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg: #0a0e17;
  --bg2: #0f1520;
  --bg3: #141c2d;
  --border: #1e2d48;
  --cyan: #00d4ff;
  --cyan-dim: #007a9a;
  --text: #c8d8f0;
  --text-dim: #5a7090;
  --text-mid: #8aa0c0;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --mask-color: rgba(239, 68, 68, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Header ── */
.header {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-logo-link {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.header-logo-img {
  height: 24px;
  width: auto;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mid);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

/* ── Theme Toggle ── */
.theme-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.theme-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s;
}

.theme-btn.active {
  background: var(--bg2);
  box-shadow: var(--shadow);
}

/* ── Intro Box ── */
.intro-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.intro-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.intro-desc {
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.7;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg2);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--cyan);
  background: rgba(14, 165, 233, 0.04);
}

[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.drag-over {
  background: rgba(0, 212, 255, 0.04);
}

.drop-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.drop-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ── File Info ── */
.file-info {
  margin-top: 16px;
}

.file-info-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-info-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.file-info-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-info-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.file-remove-btn {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.file-remove-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ── Editor ── */
.editor {
  margin: 24px 0;
}

/* ── Model Selector ── */
.model-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.model-btn {
  flex: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  transition: all 0.15s;
}

.model-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.model-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(14, 165, 233, 0.06);
}

[data-theme="dark"] .model-btn.active {
  background: rgba(0, 212, 255, 0.06);
}

.model-btn-icon {
  font-size: 18px;
  line-height: 1;
}

.model-btn-text {
  font-size: 13px;
}

/* ── Toolbar ── */
.toolbar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  gap: 4px;
}

.tool-btn {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mid);
  transition: all 0.15s;
}

.tool-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.tool-btn.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(14, 165, 233, 0.08);
}

[data-theme="dark"] .tool-btn.active {
  background: rgba(0, 212, 255, 0.08);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-icon {
  font-size: 16px;
  line-height: 1;
}

.tool-label {
  font-size: 12px;
}

.brush-size-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 120px;
}

.brush-size-group label {
  font-size: 12px;
  color: var(--text-mid);
  white-space: nowrap;
}

.brush-size-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.brush-size-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid var(--bg2);
}

.brush-size-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid var(--bg2);
}

#brush-size-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  min-width: 24px;
  text-align: right;
}

/* ── Canvas Container ── */
.canvas-container {
  position: relative;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: auto;
}

#canvas-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  opacity: 0.45;
  pointer-events: none;
}

#canvas-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
}

/* ── Action Row ── */
.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* ── Primary Button ── */
.btn-primary {
  background: var(--cyan);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* ── Canvas Overlay (Processing) ── */
.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 8px;
}

.overlay-content {
  text-align: center;
  padding: 24px 32px;
  min-width: 260px;
}

.overlay-text {
  font-size: 14px;
  color: #fff;
  margin-bottom: 16px;
}

.overlay-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.overlay-progress-fill {
  height: 100%;
  background: var(--cyan);
  width: 0%;
  transition: width 0.3s ease;
}

/* ── Result Preview ── */
.result {
  margin: 24px 0;
}

.preview-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.preview-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.preview-tab {
  flex: 1;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  transition: color 0.15s, background 0.15s;
  position: relative;
}

.preview-tab:hover {
  color: var(--text);
  background: var(--bg3);
}

.preview-tab.active {
  color: var(--cyan);
}

.preview-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--cyan);
}

.preview-body {
  padding: 0;
}

.result-view {
  background: #000;
}

.result-view canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Download ── */
.download-area {
  text-align: center;
  margin: 24px 0;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ── Info Section ── */
.info-section {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.card-header span { font-size: 18px; }

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* Steps */
.how-to-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-dim) 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.step-content p {
  font-size: 0.85rem;
  color: var(--text-mid);
  line-height: 1.7;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.feature {
  padding: 16px;
  background: var(--bg3);
  border-radius: 6px;
}

.feature h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.feature p {
  font-size: 0.82rem;
  color: var(--text-mid);
  line-height: 1.6;
}

/* ── Promo Banner ── */
.promo-banner {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  margin-top: 24px;
}

.promo-banner-label {
  font-size: 0.85rem;
  color: #a0a0a0;
  margin-bottom: 8px;
}

.promo-banner-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}

.promo-banner-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 16px;
}

.promo-banner-btn {
  display: inline-block;
  background: linear-gradient(135deg, #e94560 0%, #c73659 100%);
  color: #ffffff;
  padding: 12px 28px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.promo-banner-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.promo-shizuka {
  background: linear-gradient(135deg, #0a192f 0%, #112240 100%);
  border-color: #1e3a5f;
}

.promo-shizuka-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.promo-shizuka-btn:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.promo-shaki {
  background: linear-gradient(135deg, #0a192f 0%, #112240 100%);
  border-color: #1e3a5f;
}

.promo-shaki-btn {
  background: linear-gradient(135deg, #6c5ce7 0%, #5a4bd1 100%);
}

.promo-shaki-btn:hover {
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.promo-chidimeru {
  background: linear-gradient(135deg, #0a192f 0%, #112240 100%);
  border-color: #1e3a5f;
}

.promo-chidimeru-btn {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

.promo-chidimeru-btn:hover {
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

/* ── Footer ── */
.footer {
  margin-top: 48px;
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-links { margin-bottom: 12px; }

.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0 12px;
  transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--text); }

.footer p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.footer p a { color: inherit; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  #app { padding: 16px; }
  .header-inner { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .header-right { flex-wrap: wrap; gap: 8px; }
  .privacy-badge { font-size: 11px; padding: 4px 8px; }
  .drop-zone { padding: 32px 16px; }

  .toolbar {
    gap: 8px;
    padding: 8px 12px;
  }

  .tool-label { display: none; }

  .brush-size-group {
    order: 10;
    width: 100%;
  }

  .header-logo-img { height: 20px; }
  .features { grid-template-columns: 1fr; }
  .step-number { width: 28px; height: 28px; font-size: 12px; }

  .download-area {
    flex-direction: column;
    align-items: center;
  }
}
