:root {
  --bg-primary: #000000; /* 純黒 = 加算式ディスプレイで透明 */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #4dd0ff;
  --accent-warm: #ffd23f;
  --focus-ring: #4dd0ff;
  --focus-glow: rgba(77, 208, 255, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 600; }
.header-meta { font-size: 14px; color: var(--text-secondary); }

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Intro --- */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 0 8px;
  text-align: center;
}
.intro-icon { font-size: 56px; line-height: 1; }
.intro-text { font-size: 17px; line-height: 1.7; color: var(--text-primary); }

/* --- Mini cards (stats) --- */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mini-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}
.mini-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.mini-value { font-size: 26px; font-weight: 700; }

/* --- Focus States --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 12px;
  padding: 14px 20px 18px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-family: inherit;
}
.nav-item.primary { background: #103246; color: var(--accent-primary); }

/* --- Help --- */
.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
}
.help-list li {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
}
.help-list b { color: var(--accent-primary); }

/* ==================== エディタ画面 ==================== */
.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.status-title { font-size: 15px; color: var(--text-secondary); font-weight: 600; }
.status-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  min-width: 84px;
  text-align: center;
}
.color-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #ffffff;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
}
#pix {
  width: 400px;
  height: 400px;
  border-radius: 6px;
  background: var(--bg-primary);
  box-shadow: 0 0 0 2px var(--bg-card);
}

/* --- パレット --- */
.palette-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.swatch {
  width: 44px;
  height: 40px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
}
.swatch .swatch-inner {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}
.swatch.eraser .swatch-inner {
  background: transparent;
  border: 2px dashed var(--text-muted);
  border-radius: 6px;
}
.swatch.selected {
  box-shadow: inset 0 0 0 2px var(--accent-warm);
}

.editor-actions {
  display: flex;
  gap: 10px;
  padding: 8px 16px 12px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.editor-actions .nav-item { padding: 10px 6px; font-size: 15px; }

/* ==================== うかべる画面 ==================== */
#float { background: var(--bg-primary); }
.float-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#float-canvas { width: 544px; height: 544px; }
.float-hint {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  animation: hint-fade 3s ease forwards;
}
@keyframes hint-fade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
.ghost-btn {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  background: transparent;
  border: none;
}
.ghost-btn:focus { border: none; box-shadow: none; }

/* ==================== ギャラリー画面 ==================== */
.gallery-hint {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}
.gallery-hint.danger { color: #ff8fa3; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 118px);
  gap: 12px;
  justify-content: center;
  align-content: start;
}
.slot {
  width: 118px;
  height: 118px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}
.slot canvas { width: 96px; height: 96px; border-radius: 4px; }
.slot.empty { color: var(--text-muted); font-size: 13px; }
.gallery.delete-mode .slot { box-shadow: inset 0 0 0 2px #ff5d8f; }

/* ==================== トースト ==================== */
.toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 536px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 24px;
  z-index: 20;
  pointer-events: none;
}
.toast.hidden { display: none; }
